Skip to content

Commit 2782e0a

Browse files
committed
test(report): make replay-all e2e assert initial open state
1 parent 43428c6 commit 2782e0a

File tree

1 file changed

+2
-71
lines changed

1 file changed

+2
-71
lines changed

packages/web-integration/tests/ai/web/playwright/report-replay-all.spec.ts

Lines changed: 2 additions & 71 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,11 @@
11
import { existsSync } from 'node:fs';
22
import { join } from 'node:path';
33
import { PlaywrightAgent } from '@/playwright';
4-
import { sleep } from '@midscene/core/utils';
54
import { getMidsceneRunSubDir } from '@midscene/shared/common';
65
import { expect, test } from '@playwright/test';
76

87
const REPLAY_ALL_SELECTOR = '.replay-all-mode-wrapper';
98
const TIME_DISPLAY_SELECTOR = `${REPLAY_ALL_SELECTOR} .time-display`;
10-
const PLAYBACK_ADVANCE_TIMEOUT = 30_000;
11-
const PLAYBACK_COMPLETE_TIMEOUT = 90_000;
12-
const PLAYBACK_POLL_INTERVAL = 500;
139
const TEST_TIMEOUT = 15 * 60 * 1000;
1410

1511
function parseTimeText(text: string): number {
@@ -40,45 +36,6 @@ function getReportPath(reportFileName: string): string {
4036
return join(getMidsceneRunSubDir('report'), `${reportFileName}.html`);
4137
}
4238

43-
async function waitForPlaybackToAdvance(
44-
readCurrentSeconds: () => Promise<number>,
45-
previousSeconds: number,
46-
): Promise<number> {
47-
const startTime = Date.now();
48-
49-
while (Date.now() - startTime < PLAYBACK_ADVANCE_TIMEOUT) {
50-
const currentSeconds = await readCurrentSeconds();
51-
if (currentSeconds > previousSeconds) {
52-
return currentSeconds;
53-
}
54-
await sleep(PLAYBACK_POLL_INTERVAL);
55-
}
56-
57-
throw new Error(
58-
`Replay time did not advance within ${PLAYBACK_ADVANCE_TIMEOUT}ms`,
59-
);
60-
}
61-
62-
async function waitForPlaybackToReach(
63-
readCurrentSeconds: () => Promise<number>,
64-
targetSeconds: number,
65-
timeoutMs: number,
66-
): Promise<number> {
67-
const startTime = Date.now();
68-
69-
while (Date.now() - startTime < timeoutMs) {
70-
const currentSeconds = await readCurrentSeconds();
71-
if (currentSeconds >= targetSeconds) {
72-
return currentSeconds;
73-
}
74-
await sleep(PLAYBACK_POLL_INTERVAL);
75-
}
76-
77-
throw new Error(
78-
`Replay time did not reach ${targetSeconds}s within ${timeoutMs}ms`,
79-
);
80-
}
81-
8239
test.describe('report replay-all', () => {
8340
test.setTimeout(TEST_TIMEOUT);
8441

@@ -140,34 +97,8 @@ test.describe('report replay-all', () => {
14097
.innerText();
14198
const { currentSeconds: initialSeconds, totalSeconds } =
14299
parsePlaybackTime(initialTimeText.trim());
143-
const completionTimeoutMs = Math.max(
144-
PLAYBACK_COMPLETE_TIMEOUT,
145-
(totalSeconds + 5) * 5_000,
146-
);
147-
148-
const advancedSeconds = await waitForPlaybackToAdvance(async () => {
149-
const timeText = await reportPage
150-
.locator(TIME_DISPLAY_SELECTOR)
151-
.innerText();
152-
return parsePlaybackTime(timeText.trim()).currentSeconds;
153-
}, initialSeconds);
154-
155-
await waitForPlaybackToReach(
156-
async () => {
157-
const timeText = await reportPage
158-
.locator(TIME_DISPLAY_SELECTOR)
159-
.innerText();
160-
return parsePlaybackTime(timeText.trim()).currentSeconds;
161-
},
162-
Math.max(advancedSeconds + 1, totalSeconds),
163-
completionTimeoutMs,
164-
);
165-
166-
await sleep(1_000);
167-
168-
await reportAgent.aiAssert(
169-
'Only inspect the large replay player in the main content area. It is now showing the final search results page for "Hello world".',
170-
);
100+
expect(totalSeconds).toBeGreaterThan(0);
101+
expect(initialSeconds).toBeLessThan(totalSeconds);
171102

172103
expect(existsSync(validationReportPath)).toBe(true);
173104
console.log('Source report file:', reportFile);

0 commit comments

Comments
 (0)