test(web): pin message snapshot calendars across midnight

This commit is contained in:
zhc committed 2026-10-22 00:14:00 +08:00
1 parent ea7c67887b
commit bc1bff3c82
6 files changed
+40 -17

No files matched your search

+4 -4
View File
@@ -3,11 +3,11 @@
# After editing either side, bring the other along and re-record with:
# pnpm run verify-translation-pairing --write apps/web/tests/README.md
/apps-web-browser-e2e:
en: 3e8ecd3509fa944f
zh: 3fd3ff9fcd1e1e90
en: 2deef0df72a6465c
zh: b24989ffb2d8586a
/apps-web-browser-e2e/completion-observations:
en: 1f9c004f3eb465fb
zh: 3e45ef8014bad48d
en: 8c139966983959cc
zh: 54f09f9b7ac84cda
/apps-web-browser-e2e/these-are-host-face-tests:
en: 101d687b1d98c5b7
zh: f8c31115e8a15be7
+4
View File
@@ -14,6 +14,8 @@ On Linux, `--with-deps` installs dependencies through the system package manager
Ordinary scenarios begin with no registered Workspace or Session and a durable marker recording a removed default Workspace, so explicit folder-selection scenarios retain control of their cwd. `launchWebScaffold({ firstUse: true })` leaves initialization eligible for startup scenarios.
Same-day message goldens use the shared `WEB_FIXTURE_TIME`: seeded transcripts pass it as `createdAt` and pin the browser calendar with `pinBrowserClock`; scenarios that submit live messages also use `pinHostClock` and restore it after teardown. These clocks advance with real elapsed time while keeping native timers intact, so midnight does not change a scenario's date labels.
## Completion observations
State-sensitive cases use Workspace, admission, attachment, and model-stream barriers to separate visible intermediate states from completed operations. Model-picker persistence assertions wait for the saved default, independently of menu closure. Details close waits for frame transitions; archive verification assigns an explicit title to the seeded Session and follows that identity across reload. The [CI test reliability workflow](../../../.agents/skills/dsh-ci-test-reliability/SKILL.md#synchronize-on-state) owns these synchronization rules.
@@ -24,6 +26,8 @@ Plugin-manager and HMR lifecycle switches wait up to `PLUGIN_TOGGLE_SETTLE_MS` (
Explicit scrolling uses `scrollIntoView` from `support.ts`: it resolves the locator again when its old element detaches and checks connection in the same browser task as native scrolling. Scenarios retain their visibility and geometry assertions after scrolling.
Question-composer resize assertions wait for overflow, the clipping mask, and toggle visibility to agree after CSS scroll timelines update.
[The snapshot after closing a sidebar pane](shortcuts-panels.e2e.ts) moves the pointer outside the controls and waits for hover tooltips to close before capture. Keyboard focus remains on the pane.
[The same-origin terminal case](sidebar-terminal.e2e.ts) waits for the UI-triggered Host close operation before checking process termination. It also checks the first window's process, saved bindings and layout after reload.
+4
View File
@@ -14,6 +14,8 @@ pnpm --filter @deepseek-ai/dsh-web-frontend exec playwright install --with-deps
普通场景以没有已登记 Workspace 或 Session、但持久化标记记录默认 Workspace 已被删除的状态启动,使显式文件夹选择场景自行决定 cwd。`launchWebScaffold({ firstUse: true })` 保留初始化资格,供启动场景使用。
当天消息的 golden 使用共享的 `WEB_FIXTURE_TIME`:预置会话将它传为 `createdAt`,并通过 `pinBrowserClock` 固定浏览器日期;提交实时消息的场景还使用 `pinHostClock`,在清理后恢复。固定后的时钟随真实耗时前进,保留原生定时器,因此跨午夜不会改变场景的日期标签。
## 完成状态观察
依赖状态的用例使用 Workspace、接纳、附件和模型流屏障,区分可见中间状态与已完成操作。模型选择器的持久化断言等待默认设置保存完成,不以菜单关闭作为完成信号。详情关闭等待框架过渡结束;归档验证为 seed Session 设置显式标题,并跨重载跟踪该身份。[CI 测试可靠性工作流](../../../.agents/skills/dsh-ci-test-reliability/SKILL.md#synchronize-on-state)负责这些同步规则。
@@ -24,6 +26,8 @@ pnpm --filter @deepseek-ai/dsh-web-frontend exec playwright install --with-deps
显式滚动使用 `support.ts` 的 `scrollIntoView`:旧元素脱离 DOM 时重新解析 locator,并在同一个浏览器任务中检查连接状态、执行原生滚动。各场景保留滚动后的可见性与几何断言。
问答输入框的缩放断言等待 CSS 滚动时间线更新,使溢出、裁剪遮罩与展开按钮的可见性一致。
[侧栏窗格关闭后的快照](shortcuts-panels.e2e.ts)在捕获前将指针移出控件,并等待悬停提示关闭。键盘焦点保持在窗格上。
[同源窗口终端用例](sidebar-terminal.e2e.ts)等待 UI 触发的 Host 关闭操作完成后,再检查进程终止。它还检查第一个窗口的进程、保存的绑定以及重载后的布局。
+18 -11
View File
@@ -21,7 +21,7 @@ import {
launchWebScaffold, recordFixture, seedSession, watchConsole, webSnapshotMode, type WebScaffold,
} from './scaffold.ts'
import {
connectFreshWorkspace, expandTurnProcesses, newEnglishPage, saveFailureShot,
connectFreshWorkspace, expandTurnProcesses, newEnglishPage, pinBrowserClock, pinHostClock, saveFailureShot, WEB_FIXTURE_TIME,
} from './support.ts'
const SNAPSHOT_DIR = fileURLToPath(new URL('../../../snapshots/web/question-composer', import.meta.url))
@@ -211,9 +211,7 @@ function resettledFixture(fixture: string, outcome: 'cancelled' | 'queued' | 'la
const event: unknown = JSON.parse(line)
if (!isRecord(event)) throw new Error('question fixture event is invalid')
if (event.type === 'session') {
// Keep the derived session's relative-time header stable as the source
// fixture ages.
event.createdAt = Date.now()
event.createdAt = WEB_FIXTURE_TIME
lines.push(JSON.stringify(event))
continue
}
@@ -299,9 +297,10 @@ async function openSeededTranscript(fixtureText: string, seedId: string): Promis
const scaffold = await launchWebScaffold({})
let browser: Browser | undefined
try {
await seedSession(scaffold, fixtureText, seedId)
await seedSession(scaffold, fixtureText, seedId, undefined, { createdAt: WEB_FIXTURE_TIME })
browser = await chromium.launch()
const page = await newEnglishPage(browser)
await pinBrowserClock(page)
const tripwire = watchConsole(page)
await page.goto(scaffold.authenticatedUrl, { waitUntil: 'load' })
await page.waitForSelector('[class*="frame"]', { timeout: 30_000 })
@@ -326,12 +325,15 @@ describe('web e2e: resident question composer round trip', () => {
let tripwire: ReturnType<typeof watchConsole>
const sessionEvents: SessionEvent[] = []
let answeredSession: SessionId | undefined
let hostClock: ReturnType<typeof pinHostClock> | undefined
beforeAll(async () => {
if (MODE !== 'record') hostClock = pinHostClock()
scaffold = await launchWebScaffold(MODE === 'record' ? {} : { replayFixture: FIXTURE, paceMs: 15, compareReplaySession: true })
scaffold.ctx.on('session/event', (_session, event: SessionEvent) => { sessionEvents.push(event) })
browser = await chromium.launch()
page = await newEnglishPage(browser)
if (MODE !== 'record') await pinBrowserClock(page)
tripwire = watchConsole(page)
await page.goto(scaffold.authenticatedUrl, { waitUntil: 'load' })
await page.waitForSelector('[class*="frame"]', { timeout: 30_000 })
@@ -340,8 +342,12 @@ describe('web e2e: resident question composer round trip', () => {
}, 120_000)
afterAll(async () => {
await browser?.close()
await scaffold?.close()
try {
await browser?.close()
} finally {
try { await scaffold?.close() }
finally { hostClock?.mockRestore() }
}
})
it('asks through the composer, answers, and completes with the answer logged', async () => {
@@ -412,10 +418,11 @@ describe('web e2e: resident question composer round trip', () => {
})
expect(squeeze.rows).toBeGreaterThan(0)
for (const description of await composer.locator('[data-option-description]').all()) {
const copy = await description.evaluate(readCopy)
expect(copy.lines).toBeLessThanOrEqual(2)
expect(copy.clipped).toBe(copy.overflows)
expect(copy.toggle).toBe(copy.clipped ? 'expand' : undefined)
await expect.poll(async () => {
const copy = await description.evaluate(readCopy)
return copy.lines <= 2 && copy.clipped === copy.overflows
&& copy.toggle === (copy.clipped ? 'expand' : undefined)
}).toBe(true)
}
scrollStates.push(squeeze.scrolls)
expect(squeeze.titleInScrollport).toBe(true)
+5 -1
View File
@@ -15,7 +15,7 @@ import {
parseSeedFixture, renderSeedFixture, seedSession, selectedSessionFixture, watchConsole, webSnapshotMode,
type WebScaffold,
} from './scaffold.ts'
import { newEnglishPage, saveFailureShot } from './support.ts'
import { newEnglishPage, pinBrowserClock, pinHostClock, saveFailureShot } from './support.ts'
const SNAPSHOT_DIR = fileURLToPath(new URL('../../../snapshots/web/rich-text-quotes', import.meta.url))
const BORROWED = fileURLToPath(new URL('../../../snapshots/web/seeded-history/session.jsonl', import.meta.url))
@@ -289,8 +289,10 @@ describe.skipIf(MODE === 'record')('web e2e: rich-text quotes', () => {
let page: Page
let replayDir: string
let tripwire: ReturnType<typeof watchConsole>
let hostClock: ReturnType<typeof pinHostClock> | undefined
beforeAll(async () => {
hostClock = pinHostClock()
replayDir = await mkdtemp(join(tmpdir(), 'dsh-rich-text-quotes-replay-'))
const replayOverride = join(replayDir, 'replay.override.json')
await writeFile(replayOverride, JSON.stringify(REPLAY))
@@ -316,6 +318,7 @@ describe.skipIf(MODE === 'record')('web e2e: rich-text quotes', () => {
await seedSession(scaffold, otherSessionFixture(borrowed), OTHER_ID, undefined, { createdAt: createdAt + 1_000 })
browser = await chromium.launch()
page = await newEnglishPage(browser)
await pinBrowserClock(page)
await page.addInitScript(({ key, value }) => {
if (localStorage.getItem(key) === null) localStorage.setItem(key, value)
}, { key: LEGACY_DRAFT_KEY, value: LEGACY_DRAFT })
@@ -336,6 +339,7 @@ describe.skipIf(MODE === 'record')('web e2e: rich-text quotes', () => {
await rm(replayDir, { recursive: true, force: true })
.catch((error: unknown) => failures.push(error))
}
hostClock?.mockRestore()
if (failures.length === 1) throw failures[0]
if (failures.length > 1) throw new AggregateError(failures, 'rich-text-quotes e2e cleanup failed')
})
+5 -1
View File
@@ -20,7 +20,7 @@ import {
launchWebScaffold, readPersistedEvents, realizeSeedFixture, seedSession, selectedSessionFixture, watchConsole,
webSnapshotMode, type WebScaffold,
} from './scaffold.ts'
import { connectFreshWorkspace, newEnglishPage, saveFailureShot, writeComposerDraft } from './support.ts'
import { connectFreshWorkspace, newEnglishPage, pinBrowserClock, pinHostClock, saveFailureShot, writeComposerDraft } from './support.ts'
const BASE_FIXTURE = fileURLToPath(new URL('../../../snapshots/web/live-interactions/session.v3.jsonl', import.meta.url))
const AVAILABLE_CHILD_EXPECTED = fileURLToPath(new URL('../../../snapshots/web/subagent-conversation/ui.expected.md', import.meta.url))
@@ -108,9 +108,11 @@ describe('web e2e: persisted subagent conversation and human continuation', () =
let liveReferenceOptions: string[]
let tripwire: ReturnType<typeof watchConsole>
const apiCalls: string[] = []
let hostClock: ReturnType<typeof pinHostClock> | undefined
beforeAll(async () => {
if (MODE === 'record') throw new Error('subagent conversation is a keyless assembled snapshot')
hostClock = pinHostClock()
const selectedBaseFixture = await selectedSessionFixture(BASE_FIXTURE)
const baseFixture = prepareSessionSnapshotFixtureForComparison(
await readFile(selectedBaseFixture, 'utf8'),
@@ -127,6 +129,7 @@ describe('web e2e: persisted subagent conversation and human continuation', () =
browser = await chromium.launch()
await mkdir(fileURLToPath(new URL('../../../.artifacts/screenshots/non-migrating-session-reads', import.meta.url)), { recursive: true })
page = await newEnglishPage(browser)
await pinBrowserClock(page)
page.on('request', (request) => {
const path = new URL(request.url()).pathname
if (path.startsWith('/api/')) apiCalls.push(path)
@@ -357,6 +360,7 @@ describe('web e2e: persisted subagent conversation and human continuation', () =
await rm(sidecarRoot, { recursive: true, force: true })
.catch((error: unknown) => failures.push(error))
}
hostClock?.mockRestore()
if (failures.length === 1) throw failures[0]
if (failures.length > 1) throw new AggregateError(failures, 'subagent Web teardown failed')
})