test(web): pin the parallel todo plan in the assembled application
The `+N` active count rides ToolRow's non-shrinking `summarySuffix` slot, but only jsdom package suites covered it: the ACP snapshots render no web surface and the built-boot smoke asserts no todo row. Add `apps/web/tests/todo-row.snapshot.ts`, which boots the built client bundles against the keyless fixture transport and records `summary`, `suffix`, and the plan strip's header as separate fields, so folding the count back into the summary string changes the expected output. The three assembled-jsdom files now share `apps/web/tests/assembled-boot.ts` instead of each carrying its own copy of the boot entry list, bundle map, jsdom stubs, and mount call. Also: name the policy branch in each `allowParallelInProgress` test title so no case asserting `true` sits under a `false` describe, reword the stale cap comment in todo-panel.spec.tsx, and record the plan strip's real header format in the Agent Note (per-status counts, not `<done>/<total> tasks`).
This commit is contained in:
72
apps/web/tests/todo-row.snapshot.ts
Normal file
72
apps/web/tests/todo-row.snapshot.ts
Normal file
@@ -0,0 +1,72 @@
|
||||
// @vitest-environment jsdom
|
||||
// Assembled todo snapshot: boots the real built `packages/client/*/lib/
|
||||
// client.js` bundles through AppWebEntry's ModuleLoader path against the
|
||||
// keyless FixtureApiClient transport, opens the fixture session, and pins the
|
||||
// two surfaces the fixture's parallel plan (turn 71, two items `in_progress`)
|
||||
// reaches — the `todo_write` tool row and the dock's plan strip.
|
||||
//
|
||||
// The row is pinned as three separate fields on purpose. `summary=` is the
|
||||
// ellipsized text and `suffix=` is ToolRow's non-shrinking `summarySuffix`
|
||||
// slot, so a regression that folds the `+N` count back into the summary string
|
||||
// changes this file even though the concatenated text would read the same; the
|
||||
// jsdom package suites bench over src and cannot see the bundled registration.
|
||||
import { mkdirSync, writeFileSync } from 'node:fs'
|
||||
import { dirname, join } from 'node:path'
|
||||
import { fireEvent, screen, waitFor, within } from '@testing-library/react'
|
||||
import { describe, expect, it } from 'vitest'
|
||||
import { hasClass, installAssembledBootEnv, mountAssembledApp } from './assembled-boot.ts'
|
||||
|
||||
const EXPECTED = join(process.cwd(), 'apps/web/tests/snapshots/todo-row/parallel-plan.expected.txt')
|
||||
const refreshing = process.env.DSH_SNAPSHOT === 'record' || process.env.DSH_SNAPSHOT === 'refresh'
|
||||
|
||||
installAssembledBootEnv()
|
||||
|
||||
/** Normalize the todo row and the plan strip to a stable text shape: the row's
|
||||
* title, its truncatable summary, its non-shrinking suffix, then the panel's
|
||||
* per-status header and every list item with its status. */
|
||||
function todoShape(row: Element, panel: Element): string {
|
||||
const pick = (from: Element, name: string): Element[] =>
|
||||
[...from.querySelectorAll('*')].filter(el => hasClass(el, name))
|
||||
const first = (from: Element, name: string): string =>
|
||||
pick(from, name)[0]?.textContent?.trim() ?? '<absent>'
|
||||
const items = [...panel.querySelectorAll('[data-status]')]
|
||||
.map(item => `item=${item.getAttribute('data-status')} ${item.textContent?.trim() ?? ''}`)
|
||||
return [
|
||||
`row=${row.getAttribute('data-tool')}`,
|
||||
`title=${first(row, 'title')}`,
|
||||
`summary=${first(row, 'summary')}`,
|
||||
`suffix=${first(row, 'summarySuffix')}`,
|
||||
`panel=${first(panel, 'progress')}`,
|
||||
...items,
|
||||
].join('\n')
|
||||
}
|
||||
|
||||
describe('assembled todo surfaces', () => {
|
||||
it('renders the parallel plan as a row summary, a separate active count, and the dock plan strip', async () => {
|
||||
mountAssembledApp()
|
||||
|
||||
const tree = await screen.findByRole('tree', { name: 'Sessions' }, { timeout: 10_000 })
|
||||
fireEvent.click(await within(tree).findByText('Fixture 历史会话'))
|
||||
// The todo turn is the fixture's last, so wait for its keyed row rather
|
||||
// than for chat content in general.
|
||||
const row = await waitFor(() => {
|
||||
const found = document.querySelector('[data-tool="todo_write"]')
|
||||
expect(found).not.toBeNull()
|
||||
return found!
|
||||
}, { timeout: 10_000 })
|
||||
// The panel is the standing plan the turn's `todo/write` event feeds; it
|
||||
// mounts above the composer, outside the row, and starts collapsed — its
|
||||
// list only exists once expanded.
|
||||
const panel = await screen.findByTestId('todo-panel', undefined, { timeout: 10_000 })
|
||||
const toggle = panel.querySelector('button[aria-expanded]')
|
||||
if (toggle === null) throw new Error('the plan strip must expose its expand toggle')
|
||||
if (toggle.getAttribute('aria-expanded') === 'false') fireEvent.click(toggle)
|
||||
|
||||
const shape = todoShape(row, panel)
|
||||
if (refreshing) {
|
||||
mkdirSync(dirname(EXPECTED), { recursive: true })
|
||||
writeFileSync(EXPECTED, shape)
|
||||
}
|
||||
await expect(shape).toMatchFileSnapshot(EXPECTED)
|
||||
})
|
||||
})
|
||||
Reference in New Issue
Block a user