test(web): normalize the home-relative workspace row in panel captures

The Environment section's working directory row abbreviates the home
directory, and CI keeps the scratch workspace under it, so the panel
captures map the abbreviated workspace path to {{cwd}} as the reference
composer capture does.
This commit is contained in:
LegGasai committed 2026-11-11 17:38:38 +08:00
1 parent 4b5b0b716c
commit b75713f72f
2 files changed
+12 -4

No files matched your search

+6 -1
View File
@@ -2,6 +2,7 @@
// over the real Host projection frame flow.
import { fileURLToPath } from 'node:url'
import { join } from 'node:path'
import { homedir } from 'node:os'
import type { Browser, Locator, Page } from 'playwright'
import { chromium } from 'playwright'
import { afterAll, beforeAll, describe, expect, it, onTestFailed, onTestFinished, vi } from 'vitest'
@@ -10,6 +11,7 @@ import type { SessionId } from '@deepseek-ai/dsh-session'
import { brandString } from '@deepseek-ai/dsh-brand'
import type { CommandId } from '@deepseek-ai/dsh-commands/types'
import { createMessage, createUserMessage } from '@deepseek-ai/dsh-llm'
import { abbreviateHomePath } from '@deepseek-ai/dsh-util-workspace-path'
import {
acknowledgeReloadConnectionLoss, assertFixtureInventory, captureStableAria, compareOrRefreshGolden,
launchWebScaffold, watchConsole, webSnapshotMode, type WebScaffold,
@@ -419,7 +421,10 @@ describe('web e2e: agent teamwork panel', () => {
expect(await tasks.getByRole('button', { name: /^(New task|Edit|Complete|Reopen|Delete)$/u }).count()).toBe(0)
expect(await tasks.locator('input, select, textarea').count()).toBe(0)
const snapshot = await captureStableAria(page, '[data-session-panel]', scaffold.workspaceCwd)
// The working directory row abbreviates the home directory, which holds the scratch workspace on CI.
const snapshot = await captureStableAria(page, '[data-session-panel]', scaffold.workspaceCwd, {
replacements: [[abbreviateHomePath(scaffold.workspaceCwd, homedir()), '{{cwd}}']],
})
await compareOrRefreshGolden(PANEL_EXPECTED, snapshot, MODE)
expect(projectionReads).not.toHaveBeenCalled()
expect(tripwire.pageErrors).toEqual([])
+6 -3
View File
@@ -826,7 +826,9 @@ it.skipIf(MODE === 'record')('starts a Session in a worktree before its first me
await change.getByText('等待评审', { exact: true }).waitFor()
// The random branch suffix can read as a duration, so the branch is replaced before the capture normalizes durations.
await compareOrRefreshGolden(join(EXPECTED, 'panel.expected.md'),
await captureStableAria(page, '[data-session-panel]', scaffold.workspaceCwd, { replacements: [[branch, 'dsh-{{worktree}}']] }), MODE)
await captureStableAria(page, '[data-session-panel]', scaffold.workspaceCwd, {
replacements: [[branch, 'dsh-{{worktree}}'], [abbreviateHomePath(scaffold.workspaceCwd, homedir()), '{{cwd}}']],
}), MODE)
const beforeChecks = (await readFile(join(root, 'calls.jsonl'), 'utf8')).trim().split('\n').map(line => JSON.parse(line) as string[])
expect(beforeChecks.some(args => args.includes('id=rollup-7'))).toBe(false)
const checksRow = change.getByRole('button', { name: /^检查/ })
@@ -1076,8 +1078,9 @@ it.skipIf(MODE === 'record')('shows the local changes of the Session by scope an
await page.getByRole('menuitem', { name: '查看变更', exact: true }).waitFor()
expect(await page.getByRole('menuitem', { name: '创建变更请求', exact: true }).count()).toBe(0)
await card.getByRole('button', { name: '本地变更操作', exact: true }).click()
await compareOrRefreshGolden(join(EXPECTED, 'local-and-pr.expected.md'),
await captureStableAria(page, '[data-session-panel]', scaffold.workspaceCwd), MODE)
await compareOrRefreshGolden(join(EXPECTED, 'local-and-pr.expected.md'), await captureStableAria(page, '[data-session-panel]', scaffold.workspaceCwd, {
replacements: [[abbreviateHomePath(scaffold.workspaceCwd, homedir()), '{{cwd}}']],
}), MODE)
await card.getByRole('button', { name: '本地变更 · 4 个文件,新增 4 行,删除 1 行', exact: true }).click()
await local.getByText('暂存区与 HEAD 比较', { exact: true }).waitFor()
await showSessionPanel(page)