@@ -1346,6 +1448,7 @@ export function RoomTimeline({
+ key={vListKeyRef.current}
ref={vListRef}
data={processedEvents}
shift={shouldShift}
+ id="timeline-scroller"
className={css.messageList}
style={{
flex: 1,
diff --git a/src/app/hooks/timeline/useTimelineSync.test.tsx b/src/app/hooks/timeline/useTimelineSync.test.tsx
index 1c9a1c4c6..776254d1e 100644
--- a/src/app/hooks/timeline/useTimelineSync.test.tsx
+++ b/src/app/hooks/timeline/useTimelineSync.test.tsx
@@ -727,7 +727,7 @@ describe('back-pagination', () => {
);
await act(async () => {
- await result.current.handleTimelinePagination(true);
+ await result.current.handleTimelinePagination(true, true);
});
// Nothing rendered, so the loader keeps going up to MAX_AUTO_CONTINUATIONS.
@@ -745,7 +745,7 @@ describe('back-pagination', () => {
useTimelineSync(syncOpts(thinPage.room, thinPaginate, () => true))
);
await act(async () => {
- await thin.result.current.handleTimelinePagination(true);
+ await thin.result.current.handleTimelinePagination(true, true);
});
expect(thinPaginate).toHaveBeenCalledTimes(4);
@@ -763,6 +763,23 @@ describe('back-pagination', () => {
expect(fullPaginate).toHaveBeenCalledTimes(1);
});
+ it('loads one sparse page for a user-driven scroll', async () => {
+ const { room, events } = createPaginableRoom();
+ const paginateEventTimeline = vi.fn<() => Promise>(async () => {
+ events.push({});
+ return true;
+ });
+ const { result } = renderHook(() =>
+ useTimelineSync(syncOpts(room, paginateEventTimeline, () => false))
+ );
+
+ await act(async () => {
+ await result.current.handleTimelinePagination(true);
+ });
+
+ expect(paginateEventTimeline).toHaveBeenCalledTimes(1);
+ });
+
it('never reports idle before the fetched page is committed', async () => {
// The sdk puts a fetched page in a fresh EventTimeline linked behind the
// live one, so the new events only become visible once setTimeline commits.
@@ -1171,45 +1188,6 @@ describe('live-arrive edge cases', () => {
expect(scrollToBottom).toHaveBeenCalledWith('instant');
});
- it('signals a prepend on the displayed timeline', async () => {
- const { room, timeline } = createRoom();
- const { result } = renderSyncHook(room, { isAtBottom: false });
-
- expect(result.current.prependVersion).toBe(0);
- await act(async () => {
- room.emit(RoomEvent.Timeline, makeLiveEvent(room.roomId, Date.now()), room, true, false, {
- liveEvent: false,
- timeline,
- });
- await Promise.resolve();
- });
-
- expect(result.current.prependVersion).toBe(1);
- });
-
- it('signals a filtered prepend batched with a visible append', async () => {
- const { room, timeline, events } = createRoom();
- const prependedEvent = makeLiveEvent(room.roomId, 1) as unknown as MatrixEvent;
- const appendedEvent = makeLiveEvent(room.roomId, 2) as unknown as MatrixEvent;
- const isEventVisible = (mEvent: MatrixEvent) => mEvent === appendedEvent;
- const { result } = renderSyncHook(room, { isAtBottom: false, isEventVisible });
-
- await act(async () => {
- room.emit(RoomEvent.Timeline, prependedEvent, room, true, false, {
- liveEvent: false,
- timeline,
- });
- events.push({});
- room.emit(RoomEvent.Timeline, appendedEvent, room, false, false, {
- liveEvent: true,
- timeline,
- });
- await Promise.resolve();
- });
-
- expect(result.current.prependVersion).toBe(1);
- });
-
it('ignores timeline events emitted for a different room', async () => {
const { room, timeline, events } = createRoom();
const otherRoom = createRoom('!other:test');
@@ -2170,6 +2148,29 @@ describe('event jump recovery', () => {
});
});
+ it('keeps a permalink context window when sliding sync resets the live timeline', async () => {
+ const fixture = setupUnloadedTarget('$target:test');
+ const { result } = renderSyncHook(fixture.room, { isAtBottom: false, mx: fixture.mx });
+
+ await act(async () => {
+ await result.current.loadEventTimeline('$target:test');
+ });
+ const contextTimeline = result.current.timeline;
+ const timelineSet = fixture.room.getUnfilteredTimelineSet();
+
+ await act(async () => {
+ timelineSet.emit(RoomEvent.TimelineReset, undefined, timelineSet, true);
+ await Promise.resolve();
+ });
+
+ expect(result.current.timeline).toBe(contextTimeline);
+ expect(result.current.focusItem).toEqual({
+ eventId: '$target:test',
+ scrollTo: true,
+ highlight: true,
+ });
+ });
+
it('falls back to the initial timeline when a jump load times out', async () => {
vi.useFakeTimers();
try {
diff --git a/src/app/hooks/timeline/useTimelineSync.ts b/src/app/hooks/timeline/useTimelineSync.ts
index 0ea2f6242..a214741be 100644
--- a/src/app/hooks/timeline/useTimelineSync.ts
+++ b/src/app/hooks/timeline/useTimelineSync.ts
@@ -206,7 +206,7 @@ const useTimelinePagination = (
const edgeTimeline = (lTimelines: EventTimeline[], backwards: boolean) =>
backwards ? lTimelines[0] : lTimelines.at(-1);
- return async (backwards: boolean) => {
+ return async (backwards: boolean, autoContinue = false) => {
const directionKey = backwards ? 'backward' : 'forward';
if (fetchingRef.current[directionKey]) return;
@@ -231,7 +231,8 @@ const useTimelinePagination = (
let settledStatus: PaginationStatus = 'idle';
try {
- for (let attempt = 0; attempt <= MAX_AUTO_CONTINUATIONS; attempt += 1) {
+ const maxAttempts = autoContinue ? MAX_AUTO_CONTINUATIONS : 0;
+ for (let attempt = 0; attempt <= maxAttempts; attempt += 1) {
const lTimelines = timelineRef.current.linkedTimelines;
const timelineToPaginate = edgeTimeline(lTimelines, backwards);
if (!timelineToPaginate) return;
@@ -448,7 +449,6 @@ export function useTimelineSync({
const [focusItem, setFocusItem] = useState();
const [jumpFailedFor, setJumpFailedFor] = useState();
- const [prependVersion, setPrependVersion] = useState(0);
const jumpFailed = jumpFailedFor !== undefined && jumpFailedFor === eventId;
const resetAutoScrollPendingRef = useRef(false);
@@ -621,16 +621,13 @@ export function useTimelineSync({
useLiveEventArrive(
room,
useCallback(
- (mEvt: MatrixEvent, isLive: boolean, evtTimeline?: EventTimeline, prepended?: boolean) => {
+ (mEvt: MatrixEvent, isLive: boolean, evtTimeline?: EventTimeline) => {
if (mEvt.isRedaction()) redactInFocusedWindow(mEvt);
const isDisplayedTimeline =
evtTimeline === undefined || linkedTimelinesRef.current.includes(evtTimeline);
if (isDisplayedTimeline) {
setActiveTimeline((ct) => ({ ...ct }));
- if (prepended) {
- setPrependVersion((version) => version + 1);
- }
}
if (!isLive) return;
@@ -729,8 +726,8 @@ export function useTimelineSync({
useLiveTimelineRefresh(
room,
useCallback(() => {
- applyLiveTimeline(getInitialTimeline(room).linkedTimelines);
if (focusedTimelineRef.current || inFlightJumpRef.current) return;
+ applyLiveTimeline(getInitialTimeline(room).linkedTimelines);
if (eventId) {
void loadEventTimeline(eventId);
return;
@@ -798,7 +795,6 @@ export function useTimelineSync({
return {
timeline,
eventsLength,
- prependVersion,
liveTimelineLinked,
canPaginateBack,
canPaginateForward,
diff --git a/tests/e2e/fixtures/timelineOrder.ts b/tests/e2e/fixtures/timelineOrder.ts
index 62c569751..4cc788a04 100644
--- a/tests/e2e/fixtures/timelineOrder.ts
+++ b/tests/e2e/fixtures/timelineOrder.ts
@@ -1,4 +1,4 @@
-import { expect, type Page } from '@playwright/test';
+import { expect, type Locator, type Page } from '@playwright/test';
import { getRoomMessages } from './continuwuity';
/** Event IDs for `tag`, in the server's canonical order. */
@@ -52,8 +52,48 @@ export function expectNoDuplicateRows(rendered: string[]): void {
/** Scrolls the timeline up until `text` back-paginates into view. */
export async function wheelToTopUntilVisible(page: Page, text: string): Promise {
await expect(async () => {
- await page.mouse.move(640, 400);
+ await timelineScroller(page).hover();
await page.mouse.wheel(0, -2400);
expect(await page.getByText(text, { exact: true }).count()).toBeGreaterThan(0);
}).toPass({ timeout: 120_000, intervals: [500] });
}
+
+/** Scrolls the timeline down until `text` forward-paginates into view. */
+export async function wheelToBottomUntilVisible(page: Page, text: string): Promise {
+ await expect(async () => {
+ await timelineScroller(page).hover();
+ await page.mouse.wheel(0, 2400);
+ expect(await page.getByText(text, { exact: true }).count()).toBeGreaterThan(0);
+ }).toPass({ timeout: 120_000, intervals: [500] });
+}
+
+export const timelineScroller = (page: Page): Locator => page.locator('#timeline-scroller');
+
+export async function timelineDistanceFromBottom(page: Page): Promise {
+ return timelineScroller(page).evaluate(
+ (element) => element.scrollHeight - element.scrollTop - element.clientHeight
+ );
+}
+
+export async function waitForTimelineScrollSettle(page: Page): Promise {
+ await expect
+ .poll(async () => {
+ const first = await timelineScroller(page).evaluate((element) => element.scrollTop);
+ await page.evaluate(
+ () =>
+ new Promise((resolve) =>
+ requestAnimationFrame(() => requestAnimationFrame(resolve))
+ )
+ );
+ const second = await timelineScroller(page).evaluate((element) => element.scrollTop);
+ return Math.abs(second - first);
+ })
+ .toBeLessThanOrEqual(1);
+}
+
+/** Waits for a rendered message's scroll container to settle at the live edge. */
+export async function expectTimelineAtBottom(page: Page): Promise {
+ await expect
+ .poll(() => timelineDistanceFromBottom(page), { timeout: 10_000 })
+ .toBeLessThanOrEqual(2);
+}
diff --git a/tests/e2e/permalink-jump.spec.ts b/tests/e2e/permalink-jump.spec.ts
index 2165e63b2..ac05e64a9 100644
--- a/tests/e2e/permalink-jump.spec.ts
+++ b/tests/e2e/permalink-jump.spec.ts
@@ -1,6 +1,7 @@
import { readFile } from 'node:fs/promises';
import { test, expect, type Page } from '@playwright/test';
import { createRoom, registerUser, sendMessage, sendText } from './fixtures/continuwuity';
+import { wheelToBottomUntilVisible, wheelToTopUntilVisible } from './fixtures/timelineOrder';
import { AppShell } from './pages/AppShell';
const PASSWORD = 'test-passw0rd';
@@ -75,7 +76,6 @@ test.describe('permalink jumps', () => {
test('jumps to a message beyond the loaded window when its permalink is clicked', async ({
page,
}, testInfo) => {
- test.skip(testInfo.project.name !== 'desktop', 'desktop-focused');
test.setTimeout(300_000);
const storageStatePath = testInfo.project.use.storageState as string;
const hsBaseUrl = await homeserverBaseUrl(storageStatePath);
@@ -90,10 +90,12 @@ test.describe('permalink jumps', () => {
// The client initially loads only the latest 60 events, so message 20 sits
// outside the loaded timeline: the jump has to fetch its context.
+ let firstId = '';
let targetId = '';
let latestId = '';
for (let i = 1; i <= HISTORY_SIZE; i += 1) {
const eventId = await sendText(hsBaseUrl, user.accessToken, room, `${tag}-${i}`, i);
+ if (i === 1) firstId = eventId;
if (i === 20) targetId = eventId;
latestId = eventId;
}
@@ -111,6 +113,18 @@ test.describe('permalink jumps', () => {
await expect(targetRow).toBeVisible({ timeout: 60_000 });
await expect(app.messageByEventId(latestId)).toHaveCount(0);
+ await expect(app.messageByEventId(firstId)).toHaveCount(0);
+
+ await page.reload();
+ await expect(targetRow).toBeInViewport({ timeout: 60_000 });
+ await expect(app.messageByEventId(latestId)).toHaveCount(0);
+ await expect(app.messageByEventId(firstId)).toHaveCount(0);
+
+ await wheelToTopUntilVisible(page, `${tag}-1`);
+ await expect(app.messageByEventId(firstId)).toBeVisible({ timeout: 60_000 });
+
+ await wheelToBottomUntilVisible(page, `${tag}-${HISTORY_SIZE}`);
+ await expect(app.messageByEventId(latestId)).toBeVisible({ timeout: 60_000 });
const sentBody = `${tag}-after-jump`;
await app.sendTextMessage(sentBody);
diff --git a/tests/e2e/sliding-sync-timeline.spec.ts b/tests/e2e/sliding-sync-timeline.spec.ts
index 301ba97b8..5d2af956e 100644
--- a/tests/e2e/sliding-sync-timeline.spec.ts
+++ b/tests/e2e/sliding-sync-timeline.spec.ts
@@ -1,11 +1,19 @@
import { readFile } from 'node:fs/promises';
import { test, expect, type Page } from '@playwright/test';
-import { createRoom, registerUser, sendText } from './fixtures/continuwuity';
+import { createRoom, inviteUser, joinRoom, registerUser, sendText } from './fixtures/continuwuity';
+import {
+ expectTimelineAtBottom,
+ timelineScroller,
+ wheelToBottomUntilVisible,
+} from './fixtures/timelineOrder';
import { AppShell } from './pages/AppShell';
const PASSWORD = 'test-passw0rd';
const HISTORY_SIZE = 100;
const SEND_DELAYS_MS = [0, 150, 0, 400, 50];
+const TEST_TIMEOUT = 60_000;
+const SYNC_TIMEOUT = 45_000;
+const UI_TIMEOUT = 30_000;
type InjectedSession = {
baseUrl: string;
@@ -26,7 +34,8 @@ async function homeserverBaseUrl(storageStatePath: string): Promise {
async function loginAsFreshUser(
page: Page,
baseUrl: string,
- name: string
+ name: string,
+ slidingSyncOptIn: boolean
): Promise<{ accessToken: string }> {
const user = await registerUser(baseUrl, name, PASSWORD);
const session: InjectedSession = {
@@ -34,7 +43,7 @@ async function loginAsFreshUser(
userId: user.userId,
deviceId: user.deviceId,
accessToken: user.accessToken,
- slidingSyncOptIn: true,
+ slidingSyncOptIn,
};
await page.addInitScript((injected: InjectedSession) => {
localStorage.setItem('matrixSessions', JSON.stringify([injected]));
@@ -74,120 +83,136 @@ async function sendHistory(
async function wheelToTopUntilVisible(page: Page, text: string): Promise {
await expect(async () => {
- await page.mouse.move(640, 400);
+ await timelineScroller(page).hover();
await page.mouse.wheel(0, -2400);
expect(await page.getByText(text, { exact: true }).count()).toBeGreaterThan(0);
- }).toPass({ timeout: 120_000, intervals: [500] });
+ }).toPass({ timeout: UI_TIMEOUT, intervals: [500] });
}
-test.describe('sliding sync timeline', () => {
- test('paginates backwards through pre-subscription history after leaving and reopening a room', async ({
- page,
- }, testInfo) => {
- test.skip(testInfo.project.name !== 'desktop', 'desktop-focused');
- test.setTimeout(300_000);
- const storageStatePath = testInfo.project.use.storageState as string;
- const hsBaseUrl = await homeserverBaseUrl(storageStatePath);
- const tag = `hist-${process.pid}-${Date.now().toString(36)}`;
- const app = new AppShell(page);
- const user = await loginAsFreshUser(page, hsBaseUrl, `${tag}-u`);
+const syncTransports = [
+ { name: 'sliding sync', slidingSyncOptIn: true },
+ { name: 'legacy sync', slidingSyncOptIn: false },
+];
- const room = await createRoom(hsBaseUrl, user.accessToken, {
- name: `${tag} History`,
- preset: 'private_chat',
- });
- const away = await createRoom(hsBaseUrl, user.accessToken, {
- name: `${tag} Away`,
- preset: 'private_chat',
- });
+for (const transport of syncTransports) {
+ test.describe(`timeline lifecycle (${transport.name})`, () => {
+ test('paginates backwards through pre-subscription history after leaving and reopening a room', async ({
+ page,
+ }, testInfo) => {
+ test.setTimeout(TEST_TIMEOUT);
+ const storageStatePath = testInfo.project.use.storageState as string;
+ const hsBaseUrl = await homeserverBaseUrl(storageStatePath);
+ const tag = `hist-${process.pid}-${Date.now().toString(36)}`;
+ const app = new AppShell(page);
+ const user = await loginAsFreshUser(page, hsBaseUrl, `${tag}-u`, transport.slidingSyncOptIn);
- const bodies = ['sentinel', ...Array.from({ length: HISTORY_SIZE - 1 }, (_, i) => `m${i}`)];
- const latest = `${tag}-m${HISTORY_SIZE - 2}`;
- const sentinel = `${tag}-sentinel`;
- await sendHistory(hsBaseUrl, user.accessToken, room, tag, bodies);
- await sendMessage(hsBaseUrl, user.accessToken, away, `${tag}-away-msg`);
-
- await page.goto('/');
- await expect(page.getByText(`${tag} History`).first()).toBeVisible({
- timeout: 180_000,
- });
-
- await app.openRoom(`${tag} History`);
- await expect(page.getByText(latest, { exact: true }).first()).toBeVisible({
- timeout: 180_000,
- });
- expect(await page.getByText(sentinel, { exact: true }).count()).toBe(0);
-
- await app.openRoom(`${tag} Away`);
- await expect(page.getByText(`${tag}-away-msg`, { exact: true })).toBeVisible({
- timeout: 120_000,
- });
-
- await app.openRoom(`${tag} History`);
- await expect(page.getByText(latest, { exact: true }).first()).toBeVisible({
- timeout: 120_000,
- });
- expect(await page.getByText(sentinel, { exact: true }).count()).toBe(0);
-
- await wheelToTopUntilVisible(page, sentinel);
- });
-
- test('renders messages received while the room was inactive exactly once, in order, after reopening', async ({
- page,
- }, testInfo) => {
- test.skip(testInfo.project.name !== 'desktop', 'desktop-focused');
- test.setTimeout(300_000);
- const storageStatePath = testInfo.project.use.storageState as string;
- const hsBaseUrl = await homeserverBaseUrl(storageStatePath);
- const tag = `live-${process.pid}-${Date.now().toString(36)}`;
- const app = new AppShell(page);
- const user = await loginAsFreshUser(page, hsBaseUrl, `${tag}-u`);
-
- const room = await createRoom(hsBaseUrl, user.accessToken, {
- name: `${tag} Home`,
- preset: 'private_chat',
- });
- const away = await createRoom(hsBaseUrl, user.accessToken, {
- name: `${tag} Away`,
- preset: 'private_chat',
- });
-
- await sendMessage(hsBaseUrl, user.accessToken, room, `${tag}-seed`);
- await sendMessage(hsBaseUrl, user.accessToken, away, `${tag}-away-msg`);
-
- await page.goto('/');
- await expect(page.getByText(`${tag} Home`).first()).toBeVisible({
- timeout: 180_000,
- });
-
- await app.openRoom(`${tag} Home`);
- await expect(page.getByText(`${tag}-seed`, { exact: true })).toBeVisible({
- timeout: 180_000,
- });
-
- await app.openRoom(`${tag} Away`);
- await expect(page.getByText(`${tag}-away-msg`, { exact: true })).toBeVisible({
- timeout: 120_000,
- });
-
- for (let i = 0; i < SEND_DELAYS_MS.length; i += 1) {
- if (SEND_DELAYS_MS[i]! > 0) await page.waitForTimeout(SEND_DELAYS_MS[i]!);
- await sendMessage(hsBaseUrl, user.accessToken, room, `${tag}-live-${i + 1}`);
- }
-
- await app.openRoom(`${tag} Home`);
- await expect(page.getByText(`${tag}-seed`, { exact: true })).toBeVisible({
- timeout: 120_000,
- });
-
- for (let i = 0; i < SEND_DELAYS_MS.length; i += 1) {
- await expect(page.getByText(`${tag}-live-${i + 1}`, { exact: true })).toHaveCount(1, {
- timeout: 120_000,
+ const room = await createRoom(hsBaseUrl, user.accessToken, {
+ name: `${tag} DM`,
+ preset: 'private_chat',
+ });
+ const remote = await registerUser(hsBaseUrl, `${tag}-remote`, PASSWORD);
+ await inviteUser(hsBaseUrl, user.accessToken, room, remote.userId);
+ await joinRoom(hsBaseUrl, remote.accessToken, room);
+ const away = await createRoom(hsBaseUrl, user.accessToken, {
+ name: `${tag} Away`,
+ preset: 'private_chat',
});
- await expect(page.getByText(`${tag}-live-${i + 1}`, { exact: true })).toBeVisible();
- }
- const domOrder = await page.getByText(new RegExp(`^${tag}-live-\\d+$`)).allTextContents();
- expect(domOrder).toEqual(SEND_DELAYS_MS.map((_, i) => `${tag}-live-${i + 1}`));
+ const bodies = ['sentinel', ...Array.from({ length: HISTORY_SIZE - 1 }, (_, i) => `m${i}`)];
+ const latest = `${tag}-m${HISTORY_SIZE - 2}`;
+ const sentinel = `${tag}-sentinel`;
+ await sendHistory(hsBaseUrl, remote.accessToken, room, tag, bodies);
+ await sendMessage(hsBaseUrl, user.accessToken, away, `${tag}-away-msg`);
+
+ await page.goto('/');
+ await expect(page.getByText(`${tag} DM`).first()).toBeVisible({
+ timeout: SYNC_TIMEOUT,
+ });
+
+ await app.openRoom(`${tag} DM`);
+ await expect(page.getByText(latest, { exact: true }).first()).toBeVisible({
+ timeout: SYNC_TIMEOUT,
+ });
+ await expectTimelineAtBottom(page);
+ expect(await page.getByText(sentinel, { exact: true }).count()).toBe(0);
+
+ if (testInfo.project.name === 'mobile') await page.goto('/');
+ await app.openRoom(`${tag} Away`);
+ await expect(page.getByText(`${tag}-away-msg`, { exact: true })).toBeVisible({
+ timeout: UI_TIMEOUT,
+ });
+
+ if (testInfo.project.name === 'mobile') await page.goto('/');
+ await app.openRoom(`${tag} DM`);
+ await expect(page.getByText(latest, { exact: true }).first()).toBeVisible({
+ timeout: UI_TIMEOUT,
+ });
+ await expectTimelineAtBottom(page);
+ expect(await page.getByText(sentinel, { exact: true }).count()).toBe(0);
+
+ await wheelToTopUntilVisible(page, sentinel);
+
+ await wheelToBottomUntilVisible(page, latest);
+ });
+
+ test('renders messages received while the room was inactive exactly once, in order, after reopening', async ({
+ page,
+ }, testInfo) => {
+ test.setTimeout(TEST_TIMEOUT);
+ const storageStatePath = testInfo.project.use.storageState as string;
+ const hsBaseUrl = await homeserverBaseUrl(storageStatePath);
+ const tag = `live-${process.pid}-${Date.now().toString(36)}`;
+ const app = new AppShell(page);
+ const user = await loginAsFreshUser(page, hsBaseUrl, `${tag}-u`, transport.slidingSyncOptIn);
+
+ const room = await createRoom(hsBaseUrl, user.accessToken, {
+ name: `${tag} Home`,
+ preset: 'private_chat',
+ });
+ const away = await createRoom(hsBaseUrl, user.accessToken, {
+ name: `${tag} Away`,
+ preset: 'private_chat',
+ });
+
+ await sendMessage(hsBaseUrl, user.accessToken, room, `${tag}-seed`);
+ await sendMessage(hsBaseUrl, user.accessToken, away, `${tag}-away-msg`);
+
+ await page.goto('/');
+ await expect(page.getByText(`${tag} Home`).first()).toBeVisible({
+ timeout: SYNC_TIMEOUT,
+ });
+
+ await app.openRoom(`${tag} Home`);
+ await expect(page.getByText(`${tag}-seed`, { exact: true })).toBeVisible({
+ timeout: SYNC_TIMEOUT,
+ });
+
+ if (testInfo.project.name === 'mobile') await page.goto('/');
+ await app.openRoom(`${tag} Away`);
+ await expect(page.getByText(`${tag}-away-msg`, { exact: true })).toBeVisible({
+ timeout: UI_TIMEOUT,
+ });
+
+ for (let i = 0; i < SEND_DELAYS_MS.length; i += 1) {
+ if (SEND_DELAYS_MS[i]! > 0) await page.waitForTimeout(SEND_DELAYS_MS[i]!);
+ await sendMessage(hsBaseUrl, user.accessToken, room, `${tag}-live-${i + 1}`);
+ }
+
+ if (testInfo.project.name === 'mobile') await page.goto('/');
+ await app.openRoom(`${tag} Home`);
+ await expect(page.getByText(`${tag}-seed`, { exact: true })).toBeVisible({
+ timeout: UI_TIMEOUT,
+ });
+
+ for (let i = 0; i < SEND_DELAYS_MS.length; i += 1) {
+ await expect(page.getByText(`${tag}-live-${i + 1}`, { exact: true })).toHaveCount(1, {
+ timeout: UI_TIMEOUT,
+ });
+ await expect(page.getByText(`${tag}-live-${i + 1}`, { exact: true })).toBeVisible();
+ }
+
+ const domOrder = await page.getByText(new RegExp(`^${tag}-live-\\d+$`)).allTextContents();
+ expect(domOrder).toEqual(SEND_DELAYS_MS.map((_, i) => `${tag}-live-${i + 1}`));
+ });
});
-});
+}