Files
deepseek-harness/apps/web/tests/workspace-new-session-folding.e2e.ts
T
Tianyi Cui 62ac57218d test(web): correct the states the new comments and note name
Review found two factual errors in the prose this change adds.

plugin-install-cancel: the scenario pauses the page clock before the
enable click, so the highlight's `setTimeout(clearHighlight, 2400)`
cannot fire while the status poll runs. The comment claimed a reload
could outlive that expiry, and the note explained the two CI timeouts
at the untouched highlight locator the same way. The cause of those
timeouts is not diagnosed, so both now say so instead of offering a
mechanism the paused clock rules out. The pre-change file reproduces the
same hang under the same lane command, which the note records.

workspace-new-session-folding: `nth(7)` is the first row the batch
reveals, not the last established one, and the reflowing `showMore.click()`
is above the comment, not below. Both are corrected, and the workspace-row
comment names what `:hover` reveals instead of restating a cell swap the
project row does not have.

turn-tail-actions: clear the pointer modality flag with `Shift`, which
moves no focus, matching focus-rings.e2e.ts.
2026-09-27 20:13:00 +08:00

115 lines
5.3 KiB
TypeScript

/** Blank New Session folding through the shipped Web composition. */
import { readFile } from 'node:fs/promises'
import { basename, join } from 'node:path'
import { fileURLToPath } from 'node:url'
import type { Browser, Page } from 'playwright'
import { chromium } from 'playwright'
import { afterAll, beforeAll, describe, expect, it, onTestFailed } from 'vitest'
import {
assertFixtureInventory,
captureStableAria,
compareOrRefreshGolden,
launchWebScaffold,
seedSession,
watchConsole,
webSnapshotMode,
type WebScaffold,
} from './scaffold.ts'
import { newEnglishPage, saveFailureShot } from './support.ts'
const EXPECTED_DIR = fileURLToPath(new URL('./expected/workspace-new-session-folding', import.meta.url))
const SIDEBAR_EXPECTED = join(EXPECTED_DIR, 'sidebar.expected.md')
const SEED = fileURLToPath(new URL('../../../snapshots/web/message-feedback-protocol/session.v3.jsonl', import.meta.url))
const MODE = webSnapshotMode()
const EXISTING_SESSION_COUNT = 16
describe('web e2e: blank New Session folding quota', () => {
let scaffold: WebScaffold
let browser: Browser
let page: Page
let tripwire: ReturnType<typeof watchConsole>
beforeAll(async () => {
scaffold = await launchWebScaffold({})
const fixture = await readFile(SEED, 'utf8')
const sessionIds = []
for (let index = 1; index <= EXISTING_SESSION_COUNT; index += 1) {
sessionIds.push(await seedSession(
scaffold,
fixture,
`workspace-new-session-folding-${String(index).padStart(2, '0')}`,
))
}
const workspace = await scaffold.ctx.workspaceRegistry.create(scaffold.workspaceCwd)
for (const sessionId of sessionIds) await workspace.attachSession(sessionId)
browser = await chromium.launch()
page = await newEnglishPage(browser)
tripwire = watchConsole(page)
await page.goto(scaffold.authenticatedUrl, { waitUntil: 'load' })
await page.waitForSelector('[class*="frame"]', { timeout: 30_000 })
const workspaceTitle = basename(scaffold.workspaceCwd)
const workspaceRow = page.getByText(workspaceTitle, { exact: true }).first()
.locator('xpath=ancestor::*[@role="treeitem"][1]')
await workspaceRow.waitFor({ timeout: 15_000 })
if (await workspaceRow.getAttribute('aria-expanded') !== 'true') await workspaceRow.click()
await workspaceRow.hover()
await page.getByRole('button', { name: `New session in ${workspaceTitle}` }).click()
await page.getByRole('tree', { name: 'Sessions' })
.getByText('New Session', { exact: true }).waitFor({ timeout: 15_000 })
}, 120_000)
afterAll(async () => {
await browser?.close()
await scaffold?.close()
})
it('keeps five established sessions beside the provisional row', async () => {
onTestFailed(() => saveFailureShot(page, 'web-e2e-workspace-new-session-folding'))
const sidebar = page.getByRole('tree', { name: 'Sessions' })
await expect.poll(() => sidebar.getByRole('treeitem').count(), { timeout: 15_000 }).toBe(7)
expect(await sidebar.getByText('New Session', { exact: true }).count()).toBe(1)
expect(await sidebar.getByText('Untitled', { exact: true }).count()).toBe(5)
const showMore = sidebar.getByRole('button', { name: 'Show 11 more sessions' })
await showMore.waitFor({ timeout: 15_000 })
// The sidebar golden records its workspace row hovered, which reveals the
// row actions `.projectRow:hover` otherwise hides. Chromium does not
// recompute `:hover` when a re-render moves rows under a pointer that does
// not move, so the state is set rather than inherited from the New Session
// click above.
await sidebar.getByRole('treeitem').first().hover()
await compareOrRefreshGolden(
SIDEBAR_EXPECTED,
await captureStableAria(page, '[role="tree"][aria-label="Sessions"]', scaffold.workspaceCwd),
MODE,
)
await showMore.click()
await expect.poll(() => sidebar.getByRole('treeitem').count(), { timeout: 10_000 }).toBe(12)
expect(await sidebar.getByText('Untitled', { exact: true }).count()).toBe(10)
// `first-batch.expected.md` records the first row the batch reveals
// hovered — the sixth session, which takes the former Show-more button's
// position. Under `:hover` its trailing cell swaps the relative time for
// the row actions. The `showMore.click()` above reflows the list beneath a
// stationary pointer, so the row that ends up there follows the layout,
// not the scenario; hover the row the golden records instead.
await sidebar.getByRole('treeitem').nth(7).hover()
await compareOrRefreshGolden(
join(EXPECTED_DIR, 'first-batch.expected.md'),
await captureStableAria(page, '[role="tree"][aria-label="Sessions"]', scaffold.workspaceCwd),
MODE,
)
await sidebar.getByRole('button', { name: 'Show 6 more sessions' }).click()
await expect.poll(() => sidebar.getByRole('treeitem').count()).toBe(17)
await sidebar.getByRole('button', { name: 'Show 1 more sessions' }).click()
await expect.poll(() => sidebar.getByRole('treeitem').count()).toBe(18)
await sidebar.getByRole('button', { name: 'Show less' }).click()
await expect.poll(() => sidebar.getByRole('treeitem').count()).toBe(7)
await assertFixtureInventory(EXPECTED_DIR, ['sidebar.expected.md', 'first-batch.expected.md'])
expect(tripwire.pageErrors).toEqual([])
expect(tripwire.warnings).toEqual([])
})
})