test(web): stabilize snapshot replay

This commit is contained in:
07akioni committed 2026-09-04 16:51:31 +08:00
1 parent 737a965e92
commit 81c6f740e0
2 files changed
+11

No files matched your search

@@ -194,6 +194,8 @@
- textbox "Message or run a task... / commands, @ files or sessions"
- button "Commands":
- img
- button "Add attachment":
- img
- 'button "Access mode, current: Workspace Write"': Workspace Write
- button "Select model, current DeepSeek-V4-Flash":
- text: DeepSeek-V4-Flash
+9
View File
@@ -38,6 +38,10 @@ const MODE = webSnapshotMode()
const NARRATION = 'Reading the workspace now.'
const PROMPT = `Begin your reply with the plain sentence "${NARRATION}" as text, and in that same message call the bash tool with the command "echo alpha". After the tool result, reply with the single word DONE and stop.`
async function waitForStatsThroughput(page: Page): Promise<void> {
await page.locator('[class*="centerCol"]').getByText(/tok\/s/).first().waitFor({ timeout: 10_000 })
}
describe('web e2e: assistant IconActions wait for the turn to end', () => {
let scaffold: WebScaffold | undefined
let browser: Browser | undefined
@@ -147,6 +151,7 @@ describe('web e2e: assistant IconActions wait for the turn to end', () => {
const copyButtons = page.getByRole('button', { name: 'Copy' })
await expect.poll(() => copyButtons.count(), { timeout: 10_000 }).toBe(1)
expect(await page.getByRole('button', { name: 'Branch into a new conversation' }).count()).toBe(0)
await waitForStatsThroughput(page)
await copyButtons.first().focus()
const running = await captureStableAria(page, '[class*="centerCol"]', scaffold!.workspaceCwd)
await compareOrRefreshGolden(RUNNING_EXPECTED, running, MODE)
@@ -160,6 +165,7 @@ describe('web e2e: assistant IconActions wait for the turn to end', () => {
await page.locator('[data-turn-process]').waitFor({ timeout: 10_000 })
await expect.poll(() => copyButtons.count(), { timeout: 10_000 }).toBe(2)
await expect.poll(() => page.locator('[data-streaming="true"]').count(), { timeout: 10_000 }).toBe(0)
await waitForStatsThroughput(page)
await copyButtons.last().focus()
const settledAria = await captureStableAria(page, '[class*="centerCol"]', scaffold!.workspaceCwd)
await compareOrRefreshGolden(SETTLED_EXPECTED, settledAria, MODE)
@@ -205,6 +211,7 @@ describe('web e2e: assistant IconActions wait for the turn to end', () => {
await page.keyboard.press('Escape')
await trigger.click()
await waitForStatsThroughput(page)
const expanded = await captureStableAria(page, '[class*="centerCol"]', scaffold!.workspaceCwd)
await compareOrRefreshGolden(USAGE_EXPANDED_EXPECTED, expanded, MODE)
expect(tripwire.pageErrors).toEqual([])
@@ -226,6 +233,7 @@ describe('web e2e: assistant IconActions wait for the turn to end', () => {
const answerTop = await page.getByText('DONE', { exact: true }).evaluate(element =>
element.closest<HTMLElement>('[data-chat-flow-kind="assistant-step"]')?.getBoundingClientRect().top)
expect(answerTop).toBe((processBottom ?? 0) + 8)
await waitForStatsThroughput(page)
await process.focus()
const completed = await captureStableAria(page, '[class*="centerCol"]', scaffold!.workspaceCwd)
await compareOrRefreshGolden(COMPLETED_EXPECTED, completed, MODE)
@@ -281,6 +289,7 @@ describe('web e2e: assistant IconActions wait for the turn to end', () => {
await expect.poll(() => process.count(), { timeout: 10_000 }).toBe(1)
expect(await process.getAttribute('aria-expanded')).toBe('true')
expect(await tool.evaluate(element => element.ownerDocument.activeElement === element)).toBe(true)
await waitForStatsThroughput(page)
const focused = await captureStableAria(page, '[class*="centerCol"]', scaffold!.workspaceCwd)
await compareOrRefreshGolden(FOCUSED_EXPECTED, focused, MODE)
expect(tripwire.pageErrors).toEqual([])