test(web): align translation replay with plugin-owned controls

This commit is contained in:
imccyu committed 2026-10-09 01:57:14 +08:00
1 parent a561924313
commit 6576ff5bf1
2 files changed
+7 -7

No files matched your search

+2 -3
View File
@@ -193,10 +193,9 @@ it.skipIf(MODE === 'record')('reuses saved native Account Flash translations acr
expect(calls).toHaveLength(1)
await compareOrRefreshGolden(join(EXPECTED, 'paid-result.expected.md'),
await captureStableAria(page, '[data-variant="think"]', scaffold.workspaceCwd), MODE)
await reasoning.hover()
await reasoning.getByRole('button', { name: '查看原文', exact: true }).click()
await translated.getByRole('button', { name: '查看原文', exact: true }).click()
await translated.getByText(ORIGINAL, { exact: true }).waitFor()
await reasoning.getByRole('button', { name: '查看译文', exact: true }).click()
await translated.getByRole('button', { name: '查看译文', exact: true }).click()
expect(calls).toHaveLength(1)
const saved = await readPersistedEvents(scaffold, auditSessionId)
expect(saved.filter(event => !isTranslationRecord(event))).toEqual(events)
+5 -4
View File
@@ -226,10 +226,11 @@ it.skipIf(MODE === 'record')('persists Bing reasoning translation across reopen
return [style.fontFamily, style.fontSize, style.fontWeight, style.lineHeight, style.color, style.padding, style.margin]
})
const translatedTypography = await typography()
const originalAction = reasoning.getByRole('button', { name: '查看原文', exact: true })
const originalAction = body.getByRole('button', { name: '查看原文', exact: true })
await composer.focus()
await page.mouse.move(0, 0)
await expect.poll(() => originalAction.evaluate(element => getComputedStyle(element).opacity)).toBe('0')
await expect.poll(() => originalAction.evaluate(element => getComputedStyle(element).opacity)).toBe('1')
expect(await originalAction.evaluate(element => element.closest('[data-disclosure-header]') === null)).toBe(true)
await originalAction.focus()
await expect.poll(() => originalAction.evaluate(element => getComputedStyle(element).opacity)).toBe('1')
await originalAction.press('Enter')
@@ -237,11 +238,11 @@ it.skipIf(MODE === 'record')('persists Bing reasoning translation across reopen
expect(await body.getAttribute('data-translation-view')).toBe('original')
expect(await typography()).toEqual(translatedTypography)
await page.mouse.move(0, 0)
const translationAction = reasoning.getByRole('button', { name: '查看译文', exact: true })
const translationAction = body.getByRole('button', { name: '查看译文', exact: true })
const titleBox = await reasoning.getByRole('button', { name: '思考', exact: true }).boundingBox()
const actionBox = await translationAction.boundingBox()
if (titleBox === null || actionBox === null) throw new Error('Reasoning title and translation action must be visible')
expect(actionBox.y + actionBox.height / 2).toBeCloseTo(titleBox.y + titleBox.height / 2, 1)
expect(actionBox.y).toBeGreaterThanOrEqual(titleBox.y + titleBox.height)
expect(await translationAction.evaluate(element => getComputedStyle(element).opacity)).toBe('1')
await translationAction.click()
await composer.focus()