Files
orca/tests/e2e/accumulated-workspace-state-builder.unit.test.ts
Jinwoo Hong bdb18003e0 test: add accumulated-workspace terminal typing reproduction (#20934)
* test: reproduce accumulated-workspace typing latency through real PTYs

* test: make the bench harness self-checks falsifiable

Review found four assertions that could not fail and one fixture gap:

- `missingPtyArrivalCount`/`missingEchoCount` were hardcoded `0` and
  `validateExpectedSeqs` throws before them, so every assertion on them
  was vacuous and every report read `0`. The throw is the real guard and
  is already covered; drop the vestigial fields.
- An absent status controller returned an all-zero result, which satisfied
  its own accepted-equals-generated equality. Assert presence first.
- The byte-pacing control had only an upper bound, so a generator emitting
  no stream bytes passed. Add the lower bound.
- `lineageEvery: 1` built zero lineage: no ordinal satisfies
  `% 1 === 1`. Offset the interval and cover the densest setting.
- The documented control command never set ORCA_TYPING_BENCH, so it
  skipped instead of running.
2026-09-16 13:10:46 -04:00

52 lines
2.5 KiB
TypeScript

import { describe, expect, it } from 'vitest'
import { normalizeAccumulatedWorkspaceFixtureOptions } from './accumulated-workspace-profile'
import { buildAccumulatedWorkspaceSeed } from './accumulated-workspace-state-builder'
describe('accumulated workspace state builder', () => {
it('matches the captured production scale with canonical terminal identities', () => {
const seed = buildAccumulatedWorkspaceSeed(
normalizeAccumulatedWorkspaceFixtureOptions({}),
1_700_000_000_000
)
const worktrees = Object.values(seed.worktreesByRepo).flat()
const terminalTabs = Object.values(seed.tabsByWorktree).flat()
const unifiedTabs = Object.values(seed.unifiedTabsByWorktree).flat()
const unifiedTerminalTabs = unifiedTabs.filter(({ contentType }) => contentType === 'terminal')
expect(seed.repos).toHaveLength(27)
expect(worktrees).toHaveLength(870)
expect(terminalTabs).toHaveLength(1_410)
expect(unifiedTabs).toHaveLength(2_000)
expect(Object.keys(seed.terminalLayoutsByTabId)).toHaveLength(1_410)
expect(Object.keys(seed.sleepingAgentSessionsByPaneKey)).toHaveLength(857)
expect(seed.liveStatuses).toHaveLength(177)
expect(unifiedTerminalTabs.map(({ id }) => id)).toEqual(terminalTabs.map(({ id }) => id))
expect(unifiedTerminalTabs.every(({ id, entityId }) => id === entityId)).toBe(true)
})
it('uses shallow independent lineage pairs instead of one synthetic chain', () => {
const seed = buildAccumulatedWorkspaceSeed(normalizeAccumulatedWorkspaceFixtureOptions({}))
const lineages = Object.values(seed.worktreeLineageById)
const childIds = new Set(lineages.map(({ worktreeId }) => worktreeId))
expect(lineages.length).toBeGreaterThan(0)
expect(lineages.every(({ parentWorktreeId }) => !childIds.has(parentWorktreeId))).toBe(true)
})
// `lineageEvery: 1` means "every non-main worktree", but the interval check used
// `% lineageEvery === 1`, which no ordinal satisfies at 1 — the fixture silently
// built zero lineage records at the densest setting.
it('builds lineage for every non-main worktree at an interval of 1', () => {
const options = normalizeAccumulatedWorkspaceFixtureOptions({
worktrees: 9,
repositories: 3,
lineageEvery: 1
})
const seed = buildAccumulatedWorkspaceSeed(options)
const lineages = Object.values(seed.worktreeLineageById)
// 9 worktrees over 3 repos gives ordinals 0..2 each; ordinal 0 is the main row.
expect(lineages).toHaveLength(6)
})
})