|
|
@@ -1,4 +1,4 @@
|
|
|
-/** Cold rendering of the shared filesystem edit Session preserves neutral context. */
|
|
|
+/** Cold Session rendering covers exact context and bounded whole-fragment replacements. */
|
|
|
import { readFile } from 'node:fs/promises'
|
|
|
import { fileURLToPath } from 'node:url'
|
|
|
import { chromium, type Browser, type Page } from 'playwright'
|
|
|
@@ -9,11 +9,15 @@ import {
|
|
|
} from './scaffold.ts'
|
|
|
import { expandTurnProcesses, newEnglishPage, saveFailureShot } from './support.ts'
|
|
|
|
|
|
-const SNAPSHOT_DIR = fileURLToPath(new URL('../../../snapshots/web/diff-context', import.meta.url))
|
|
|
-const SOURCE = fileURLToPath(new URL('../../../snapshots/session/fs-edit/session.v3.jsonl', import.meta.url))
|
|
|
+const ROOT = fileURLToPath(new URL('../../../snapshots', import.meta.url))
|
|
|
const MODE = webSnapshotMode()
|
|
|
|
|
|
-describe.skipIf(MODE === 'record')('web e2e: contextual edit diff', () => {
|
|
|
+const CASES = [
|
|
|
+ { name: 'diff-context', source: 'session/fs-edit/session.v3.jsonl', totals: '+1 -1', shared: 'level=info', inventory: ['ui.expected.md'] },
|
|
|
+ { name: 'diff-bounded', source: 'web/diff-bounded/session.v3.jsonl', totals: '+130 -130', shared: 'shared heading', inventory: ['session.v3.jsonl', 'ui.expected.md'] },
|
|
|
+]
|
|
|
+
|
|
|
+describe.skipIf(MODE === 'record').each(CASES)('web e2e: $name', (scenario) => {
|
|
|
let scaffold: WebScaffold
|
|
|
let browser: Browser
|
|
|
let page: Page
|
|
|
@@ -21,7 +25,7 @@ describe.skipIf(MODE === 'record')('web e2e: contextual edit diff', () => {
|
|
|
|
|
|
beforeAll(async () => {
|
|
|
scaffold = await launchWebScaffold({})
|
|
|
- await seedSession(scaffold, await readFile(SOURCE, 'utf8'), 'diff-context')
|
|
|
+ await seedSession(scaffold, await readFile(`${ROOT}/${scenario.source}`, 'utf8'), scenario.name)
|
|
|
browser = await chromium.launch()
|
|
|
page = await newEnglishPage(browser)
|
|
|
tripwire = watchConsole(page)
|
|
|
@@ -36,8 +40,8 @@ describe.skipIf(MODE === 'record')('web e2e: contextual edit diff', () => {
|
|
|
}
|
|
|
})
|
|
|
|
|
|
- it('shows true totals before expansion and neutral shared context after expansion', async () => {
|
|
|
- onTestFailed(() => saveFailureShot(page, 'web-e2e-diff-context'))
|
|
|
+ it('keeps collapsed and expanded counts consistent with the displayed diff', async () => {
|
|
|
+ onTestFailed(() => saveFailureShot(page, `web-e2e-${scenario.name}`))
|
|
|
const group = page.locator('[role="treeitem"]').first()
|
|
|
await group.waitFor({ timeout: 15_000 })
|
|
|
await group.click()
|
|
|
@@ -45,16 +49,17 @@ describe.skipIf(MODE === 'record')('web e2e: contextual edit diff', () => {
|
|
|
await page.getByText('DONE', { exact: true }).waitFor({ timeout: 15_000 })
|
|
|
await expandTurnProcesses(page)
|
|
|
const edit = page.locator('[data-variant="edit"]')
|
|
|
- expect(await edit.textContent()).toContain('+1 -1')
|
|
|
+ expect(await edit.textContent()).toContain(scenario.totals)
|
|
|
expect(await edit.locator('[data-diff]').count()).toBe(0)
|
|
|
await edit.locator('[data-expandable]').click()
|
|
|
const card = edit.locator('[data-diff]')
|
|
|
await card.waitFor()
|
|
|
- expect(await card.getByText('level=info', { exact: true }).count()).toBe(1)
|
|
|
- expect(await card.textContent()).toContain('+1 -1 · 1 file')
|
|
|
- await compareOrRefreshGolden(`${SNAPSHOT_DIR}/ui.expected.md`,
|
|
|
+ expect(await card.getByText(scenario.shared, { exact: true }).count()).toBe(1)
|
|
|
+ expect(await card.textContent()).toContain(`${scenario.totals} · 1 file`)
|
|
|
+ const snapshotDir = `${ROOT}/web/${scenario.name}`
|
|
|
+ await compareOrRefreshGolden(`${snapshotDir}/ui.expected.md`,
|
|
|
await captureStableAria(page, '[data-variant="edit"]', scaffold.workspaceCwd), MODE)
|
|
|
- await assertFixtureInventory(SNAPSHOT_DIR, ['ui.expected.md'])
|
|
|
+ await assertFixtureInventory(snapshotDir, scenario.inventory)
|
|
|
expect(tripwire.pageErrors).toEqual([])
|
|
|
expect(tripwire.warnings).toEqual([])
|
|
|
})
|