test: remove low-value journal, input and capture examples (#41368)

* test: remove low-value journal and smart-key samples

* test: remove low-value journal, input and capture examples

---------

Co-authored-by: OrcaWin <293788423+OrcaWin@users.noreply.github.com>
This commit is contained in:
OrcaWin
2026-11-11 20:32:02 -08:00
committed by GitHub
co-authored by OrcaWin
parent 2d0f453776
commit bedb2bbaf1
8 changed files with 31 additions and 261 deletions
File diff suppressed because one or more lines are too long
@@ -22,25 +22,6 @@ function shellContractsStepTests(workflowYaml) {
return step.run.split(/\s+/).filter((token) => token.endsWith('.test.ts'))
}
/** A pr.yml shaped like the real one around the shell contracts step, with `run` as the block scalar body. */
function workflowWithShellContractsRun(run) {
const body = run
.split('\n')
.map((line) => (line === '' ? '' : ` ${line}`))
.join('\n')
return `jobs:
shell_contracts:
steps:
- name: Install fish
run: echo fish
- name: ${SHELL_CONTRACTS_STEP}
run: |
${body}
- name: Later step
run: pnpm exec vitest run src/later.test.ts
`
}
describe('per-job path classification', () => {
// Mobile-only edits must run audits that lint mobile; skipped audits let #20702 duplicate imports break later merge refs.
@@ -96,37 +77,6 @@ describe('per-job path classification', () => {
expect(stdout).toContain('xterm_patch_sync=true\n')
})
describe('shell contracts step parsing', () => {
it('reads every command of the step, past a blank line, and no other step', () => {
const run = [
'pnpm exec vitest run --maxWorkers=1 \\',
' src/first.live-shell.test.ts \\',
' src/second.node-pty.test.ts',
'',
'# A second command after a blank line is still part of the step.',
'pnpm exec vitest run src/third.test.ts'
].join('\n')
expect(shellContractsStepTests(workflowWithShellContractsRun(run))).toEqual([
'src/first.live-shell.test.ts',
'src/second.node-pty.test.ts',
'src/third.test.ts'
])
})
it('returns the exact list, so a dropped entry is a failure rather than a smaller count', () => {
const files = Array.from(
{ length: 12 },
(_, index) => `src/shell-${index}.live-shell.test.ts`
)
const run = `pnpm exec vitest run --reporter=dot \\\n${files.map((file) => ` ${file} \\`).join('\n')}\n --bail=1`
expect(shellContractsStepTests(workflowWithShellContractsRun(run))).toEqual(files)
})
it('reports a missing step instead of an empty list', () => {
expect(shellContractsStepTests('jobs:\n shell_contracts:\n steps: []\n')).toBeNull()
})
})
// Unit shards exclude live-shell tests, so a test the shell contracts job runs must also route a focused
// edit to that job; otherwise a change to it, or to what it guards, runs no real shell at all (STA-2380 C2 F1).
it('routes every test the shell contracts job runs to shell_contracts', () => {
@@ -144,25 +94,4 @@ describe('per-job path classification', () => {
const unrouted = tests.filter((file) => classifyPrJobs([file]).shell_contracts !== true)
expect(unrouted).toEqual([])
})
it('routes the command-paint attribution sources to shell_contracts, and only those', () => {
const guarded = [
'src/main/runtime/terminal/input/terminal-command-paint.ts',
'src/main/runtime/terminal/wait/tui-idle-evidence-source.ts',
'src/main/runtime/terminal/wait/tui-idle-evidence.ts',
'src/shared/draft-paste-ready-scanner.ts',
'src/main/runtime/terminal/wait/tui-idle-zsh-preexec-hook-order.live-shell.test.ts'
]
for (const file of guarded) {
expect(classifyPrJobs([file]).shell_contracts, file).toBe(true)
}
// Neighbours the live-shell test does not guard stay on the ordinary unit shards.
for (const file of [
'src/main/runtime/terminal/wait/tui-idle-hook-lane.ts',
'src/main/runtime/terminal/input/terminal-command-paint.test.ts',
'src/shared/draft-paste-ready-scanner.test.ts'
]) {
expect(classifyPrJobs([file]).shell_contracts, file).toBe(false)
}
})
})
@@ -26,7 +26,7 @@ vi.mock('./renderer-hang-records', () => ({
return state.publication
}
}))
import { startRendererHangCapture, reduceRendererHangStack } from './renderer-hang-capture'
import { startRendererHangCapture } from './renderer-hang-capture'
const handles: { stop: () => void }[] = []
const responses: (() => void)[] = []
@@ -131,26 +131,6 @@ it('reconciles a dead generation before admission and an old reply cannot clear
expect(state.records.at(-1)).toMatchObject({ windowId: 4, status: 'captured' })
})
it('drops a cut input field before redaction while preserving complete frames', () => {
const result = reduceRendererHangStack(
`at busy (file:///private/home/app.js:7:3)\n${'at '.repeat(6000)}`
)
expect(result).toEqual({
frames: [{ name: 'busy', module: 'app.js', line: 7, column: 3 }],
status: 'captured',
truncated: true
})
})
it('records an unanswered renderer request explicitly while retaining its physical owner', async () => {
const blocked = window(6)
;(await blocked.start())?.stop()
expect(state.records.at(-1)).toMatchObject({ windowId: 6, status: 'request-pending', samples: 0 })
const shared = window(7)
await shared.start()
expect(state.records.at(-1)).toMatchObject({ windowId: 7, status: 'process-capture-pending' })
})
it('awaits baseline publication before requesting a stack and cannot start after cancellation during the write', async () => {
let finishPublication: () => void = () => {}
state.publication = new Promise<void>((resolve) => {
@@ -81,34 +81,6 @@ describe('tui-idle on a slow-starting Claude', () => {
await vi.advanceTimersByTimeAsync(POLL_INTERVAL_MS * 3)
await expect(wait).resolves.toMatchObject({ satisfied: true })
})
it('does not settle on a boot banner Claude printed before its composer', async () => {
const { runtime, handle, write } = await startClaudePane()
write(SHELL_RUNS_CLAUDE)
const settled = vi.fn()
const wait = runtime.waitForTerminal(handle, { condition: 'tui-idle', timeoutMs: 60_000 })
wait.then(settled, () => {})
await vi.advanceTimersByTimeAsync(POLL_INTERVAL_MS)
write('Loading Claude Code…\r\n')
await vi.advanceTimersByTimeAsync(POLL_INTERVAL_MS * 4)
expect(settled).not.toHaveBeenCalled()
write(CLAUDE_COMPOSER_BARE_TITLE)
await vi.advanceTimersByTimeAsync(POLL_INTERVAL_MS * 3)
await expect(wait).resolves.toMatchObject({ satisfied: true })
})
it('settles the bare-title weak lane once the composer marker has arrived and output is quiet', async () => {
const { runtime, handle, write } = await startClaudePane()
write(SHELL_RUNS_CLAUDE + LATER_PREEXEC_HOOK_PRINTS)
await vi.advanceTimersByTimeAsync(POLL_INTERVAL_MS)
write(CLAUDE_COMPOSER_BARE_TITLE)
const wait = runtime.waitForTerminal(handle, { condition: 'tui-idle', timeoutMs: 60_000 })
await vi.advanceTimersByTimeAsync(POLL_INTERVAL_MS * 3)
await expect(wait).resolves.toMatchObject({ satisfied: true })
})
})
describe('worker start on a slow-starting Claude', () => {
@@ -313,19 +313,6 @@ describe.skipIf(process.platform === 'win32')('tui-idle under real zsh preexec h
}
)
itWithZsh('attributes paint to Claude only once its own composer marker arrives', () => {
const { shell, agent } = splitAtAgentStart(capture.chunks)
const paint = new TerminalCommandPaint()
const observe = paintObserver(paint)
observe(shell)
// The any-visible-byte latch is what C1 F1 found: hook text satisfies it before Claude runs.
expect(paint.hasPainted()).toBe(hookCase.anyBytePaintBeforeAgent)
expect(hasTerminalAgentPainted({ commandPaint: paint }, 'claude')).toBe(false)
observe(agent)
expect(hasTerminalAgentPainted({ commandPaint: paint }, 'claude')).toBe(true)
})
itWithZsh.each(RECHUNKINGS)(
'attributes paint the same way with the capture %s',
(_label, rechunk) => {
@@ -1,9 +1,5 @@
import { afterEach, describe, expect, it, vi } from 'vitest'
import {
isEditableDetailsHtmlBlock,
matchDetailsHtmlBlock,
type DetailsHtmlBlock
} from './details-markdown-html'
import { describe, expect, it } from 'vitest'
import { isEditableDetailsHtmlBlock, matchDetailsHtmlBlock } from './details-markdown-html'
function nestedToggles(depth: number): string {
let html = '<details class="orca-details" open>\n<summary>leaf</summary>\n\nBody\n\n</details>'
@@ -18,10 +14,6 @@ function isEditableHtml(html: string): boolean {
return block !== null && isEditableDetailsHtmlBlock(block)
}
afterEach(() => {
vi.restoreAllMocks()
})
describe('details markdown html', () => {
it('bounds each of many sibling nested toggles independently', () => {
const siblings = (count: number, extra = ''): string =>
@@ -42,20 +34,4 @@ describe('details markdown html', () => {
expect(isEditableHtml(nestedToggles(17))).toBe(false)
expect(isEditableHtml(nestedToggles(400))).toBe(false)
})
it('rejects unbalanced and non-toggle tags that start with details', () => {
const unbalanced: DetailsHtmlBlock = {
raw: '',
openingAttributes: '',
inner: '<summary>Outer</summary><details><summary>Inner</summary>'
}
const lookalike: DetailsHtmlBlock = {
raw: '',
openingAttributes: '',
inner: '<summary>Outer</summary><detailsish>Body</detailsish>'
}
expect(isEditableDetailsHtmlBlock(unbalanced)).toBe(false)
expect(isEditableDetailsHtmlBlock(lookalike)).toBe(false)
})
})
@@ -1,32 +0,0 @@
import { expect, it } from 'vitest'
import {
agentJournalItemSubagentId,
isRootAgentJournalItem
} from './agent-session-journal-producer'
import type { NativeChatBlock } from '../../native-chat/native-chat-types'
it('groups only a background producer own task row under its owner on both journal and message readers', () => {
const linkage = { agentId: 'shell', parentAgentId: 'owner', producerKind: 'background' as const }
const task: NativeChatBlock = {
type: 'background-task',
taskId: 'shell',
kind: 'command',
label: 'sleep',
state: 'working'
}
const output: NativeChatBlock = { type: 'text', text: 'workflow output' }
for (const [blocks, expected] of [
[[task], 'owner'],
[[output], 'shell'],
[[{ ...task, taskId: 'another' }], 'shell']
] as const) {
expect(agentJournalItemSubagentId({ ...linkage, blocks })).toBe(expected)
const journal = {
...linkage,
body: { kind: 'message' as const, role: 'assistant' as const, blocks: [...blocks] }
}
expect(agentJournalItemSubagentId(journal)).toBe(expected)
expect(isRootAgentJournalItem(journal)).toBe(false)
}
expect(isRootAgentJournalItem({})).toBe(true)
})
@@ -1,58 +0,0 @@
import { describe, expect, it } from 'vitest'
import { resolveAgentSmartKeys } from './agent-smart-keys'
const approval = JSON.stringify({ approval: { tool: 'Bash', summary: 'pnpm tc' } })
const questions = JSON.stringify({
questions: [
{ question: 'Where?', options: [{ label: 'a' }, { label: 'b' }, { label: 'c' }] },
{ question: 'Which?', options: [{ label: 'x' }, { label: 'y' }] }
]
})
describe('resolveAgentSmartKeys', () => {
it('tells a permission prompt from a question by the prompt shape', () => {
expect(
resolveAgentSmartKeys('claude', { state: 'waiting', interactivePrompt: approval })?.state
).toBe('permission')
const ask = resolveAgentSmartKeys('claude', {
state: 'waiting',
interactivePrompt: questions,
toolName: 'AskUserQuestion'
})
expect(ask?.state).toBe('question')
// The phone can't see the open question tab, so it offers digits for the longest one.
expect(ask?.keys.filter((key) => /^\d$/.test(key.combo)).map((key) => key.writes)).toEqual([
['1'],
['2'],
['3']
])
})
it("opens Codex's async question with ⇧← before its digits", () => {
const ask = resolveAgentSmartKeys('codex', {
state: 'waiting',
toolName: 'request_user_input_async',
interactivePrompt: JSON.stringify({
questions: [{ title: 'Which db?', options: ['a', 'b', 'c'] }, { title: 'Table name?' }]
})
})
expect(ask?.state).toBe('question')
expect(ask?.keys.map((key) => key.writes.join(''))).toEqual([
'\x1b[1;2D',
'1',
'2',
'3',
'\r',
'\x1d'
])
})
it('shows nothing for an unknown agent, state or prompt', () => {
expect(resolveAgentSmartKeys('gemini', { state: 'working' })).toBeNull()
expect(resolveAgentSmartKeys('claude', { state: 'waiting' })).toBeNull()
expect(
resolveAgentSmartKeys('codex', { state: 'waiting', interactivePrompt: questions })
).toBeNull()
expect(resolveAgentSmartKeys('codex', { state: 'done' })).toBeNull()
})
})