- Compute each group's baseline watermark once per render. - Skip the row-motion reset when folding drops no raised watermark. - Document that the watermark is a row count that a reorder can outrun, and that any unmount of the grouped tree resets it; pin both in tests. - Cover raise-to-current, keep-after-leaving, and fold reset in the keyless Web folding scenario.
150 lines
7.1 KiB
TypeScript
150 lines
7.1 KiB
TypeScript
/** Blank New Session folding and the session watermark 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)
|
|
expect(tripwire.pageErrors).toEqual([])
|
|
expect(tripwire.warnings).toEqual([])
|
|
})
|
|
|
|
it('raises the watermark to the open session, keeps it after leaving, and resets it on fold', async () => {
|
|
onTestFailed(() => saveFailureShot(page, 'web-e2e-workspace-session-watermark'))
|
|
const sidebar = page.getByRole('tree', { name: 'Sessions' })
|
|
const workspaceTitle = basename(scaffold.workspaceCwd)
|
|
const sessions = () => sidebar.getByText('Untitled', { exact: true }).count()
|
|
await sidebar.getByRole('button', { name: 'Show 11 more sessions' }).click()
|
|
await expect.poll(sessions).toBe(10)
|
|
await sidebar.getByText('Untitled', { exact: true }).nth(8).click()
|
|
await sidebar.getByRole('button', { name: 'Show 6 more sessions' }).click()
|
|
await sidebar.getByRole('button', { name: 'Show 1 more sessions' }).click()
|
|
await expect.poll(sessions).toBe(16)
|
|
await sidebar.getByRole('button', { name: 'Show less' }).click()
|
|
await expect.poll(sessions).toBe(9)
|
|
await sidebar.getByRole('button', { name: 'Show 7 more sessions' }).waitFor()
|
|
|
|
const workspaceRow = sidebar.getByRole('treeitem').first()
|
|
await workspaceRow.hover()
|
|
await page.getByRole('button', { name: `New session in ${workspaceTitle}` }).click()
|
|
await sidebar.getByText('New Session', { exact: true }).waitFor()
|
|
expect(await sessions()).toBe(9)
|
|
await workspaceRow.hover()
|
|
await compareOrRefreshGolden(
|
|
join(EXPECTED_DIR, 'watermark-kept.expected.md'),
|
|
await captureStableAria(page, '[role="tree"][aria-label="Sessions"]', scaffold.workspaceCwd),
|
|
MODE,
|
|
)
|
|
|
|
await workspaceRow.click()
|
|
await workspaceRow.click()
|
|
await expect.poll(sessions).toBe(5)
|
|
await sidebar.getByRole('button', { name: 'Show 11 more sessions' }).waitFor()
|
|
await assertFixtureInventory(EXPECTED_DIR, ['sidebar.expected.md', 'first-batch.expected.md', 'watermark-kept.expected.md'])
|
|
expect(tripwire.pageErrors).toEqual([])
|
|
expect(tripwire.warnings).toEqual([])
|
|
})
|
|
})
|