Verify physical reading stability through background completion (U5)

Why: Retained React nodes alone did not prove actual browser scrolling was preserved.

Evidence: The settled Chromium case failed on the previous bundle, then all 11 browser cases passed with exact material, scroll and focus assertions.

Impact: Browser regression coverage only; fixture transport stays outside the production bundle.

Refs: UI10, ce-code-review UI finding #3, work-companion-ui
This commit is contained in:
2026-10-12 17:57:43 +00:00
parent ac668d11d3
commit e6eecb2bfa
+35
View File
@@ -125,6 +125,41 @@ test('keeps one expanded ordinary summary when the desktop work pane opens', asy
expect(state.errors).toEqual([])
})
test('preserves the selected material, physical scroll and focus when background work finishes', async ({ page }) => {
await page.setViewportSize({ width: 1440, height: 960 })
const tabbed = work('work1', 'active', { body: [...progress.body!, {
type: 'tabs', id: 'materials', tabs: { tabs: [
{ id: 'first', label: '第一份材料', nodes: [{ type: 'markdown', markdown: '第一份材料的范围' }] },
{ id: 'second', label: '第二份材料', nodes: [{ type: 'markdown', markdown: Array.from({ length: 70 }, (_, i) => `待核对事项 ${i + 1}`).join('\n\n') }] },
] },
}] })
const state = await fixture(page, [tabbed, work('peer', 'active', { body: [] })])
await page.getByRole('button', { name: '打开工作', exact: true }).click()
const card = page.locator('.right-panel [data-card-id="work1"]')
await card.getByRole('button', { name: '查看依据与范围', exact: true }).click()
const tab = card.getByRole('tab', { name: '第二份材料', exact: true })
await tab.click()
await tab.focus()
const details = card.locator('.acard-detail-body')
await expect.poll(() => details.evaluate(element => element.clientHeight)).toBe(420)
const physical = await details.evaluate(element => {
Object.assign(window, { __workReading: element })
element.scrollTop = 137
return { height: element.clientHeight, scrollHeight: element.scrollHeight, top: element.scrollTop }
})
expect(physical.scrollHeight).toBeGreaterThan(physical.height)
expect(physical.top).toBe(137)
await state.emit('card.status', { cardId: 'work1', status: 'done' }, 12)
await expect(card.locator('.acard-status')).toHaveText('已完成')
await expect(tab).toHaveAttribute('aria-selected', 'true')
expect(await details.evaluate(element => ({
retained: (window as typeof window & { __workReading: Element }).__workReading === element,
top: element.scrollTop,
}))).toEqual({ retained: true, top: 137 })
expect(await tab.evaluate(element => document.activeElement === element)).toBe(true)
expect(state.errors).toEqual([])
})
test('shares submitting feedback between conversation and work confirmations', async ({ page }) => {
const state = await fixture(page, [confirmation])
await page.getByRole('button', { name: '打开工作', exact: true }).click()