Files
orca/src/shared/workspace-statuses.test.ts
T
Neil dcaef9dee5 test: retire relay, preload and shared cases that re-prove an owned contract (#24007)
Audit sweep over `src/relay`, `src/preload` and `src/shared` (1,087 test files
reviewed). 101 case declarations removed across 40 files, 6 test files deleted
outright, 1,143 lines gone. Executed-case count falls further, since several
removals were `it.each` tables.

Dominant patterns, by frequency:

- Self-comparisons that cannot fail: `expect(f(x)).toBe(f(x))`,
  `JSON.parse(JSON.stringify(literal))` deep-equalling the literal for a type
  with no codec, and `normalizeKeyToken(t) === normalizeKeyToken(t)` presented as
  proof of memoization.
- Object literals asserting their own fields back, where the guarantee comes from
  the type annotation and the runtime assertion cannot fail.
- Copied inventories: constants compared to their own initializers, and a
  function returning a copy of an exported constant checked against that
  constant's literal contents.
- Duplicate invocations of a contract owned at a stronger boundary, including
  provider-local replays of a shared helper.
- Table rows varying a field production never reads, so every row runs one path.
- Names promising more than the input exercises: a "Windows launch" case in a
  module with no platform input, and a case whose named branch is never entered.

Two production symbols go with them, each a test-only export whose sole caller
was a deleted case:

- `getGitHubProjectRefInputByteLength` — a one-line forward to
  `getClipboardTextByteLength`. The real bound
  (`GITHUB_PROJECT_REF_INPUT_MAX_BYTES`) and its guard stay.
- `GRAB_STYLE_PROPERTIES` — an intended shared source of truth that nothing ever
  consulted; the property set is hand-enumerated at three independent sites.

One case was deliberately restored and strengthened rather than dropped. The
relay integration suite is the only place the real `SshChannelMultiplexer` is
wired to `RelayDispatcher`, so it reaches transport behavior the handler suites
cannot (they use `createMockDispatcher`). Its `fs.writeFile` roundtrip is the one
case producing a void result, and `JSON.stringify` drops an absent `result`
member — a shape no other surviving case exercises. Restored with an assertion
pinning what the client actually observes: `null`, not `undefined`. That
assertion failed on first run, so the fact was previously unasserted anywhere.

One deletion was reverted mid-audit. A case asserting that optional fields stay
invisible to "old attach and ready decoders" builds those decoders from `z.object`
schemas declared in the test file, so it demonstrates zod's unknown-key stripping
rather than anything shipped. It is nonetheless the only forward-compatibility
coverage these envelopes have, and `reliability-gates.jsonc:6232` names it as
evidence verbatim, so it stays. Note that `check-reliability-gates.mjs` passed
both with and without it: the script resolves manifest paths and commands, and
does not check that a named assertion still corresponds to a live case.

Kept deliberately: everything a reliability gate cites as evidence; the three
`registers all expected handlers` RPC manifests (a dropped registration is a
silent wire break no type checker catches, and one carries the STA-4571
`pty.ackData` ratchet); the `child-process` direct-import ratchet; and
prototype-spy cases paired with a `.repeat(10_000)` input, which assert a real
memory bound rather than merely forbidding a technique.

Verified: `pnpm test src/shared src/relay src/preload` (1073 files, 11996
passed, 1 pre-existing `it.fails`, 131 skipped), `pnpm tc` after clearing
`.tsbuildinfo`, `check-reliability-gates.mjs` (140 gates),
`check:code-quality:changed` (0 new findings).
2026-09-29 22:17:13 -07:00

278 lines
9.3 KiB
TypeScript

import { describe, expect, it } from 'vitest'
import {
WORKSPACE_BOARD_COLUMN_WIDTH_DEFAULT,
WORKSPACE_BOARD_COLUMN_WIDTH_MAX,
WORKSPACE_BOARD_COLUMN_WIDTH_MIN,
clampWorkspaceBoardColumnWidth,
cloneDefaultWorkspaceStatuses,
normalizePersistedWorkspaceStatuses,
normalizeWorkspaceStatuses
} from './workspace-statuses'
describe('workspace status visuals', () => {
it('normalizes every valid status without truncating the workflow', () => {
const authored = Array.from({ length: 500 }, (_, index) => ({
id: `state-${index}`,
label: `State ${index}`
}))
expect(normalizeWorkspaceStatuses(authored).map((status) => status.id)).toEqual(
authored.map((status) => status.id)
)
})
it('keeps the default workflow order', () => {
expect(cloneDefaultWorkspaceStatuses().map((status) => status.id)).toEqual([
'todo',
'in-progress',
'in-review',
'completed'
])
expect(cloneDefaultWorkspaceStatuses()[0]).toMatchObject({ id: 'todo', label: 'Todo' })
expect(cloneDefaultWorkspaceStatuses().at(-1)).toMatchObject({ id: 'completed', label: 'Done' })
})
it('migrates legacy default statuses to the default workflow order', () => {
const statuses = normalizePersistedWorkspaceStatuses(
[
{ id: 'todo', label: 'Todo', color: 'neutral', icon: 'circle' },
{
id: 'in-progress',
label: 'In progress',
color: 'conductor-progress',
icon: 'conductor-progress'
},
{
id: 'in-review',
label: 'In review',
color: 'conductor-review',
icon: 'conductor-review'
},
{ id: 'completed', label: 'Completed', color: 'conductor-done', icon: 'conductor-done' }
],
{ migrateDefaultWorkflowStatuses: true }
)
expect(statuses).toEqual(cloneDefaultWorkspaceStatuses())
})
it('migrates the old default status visuals without reordering the board', () => {
const statuses = normalizePersistedWorkspaceStatuses(
[
{ id: 'todo', label: 'Todo', color: 'neutral', icon: 'circle' },
{ id: 'in-progress', label: 'In progress', color: 'blue', icon: 'circle-dot' },
{ id: 'in-review', label: 'In review', color: 'violet', icon: 'git-pull-request' },
{ id: 'completed', label: 'Completed', color: 'emerald', icon: 'circle-check' }
],
{ migrateLegacyDefaultStatusVisuals: true }
)
expect(statuses.map((status) => status.id)).toEqual([
'todo',
'in-progress',
'in-review',
'completed'
])
expect(statuses.map((status) => status.color)).toEqual([
'neutral',
'conductor-progress',
'conductor-review',
'conductor-done'
])
})
it('preserves explicit status order while migrating default visuals', () => {
const statuses = normalizePersistedWorkspaceStatuses(
[
{ id: 'completed', label: 'Completed', color: 'emerald', icon: 'circle-check' },
{ id: 'in-review', label: 'In review', color: 'violet', icon: 'git-pull-request' },
{ id: 'in-progress', label: 'In progress', color: 'blue', icon: 'circle-dot' },
{ id: 'todo', label: 'Todo', color: 'neutral', icon: 'circle' }
],
{ migrateLegacyDefaultStatusVisuals: true }
)
expect(statuses.map((status) => status.id)).toEqual([
'completed',
'in-review',
'in-progress',
'todo'
])
expect(statuses[0]).toMatchObject({
color: 'conductor-done',
icon: 'conductor-done'
})
})
it('preserves default-label reordered statuses unless a default migration is requested', () => {
const statuses = normalizePersistedWorkspaceStatuses([
{ id: 'completed', label: 'Completed', color: 'conductor-done', icon: 'conductor-done' },
{ id: 'in-review', label: 'In review', color: 'conductor-review', icon: 'conductor-review' },
{
id: 'in-progress',
label: 'In progress',
color: 'conductor-progress',
icon: 'conductor-progress'
},
{ id: 'todo', label: 'Todo', color: 'neutral', icon: 'circle' }
])
expect(statuses.map((status) => status.id)).toEqual([
'completed',
'in-review',
'in-progress',
'todo'
])
})
it('migrates exact reordered default statuses to the new Done label when requested', () => {
const statuses = normalizePersistedWorkspaceStatuses(
[
{ id: 'completed', label: 'Completed', color: 'conductor-done', icon: 'conductor-done' },
{
id: 'in-review',
label: 'In review',
color: 'conductor-review',
icon: 'conductor-review'
},
{
id: 'in-progress',
label: 'In progress',
color: 'conductor-progress',
icon: 'conductor-progress'
},
{ id: 'todo', label: 'Todo', color: 'neutral', icon: 'circle' }
],
{ migrateDefaultWorkflowStatuses: true }
)
expect(statuses).toEqual(cloneDefaultWorkspaceStatuses())
})
it('repairs the exact PR-introduced default status reorder when migration-gated', () => {
const statuses = normalizePersistedWorkspaceStatuses(
[
{ id: 'completed', label: 'Completed', color: 'conductor-done', icon: 'conductor-done' },
{
id: 'in-review',
label: 'In review',
color: 'conductor-review',
icon: 'conductor-review'
},
{
id: 'in-progress',
label: 'In progress',
color: 'conductor-progress',
icon: 'conductor-progress'
},
{ id: 'todo', label: 'Todo', color: 'neutral', icon: 'circle' }
],
{ repairReorderedDefaultStatuses: true }
)
expect(statuses).toEqual(cloneDefaultWorkspaceStatuses())
})
it('repairs the exact reordered default status payload with the Done label', () => {
const statuses = normalizePersistedWorkspaceStatuses(
[
{ id: 'completed', label: 'Done', color: 'conductor-done', icon: 'conductor-done' },
{
id: 'in-review',
label: 'In review',
color: 'conductor-review',
icon: 'conductor-review'
},
{
id: 'in-progress',
label: 'In progress',
color: 'conductor-progress',
icon: 'conductor-progress'
},
{ id: 'todo', label: 'Todo', color: 'neutral', icon: 'circle' }
],
{ repairReorderedDefaultStatuses: true }
)
expect(statuses).toEqual(cloneDefaultWorkspaceStatuses())
})
it('does not repair reordered default-label statuses with a different raw shape', () => {
const statuses = normalizePersistedWorkspaceStatuses(
[
{ id: 'completed', label: 'Completed', color: 'emerald', icon: 'circle-check' },
{ id: 'in-review', label: 'In review', color: 'violet', icon: 'git-pull-request' },
{ id: 'in-progress', label: 'In progress', color: 'blue', icon: 'circle-dot' },
{ id: 'todo', label: 'Todo', color: 'neutral', icon: 'circle' }
],
{ repairReorderedDefaultStatuses: true }
)
expect(statuses.map((status) => status.id)).toEqual([
'completed',
'in-review',
'in-progress',
'todo'
])
})
it('leaves custom persisted status layouts in their saved order', () => {
const statuses = normalizePersistedWorkspaceStatuses([
{ id: 'completed', label: 'Shipped', color: 'conductor-done', icon: 'conductor-done' },
{ id: 'todo', label: 'Todo', color: 'neutral', icon: 'circle' }
])
expect(statuses.map((status) => status.id)).toEqual(['completed', 'todo'])
})
it('uses Conductor-style visuals for the default status icons', () => {
const statuses = cloneDefaultWorkspaceStatuses()
const inProgress = statuses.find((status) => status.id === 'in-progress')
const inReview = statuses.find((status) => status.id === 'in-review')
const completed = statuses.find((status) => status.id === 'completed')
expect(inProgress).toMatchObject({
color: 'conductor-progress',
icon: 'conductor-progress'
})
expect(inReview).toMatchObject({
color: 'conductor-review',
icon: 'conductor-review'
})
expect(completed).toMatchObject({
color: 'conductor-done',
icon: 'conductor-done'
})
})
it('migrates the old in-progress blue dot default only when requested', () => {
const statuses = normalizePersistedWorkspaceStatuses(
[{ id: 'in-progress', label: 'In progress', color: 'blue', icon: 'circle-dot' }],
{ migrateLegacyDefaultStatusVisuals: true }
)
expect(statuses[0]).toMatchObject({
color: 'conductor-progress',
icon: 'conductor-progress'
})
})
it('preserves valid legacy visuals for default-label statuses at runtime', () => {
const statuses = normalizeWorkspaceStatuses([
{ id: 'in-progress', label: 'In progress', color: 'blue', icon: 'circle-dot' }
])
expect(statuses[0]).toMatchObject({
color: 'blue',
icon: 'circle-dot'
})
})
it('clamps workspace board column widths to resizable bounds', () => {
expect(clampWorkspaceBoardColumnWidth(undefined)).toBe(WORKSPACE_BOARD_COLUMN_WIDTH_DEFAULT)
expect(clampWorkspaceBoardColumnWidth(100)).toBe(WORKSPACE_BOARD_COLUMN_WIDTH_MIN)
expect(clampWorkspaceBoardColumnWidth(321.6)).toBe(322)
expect(clampWorkspaceBoardColumnWidth(900)).toBe(WORKSPACE_BOARD_COLUMN_WIDTH_MAX)
})
})