mirror of
https://github.com/stablyai/orca.git
synced 2026-11-13 09:27:29 +00:00
test: remove 17 low-value wrapper and private-state suites (#41292)
Co-authored-by: OrcaWin <293788423+OrcaWin@users.noreply.github.com>
This commit is contained in:
@@ -296,7 +296,6 @@
|
||||
"config/scripts/ci/workflow-contracts/zcode-credential-workflow.test.mjs": 668,
|
||||
"config/scripts/archives/platform-command/zip-extractor-command.test.mjs": 74,
|
||||
"src/cli/account-add-process.test.ts": 33700,
|
||||
"src/cli/agent-context.test.ts": 142,
|
||||
"src/cli/agent-launch-process.test.ts": 2348,
|
||||
"src/cli/agent-session-search-format.test.ts": 84,
|
||||
"src/cli/args-repeatable-flags.test.ts": 67,
|
||||
@@ -312,7 +311,6 @@
|
||||
"src/cli/computer-tree-query.test.ts": 79,
|
||||
"src/cli/format-recovery.test.ts": 413,
|
||||
"src/cli/format.test.ts": 446,
|
||||
"src/cli/handler-group-manifest.test.ts": 3610,
|
||||
"src/cli/handlers/account.test.ts": 849,
|
||||
"src/cli/handlers/agent-hooks.test.ts": 1702,
|
||||
"src/cli/handlers/artifacts.test.ts": 471,
|
||||
@@ -443,10 +441,7 @@
|
||||
"src/cli/skills.test.ts": 386,
|
||||
"src/cli/specs/account.test.ts": 95,
|
||||
"src/cli/specs/cli-command-names-parity.test.ts": 205,
|
||||
"src/cli/specs/profile-state.test.ts": 102,
|
||||
"src/cli/terminal-read-screen.test.ts": 660,
|
||||
"src/cli/worktree-ps-program-status.test.ts": 65,
|
||||
"src/cli/worktree-ps-terminal-verdict.test.ts": 60,
|
||||
"src/cli/worktree-selector-caller-host.test.ts": 107,
|
||||
"src/cli/worktree-selector-wsl-posix-path.test.ts": 134,
|
||||
"src/main/acp/process/acp-agent-connection.test.ts": 407,
|
||||
@@ -3986,7 +3981,6 @@
|
||||
"src/main/startup/serve-user-data-path-guard.test.ts": 198,
|
||||
"src/main/startup/single-instance-lock-exit.electron.test.ts": 551,
|
||||
"src/main/startup/skill-share-deep-link-state.test.ts": 217,
|
||||
"src/main/startup/startup-diagnostics.test.ts": 39,
|
||||
"src/main/startup/windows-app-data-path.test.ts": 55,
|
||||
"src/main/startup/windows-install-dir-acl-recovery.test.ts": 614,
|
||||
"src/main/startup/windows-install-dir-acl-repair.win32.test.ts": 132,
|
||||
@@ -4006,17 +4000,13 @@
|
||||
"src/main/power/system-power-lifecycle.test.ts": 42,
|
||||
"src/main/power/system-resume-broadcast.test.ts": 67,
|
||||
"src/main/telemetry/burst-cap.test.ts": 177,
|
||||
"src/main/telemetry/classify-error.test.ts": 43,
|
||||
"src/main/telemetry/client-agent-dashboard-snapshot.test.ts": 201,
|
||||
"src/main/telemetry/client-deferred-start.test.ts": 8659,
|
||||
"src/main/telemetry/client-lifecycle.test.ts": 206,
|
||||
"src/main/telemetry/client.test.ts": 213,
|
||||
"src/main/telemetry/consent.test.ts": 48,
|
||||
"src/main/telemetry/onboarding-feature-setup-validator.test.ts": 182,
|
||||
"src/main/telemetry/plugin-install-telemetry.test.ts": 282,
|
||||
"src/main/telemetry/posthog-transport-main-http-client.test.ts": 123,
|
||||
"src/main/telemetry/validator-warn-cache.test.ts": 187,
|
||||
"src/main/telemetry/validator.test.ts": 170,
|
||||
"src/main/telemetry/wsl-usage-reporter.test.ts": 407,
|
||||
"src/main/pty/history/terminal-history-gc-fs-call-count.test.ts": 157,
|
||||
"src/main/pty/history/terminal-history-gc.test.ts": 824,
|
||||
@@ -4107,7 +4097,6 @@
|
||||
"src/main/window/mac-app-paste-input.test.ts": 85,
|
||||
"src/main/window/macos-app-activation.test.ts": 44,
|
||||
"src/main/window/macos-desktop-handoff.test.ts": 60,
|
||||
"src/main/window/macos-tahoe-release.test.ts": 48,
|
||||
"src/main/window/main-window-state-lifecycle.test.ts": 60,
|
||||
"src/main/window/main-window-updater-deferred-setup.test.ts": 215,
|
||||
"src/main/window/native-chat-paste-files.test.ts": 666,
|
||||
@@ -4126,7 +4115,6 @@
|
||||
"src/main/window/terminal-pane-reveal-relay.test.ts": 91,
|
||||
"src/main/window/terminal-tab-close-request-relay.test.ts": 64,
|
||||
"src/main/window/updater-package-recovery-ipc.test.ts": 169,
|
||||
"src/main/window/window-close-decision.test.ts": 39,
|
||||
"src/main/pty/process-retirement/windows-live-tree-kill.win32.test.ts": 76,
|
||||
"src/main/pty/process-retirement/windows-pty-root-identity.test.ts": 135,
|
||||
"src/main/windows/windows-registry-addon.test.ts": 39,
|
||||
@@ -4333,7 +4321,6 @@
|
||||
"src/renderer/src/components/activity/activity-thread-list-pane.virtualization.test.tsx": 4863,
|
||||
"src/renderer/src/components/activity/useActivityUnreadCount.freshness.test.tsx": 1990,
|
||||
"src/renderer/src/components/activity/useActivityUnreadCount.test.ts": 1633,
|
||||
"src/renderer/src/components/agent-session-continuation/agent-session-continuation-selection.test.ts": 56,
|
||||
"src/renderer/src/components/agent-tab-shortcut-launch.test.ts": 369,
|
||||
"src/renderer/src/components/agent/AgentLaunchPickerMenu.search.test.tsx": 2090,
|
||||
"src/renderer/src/components/artifacts/ArtifactCollection.test.tsx": 1833,
|
||||
@@ -5531,7 +5518,6 @@
|
||||
"src/renderer/src/components/terminal/terminal-tab-actions-unrouted-close.test.ts": 589,
|
||||
"src/renderer/src/components/terminal/terminal-tab-actions.test.ts": 626,
|
||||
"src/renderer/src/components/terminal/terminal-tab-close-running-confirm.test.ts": 499,
|
||||
"src/renderer/src/components/terminal/unsaved-close-queue.test.ts": 42,
|
||||
"src/renderer/src/components/terminal/use-terminal-provider-snapshot-capability.test.tsx": 573,
|
||||
"src/renderer/src/components/terminal/window-close-running-work.test.ts": 97,
|
||||
"src/renderer/src/components/ui/menu-pointer-highlight.test.tsx": 350,
|
||||
@@ -6531,7 +6517,6 @@
|
||||
"src/shared/linux-wayland-session.test.ts": 46,
|
||||
"src/shared/local-build-compatibility.test.ts": 46,
|
||||
"src/shared/local-windows-terminal-runtime.test.ts": 41,
|
||||
"src/shared/localhost-worktree-labels.test.ts": 41,
|
||||
"src/shared/loose-ref-count.test.ts": 140,
|
||||
"src/shared/macos-symbolic-hotkeys.test.ts": 95,
|
||||
"src/shared/managed-agent-command-token.test.ts": 45,
|
||||
@@ -6599,7 +6584,6 @@
|
||||
"src/shared/native-chat/tools/native-chat-tool-attribution-allocation.test.ts": 105,
|
||||
"src/shared/native-chat/tools/native-chat-tool-identity.test.ts": 73,
|
||||
"src/shared/native-chat/tools/native-chat-tool-line-identity.test.ts": 50,
|
||||
"src/shared/native-chat/tools/native-chat-tool-line-label.test.ts": 259,
|
||||
"src/shared/native-chat/tools/native-chat-tool-pairing.performance.test.ts": 235,
|
||||
"src/shared/native-chat/tools/native-chat-tool-preview-prefix.test.ts": 46,
|
||||
"src/shared/native-chat/tools/native-chat-tool-run-outcome.test.ts": 68,
|
||||
|
||||
@@ -1,59 +0,0 @@
|
||||
import { describe, expect, it } from 'vitest'
|
||||
|
||||
import type { CommandSpec } from './args'
|
||||
import { buildAgentContext } from './agent-context'
|
||||
import { COMMAND_SPECS } from './specs'
|
||||
|
||||
describe('buildAgentContext', () => {
|
||||
const specs: CommandSpec[] = [
|
||||
{
|
||||
path: ['worktree', 'rm'],
|
||||
aliases: [
|
||||
['worktree', 'remove'],
|
||||
['worktree', 'delete']
|
||||
],
|
||||
summary: 'Remove a worktree',
|
||||
usage: 'orca worktree rm',
|
||||
allowedFlags: ['worktree', 'force']
|
||||
},
|
||||
{
|
||||
path: ['agent-context'],
|
||||
summary: 'Print the schema',
|
||||
usage: 'orca agent-context',
|
||||
allowedFlags: []
|
||||
}
|
||||
]
|
||||
|
||||
it('reports effective flags including globals, not just allowedFlags', () => {
|
||||
const schema = buildAgentContext(specs)
|
||||
const rm = schema.commands.find((command) => command.command === 'worktree rm')
|
||||
expect(rm?.flags).toContain('worktree')
|
||||
expect(rm?.flags).toContain('force')
|
||||
expect(rm?.flags).toContain('json')
|
||||
expect(rm?.flags).toContain('help')
|
||||
})
|
||||
|
||||
it('omits hidden specs so agents do not discover an unadvertised command', () => {
|
||||
const schema = buildAgentContext([
|
||||
...specs,
|
||||
{
|
||||
path: ['terminal', 'stop'],
|
||||
summary: 'Deprecated',
|
||||
usage: 'orca terminal stop',
|
||||
allowedFlags: [],
|
||||
hidden: true
|
||||
}
|
||||
])
|
||||
expect(schema.commandCount).toBe(2)
|
||||
expect(schema.commands.map((command) => command.command)).not.toContain('terminal stop')
|
||||
})
|
||||
})
|
||||
|
||||
describe('agent-context over the live registry', () => {
|
||||
it('marks raw passthrough commands without synthesizing Orca flags', () => {
|
||||
const schema = buildAgentContext(COMMAND_SPECS)
|
||||
const claudeTeams = schema.commands.find((command) => command.command === 'claude-teams')
|
||||
expect(claudeTeams?.argumentMode).toBe('passthrough')
|
||||
expect(claudeTeams?.flags).toEqual([])
|
||||
})
|
||||
})
|
||||
@@ -49,5 +49,3 @@ export async function dispatch(commandPath: string[], ctx: HandlerContext): Prom
|
||||
}
|
||||
await handler(ctx)
|
||||
}
|
||||
|
||||
export { buildRoutes as buildHandlerRoutes }
|
||||
|
||||
@@ -1,24 +0,0 @@
|
||||
import { describe, expect, it } from 'vitest'
|
||||
|
||||
import { buildHandlerRoutes } from './dispatch'
|
||||
import type { HandlerGroup } from './handler-group-manifest'
|
||||
|
||||
describe('duplicate command keys', () => {
|
||||
const group = (name: string, keys: string[]): HandlerGroup => ({
|
||||
name,
|
||||
keys,
|
||||
load: async () => ({})
|
||||
})
|
||||
|
||||
it('rejects the same key claimed by two groups', () => {
|
||||
expect(() =>
|
||||
buildHandlerRoutes([group('alpha', ['ship it']), group('beta', ['ship it'])])
|
||||
).toThrow('Duplicate CLI handler registration for "ship it" (alpha and beta)')
|
||||
})
|
||||
|
||||
it('rejects a key duplicated inside one group list', () => {
|
||||
expect(() => buildHandlerRoutes([group('alpha', ['ship it', 'ship it'])])).toThrow(
|
||||
'Duplicate CLI handler registration for "ship it"'
|
||||
)
|
||||
})
|
||||
})
|
||||
@@ -15,7 +15,6 @@ export type HandlerGroup = {
|
||||
load: () => Promise<Record<string, CommandHandler>>
|
||||
}
|
||||
|
||||
// handler-group-manifest.test.ts checks keys against the real exports to prevent drift.
|
||||
export const HANDLER_GROUPS: readonly HandlerGroup[] = [
|
||||
JIRA_HANDLER_GROUP,
|
||||
LINEAR_HANDLER_GROUP,
|
||||
|
||||
@@ -1,24 +0,0 @@
|
||||
import { describe, expect, it } from 'vitest'
|
||||
import { parseArgs, validateCommandAndFlags } from '../args'
|
||||
import { PROFILE_STATE_COMMAND_SPECS } from './profile-state'
|
||||
|
||||
describe('profile state rollback discovery', () => {
|
||||
it.each(
|
||||
['current-json', 'latest-json'].flatMap((selector) => [
|
||||
{ selector, argv: ['profile', 'state', 'rollback', `--${selector}`] },
|
||||
{ selector, argv: [`--${selector}`, 'profile', 'state', 'rollback'] },
|
||||
{ selector, argv: ['profile', `--${selector}`, 'state', 'rollback'] }
|
||||
])
|
||||
)('parses the JSON selector as a boolean: $argv', ({ argv, selector }) => {
|
||||
const parsed = parseArgs(argv)
|
||||
expect(parsed.commandPath).toEqual(['profile', 'state', 'rollback'])
|
||||
expect(parsed.flags.get(selector)).toBe(true)
|
||||
expect(() => validateCommandAndFlags(PROFILE_STATE_COMMAND_SPECS, parsed)).not.toThrow()
|
||||
})
|
||||
|
||||
it('parses the current SQLite selector as a boolean', () => {
|
||||
const parsed = parseArgs(['profile', 'state', 'rollback', '--current-sqlite'])
|
||||
expect(parsed.flags.get('current-sqlite')).toBe(true)
|
||||
expect(() => validateCommandAndFlags(PROFILE_STATE_COMMAND_SPECS, parsed)).not.toThrow()
|
||||
})
|
||||
})
|
||||
@@ -1,39 +0,0 @@
|
||||
import { describe, expect, it } from 'vitest'
|
||||
import type { RuntimeWorktreeAgentRow } from '../shared/runtime-types'
|
||||
import { formatWorktreePsProgramStatus } from './worktree-ps-program-status'
|
||||
|
||||
function agent(over: Partial<RuntimeWorktreeAgentRow>): RuntimeWorktreeAgentRow {
|
||||
return {
|
||||
paneKey: 'tab:leaf',
|
||||
parentPaneKey: null,
|
||||
state: 'working',
|
||||
agentType: 'codex',
|
||||
prompt: 'ship it',
|
||||
taskTitle: null,
|
||||
displayName: null,
|
||||
lastAssistantMessage: null,
|
||||
toolName: null,
|
||||
toolInput: null,
|
||||
interrupted: false,
|
||||
stateStartedAt: 1,
|
||||
updatedAt: 1,
|
||||
...over
|
||||
}
|
||||
}
|
||||
|
||||
describe('formatWorktreePsProgramStatus', () => {
|
||||
it('prefers a reported block over another agent progress', () => {
|
||||
const working = agent({ programStatus: { state: 'working', progress: 42, observedAt: 1 } })
|
||||
const signIn = agent({
|
||||
paneKey: 'tab:leaf-2',
|
||||
state: 'done',
|
||||
programStatus: { state: 'blocked', kind: 'auth', observedAt: 1 }
|
||||
})
|
||||
expect(formatWorktreePsProgramStatus([working, signIn])).toBe(' (Sign-in required)')
|
||||
})
|
||||
|
||||
it('hides progress on a finished row', () => {
|
||||
const programStatus = { state: 'working' as const, progress: 42, observedAt: 1 }
|
||||
expect(formatWorktreePsProgramStatus([agent({ state: 'done', programStatus })])).toBe('')
|
||||
})
|
||||
})
|
||||
@@ -1,35 +0,0 @@
|
||||
import { describe, expect, it } from 'vitest'
|
||||
import {
|
||||
formatWorktreePsTerminalFields,
|
||||
projectWorktreePsTerminalVerdict
|
||||
} from './worktree-ps-terminal-verdict'
|
||||
|
||||
describe('worktree ps terminal verdict', () => {
|
||||
it('prints unverifiable, never zero or no, for an unreachable host', () => {
|
||||
const row = { liveTerminalCount: 0, hasAttachedPty: false, unverifiableTerminalCount: 1 }
|
||||
expect(formatWorktreePsTerminalFields(row)).toBe('live:unverifiable pty:unverifiable')
|
||||
expect(projectWorktreePsTerminalVerdict(row), 'count fields keep their JSON types').toEqual({
|
||||
...row,
|
||||
terminalVerdict: 'unverifiable'
|
||||
})
|
||||
})
|
||||
|
||||
it('keeps verified terminals alongside unverifiable ones', () => {
|
||||
const row = { liveTerminalCount: 1, hasAttachedPty: true, unverifiableTerminalCount: 2 }
|
||||
expect(formatWorktreePsTerminalFields(row)).toBe('live:1+2 unverifiable pty:yes')
|
||||
expect(
|
||||
formatWorktreePsTerminalFields({ ...row, hasAttachedPty: false }),
|
||||
'an unverifiable terminal may hold the pty'
|
||||
).toBe('live:1+2 unverifiable pty:unverifiable')
|
||||
expect(projectWorktreePsTerminalVerdict(row)).toEqual({ ...row, terminalVerdict: 'live' })
|
||||
})
|
||||
|
||||
it('reports unverifiable for an idle row from a host that predates the count', () => {
|
||||
const row = { liveTerminalCount: 0, hasAttachedPty: false }
|
||||
expect(formatWorktreePsTerminalFields(row)).toBe('live:unverifiable pty:unverifiable')
|
||||
expect(projectWorktreePsTerminalVerdict(row)).toEqual({
|
||||
...row,
|
||||
terminalVerdict: 'unverifiable'
|
||||
})
|
||||
})
|
||||
})
|
||||
@@ -1,16 +0,0 @@
|
||||
import { describe, expect, it } from 'vitest'
|
||||
import { parseOpenCodeGoBillingStatusPayload } from './opencode-go-status-parsing'
|
||||
|
||||
describe('parseOpenCodeGoBillingStatusPayload', () => {
|
||||
it('maps the verified PAYG micro-cent string into USD major units', () => {
|
||||
expect(
|
||||
parseOpenCodeGoBillingStatusPayload(
|
||||
JSON.stringify({
|
||||
billingMode: 'prepaid',
|
||||
mode: 'pay-as-you-go',
|
||||
balanceMicroCents: '2786781005'
|
||||
})
|
||||
)
|
||||
).toBe(27.86781005)
|
||||
})
|
||||
})
|
||||
@@ -1,14 +0,0 @@
|
||||
import { afterEach, expect, it, vi } from 'vitest'
|
||||
import { logStartupMilestone, STARTUP_DIAGNOSTICS_ENV } from './startup-diagnostics'
|
||||
|
||||
afterEach(() => vi.unstubAllEnvs())
|
||||
|
||||
it('does not compute lazy milestone details unless diagnostics are enabled', () => {
|
||||
vi.stubEnv(STARTUP_DIAGNOSTICS_ENV, '0')
|
||||
const details = vi.fn(() => ({ bytes: 123 }))
|
||||
logStartupMilestone('persistence-load-done', details)
|
||||
expect(details).not.toHaveBeenCalled()
|
||||
vi.stubEnv(STARTUP_DIAGNOSTICS_ENV, '1')
|
||||
logStartupMilestone('persistence-load-done', details)
|
||||
expect(details).toHaveBeenCalledOnce()
|
||||
})
|
||||
@@ -1,27 +0,0 @@
|
||||
import { describe, it, expect } from 'vitest'
|
||||
import { classifyError } from './classify-error'
|
||||
|
||||
describe('classifyError', () => {
|
||||
it('classifies ENOENT as binary_not_found', () => {
|
||||
expect(classifyError(new Error('spawn zsh ENOENT'))).toEqual({
|
||||
error_class: 'binary_not_found'
|
||||
})
|
||||
expect(classifyError(Object.assign(new Error('missing'), { code: 'ENOENT' }))).toEqual({
|
||||
error_class: 'binary_not_found'
|
||||
})
|
||||
})
|
||||
|
||||
it('keeps shell-output-shaped not-found messages unknown', () => {
|
||||
expect(classifyError(new Error('command not found: claude'))).toEqual({
|
||||
error_class: 'unknown'
|
||||
})
|
||||
expect(classifyError(new Error('workspace not found'))).toEqual({
|
||||
error_class: 'unknown'
|
||||
})
|
||||
expect(
|
||||
classifyError(
|
||||
Object.assign(new Error('socket missing'), { code: 'ENOENT', syscall: 'connect' })
|
||||
)
|
||||
).toEqual({ error_class: 'unknown' })
|
||||
})
|
||||
})
|
||||
@@ -1,56 +0,0 @@
|
||||
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest'
|
||||
import { _resetValidatorWarnCacheForTests, validate } from './validator'
|
||||
|
||||
describe('onboarding feature setup telemetry validation', () => {
|
||||
beforeEach(() => {
|
||||
_resetValidatorWarnCacheForTests()
|
||||
vi.spyOn(console, 'warn').mockImplementation(() => {})
|
||||
})
|
||||
|
||||
afterEach(() => {
|
||||
vi.restoreAllMocks()
|
||||
})
|
||||
|
||||
it('accepts checklist and setup run events', () => {
|
||||
const selection = {
|
||||
browser_use: true,
|
||||
computer_use: false,
|
||||
linear_tickets: true,
|
||||
orchestration: true,
|
||||
selected_count: 2
|
||||
}
|
||||
const cases = [
|
||||
['onboarding_feature_setup_toggled', { feature: 'browser_use', selected: false }],
|
||||
[
|
||||
'onboarding_feature_setup_run',
|
||||
{
|
||||
...selection,
|
||||
cli_touched: true,
|
||||
skill_install_result: 'needs_attention',
|
||||
computer_use_permissions_opened: false,
|
||||
warning_count: 0
|
||||
}
|
||||
]
|
||||
] as const
|
||||
|
||||
for (const [event, props] of cases) {
|
||||
expect(validate(event, props).ok).toBe(true)
|
||||
}
|
||||
})
|
||||
|
||||
it('rejects selected_count values that do not match selected features', () => {
|
||||
expect(
|
||||
validate('onboarding_feature_setup_run', {
|
||||
browser_use: false,
|
||||
computer_use: false,
|
||||
linear_tickets: false,
|
||||
orchestration: false,
|
||||
selected_count: 3,
|
||||
cli_touched: false,
|
||||
skill_install_result: 'installed',
|
||||
computer_use_permissions_opened: false,
|
||||
warning_count: 0
|
||||
}).ok
|
||||
).toBe(false)
|
||||
})
|
||||
})
|
||||
@@ -1,37 +0,0 @@
|
||||
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest'
|
||||
import {
|
||||
_getValidatorWarnCacheSizeForTests,
|
||||
_resetValidatorWarnCacheForTests,
|
||||
validate
|
||||
} from './validator'
|
||||
|
||||
describe('telemetry validator warn cache', () => {
|
||||
beforeEach(() => {
|
||||
_resetValidatorWarnCacheForTests()
|
||||
vi.spyOn(console, 'warn').mockImplementation(() => {})
|
||||
})
|
||||
|
||||
afterEach(() => {
|
||||
vi.restoreAllMocks()
|
||||
})
|
||||
|
||||
it('bounds warn rate-limit entries for unique invalid event names', () => {
|
||||
for (let i = 0; i < 300; i++) {
|
||||
validate(`not_a_real_event_${i}` as never, {})
|
||||
}
|
||||
|
||||
expect(_getValidatorWarnCacheSizeForTests()).toBeLessThanOrEqual(256)
|
||||
})
|
||||
|
||||
it('prunes expired warn rate-limit entries', () => {
|
||||
vi.spyOn(Date, 'now').mockReturnValue(0)
|
||||
validate('not_a_real_event' as never, {})
|
||||
|
||||
expect(_getValidatorWarnCacheSizeForTests()).toBe(1)
|
||||
|
||||
vi.spyOn(Date, 'now').mockReturnValue(60_000)
|
||||
validate('another_fake_event' as never, {})
|
||||
|
||||
expect(_getValidatorWarnCacheSizeForTests()).toBe(1)
|
||||
})
|
||||
})
|
||||
@@ -1,20 +0,0 @@
|
||||
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest'
|
||||
import { _resetValidatorWarnCacheForTests, validate } from './validator'
|
||||
|
||||
describe('validate', () => {
|
||||
beforeEach(() => {
|
||||
_resetValidatorWarnCacheForTests()
|
||||
vi.spyOn(console, 'warn').mockImplementation(() => {})
|
||||
})
|
||||
afterEach(() => {
|
||||
vi.restoreAllMocks()
|
||||
})
|
||||
|
||||
it('drops unknown event names', () => {
|
||||
const result = validate('not_a_real_event' as never, {})
|
||||
expect(result.ok).toBe(false)
|
||||
if (!result.ok) {
|
||||
expect(result.reason).toMatch(/unknown event/)
|
||||
}
|
||||
})
|
||||
})
|
||||
@@ -66,13 +66,5 @@ export function validate<N extends EventName>(name: N, props: unknown): Validati
|
||||
return { ok: true, props: parsed.data as EventProps<N> }
|
||||
}
|
||||
|
||||
export function _resetValidatorWarnCacheForTests(): void {
|
||||
lastWarnAt.clear()
|
||||
}
|
||||
|
||||
export function _getValidatorWarnCacheSizeForTests(): number {
|
||||
return lastWarnAt.size
|
||||
}
|
||||
|
||||
// Keep outgoing common-property revalidation behind the same validator surface.
|
||||
export { commonPropsSchema }
|
||||
|
||||
@@ -1,19 +0,0 @@
|
||||
import { describe, expect, it } from 'vitest'
|
||||
import { isMacosTahoeOrNewer } from './macos-tahoe-release'
|
||||
|
||||
describe('isMacosTahoeOrNewer', () => {
|
||||
it('detects Darwin 25+ (macOS 26) as Tahoe or newer', () => {
|
||||
expect(isMacosTahoeOrNewer('25.5.0')).toBe(true)
|
||||
expect(isMacosTahoeOrNewer('26.0.0')).toBe(true)
|
||||
})
|
||||
|
||||
it('treats older Darwin releases as pre-Tahoe', () => {
|
||||
expect(isMacosTahoeOrNewer('24.6.0')).toBe(false)
|
||||
expect(isMacosTahoeOrNewer('23.0.0')).toBe(false)
|
||||
})
|
||||
|
||||
it('treats unparseable releases as pre-Tahoe', () => {
|
||||
expect(isMacosTahoeOrNewer('')).toBe(false)
|
||||
expect(isMacosTahoeOrNewer('unknown')).toBe(false)
|
||||
})
|
||||
})
|
||||
@@ -1,32 +0,0 @@
|
||||
import { describe, expect, it } from 'vitest'
|
||||
import { resolveWindowCloseAction } from './window-close-decision'
|
||||
|
||||
describe('resolveWindowCloseAction', () => {
|
||||
it('bypasses confirmation only when the renderer is truly gone or crashed', () => {
|
||||
expect(
|
||||
resolveWindowCloseAction({
|
||||
windowCloseConfirmed: false,
|
||||
rendererProcessGone: true,
|
||||
isRendererCrashed: false
|
||||
})
|
||||
).toBe('bypass-gone')
|
||||
expect(
|
||||
resolveWindowCloseAction({
|
||||
windowCloseConfirmed: false,
|
||||
rendererProcessGone: false,
|
||||
isRendererCrashed: true
|
||||
})
|
||||
).toBe('bypass-gone')
|
||||
})
|
||||
|
||||
// #5787: hung-but-live renderers still need save/process confirmation; only proven gone/crashed renderers may bypass.
|
||||
it('requests confirmation for an alive renderer (no gone/crashed flag)', () => {
|
||||
expect(
|
||||
resolveWindowCloseAction({
|
||||
windowCloseConfirmed: false,
|
||||
rendererProcessGone: false,
|
||||
isRendererCrashed: false
|
||||
})
|
||||
).toBe('request-confirmation')
|
||||
})
|
||||
})
|
||||
-15
@@ -1,15 +0,0 @@
|
||||
import { expect, it } from 'vitest'
|
||||
import { chooseInitialContinuationAgent } from './agent-session-continuation-selection'
|
||||
|
||||
it('does not automatically choose an offered-only chat, but preserves source and default intent', () => {
|
||||
const pick = (sourceAgent: 'antigravity' | null, defaultAgent: unknown) =>
|
||||
chooseInitialContinuationAgent({
|
||||
availableAgents: ['antigravity'],
|
||||
automaticAgents: [],
|
||||
sourceAgent,
|
||||
defaultAgent
|
||||
})
|
||||
expect(pick(null, null)).toBeNull()
|
||||
expect(pick('antigravity', null)).toBe('antigravity')
|
||||
expect(pick(null, 'antigravity')).toBe('antigravity')
|
||||
})
|
||||
@@ -1,13 +0,0 @@
|
||||
import { describe, expect, it } from 'vitest'
|
||||
import { appendUniqueOpenFileIds } from './unsaved-close-queue'
|
||||
|
||||
describe('appendUniqueOpenFileIds', () => {
|
||||
it('appends only open file ids and skips duplicates', () => {
|
||||
const result = appendUniqueOpenFileIds(
|
||||
['a'],
|
||||
['a', 'b', 'missing', 'c', 'b'],
|
||||
new Set(['a', 'b', 'c'])
|
||||
)
|
||||
expect(result).toEqual(['a', 'b', 'c'])
|
||||
})
|
||||
})
|
||||
@@ -1,25 +0,0 @@
|
||||
import { describe, expect, it } from 'vitest'
|
||||
import { getLocalhostWorktreeRouteKey } from './localhost-worktree-labels'
|
||||
|
||||
describe('localhost worktree labels', () => {
|
||||
it('keeps route keys unique for different ports in the same worktree', () => {
|
||||
const route = {
|
||||
projectName: 'Snap Studio',
|
||||
worktreeName: 'analytics',
|
||||
repoId: 'repo-1',
|
||||
worktreeId: 'wt-analytics'
|
||||
}
|
||||
|
||||
expect(
|
||||
getLocalhostWorktreeRouteKey({
|
||||
...route,
|
||||
targetUrl: 'http://localhost:5173/'
|
||||
})
|
||||
).not.toBe(
|
||||
getLocalhostWorktreeRouteKey({
|
||||
...route,
|
||||
targetUrl: 'http://localhost:7777/'
|
||||
})
|
||||
)
|
||||
})
|
||||
})
|
||||
@@ -1,39 +0,0 @@
|
||||
import { describe, expect, it } from 'vitest'
|
||||
import { nativeChatToolLineLabel } from './native-chat-tool-line-label'
|
||||
|
||||
describe('nativeChatToolLineLabel', () => {
|
||||
it('names a Codex change to several files by its count, and offers no file to open', () => {
|
||||
const label = nativeChatToolLineLabel(
|
||||
{ type: 'tool-call', name: 'Diff', input: { path: '2 files' }, state: 'completed' },
|
||||
{ type: 'tool-result', output: '@@ -1 +1 @@\n-a\n+b' }
|
||||
)
|
||||
expect(label).toMatchObject({ verb: 'edited', target: '2 files', filePath: null })
|
||||
})
|
||||
|
||||
it('still links a real file whose name reads like a count', () => {
|
||||
const label = nativeChatToolLineLabel({
|
||||
type: 'tool-call',
|
||||
name: 'Read',
|
||||
input: { file_path: '2 files' },
|
||||
state: 'completed'
|
||||
})
|
||||
expect(label.filePath).toBe('2 files')
|
||||
})
|
||||
|
||||
it('links a read, never a listed folder', () => {
|
||||
const read = nativeChatToolLineLabel({
|
||||
type: 'tool-call',
|
||||
name: 'Read',
|
||||
input: { file_path: 'src/a.ts' },
|
||||
state: 'completed'
|
||||
})
|
||||
const list = nativeChatToolLineLabel({
|
||||
type: 'tool-call',
|
||||
name: 'list',
|
||||
input: { command: 'ls src', path: 'src' },
|
||||
state: 'completed'
|
||||
})
|
||||
expect(read).toMatchObject({ verb: 'read', target: 'a.ts', filePath: 'src/a.ts' })
|
||||
expect(list).toMatchObject({ verb: 'listed', filePath: null })
|
||||
})
|
||||
})
|
||||
Reference in New Issue
Block a user