From 7ec9a6b1fcf29efeb39236f86b3f70c0b14d5dfb Mon Sep 17 00:00:00 2001 From: OrcaWin Date: Sat, 31 Oct 2026 19:54:00 -0700 Subject: [PATCH] test: remove 247 low-value tests, including 22 suites (#36857) * test: remove low-value suites and cases * test: update wall-clock ratchet after low-value test removals --- config/flaky-test-pattern-baseline.txt | 3 +- config/scripts/ci-shard-timings.json | 21 ---- .../ai-vault-wsl-session-carryover.test.ts | 31 ------ ...rowser-screencast-snapshot-scaling.test.ts | 99 ----------------- .../browser-extension-commands.test.ts | 18 ---- .../browser-extension-tab-query.test.ts | 16 --- .../claude-structured-auth-policy.test.ts | 46 +------- ...laude-structured-conversation-stop.test.ts | 20 ---- .../codex-credential-absence-grace.test.ts | 18 ---- ...codex-structured-conversation-stop.test.ts | 9 -- .../daemon-background-transient-facts.test.ts | 30 ------ src/main/daemon/node-pty-error-hints.test.ts | 102 ------------------ ...pty-subprocess-cwd-cancel-identity.test.ts | 16 --- .../terminal-snapshot-osc8-roundtrip.test.ts | 21 ---- src/main/git/porcelain-v1-records.test.ts | 16 --- .../git/runner-buffer-cancellation.test.ts | 9 -- .../journal-dispatch-settlement.test.ts | 14 --- .../journal-reducer-rejection-fact.test.ts | 35 ------ ...uctured-agent-session-read-restore.test.ts | 12 --- .../opencode-launch-model-context.test.ts | 27 ----- .../wsl-move-use-locally.test.ts | 6 -- src/main/providers/windows-powershell.test.ts | 100 ----------------- src/main/provisioned-root-checkout.test.ts | 14 --- .../first-host-launch-env-gate.test.ts | 23 ---- ...tructured-session-pointer-delivery.test.ts | 43 +------- .../runtime-mobile-codex-side-title.test.ts | 22 ---- .../runtime-worktree-selection.test.ts | 31 ------ .../terminal-model-query-authority.test.ts | 98 ----------------- .../runtime/wait-blocked-check-state.test.ts | 30 +----- .../speech/stt-offline-audio-chunker.test.ts | 38 ------- .../ssh-host-relay-windows-inventory.test.ts | 8 +- ...rktree-create-preparation-activity.test.ts | 89 --------------- ...e-create-preparation-stale-cleanup.test.ts | 22 ---- .../browser-page-download-activity.test.ts | 22 ---- ...hromium-error-page-poll-visibility.test.ts | 9 -- .../editor/diff-section-preview.test.ts | 100 ----------------- .../markdown-toc-collapse-state.test.ts | 93 ---------------- .../pdf-scale-preference-storage.test.ts | 99 ----------------- ...rich-markdown-search-matches-cache.test.ts | 39 ------- .../rich-markdown-terminal-path-paste.test.ts | 30 +----- .../AgentCapabilitiesSetupAction.test.ts | 100 ----------------- .../native-chat-find-visibility.test.ts | 91 ---------------- .../native-chat/native-chat-shortcut.test.ts | 48 +-------- .../native-chat-tab-agent-entry.test.ts | 94 ---------------- .../native-chat-task-list-state.test.ts | 34 ------ ...uctured-agent-session-rail-outline.test.ts | 33 ------ ...tive-chat-prompt-card-presentation.test.ts | 9 -- .../plugins/state/use-plugin-in-use.test.ts | 99 ----------------- ...SourceControl.remote-action-errors.test.ts | 98 ----------------- .../checks-panel-async-result-key.test.ts | 90 ---------------- .../file-explorer-row-projection.test.ts | 101 ----------------- .../file-explorer-selection.test.ts | 100 ----------------- ...worktree-header-section-boundaries.test.ts | 11 -- ...orktree-list-groups-host-collision.test.ts | 16 +-- .../use-row-removal-animation.test.ts | 99 ----------------- .../terminal-clipboard-event-paste.test.ts | 98 ----------------- .../terminal-link-pointer-gesture.test.ts | 9 -- .../terminal/active-terminal-repair.test.ts | 99 ----------------- .../terminal/split-group-mount.test.ts | 99 ----------------- .../hooks/useComposerState-decisions.test.ts | 94 ---------------- .../useIpcEvents-cmd-j-digit-chord.test.ts | 12 --- .../runtime/web-session-close-intent.test.ts | 26 +---- .../host-workspace-status-columns.test.ts | 14 +-- .../src/store/settled-sort-epoch.test.ts | 23 ---- .../agent-status-program-status.test.ts | 26 ----- ...github-branch-mismatched-linked-pr.test.ts | 34 ------ ...r-refresh-hosted-review-cache-leak.test.ts | 10 -- .../github-pr-refresh-sequences-leak.test.ts | 11 -- .../slices/superseded-ssh-repo-rows.test.ts | 34 +----- ...e-identity-rename-row-worktree-ids.test.ts | 95 ---------------- .../terminal-workspace-routing.scale.test.ts | 22 ---- .../store/workspace-record-selectors.test.ts | 16 +-- .../worktree-host-collision-index.test.ts | 29 +---- .../plugins/catalog/plugin-kill-list.test.ts | 33 ------ 74 files changed, 17 insertions(+), 3269 deletions(-) delete mode 100644 src/main/browser/browser-screencast-snapshot-scaling.test.ts delete mode 100644 src/main/daemon/node-pty-error-hints.test.ts delete mode 100644 src/main/providers/windows-powershell.test.ts delete mode 100644 src/main/runtime/terminal-model-query-authority.test.ts delete mode 100644 src/main/worktree-create-preparation-activity.test.ts delete mode 100644 src/renderer/src/components/editor/diff-section-preview.test.ts delete mode 100644 src/renderer/src/components/editor/markdown-toc-collapse-state.test.ts delete mode 100644 src/renderer/src/components/editor/pdf-scale-preference-storage.test.ts delete mode 100644 src/renderer/src/components/feature-wall/AgentCapabilitiesSetupAction.test.ts delete mode 100644 src/renderer/src/components/native-chat/native-chat-find-visibility.test.ts delete mode 100644 src/renderer/src/components/native-chat/native-chat-tab-agent-entry.test.ts delete mode 100644 src/renderer/src/components/plugins/state/use-plugin-in-use.test.ts delete mode 100644 src/renderer/src/components/right-sidebar/SourceControl.remote-action-errors.test.ts delete mode 100644 src/renderer/src/components/right-sidebar/checks-panel-async-result-key.test.ts delete mode 100644 src/renderer/src/components/right-sidebar/file-explorer-row-projection.test.ts delete mode 100644 src/renderer/src/components/right-sidebar/file-explorer-selection.test.ts delete mode 100644 src/renderer/src/components/sidebar/worktree-list/viewport/use-row-removal-animation.test.ts delete mode 100644 src/renderer/src/components/terminal-pane/terminal-clipboard-event-paste.test.ts delete mode 100644 src/renderer/src/components/terminal/active-terminal-repair.test.ts delete mode 100644 src/renderer/src/components/terminal/split-group-mount.test.ts delete mode 100644 src/renderer/src/hooks/useComposerState-decisions.test.ts delete mode 100644 src/renderer/src/store/slices/worktrees/session/worktree-identity-rename-row-worktree-ids.test.ts diff --git a/config/flaky-test-pattern-baseline.txt b/config/flaky-test-pattern-baseline.txt index eb540db81e5..7730ab4eb96 100644 --- a/config/flaky-test-pattern-baseline.txt +++ b/config/flaky-test-pattern-baseline.txt @@ -989,7 +989,7 @@ 2 test-no-wall-clock:src/main/runtime/runtime-client-agent-launch-settings-durability.test.ts 10 test-no-wall-clock:src/main/runtime/runtime-hook-agent-row-selection.test.ts 9 test-no-wall-clock:src/main/runtime/runtime-mobile-agent-status-builder.test.ts -5 test-no-wall-clock:src/main/runtime/runtime-mobile-codex-side-title.test.ts +3 test-no-wall-clock:src/main/runtime/runtime-mobile-codex-side-title.test.ts 6 test-no-wall-clock:src/main/runtime/runtime-rpc-pairing-mode-persistence.test.ts 11 test-no-wall-clock:src/main/runtime/runtime-rpc-relay-pairing.test.ts 2 test-no-wall-clock:src/main/runtime/runtime-rpc-websocket-bind-host.test.ts @@ -1159,7 +1159,6 @@ 2 test-no-wall-clock:src/shared/fish-query-reply-child-stdin.node-pty.test.ts 1 test-no-wall-clock:src/shared/git-binary-compatibility.test.ts 1 test-no-wall-clock:src/shared/mobile-push-contract.test.ts -1 test-no-wall-clock:src/shared/plugins/catalog/plugin-kill-list.test.ts 2 test-no-wall-clock:src/shared/pty-reply-echo-shapes.node-pty.test.ts 4 test-no-wall-clock:src/shared/sidebar-list/smart-sort.test.ts 2 test-no-wall-clock:src/shared/startup-command-staging.node-pty.test.ts diff --git a/config/scripts/ci-shard-timings.json b/config/scripts/ci-shard-timings.json index d7bfcd33f71..623056b1781 100644 --- a/config/scripts/ci-shard-timings.json +++ b/config/scripts/ci-shard-timings.json @@ -1307,7 +1307,6 @@ "src/main/browser/browser-screencast-guest-view-limit.test.ts": 758, "src/main/browser/browser-screencast-lifecycle.test.ts": 95, "src/main/browser/browser-screencast-live-frame-allocation.test.ts": 90, - "src/main/browser/browser-screencast-snapshot-scaling.test.ts": 237, "src/main/browser/browser-screencast-stream.test.ts": 712, "src/main/browser/browser-session-cookie-staging.scoped.test.ts": 521, "src/main/browser/browser-session-cookie-staging.test.ts": 259, @@ -2180,7 +2179,6 @@ "src/main/daemon/macos-retired-daemon-recovery.test.ts": 169, "src/main/daemon/ndjson.test.ts": 93, "src/main/daemon/node-pty-conout-worker-errors.test.ts": 173, - "src/main/daemon/node-pty-error-hints.test.ts": 44, "src/main/daemon/node-pty-windows-input-error.win32.test.ts": 38, "src/main/daemon/node-pty-windows-output-error.win32.test.ts": 72, "src/main/daemon/osc7-file-uri.test.ts": 63, @@ -4459,7 +4457,6 @@ "src/main/providers/windows-foreground-process-inspection-cost.test.ts": 93, "src/main/providers/windows-foreground-process-rows.test.ts": 83, "src/main/providers/windows-powershell-executable.test.ts": 42, - "src/main/providers/windows-powershell.test.ts": 55, "src/main/providers/windows-pty-job-membership.test.ts": 59, "src/main/providers/windows-shell-alone-in-job.test.ts": 66, "src/main/providers/windows-shell-args.test.ts": 189, @@ -5787,7 +5784,6 @@ "src/main/runtime/terminal-leaf-tab-resolution.test.ts": 42, "src/main/runtime/terminal-list-payload-size.test.ts": 2835, "src/main/runtime/terminal-list-pending-pty-registration.test.ts": 2947, - "src/main/runtime/terminal-model-query-authority.test.ts": 60, "src/main/runtime/terminal-orphan-owner.test.ts": 29, "src/main/runtime/terminal-orphan-topology.test.ts": 49, "src/main/runtime/terminal-pane-recovery-liveness-gate.test.ts": 4201, @@ -6530,7 +6526,6 @@ "src/main/worktree-create-candidates.test.ts": 54, "src/main/worktree-create-concurrency.test.ts": 44, "src/main/worktree-create-in-flight.test.ts": 175, - "src/main/worktree-create-preparation-activity.test.ts": 42, "src/main/worktree-create-preparation-cancellation.test.ts": 613, "src/main/worktree-create-preparation-claim.test.ts": 53, "src/main/worktree-create-preparation-contention.test.ts": 338, @@ -7191,7 +7186,6 @@ "src/renderer/src/components/editor/diff-navigation-context.test.tsx": 1470, "src/renderer/src/components/editor/diff-section-comment-submit.test.ts": 130, "src/renderer/src/components/editor/diff-section-layout.test.ts": 71, - "src/renderer/src/components/editor/diff-section-preview.test.ts": 1302, "src/renderer/src/components/editor/diff-viewer-large-diff-save-action.test.ts": 146, "src/renderer/src/components/editor/discard-editor-file-changes.save-race.test.ts": 704, "src/renderer/src/components/editor/drag-selection-guard-lifetime.test.ts": 584, @@ -7295,7 +7289,6 @@ "src/renderer/src/components/editor/markdown-round-trip.test.ts": 1552, "src/renderer/src/components/editor/markdown-scanner-boundaries.test.ts": 59, "src/renderer/src/components/editor/markdown-table-of-contents.test.ts": 97, - "src/renderer/src/components/editor/markdown-toc-collapse-state.test.ts": 47, "src/renderer/src/components/editor/markdown-toc-visibility-gate.test.ts": 106, "src/renderer/src/components/editor/markdown-tokenizer-start.test.ts": 68, "src/renderer/src/components/editor/mermaid-config.test.ts": 579, @@ -7312,7 +7305,6 @@ "src/renderer/src/components/editor/monaco-programmatic-sync.test.ts": 39, "src/renderer/src/components/editor/monaco-reveal-range.test.ts": 34, "src/renderer/src/components/editor/pan-zoom-view.test.ts": 35, - "src/renderer/src/components/editor/pdf-scale-preference-storage.test.ts": 45, "src/renderer/src/components/editor/pdf-scale-preference.test.ts": 59, "src/renderer/src/components/editor/pdf-view-position.test.ts": 43, "src/renderer/src/components/editor/pdf-viewer-failed-load-recovery.test.tsx": 1630, @@ -7463,7 +7455,6 @@ "src/renderer/src/components/feature-tips/feature-tip-modal-state.test.ts": 139, "src/renderer/src/components/feature-tips/feature-tip-startup-gate.test.ts": 105, "src/renderer/src/components/feature-tips/use-session-search-tip-setup.test.tsx": 520, - "src/renderer/src/components/feature-wall/AgentCapabilitiesSetupAction.test.ts": 1690, "src/renderer/src/components/feature-wall/FeatureWallSetupWorkflowActions.test.tsx": 1589, "src/renderer/src/components/feature-wall/FullDiskAccessSetupPrompt.test.ts": 695, "src/renderer/src/components/feature-wall/browser-animated-visual-sequence.test.ts": 42, @@ -7703,7 +7694,6 @@ "src/renderer/src/components/native-chat/native-chat-external-attachments-destination.test.tsx": 443, "src/renderer/src/components/native-chat/native-chat-file-link-existence.test.ts": 1523, "src/renderer/src/components/native-chat/native-chat-file-link.test.ts": 179, - "src/renderer/src/components/native-chat/native-chat-find-visibility.test.ts": 134, "src/renderer/src/components/native-chat/native-chat-floating-file-drop.test.tsx": 577, "src/renderer/src/components/native-chat/native-chat-font-size.test.ts": 64, "src/renderer/src/components/native-chat/native-chat-header-ownership.test.tsx": 2221, @@ -7766,7 +7756,6 @@ "src/renderer/src/components/native-chat/native-chat-subagent-sections-retention.test.ts": 609, "src/renderer/src/components/native-chat/native-chat-subagent-sections.test.ts": 555, "src/renderer/src/components/native-chat/native-chat-submission-navigation.test.tsx": 793, - "src/renderer/src/components/native-chat/native-chat-tab-agent-entry.test.ts": 109, "src/renderer/src/components/native-chat/native-chat-tab-directory.test.ts": 200, "src/renderer/src/components/native-chat/native-chat-task-list-state.test.ts": 68, "src/renderer/src/components/native-chat/native-chat-terminal-turn.test.ts": 50, @@ -8010,7 +7999,6 @@ "src/renderer/src/components/right-sidebar/SourceControl.pr-generation-records.test.ts": 125, "src/renderer/src/components/right-sidebar/SourceControl.preview-open.test.tsx": 3358, "src/renderer/src/components/right-sidebar/SourceControl.push-failure-recovery.test.ts": 40, - "src/renderer/src/components/right-sidebar/SourceControl.remote-action-errors.test.ts": 42, "src/renderer/src/components/right-sidebar/SourceControl.resolve-conflicts-prompt.test.ts": 96, "src/renderer/src/components/right-sidebar/SourceControl.virtual-file-list.test.tsx": 3910, "src/renderer/src/components/right-sidebar/SourceControlAgentActionDialog.test.tsx": 7135, @@ -8054,7 +8042,6 @@ "src/renderer/src/components/right-sidebar/check-log-initial-diagnostic-position.test.ts": 185, "src/renderer/src/components/right-sidebar/checks-entry-refresh.test.ts": 44, "src/renderer/src/components/right-sidebar/checks-list-expanded-details.test.tsx": 862, - "src/renderer/src/components/right-sidebar/checks-panel-async-result-key.test.ts": 70, "src/renderer/src/components/right-sidebar/checks-panel-content.test.tsx": 1525, "src/renderer/src/components/right-sidebar/checks-panel-empty-state.test.ts": 147, "src/renderer/src/components/right-sidebar/checks-panel-git-status-snapshot.test.ts": 50, @@ -8104,8 +8091,6 @@ "src/renderer/src/components/right-sidebar/file-explorer-refresh-concurrency.test.ts": 30, "src/renderer/src/components/right-sidebar/file-explorer-replace-selection-order-budget.test.tsx": 379, "src/renderer/src/components/right-sidebar/file-explorer-row-context-menu.test.tsx": 260, - "src/renderer/src/components/right-sidebar/file-explorer-row-projection.test.ts": 51, - "src/renderer/src/components/right-sidebar/file-explorer-selection.test.ts": 45, "src/renderer/src/components/right-sidebar/file-explorer-stale-dir-cache.test.ts": 49, "src/renderer/src/components/right-sidebar/file-explorer-stale-retry.test.tsx": 1734, "src/renderer/src/components/right-sidebar/file-explorer-watch-drive-root.test.ts": 1216, @@ -8707,7 +8692,6 @@ "src/renderer/src/components/sidebar/worktree-list/viewport/hard-scroll-up.test.ts": 48, "src/renderer/src/components/sidebar/worktree-list/viewport/scroll-adjustment.test.ts": 1810, "src/renderer/src/components/sidebar/worktree-list/viewport/sticky-headers.test.ts": 195, - "src/renderer/src/components/sidebar/worktree-list/viewport/use-row-removal-animation.test.ts": 33, "src/renderer/src/components/sidebar/worktree-list/viewport/use-scroll-to-top.test.ts": 233, "src/renderer/src/components/sidebar/worktree-list/viewport/use-scroll-to-top.test.tsx": 192, "src/renderer/src/components/sidebar/worktree-list/viewport/virtual-rows.test.ts": 58, @@ -9295,7 +9279,6 @@ "src/renderer/src/components/terminal-pane/terminal-captured-input-dispatch.test.ts": 63, "src/renderer/src/components/terminal-pane/terminal-chat-ownership-lifecycle.test.tsx": 572, "src/renderer/src/components/terminal-pane/terminal-cjk-cursor-cell-placement.test.ts": 169, - "src/renderer/src/components/terminal-pane/terminal-clipboard-event-paste.test.ts": 70, "src/renderer/src/components/terminal-pane/terminal-clipboard-paste.test.ts": 59, "src/renderer/src/components/terminal-pane/terminal-clipboard-selection-text.test.ts": 50, "src/renderer/src/components/terminal-pane/terminal-cold-park-exempt-flip.react185.test.tsx": 1035, @@ -9540,7 +9523,6 @@ "src/renderer/src/components/terminal-workspace-surface-ids.test.tsx": 1948, "src/renderer/src/components/terminal/activation-deferred-tab-admission.test.ts": 1338, "src/renderer/src/components/terminal/active-terminal-repair-loop.react185.test.tsx": 1641, - "src/renderer/src/components/terminal/active-terminal-repair.test.ts": 38, "src/renderer/src/components/terminal/background-terminal-worktree-mount.test.ts": 1278, "src/renderer/src/components/terminal/background-terminal-worktree-visibility.test.ts": 1736, "src/renderer/src/components/terminal/cold-activation-deferral-stranding.test.ts": 2600, @@ -9548,7 +9530,6 @@ "src/renderer/src/components/terminal/initial-terminal-structured-launch.test.tsx": 428, "src/renderer/src/components/terminal/pty-running-work-probe-child-evidence.test.ts": 71, "src/renderer/src/components/terminal/running-terminal-close-guard.test.ts": 55, - "src/renderer/src/components/terminal/split-group-mount.test.ts": 58, "src/renderer/src/components/terminal/startup-terminal-tab-hold.test.ts": 1872, "src/renderer/src/components/terminal/tab-type-cycle.test.ts": 39, "src/renderer/src/components/terminal/terminal-close-copy-kind.test.ts": 40, @@ -9729,7 +9710,6 @@ "src/renderer/src/hooks/useAgentDetectionTarget.test.ts": 1175, "src/renderer/src/hooks/useAppMenuSelectionActions.test.tsx": 262, "src/renderer/src/hooks/useAutomationDispatchEvents.test.ts": 910, - "src/renderer/src/hooks/useComposerState-decisions.test.ts": 70, "src/renderer/src/hooks/useComposerState-host-context-boundaries.test.ts": 52, "src/renderer/src/hooks/useComposerState-host-retarget.test.ts": 68, "src/renderer/src/hooks/useComposerState.integration.test.ts": 2274, @@ -11235,7 +11215,6 @@ "src/renderer/src/store/slices/worktrees/listing/worktree-sort-order-patch.test.ts": 159, "src/renderer/src/store/slices/worktrees/metadata/worktree-meta-persist.test.ts": 184, "src/renderer/src/store/slices/worktrees/session/worktree-identity-rename-main-agreement.test.ts": 2125, - "src/renderer/src/store/slices/worktrees/session/worktree-identity-rename-row-worktree-ids.test.ts": 665, "src/renderer/src/store/slices/worktrees/session/worktree-no-op-notifications.test.ts": 1002, "src/renderer/src/store/slices/worktrees/teardown/host-qualified-removal-refusal.test.ts": 405, "src/renderer/src/store/slices/worktrees/teardown/host-worktree-removal-state.test.ts": 118, diff --git a/src/main/ai-vault/ai-vault-wsl-session-carryover.test.ts b/src/main/ai-vault/ai-vault-wsl-session-carryover.test.ts index 7213db10b73..c53f883afd1 100644 --- a/src/main/ai-vault/ai-vault-wsl-session-carryover.test.ts +++ b/src/main/ai-vault/ai-vault-wsl-session-carryover.test.ts @@ -52,21 +52,6 @@ describe('AI Vault WSL session carryover retention', () => { expect(probeFailed('scope-a')).toEqual(['a3']) }) - it('evicts the least recently used scope past the cap', () => { - const scopes = Array.from( - { length: AI_VAULT_WSL_CARRYOVER_SCOPE_LIMIT + 1 }, - (_, index) => `scope-${index}` - ) - for (const scope of scopes) { - confirm(scope, [`${scope}-row`]) - } - - expect(probeFailed('scope-0')).toEqual([]) - for (const scope of scopes.slice(1)) { - expect(probeFailed(scope)).toEqual([`${scope}-row`]) - } - }) - it('keeps the scope the user is on when others are visited after it', () => { confirm('active', ['row']) for (let index = 0; index < AI_VAULT_WSL_CARRYOVER_SCOPE_LIMIT - 1; index += 1) { @@ -79,20 +64,4 @@ describe('AI Vault WSL session carryover retention', () => { expect(probeFailed('active')).toEqual(['row']) expect(probeFailed('other-0')).toEqual([]) }) - - it('spends no slot on a scope with no WSL rows', () => { - confirm('wsl-scope', ['w']) - for (let index = 0; index < AI_VAULT_WSL_CARRYOVER_SCOPE_LIMIT * 2; index += 1) { - confirm(`host-only-${index}`, []) - } - - expect(probeFailed('wsl-scope')).toEqual(['w']) - }) - - it('an explicit delete still clears every scope', () => { - confirm('scope-a', ['a1']) - resetAiVaultWslSessionCarryover() - - expect(probeFailed('scope-a')).toEqual([]) - }) }) diff --git a/src/main/browser/browser-screencast-snapshot-scaling.test.ts b/src/main/browser/browser-screencast-snapshot-scaling.test.ts deleted file mode 100644 index 1398214f2dc..00000000000 --- a/src/main/browser/browser-screencast-snapshot-scaling.test.ts +++ /dev/null @@ -1,99 +0,0 @@ -import { Buffer } from 'node:buffer' -import { EventEmitter } from 'node:events' -import { describe, expect, it, vi } from 'vitest' - -import { startBrowserScreencast } from './browser-screencast-stream' - -function createMockWebContents(capturePage: () => Promise) { - let attached = false - const dbg = new EventEmitter() as EventEmitter & { - isAttached: ReturnType - attach: ReturnType - detach: ReturnType - sendCommand: ReturnType - } - dbg.isAttached = vi.fn(() => attached) - dbg.attach = vi.fn(() => { - attached = true - }) - dbg.detach = vi.fn(() => { - attached = false - }) - dbg.sendCommand = vi.fn(async () => ({})) - return { - isDestroyed: vi.fn(() => false), - isCrashed: vi.fn(() => false), - debugger: dbg, - capturePage: vi.fn(capturePage) - } -} - -function createCapturedImage(width: number, height: number) { - const resized = { - getSize: vi.fn(() => ({ width, height })), - resize: vi.fn(), - toJPEG: vi.fn(() => Buffer.from('scaled-frame')), - toPNG: vi.fn(() => Buffer.from('scaled-frame')) - } - const image = { - getSize: vi.fn(() => ({ width, height })), - resize: vi.fn(() => resized), - toJPEG: vi.fn(() => Buffer.from('captured-frame')), - toPNG: vi.fn(() => Buffer.from('captured-frame')) - } - return { image, resized } -} - -describe('browser screencast snapshot scaling', () => { - it('scales a hi-DPI capture down to the requested frame bounds', async () => { - const { image, resized } = createCapturedImage(4000, 3000) - const webContents = createMockWebContents(async () => image) - const onFrame = vi.fn() - - const session = await startBrowserScreencast(webContents as never, { - format: 'jpeg', - quality: 70, - maxWidth: 1440, - maxHeight: 1200, - viewportWidth: 2000, - viewportHeight: 1500, - deviceScaleFactor: 2, - everyNthFrame: 2, - minFrameIntervalMs: 0, - onFrame - }) - - await vi.waitFor(() => expect(onFrame).toHaveBeenCalledTimes(1)) - expect(image.resize).toHaveBeenCalledWith({ width: 1440, height: 1080 }) - expect(resized.toJPEG).toHaveBeenCalledWith(70) - expect(image.toJPEG).not.toHaveBeenCalled() - - session.stop() - await session.done - }) - - it('leaves a capture already within the frame bounds unscaled', async () => { - const { image } = createCapturedImage(1200, 800) - const webContents = createMockWebContents(async () => image) - const onFrame = vi.fn() - - const session = await startBrowserScreencast(webContents as never, { - format: 'jpeg', - quality: 70, - maxWidth: 1440, - maxHeight: 1200, - viewportWidth: 1200, - viewportHeight: 800, - everyNthFrame: 2, - minFrameIntervalMs: 0, - onFrame - }) - - await vi.waitFor(() => expect(onFrame).toHaveBeenCalledTimes(1)) - expect(image.resize).not.toHaveBeenCalled() - expect(image.toJPEG).toHaveBeenCalledWith(70) - - session.stop() - await session.done - }) -}) diff --git a/src/main/browser/extensions/browser-extension-commands.test.ts b/src/main/browser/extensions/browser-extension-commands.test.ts index 5789c321e4c..ea4d67c9fe6 100644 --- a/src/main/browser/extensions/browser-extension-commands.test.ts +++ b/src/main/browser/extensions/browser-extension-commands.test.ts @@ -49,24 +49,6 @@ describe('manifest commands', () => { expect(readBrowserExtensionCommands(manifest, 'win32')[1].shortcut).toBe('Ctrl+Shift+L') }) - it('assigns suggested keys to at most four commands', () => { - const many = { - commands: Object.fromEntries( - ['a', 'b', 'c', 'd', 'e'].map((name, index) => [ - name, - { suggested_key: { default: `Alt+Shift+${index}` } } - ]) - ) - } - expect(readBrowserExtensionCommands(many, 'win32').map((c) => c.shortcut)).toEqual([ - 'Alt+Shift+0', - 'Alt+Shift+1', - 'Alt+Shift+2', - 'Alt+Shift+3', - '' - ]) - }) - it('refuses shortcuts without Ctrl, Command or Alt', () => { expect(parseExtensionShortcut('Shift+Y', 'win32')).toBeNull() expect(parseExtensionShortcut('MacCtrl+Shift+Y', 'darwin')).toMatchObject({ diff --git a/src/main/browser/extensions/browser-extension-tab-query.test.ts b/src/main/browser/extensions/browser-extension-tab-query.test.ts index 1fcf1280832..9b8925a9d22 100644 --- a/src/main/browser/extensions/browser-extension-tab-query.test.ts +++ b/src/main/browser/extensions/browser-extension-tab-query.test.ts @@ -52,22 +52,6 @@ describe('matchesOrcaTabQuery', () => { expect(query({ active: true, currentWindow: true }, POPOUT)).toEqual([20]) expect(query({ active: true, lastFocusedWindow: true }, POPOUT)).toEqual([11]) }) - - it('resolves WINDOW_ID_CURRENT and window types', () => { - expect(query({ windowId: -2 }, POPOUT)).toEqual([20]) - expect(query({ windowType: 'normal' })).toEqual([10, 11, 30]) - expect(query({ currentWindow: false })).toEqual([20]) - }) - - it('filters status and index, and never matches pinned or grouped tabs', () => { - expect(query({ status: 'loading' })).toEqual([11]) - expect(query({ status: 'unloaded' })).toEqual([30]) - expect(query({ discarded: true })).toEqual([30]) - expect(query({ discarded: false, index: 0 })).toEqual([10, 20]) - expect(query({ index: 0 })).toEqual([10, 20]) - expect(query({ pinned: true })).toEqual([]) - expect(query({ groupId: 3 })).toEqual([]) - }) }) describe('matchesDiscardedTabNativeQuery', () => { diff --git a/src/main/claude-accounts/claude-structured-auth-policy.test.ts b/src/main/claude-accounts/claude-structured-auth-policy.test.ts index 98925850d4e..55036620abf 100644 --- a/src/main/claude-accounts/claude-structured-auth-policy.test.ts +++ b/src/main/claude-accounts/claude-structured-auth-policy.test.ts @@ -1,7 +1,8 @@ import { describe, expect, it } from 'vitest' import type { GlobalSettings } from '../../shared/global-settings-types' import type { ClaudeManagedAccount } from '../../shared/managed-account-types' -import { CLAUDE_AUTH_ENV_VARS, isHostManagedClaudeAccount } from './environment' +import { isHostManagedClaudeAccount } from './environment' + import { claudeStructuredAuthPolicyForSettings } from './claude-structured-auth-policy' const HOST_ACCOUNT = { id: 'host-a', managedAuthRuntime: 'host' } as ClaudeManagedAccount @@ -26,24 +27,6 @@ function settings( } describe('isHostManagedClaudeAccount', () => { - it('is false when no managed account is selected', () => { - expect(isHostManagedClaudeAccount([HOST_ACCOUNT], null)).toBe(false) - expect(isHostManagedClaudeAccount([HOST_ACCOUNT], undefined)).toBe(false) - expect(isHostManagedClaudeAccount([HOST_ACCOUNT], '')).toBe(false) - }) - - it('is true for a host-managed account', () => { - expect(isHostManagedClaudeAccount([HOST_ACCOUNT, WSL_ACCOUNT], 'host-a')).toBe(true) - }) - - it('is true for an account with no explicit runtime (the legacy host shape)', () => { - expect(isHostManagedClaudeAccount([LEGACY_ACCOUNT], 'legacy-c')).toBe(true) - }) - - it('is false for a WSL-managed account', () => { - expect(isHostManagedClaudeAccount([HOST_ACCOUNT, WSL_ACCOUNT], 'wsl-b')).toBe(false) - }) - it('is true for a selected id no account list explains', () => { expect(isHostManagedClaudeAccount([HOST_ACCOUNT], 'deleted-d')).toBe(true) expect(isHostManagedClaudeAccount(undefined, 'deleted-d')).toBe(true) @@ -63,20 +46,6 @@ describe('claudeStructuredAuthPolicyForSettings', () => { ).toEqual({ account: 'managed' }) }) - it('names a host account pinned by runtime selection', () => { - expect( - claudeStructuredAuthPolicyForSettings( - settings({ activeClaudeManagedAccountIdsByRuntime: { host: 'host-a', wsl: {} } }) - ) - ).toEqual({ account: 'managed' }) - }) - - it('names System default when no account is selected', () => { - expect(claudeStructuredAuthPolicyForSettings(settings({}))).toEqual({ - account: 'system' - }) - }) - it('ignores a WSL-only selection: the structured child is always a native host process', () => { expect( claudeStructuredAuthPolicyForSettings( @@ -87,14 +56,3 @@ describe('claudeStructuredAuthPolicyForSettings', () => { ).toEqual({ account: 'system' }) }) }) - -describe('the Anthropic auth variables Orca keeps out of its own processes', () => { - it('covers every Anthropic auth variable the terminal path knows about', () => { - expect([...CLAUDE_AUTH_ENV_VARS]).toEqual([ - 'ANTHROPIC_API_KEY', - 'ANTHROPIC_AUTH_TOKEN', - 'CLAUDE_CODE_OAUTH_TOKEN', - 'AWS_BEARER_TOKEN_BEDROCK' - ]) - }) -}) diff --git a/src/main/claude/claude-structured-conversation-stop.test.ts b/src/main/claude/claude-structured-conversation-stop.test.ts index e034ce85f17..eedb688e198 100644 --- a/src/main/claude/claude-structured-conversation-stop.test.ts +++ b/src/main/claude/claude-structured-conversation-stop.test.ts @@ -29,26 +29,6 @@ describe('Claude Stop that names no turn', () => { expect(interrupts(claude)).toBe(1) }) - it('interrupts that gap the same way when the Stop names a turn with no journal row yet', async () => { - const claude = fakeClaude({ replayUuid: null }) - const adapter = await written(claude) - - await expect( - adapter.cancelTurn({ sessionId: 'session-1', turnId: 'turn-ended', fence: 7 }) - ).resolves.toEqual({ cancelled: true }) - expect(interrupts(claude)).toBe(1) - }) - - it('interrupts a turn Claude opened on its own echo', async () => { - const claude = fakeClaude({ replayUuid: 'turn-T' }) - const adapter = await written(claude) - - await expect(adapter.cancelTurn({ sessionId: 'session-1', fence: 7 })).resolves.toEqual({ - cancelled: true - }) - expect(interrupts(claude)).toBe(1) - }) - it('does nothing for another fence, or with nothing in flight', async () => { const claude = fakeClaude({ replayUuid: null }) const adapter = await acquired(claude) diff --git a/src/main/codex-accounts/codex-credential-absence-grace.test.ts b/src/main/codex-accounts/codex-credential-absence-grace.test.ts index ac82a883780..5852d1dddf0 100644 --- a/src/main/codex-accounts/codex-credential-absence-grace.test.ts +++ b/src/main/codex-accounts/codex-credential-absence-grace.test.ts @@ -4,7 +4,6 @@ import { join } from 'node:path' import { afterEach, beforeEach, describe, expect, it } from 'vitest' import { CODEX_CREDENTIAL_ABSENCE_GRACE_MS, - CODEX_CREDENTIAL_ABSENCE_MAX_TRACKED_PATHS, CodexCredentialAbsenceGrace } from './codex-credential-absence-grace' @@ -26,17 +25,6 @@ describe('CodexCredentialAbsenceGrace', () => { rmSync(dir, { recursive: true, force: true }) }) - it('bounds unresolved credential paths', () => { - const grace = new CodexCredentialAbsenceGrace() - for (let index = 0; index < CODEX_CREDENTIAL_ABSENCE_MAX_TRACKED_PATHS + 4; index += 1) { - expect(grace.assess(join(dir, `account-${index}.json`), 1_000)).toMatchObject({ - durable: false - }) - } - - expect(grace.trackedPathCountForTests()).toBe(CODEX_CREDENTIAL_ABSENCE_MAX_TRACKED_PATHS) - }) - it('treats a torn mid-write read as transient until it outlives the grace window', () => { const grace = new CodexCredentialAbsenceGrace() writeFileSync(authPath, '{"tokens":{"acc', 'utf-8') @@ -82,10 +70,4 @@ describe('CodexCredentialAbsenceGrace', () => { durable: true }) }) - - it('reports settled credential-free JSON as durable immediately', () => { - const grace = new CodexCredentialAbsenceGrace() - writeFileSync(authPath, '{}', 'utf-8') - expect(grace.assess(authPath, 1_000)).toEqual({ state: 'no-credential', durable: true }) - }) }) diff --git a/src/main/codex/codex-structured-conversation-stop.test.ts b/src/main/codex/codex-structured-conversation-stop.test.ts index 3c146767aa8..f82cc38833f 100644 --- a/src/main/codex/codex-structured-conversation-stop.test.ts +++ b/src/main/codex/codex-structured-conversation-stop.test.ts @@ -30,15 +30,6 @@ describe('a Codex Stop that names no turn', () => { expect(rig.interrupts().map((call) => call.params?.turnId)).toEqual(['turn-1']) }) - it('interrupts no turn that already ended', async () => { - const rig = await codexTurnLifecycleRig() - await openedTurn(rig) - rig.turns.end('completed') - - await expect(stop(rig)).resolves.toEqual({ cancelled: false }) - expect(rig.interrupts()).toEqual([]) - }) - it("names the journal's turn over the one it saw open, and carries Codex's refusal", async () => { const rig = await codexTurnLifecycleRig() await openedTurn(rig) diff --git a/src/main/daemon/daemon-background-transient-facts.test.ts b/src/main/daemon/daemon-background-transient-facts.test.ts index 84db8f73c4d..89ffe554383 100644 --- a/src/main/daemon/daemon-background-transient-facts.test.ts +++ b/src/main/daemon/daemon-background-transient-facts.test.ts @@ -11,13 +11,6 @@ function createRelay() { } describe('BackgroundTransientFactRelay', () => { - it('emits a bell fact for a backgrounded session', () => { - const { relay, emitted } = createRelay() - relay.setSessionBackground('s1', true) - relay.onSessionData('s1', 'build output\x07more') - expect(emitted).toEqual([{ sessionId: 's1', fact: { kind: 'bell' } }]) - }) - it('keeps OSC escape state across chunks — a title terminator BEL is not a bell', () => { const { relay, emitted } = createRelay() relay.setSessionBackground('s1', true) @@ -26,19 +19,6 @@ describe('BackgroundTransientFactRelay', () => { expect(emitted).toEqual([]) }) - it('emits nothing for sessions that are not backgrounded', () => { - const { relay, emitted } = createRelay() - relay.onSessionData('s1', 'ding\x07') - expect(emitted).toEqual([]) - }) - - it('emits command-finished with the OSC 133;D exit code', () => { - const { relay, emitted } = createRelay() - relay.setSessionBackground('s1', true) - relay.onSessionData('s1', '\x1b]133;D;0\x07') - expect(emitted).toEqual([{ sessionId: 's1', fact: { kind: 'command-finished', exitCode: 0 } }]) - }) - it('preserves a provisional 2031 subscribe when scan authority moves to the daemon', () => { const { relay, emitted } = createRelay() relay.onSessionData('s1', '\x1b[?2031h\x1b[?') @@ -62,16 +42,6 @@ describe('BackgroundTransientFactRelay', () => { }) }) - it('stops emitting after un-background and reports the toggle as a state change', () => { - const { relay, emitted } = createRelay() - expect(relay.setSessionBackground('s1', true)).toBe(true) - expect(relay.setSessionBackground('s1', true)).toBe(false) - expect(relay.setSessionBackground('s1', false)).toBe(true) - expect(relay.setSessionBackground('s1', false)).toBe(false) - relay.onSessionData('s1', 'ding\x07') - expect(emitted).toEqual([]) - }) - it('drops the tracker on session exit', () => { const { relay, emitted } = createRelay() relay.setSessionBackground('s1', true) diff --git a/src/main/daemon/node-pty-error-hints.test.ts b/src/main/daemon/node-pty-error-hints.test.ts deleted file mode 100644 index 361d8b73ba1..00000000000 --- a/src/main/daemon/node-pty-error-hints.test.ts +++ /dev/null @@ -1,102 +0,0 @@ -import { describe, expect, it } from 'vitest' -import { - LEGACY_PTY_ALLOCATION_HINT, - LEGACY_TERMINAL_PROCESS_LIMIT_HINT, - PTY_ALLOCATION_HINT, - TERMINAL_PROCESS_LIMIT_HINT -} from '../../shared/terminal-spawn-error-copy' -import { addNodePtyRecoveryHint, parseNodePtyDiagnostic } from './node-pty-error-hints' - -describe('node-pty diagnostic error hints', () => { - it('parses the native step and errno without dropping the original message', () => { - const message = - "node-pty: posix_spawn failed: ENOENT (errno 2, No such file or directory) - helper='/tmp/deleted/node-pty/spawn-helper'" - - expect(parseNodePtyDiagnostic(message)).toEqual({ step: 'posix_spawn', errno: 2 }) - expect(addNodePtyRecoveryHint(message)).toBe( - `Daemon's node-pty install is gone (worktree deleted?). Restart Orca. ${message}` - ) - }) - - it('hints when the daemon exhausts file descriptors opening the slave pty', () => { - const message = - "node-pty: open_slave failed: EMFILE (errno 24, Too many open files) - slave='/dev/ttys003'" - - expect(addNodePtyRecoveryHint(message)).toBe(`${PTY_ALLOCATION_HINT}\n${message}`) - }) - - it('hints when the system cannot allocate a pty master', () => { - const message = - 'node-pty: posix_openpt failed: ENFILE (errno 23, Too many open files in system)' - - expect(addNodePtyRecoveryHint(message)).toBe(`${PTY_ALLOCATION_HINT}\n${message}`) - }) - - it('hints when macOS cannot configure a pty master device', () => { - const message = 'node-pty: posix_openpt failed: errno (errno 6, Device not configured)' - - expect(addNodePtyRecoveryHint(message)).toBe(`${PTY_ALLOCATION_HINT}\n${message}`) - }) - - it('hints local wrapped spawn errors from pty allocation failures', () => { - const message = - 'Failed to spawn shell "/bin/zsh": node-pty: open_slave failed: EMFILE (errno 24, Too many open files) - slave=\'/dev/ttys003\' (shell: /bin/zsh, cwd: /tmp, arch: arm64, platform: darwin 25.0.0, orca: 1.4.178). If this persists, please file an issue.' - - expect(addNodePtyRecoveryHint(message)).toBe(`${PTY_ALLOCATION_HINT}\n${message}`) - }) - - it('keeps the whole recovery action on the first line', () => { - const message = - 'Failed to spawn shell "/bin/zsh": node-pty: posix_openpt failed: errno (errno 6, Device not configured) (shell: /bin/zsh). If this persists, please file an issue.' - - expect(addNodePtyRecoveryHint(message).split('\n')[0]).toBe(PTY_ALLOCATION_HINT) - }) - - it('hints unstructured openpty allocation failures', () => { - const message = 'Failed to spawn shell "/bin/bash": openpty(3) failed.' - - expect(addNodePtyRecoveryHint(message)).toBe(`${PTY_ALLOCATION_HINT}\n${message}`) - }) - - it('hints when posix_spawn reports the per-user process limit', () => { - const message = - "node-pty: posix_spawn failed: EAGAIN (errno 35, Resource temporarily unavailable) - helper='/tmp/node-pty/spawn-helper'" - - expect(addNodePtyRecoveryHint(message)).toBe(`${TERMINAL_PROCESS_LIMIT_HINT}\n${message}`) - }) - - it('does not duplicate an existing recovery hint', () => { - const message = - "node-pty: open_slave failed: EMFILE (errno 24, Too many open files) - slave='/dev/ttys003'" - const hinted = `${PTY_ALLOCATION_HINT}\n${message}` - - expect(addNodePtyRecoveryHint(hinted)).toBe(hinted) - }) - - it('does not duplicate hints from an older remote host', () => { - const ptyError = 'node-pty: open_slave failed: EMFILE (errno 24, Too many open files)' - const processError = 'node-pty: posix_spawn failed: EAGAIN (errno 35, Resource unavailable)' - - expect(addNodePtyRecoveryHint(`${LEGACY_PTY_ALLOCATION_HINT} ${ptyError}`)).toBe( - `${LEGACY_PTY_ALLOCATION_HINT} ${ptyError}` - ) - expect(addNodePtyRecoveryHint(`${LEGACY_TERMINAL_PROCESS_LIMIT_HINT} ${processError}`)).toBe( - `${LEGACY_TERMINAL_PROCESS_LIMIT_HINT} ${processError}` - ) - }) - - it('does not duplicate a legacy hint on unstructured openpty failures', () => { - const hinted = `${LEGACY_PTY_ALLOCATION_HINT} Failed to spawn shell "/bin/bash": openpty(3) failed.` - - expect(addNodePtyRecoveryHint(hinted)).toBe(hinted) - }) - - it('leaves unrelated and unhinted node-pty diagnostics unchanged', () => { - expect(addNodePtyRecoveryHint('plain failure')).toBe('plain failure') - expect( - addNodePtyRecoveryHint( - "node-pty: tcsetattr failed: EIO (errno 5, Input/output error) - slave='/dev/ttys003'" - ) - ).toBe("node-pty: tcsetattr failed: EIO (errno 5, Input/output error) - slave='/dev/ttys003'") - }) -}) diff --git a/src/main/daemon/pty-subprocess-cwd-cancel-identity.test.ts b/src/main/daemon/pty-subprocess-cwd-cancel-identity.test.ts index c5dac38154a..592e054e42d 100644 --- a/src/main/daemon/pty-subprocess-cwd-cancel-identity.test.ts +++ b/src/main/daemon/pty-subprocess-cwd-cancel-identity.test.ts @@ -78,20 +78,4 @@ describe('createPtySubprocess cwd cancellation identity', () => { ).rejects.toThrow(TerminalAttachCanceledError) expect(spawnMock).not.toHaveBeenCalled() }) - - it('leaves a genuine missing-directory failure alone', async () => { - const cwd = process.platform === 'win32' ? 'C:\\gone' : '/gone' - validateWorkingDirectoryAsyncMock.mockRejectedValue( - new Error(`Working directory "${cwd}" does not exist. It may have been deleted.`) - ) - - await expect( - createPtySubprocess({ - sessionId: 'missing-cwd-session', - cols: 80, - rows: 24, - cwd - }) - ).rejects.toThrow(/does not exist/) - }) }) diff --git a/src/main/daemon/terminal-snapshot-osc8-roundtrip.test.ts b/src/main/daemon/terminal-snapshot-osc8-roundtrip.test.ts index f0575984016..685e54922d3 100644 --- a/src/main/daemon/terminal-snapshot-osc8-roundtrip.test.ts +++ b/src/main/daemon/terminal-snapshot-osc8-roundtrip.test.ts @@ -52,15 +52,6 @@ describe('OSC 8 hyperlink snapshot round-trip', () => { expect(oscLinkAt(restored, 0, 13)).toBeNull() }) - it('retains an explicit OSC link id', async () => { - const url = 'https://example.com/identified' - const { terminal, addon } = createTerminal() - await write(terminal, `\x1b]8;id=review-42;${url}\x1b\\review\x1b]8;;\x1b\\`) - - const restored = await replay(addon.serialize()) - expect(oscLinkAt(restored, 0, 0)).toEqual({ id: 'review-42', uri: url }) - }) - it('keeps an open link active for output arriving after replay', async () => { const url = 'https://example.com/streaming-link' const { terminal, addon } = createTerminal() @@ -71,18 +62,6 @@ describe('OSC 8 hyperlink snapshot round-trip', () => { expect(oscLinkAt(restored, 0, 6)).toEqual({ id: 'stream', uri: url }) }) - it('retains the URI across repeated serialize and replay cycles', async () => { - const url = 'https://example.com/repeated' - const { terminal, addon } = createTerminal() - await write(terminal, `\x1b]8;;${url}\x1b\\again\x1b]8;;\x1b\\`) - - const first = await replay(addon.serialize()) - const secondAddon = new SerializeAddon() - first.loadAddon(secondAddon) - const second = await replay(secondAddon.serialize()) - expect(oscLinkAt(second, 0, 0)?.uri).toBe(url) - }) - it('does not leak an open alternate-screen link into its unlinked prefix', async () => { const url = 'https://example.com/alternate' const { terminal, addon } = createTerminal() diff --git a/src/main/git/porcelain-v1-records.test.ts b/src/main/git/porcelain-v1-records.test.ts index 8f4193b3590..3d6a8188873 100644 --- a/src/main/git/porcelain-v1-records.test.ts +++ b/src/main/git/porcelain-v1-records.test.ts @@ -26,10 +26,6 @@ afterEach(() => { }) describe('parsePorcelainV1Records', () => { - it('returns [] for a clean status', () => { - expect(parsePorcelainV1Records('')).toEqual([]) - }) - it('keeps paths containing spaces and quotes intact', () => { const repo = createRepo() writeFileSync(join(repo, 'a file "quoted".txt'), 'x') @@ -77,16 +73,4 @@ describe('parsePorcelainV1Records', () => { { xy: '??', path: 'node_modules/' } ]) }) - - it('parses staged and unstaged codes distinctly', () => { - const repo = createRepo() - writeFileSync(join(repo, 'tracked.txt'), 'v1\n') - git(['add', '-A'], repo) - git(['commit', '-qm', 'init'], repo) - writeFileSync(join(repo, 'tracked.txt'), 'v2\n') - - expect(parsePorcelainV1Records(git(['status', '--porcelain', '-z'], repo))).toEqual([ - { xy: ' M', path: 'tracked.txt' } - ]) - }) }) diff --git a/src/main/git/runner-buffer-cancellation.test.ts b/src/main/git/runner-buffer-cancellation.test.ts index 59a17a046de..483e65a570a 100644 --- a/src/main/git/runner-buffer-cancellation.test.ts +++ b/src/main/git/runner-buffer-cancellation.test.ts @@ -22,15 +22,6 @@ afterEach(() => { }) describe('buffered Git cancellation', () => { - it('rejects an already canceled read without launching Git', async () => { - const controller = new AbortController() - controller.abort() - await expect( - gitExecFileAsyncBuffer(['show', 'HEAD:file'], { cwd: '/repo', signal: controller.signal }) - ).rejects.toMatchObject({ name: 'AbortError' }) - expect(execFileMock).not.toHaveBeenCalled() - }) - it('removes a canceled queued read without waiting for the active child', async () => { const scheduler = new GitAdmissionScheduler({ generalCap: 1, generalHeadroom: 0 }) _resetGitAdmissionForTests(scheduler) diff --git a/src/main/native-chat/agent-session-journal/journal-dispatch-settlement.test.ts b/src/main/native-chat/agent-session-journal/journal-dispatch-settlement.test.ts index 60f43973c44..2202183a114 100644 --- a/src/main/native-chat/agent-session-journal/journal-dispatch-settlement.test.ts +++ b/src/main/native-chat/agent-session-journal/journal-dispatch-settlement.test.ts @@ -73,18 +73,4 @@ describe('what a rejection does to the draft it was consumed from', () => { // Legacy rows lack handover evidence and may already have reached the provider. expect(queuedHandOffOutcome({ reason: DISPATCH_REJECTED_HOST_RESTARTED })).toBe('inDoubt') }) - - it('a failure returns the card for the user to act on', () => { - for (const kind of [ - 'providerRejected', - 'providerExited', - 'hostStopped', - 'startFailed', - 'writeFailed', - 'queueFull' - ] as const) { - expect(settle(kind)).toBe('returned') - } - expect(queuedHandOffOutcome({ reason: 'the provider said no' })).toBe('returned') - }) }) diff --git a/src/main/native-chat/agent-session-journal/journal-reducer-rejection-fact.test.ts b/src/main/native-chat/agent-session-journal/journal-reducer-rejection-fact.test.ts index 80f048a36e1..b2aa8613397 100644 --- a/src/main/native-chat/agent-session-journal/journal-reducer-rejection-fact.test.ts +++ b/src/main/native-chat/agent-session-journal/journal-reducer-rejection-fact.test.ts @@ -34,41 +34,6 @@ describe('a rejected dispatch', () => { ...base(1) } - it("copies a rejection's typed fact onto the submission, and only on `rejected`", () => { - const rejection = { kind: 'providerRejected', detail: { text: 'Too long', audience: 'person' } } - const state = fold([ - submission, - { - kind: 'dispatch', - clientMessageId: 'cm_1', - state: 'rejected', - providerItemId: null, - reason: "The agent didn't accept this message.", - rejection: { kind: 'providerRejected', detail: { text: 'Too long', audience: 'person' } }, - ...base(2) - } - ]) - expect(state.submissions.get('cm_1')).toMatchObject({ - dispatchState: 'rejected', - reason: "The agent didn't accept this message.", - rejection - }) - - const doubt = fold([ - { ...submission, clientMessageId: 'cm_2' }, - { - kind: 'dispatch', - clientMessageId: 'cm_2', - state: 'unknown', - providerItemId: null, - reason: 'provider_exited_before_acknowledgement', - rejection: { kind: 'writeFailed' }, - ...base(2) - } - ]) - expect(doubt.submissions.get('cm_2')).not.toHaveProperty('rejection') - }) - it('keeps only the kind of a rejection fact it cannot place, so it reads as no verdict', () => { const rejected = (rejection: unknown): JournalRow => { const row: JournalRow = { diff --git a/src/main/native-chat/agent-session-wire/structured-agent-session-read-restore.test.ts b/src/main/native-chat/agent-session-wire/structured-agent-session-read-restore.test.ts index 9a79039e4f7..4eef9361604 100644 --- a/src/main/native-chat/agent-session-wire/structured-agent-session-read-restore.test.ts +++ b/src/main/native-chat/agent-session-wire/structured-agent-session-read-restore.test.ts @@ -87,16 +87,4 @@ describe('read restore', () => { opened.push(published!.session.journal) expect(published!.session.child).toBeNull() }) - - it('drops a session with no journal', async () => { - const restored = await restoreStructuredAgentSessionRead(openDeps(), SESSION_ID) - - expect(restored).toBeNull() - }) - - it('drops a session with no record', async () => { - const restored = await restoreStructuredAgentSessionRead(openDeps(), 'unknown-session') - - expect(restored).toBeNull() - }) }) diff --git a/src/main/opencode/opencode-launch-model-context.test.ts b/src/main/opencode/opencode-launch-model-context.test.ts index fa4615d5a36..0a7d7ebafee 100644 --- a/src/main/opencode/opencode-launch-model-context.test.ts +++ b/src/main/opencode/opencode-launch-model-context.test.ts @@ -16,16 +16,6 @@ const snapshot = { } describe('OpenCode execution-host primary-agent context', () => { - it('uses the resolved first selectable primary and leaves absent identity unknown', () => { - expect(parseOpenCodeLaunchModelContext(snapshot)).toEqual({ primaryAgent: 'build' }) - expect( - parseOpenCodeLaunchModelContext({ - ...snapshot, - agents: { location: { directory }, data: [] } - }) - ).toBeNull() - }) - it('uses recorded 2.0.19 resolved agents without inventing stale or disabled primaries', () => { for (const capture of recordedCases) { const original = JSON.parse(capture.configContent) @@ -73,23 +63,6 @@ describe('OpenCode execution-host primary-agent context', () => { } }) - it('tolerates absent model fields and unrelated agent records', () => { - expect( - parseOpenCodeLaunchModelContext({ - ...snapshot, - agents: { - location: { directory }, - data: [ - { unrelated: true }, - { id: 'hidden', hidden: true }, - { id: 'child', mode: 'subagent' }, - { id: 'reviewer', mode: 'primary', model: null } - ] - } - }) - ).toEqual({ primaryAgent: 'reviewer' }) - }) - it('never uses primary-agent data from a foreign location', () => { expect( parseOpenCodeLaunchModelContext({ diff --git a/src/main/persistence/moving-wsl-projects/wsl-move-use-locally.test.ts b/src/main/persistence/moving-wsl-projects/wsl-move-use-locally.test.ts index daa87cc104d..ddc6f66ee76 100644 --- a/src/main/persistence/moving-wsl-projects/wsl-move-use-locally.test.ts +++ b/src/main/persistence/moving-wsl-projects/wsl-move-use-locally.test.ts @@ -39,12 +39,6 @@ describe('bringWslMovedProjectBack', () => { expect(hidden().size).toBe(0) }) - it('also releases a committed move whose desktop rewrite never finished', () => { - seedWslMoveCutover(userDataPath, wslMoveCutoverFixture('move-1', 'destination-committed')) - expect(bringWslMovedProjectBack(userDataPath, { repoId: 'repo-1' }).released).toBe(true) - expect(hidden().size).toBe(0) - }) - it('refuses a project no committed move took', () => { seedWslMoveCutover(userDataPath, wslMoveCutoverFixture('move-1', 'blobs-transferred')) expect(bringWslMovedProjectBack(userDataPath, { repoId: 'repo-1' })).toEqual({ diff --git a/src/main/providers/windows-powershell.test.ts b/src/main/providers/windows-powershell.test.ts deleted file mode 100644 index f8d791df14d..00000000000 --- a/src/main/providers/windows-powershell.test.ts +++ /dev/null @@ -1,100 +0,0 @@ -import { describe, expect, it } from 'vitest' -import { resolveEffectiveWindowsPowerShell } from './windows-powershell' - -describe('resolveEffectiveWindowsPowerShell', () => { - it('returns null for non-PowerShell shell families', () => { - expect( - resolveEffectiveWindowsPowerShell({ - shellFamily: 'cmd.exe', - implementation: 'pwsh.exe', - pwshAvailable: true - }) - ).toBeNull() - - expect( - resolveEffectiveWindowsPowerShell({ - shellFamily: 'wsl.exe', - implementation: 'powershell.exe', - pwshAvailable: true - }) - ).toBeNull() - - expect( - resolveEffectiveWindowsPowerShell({ - shellFamily: undefined, - implementation: 'pwsh.exe', - pwshAvailable: true - }) - ).toBeNull() - }) - - it('honors a direct pwsh.exe shell request even when the availability probe is false', () => { - expect( - resolveEffectiveWindowsPowerShell({ - shellFamily: 'pwsh.exe', - implementation: 'powershell.exe', - pwshAvailable: false - }) - ).toBe('pwsh.exe') - }) - - it('returns powershell.exe when the saved implementation is powershell.exe', () => { - expect( - resolveEffectiveWindowsPowerShell({ - shellFamily: 'powershell.exe', - implementation: 'powershell.exe', - pwshAvailable: true - }) - ).toBe('powershell.exe') - }) - - it('returns pwsh.exe when the saved implementation is pwsh.exe and pwsh is available', () => { - expect( - resolveEffectiveWindowsPowerShell({ - shellFamily: 'powershell.exe', - implementation: 'pwsh.exe', - pwshAvailable: true - }) - ).toBe('pwsh.exe') - }) - - it('keeps an explicit pwsh.exe preference when the availability probe is false', () => { - expect( - resolveEffectiveWindowsPowerShell({ - shellFamily: 'powershell.exe', - implementation: 'pwsh.exe', - pwshAvailable: false - }) - ).toBe('pwsh.exe') - }) - - it('uses pwsh.exe for Auto when pwsh is available', () => { - expect( - resolveEffectiveWindowsPowerShell({ - shellFamily: 'powershell.exe', - implementation: 'auto', - pwshAvailable: true - }) - ).toBe('pwsh.exe') - }) - - it('uses powershell.exe for Auto when pwsh is unavailable', () => { - expect( - resolveEffectiveWindowsPowerShell({ - shellFamily: 'powershell.exe', - implementation: 'auto', - pwshAvailable: false - }) - ).toBe('powershell.exe') - }) - - it('defaults to Auto when no implementation is persisted', () => { - expect( - resolveEffectiveWindowsPowerShell({ - shellFamily: 'powershell.exe', - implementation: undefined, - pwshAvailable: true - }) - ).toBe('pwsh.exe') - }) -}) diff --git a/src/main/provisioned-root-checkout.test.ts b/src/main/provisioned-root-checkout.test.ts index dcc7f1b812a..2d3d3b08f90 100644 --- a/src/main/provisioned-root-checkout.test.ts +++ b/src/main/provisioned-root-checkout.test.ts @@ -48,26 +48,12 @@ describe('verifyProvisionedRootCheckout', () => { ).toThrow('requested ref') }) - it('accepts a requested branch created from a tag or commit ref', () => { - expect( - verify(gitWorktree(projectRoot), { baseBranch: 'v1.2.3', expectedRefHead: 'abc123' }).branch - ).toBe('refs/heads/fix-sandbox') - }) - it('rejects a requested ref without its source-host commit identity', () => { expect(() => verify(gitWorktree(projectRoot), { baseBranch: 'missing-ref' })).toThrow( 'ref identity is missing' ) }) - it('uses an explicit branch override as the requested local branch', () => { - expect( - verify(gitWorktree(projectRoot, { branch: 'refs/heads/feature/review' }), { - branchNameOverride: 'feature/review' - }).branch - ).toBe('refs/heads/feature/review') - }) - it('rejects a linked worktree and a sparse checkout', () => { expect(() => verify(gitWorktree(projectRoot, { isMainWorktree: false }))).toThrow( 'must be the repository primary checkout' diff --git a/src/main/runtime/first-host-launch-env-gate.test.ts b/src/main/runtime/first-host-launch-env-gate.test.ts index 4776e9d668f..96be8e930c3 100644 --- a/src/main/runtime/first-host-launch-env-gate.test.ts +++ b/src/main/runtime/first-host-launch-env-gate.test.ts @@ -55,29 +55,6 @@ describe('first account push on a fresh WSL host', () => { expect(second).toBe(true) }) - it('never waits on the desktop, with a saved env, or off a WSL host', async () => { - const setTimeoutSpy = vi.spyOn(globalThis, 'setTimeout') - const desktop = new RuntimeAccountController() - const saved = new RuntimeAccountController() - saved.restoreHostLaunchEnv(PUSHED, () => {}, { expectDesktopPush: true }) - const other = new RuntimeAccountController() - other.restoreHostLaunchEnv(null, () => {}) - - for (const accounts of [desktop, saved, other]) { - let done = false - void accounts.prepareHostAgentLaunch('claude').then(() => { - done = true - }) - await Promise.resolve() - await Promise.resolve() - expect(done).toBe(true) - } - expect(saved.hostLaunchEnvFor('claude')).toEqual(PUSHED.claude) - expect(desktop.getCommitMessageAgentEnvironment()).toBeUndefined() - expect(other.getCommitMessageAgentEnvironment()).toBeUndefined() - expect(setTimeoutSpy).not.toHaveBeenCalled() - }) - it('makes AI commit text wait for the push too', async () => { const accounts = freshWslHost() const resolvers = accounts.getCommitMessageAgentEnvironment() diff --git a/src/main/runtime/orchestration/structured-session-pointer-delivery.test.ts b/src/main/runtime/orchestration/structured-session-pointer-delivery.test.ts index 087e45d7dac..65afa125be4 100644 --- a/src/main/runtime/orchestration/structured-session-pointer-delivery.test.ts +++ b/src/main/runtime/orchestration/structured-session-pointer-delivery.test.ts @@ -1,10 +1,6 @@ import { describe, expect, it } from 'vitest' import type { AgentJournalRenderItem } from '../../../shared/agent-session-journal-types' -import { - retainReasonForDispatch, - structuredDispatchDelivered, - structuredSessionGateFacts -} from './structured-session-pointer-delivery' +import { structuredSessionGateFacts } from './structured-session-pointer-delivery' function statusItem( turnLifecycle: { turnId: string; state: 'running' } | undefined @@ -37,28 +33,7 @@ function pendingApproval(): AgentJournalRenderItem { } as unknown as AgentJournalRenderItem } -const IDLE = { turnRunning: false, awaitingHuman: false } - describe('structured session gate facts', () => { - it('reads an empty journal as idle', () => { - expect(structuredSessionGateFacts([])).toEqual(IDLE) - }) - - it('reads a running turn as busy', () => { - expect( - structuredSessionGateFacts([statusItem({ turnId: 'turn-1', state: 'running' })]) - ).toEqual({ turnRunning: true, awaitingHuman: false }) - }) - - it('reads a tombstoned turn as idle, since settlement removes the running row', () => { - expect(structuredSessionGateFacts([statusItem(undefined)])).toEqual(IDLE) - }) - - it('reads a worker that has finished a long turn as idle, however much history it has', () => { - // Use the full timeline: idle history and a busy turn whose lifecycle scrolled off have identical tails. - expect(structuredSessionGateFacts(transcript(120))).toEqual(IDLE) - }) - it('sees a pending approval that scrolled out of any tail window', () => { expect(structuredSessionGateFacts([pendingApproval(), ...transcript(120)])).toEqual({ turnRunning: false, @@ -75,19 +50,3 @@ describe('structured session gate facts', () => { ).toEqual({ turnRunning: true, awaitingHuman: true }) }) }) - -describe('dispatch outcome classification', () => { - it('marks mail delivered only on an accepted dispatch', () => { - expect(structuredDispatchDelivered('accepted')).toBe(true) - expect(structuredDispatchDelivered('rejected')).toBe(false) - }) - - it('does not treat unknown as delivered, because a dead child settles unknown', () => { - expect(structuredDispatchDelivered('unknown')).toBe(false) - }) - - it('names the retain reason for each non-accepted dispatch', () => { - expect(retainReasonForDispatch('rejected')).toBe('dispatch-rejected') - expect(retainReasonForDispatch('unknown')).toBe('dispatch-unknown') - }) -}) diff --git a/src/main/runtime/runtime-mobile-codex-side-title.test.ts b/src/main/runtime/runtime-mobile-codex-side-title.test.ts index d636d51b6a0..c95b08075f9 100644 --- a/src/main/runtime/runtime-mobile-codex-side-title.test.ts +++ b/src/main/runtime/runtime-mobile-codex-side-title.test.ts @@ -41,19 +41,6 @@ describe('paired/mobile Codex status while a /side chat is shown', () => { expect(out).toMatchObject({ state: 'working', prompt: 'main task please' }) }) - it('keeps the main turn prompt once the title shows main working again', () => { - const hookAt = Date.now() - 20_000 - const out = renewRuntimeMobileAgentStatusFromPtyTitle(runningExec(hookAt, 'codex'), { - ...sideChatIdlePty(hookAt), - lastOscTitle: '⠋ repo', - lastOscTitleEpochMs: hookAt + 15_000, - lastAgentStatus: 'working', - lastAgentStatusStartedAtEpochMs: hookAt + 15_000, - lastAgentStatusRichInvalidatedAtEpochMs: hookAt + 15_000 - }) - expect(out).toMatchObject({ state: 'working', prompt: 'main task please' }) - }) - it('keeps a main turn waiting on approval and its prompt once the side chat closes', () => { const hookAt = Date.now() - 20_000 const out = renewRuntimeMobileAgentStatusFromPtyTitle( @@ -87,13 +74,4 @@ describe('paired/mobile Codex status while a /side chat is shown', () => { }) expect(out).toBeNull() }) - - it('still lets an idle title end the turn of an agent whose title follows that turn', () => { - const hookAt = Date.now() - 10_000 - const out = renewRuntimeMobileAgentStatusFromPtyTitle( - runningExec(hookAt, 'claude'), - sideChatIdlePty(hookAt) - ) - expect(out?.state).toBe('done') - }) }) diff --git a/src/main/runtime/runtime-worktree-selection.test.ts b/src/main/runtime/runtime-worktree-selection.test.ts index f8aab4e34ba..f6cffacb176 100644 --- a/src/main/runtime/runtime-worktree-selection.test.ts +++ b/src/main/runtime/runtime-worktree-selection.test.ts @@ -24,17 +24,6 @@ describe('getRuntimeWorktreeRemovalOptionsKey', () => { ].map(getRuntimeWorktreeRemovalOptionsKey) expect(new Set(keys).size).toBe(keys.length) }) - - it('treats an omitted option as its off value', () => { - expect(getRuntimeWorktreeRemovalOptionsKey({})).toBe( - getRuntimeWorktreeRemovalOptionsKey({ - force: false, - runHooks: false, - allowUnverifiedPtyStop: false, - allowFailedArchiveHook: false - }) - ) - }) }) describe('runtimeRepoMatchesExecutionHost', () => { @@ -43,15 +32,6 @@ describe('runtimeRepoMatchesExecutionHost', () => { expect(runtimeRepoMatchesExecutionHost({ connectionId: 'target-1' }, 'ssh:target-1')).toBe(true) }) - it('matches a stamped SSH repo against its own host', () => { - expect( - runtimeRepoMatchesExecutionHost( - { connectionId: 'target-1', executionHostId: 'ssh:target-1' }, - 'ssh:target-1' - ) - ).toBe(true) - }) - it('rejects an unstamped SSH repo against a different SSH host', () => { expect(runtimeRepoMatchesExecutionHost({ connectionId: 'target-1' }, 'ssh:target-2')).toBe( false @@ -65,17 +45,6 @@ describe('runtimeRepoMatchesExecutionHost', () => { ) }) - it('keeps a host-less legacy repo adoptable by any host', () => { - expect(runtimeRepoMatchesExecutionHost({}, 'runtime:env-1')).toBe(true) - expect(runtimeRepoMatchesExecutionHost({}, 'local')).toBe(true) - expect(runtimeRepoMatchesExecutionHost({}, 'ssh:target-1')).toBe(true) - }) - - it('matches any repo when the caller names no host', () => { - expect(runtimeRepoMatchesExecutionHost({ connectionId: 'target-1' })).toBe(true) - expect(runtimeRepoMatchesExecutionHost({ executionHostId: 'runtime:env-1' }, null)).toBe(true) - }) - it('keeps a stamped repo bound to the host it names', () => { expect(runtimeRepoMatchesExecutionHost({ executionHostId: 'runtime:env-1' }, 'local')).toBe( false diff --git a/src/main/runtime/terminal-model-query-authority.test.ts b/src/main/runtime/terminal-model-query-authority.test.ts deleted file mode 100644 index 3a594844b5a..00000000000 --- a/src/main/runtime/terminal-model-query-authority.test.ts +++ /dev/null @@ -1,98 +0,0 @@ -import { afterEach, describe, expect, it } from 'vitest' -import { - _resetTerminalModelQueryAuthorityForTest, - clearNativeWindowsConptyPty, - isNativeWindowsConptyPty, - isNativeWindowsLocalPtySpawn, - isTerminalModelQueryAuthorityEnabled, - markNativeWindowsConptyPty, - shouldModelAnswerHiddenPtyQueries -} from './terminal-model-query-authority' -import { - _resetHiddenRendererPtyDeliveryGateForTest, - markHiddenRendererPty -} from '../ipc/pty/delivery/pty-hidden-delivery-gate' - -const ALL_ON = { - terminalMainSideEffectAuthority: true, - terminalHiddenDeliveryGate: true, - terminalModelQueryAuthority: true -} - -afterEach(() => { - _resetTerminalModelQueryAuthorityForTest() - _resetHiddenRendererPtyDeliveryGateForTest() -}) - -describe('isTerminalModelQueryAuthorityEnabled', () => { - it('defaults on, including for absent settings', () => { - expect(isTerminalModelQueryAuthorityEnabled(ALL_ON)).toBe(true) - expect(isTerminalModelQueryAuthorityEnabled({})).toBe(true) - expect(isTerminalModelQueryAuthorityEnabled(null)).toBe(true) - expect(isTerminalModelQueryAuthorityEnabled(undefined)).toBe(true) - }) -}) - -describe('shouldModelAnswerHiddenPtyQueries', () => { - const answer = (ptyId: string, overrides: Record = {}): boolean => - shouldModelAnswerHiddenPtyQueries({ - ptyId, - settings: { ...ALL_ON, ...overrides }, - hasRemoteViewSubscriber: false - }) - - it('answers only for hidden-marked PTYs (the delivery decision is the reply decision)', () => { - expect(answer('pty-1')).toBe(false) - markHiddenRendererPty('pty-1') - expect(answer('pty-1')).toBe(true) - expect(answer('pty-other')).toBe(false) - }) -}) - -describe('isNativeWindowsLocalPtySpawn (main-side mirror of isLocalNativeWindowsPty)', () => { - const base = { - connectionId: null, - cwd: 'C:\\repo', - shellOverride: undefined, - platform: 'win32' as NodeJS.Platform - } - - it('matches local native Windows spawns', () => { - expect(isNativeWindowsLocalPtySpawn(base)).toBe(true) - expect(isNativeWindowsLocalPtySpawn({ ...base, connectionId: undefined })).toBe(true) - expect( - isNativeWindowsLocalPtySpawn({ ...base, shellOverride: 'C:\\Tools\\powershell.exe' }) - ).toBe(true) - }) - - it('rejects non-Windows hosts', () => { - expect(isNativeWindowsLocalPtySpawn({ ...base, platform: 'darwin' })).toBe(false) - expect(isNativeWindowsLocalPtySpawn({ ...base, platform: 'linux' })).toBe(false) - }) - - it('rejects SSH-backed spawns', () => { - expect(isNativeWindowsLocalPtySpawn({ ...base, connectionId: 'ssh-1' })).toBe(false) - }) - - it('rejects WSL cwds and WSL shell overrides', () => { - expect( - isNativeWindowsLocalPtySpawn({ ...base, cwd: '\\\\wsl.localhost\\Ubuntu\\home\\me' }) - ).toBe(false) - expect(isNativeWindowsLocalPtySpawn({ ...base, shellOverride: 'wsl.exe' })).toBe(false) - expect( - isNativeWindowsLocalPtySpawn({ ...base, shellOverride: 'C:\\Windows\\System32\\wsl.exe' }) - ).toBe(false) - expect(isNativeWindowsLocalPtySpawn({ ...base, shellOverride: 'wsl' })).toBe(false) - }) -}) - -describe('native-Windows ConPTY spawn record', () => { - it('marks, reads, and clears per PTY', () => { - expect(isNativeWindowsConptyPty('pty-1')).toBe(false) - markNativeWindowsConptyPty('pty-1') - expect(isNativeWindowsConptyPty('pty-1')).toBe(true) - expect(isNativeWindowsConptyPty('pty-2')).toBe(false) - clearNativeWindowsConptyPty('pty-1') - expect(isNativeWindowsConptyPty('pty-1')).toBe(false) - }) -}) diff --git a/src/main/runtime/wait-blocked-check-state.test.ts b/src/main/runtime/wait-blocked-check-state.test.ts index 6c3ec64ff74..7d5c3eef336 100644 --- a/src/main/runtime/wait-blocked-check-state.test.ts +++ b/src/main/runtime/wait-blocked-check-state.test.ts @@ -2,9 +2,9 @@ import { describe, expect, it } from 'vitest' import { appendWaitBlockedCarry, createWaitBlockedAppendedCarry, - readWaitBlockedCarry, - resetWaitBlockedCarry + readWaitBlockedCarry } from './wait-blocked-check-state' + import { MAX_TAIL_CHARS } from './terminal-tail-limits' /** The accumulation this replaced, verbatim, as the equivalence oracle. */ @@ -68,30 +68,4 @@ describe('wait-blocked appended carry', () => { expect(carry.chars).toBe(reference.length) } }) - - it('retains chunks instead of flattening the window on every chunk', () => { - // Old slicing copied the full saturated 256KiB window each chunk; retain chunks and copy only the boundary head. - const carry = createWaitBlockedAppendedCarry() - const chunk = 'z'.repeat(32 * 1024) - for (let i = 0; i < 16; i += 1) { - appendWaitBlockedCarry(carry, chunk) - } - expect(carry.chars).toBe(MAX_TAIL_CHARS) - expect(carry.chunks.length).toBe(8) - - appendWaitBlockedCarry(carry, 'tail') - expect(carry.chars).toBe(MAX_TAIL_CHARS) - // Head trimmed in place by 4 chars; no full-window copy. - expect(carry.chunks.length).toBe(9) - expect(carry.chunks[0].length).toBe(chunk.length - 4) - }) - - it('reset empties the window without leaking retained chunks', () => { - const carry = createWaitBlockedAppendedCarry() - appendWaitBlockedCarry(carry, 'hello') - resetWaitBlockedCarry(carry) - expect(readWaitBlockedCarry(carry)).toBe('') - expect(carry.chars).toBe(0) - expect(carry.chunks).toHaveLength(0) - }) }) diff --git a/src/main/speech/stt-offline-audio-chunker.test.ts b/src/main/speech/stt-offline-audio-chunker.test.ts index 5652ae7c681..c1d94dcbe5a 100644 --- a/src/main/speech/stt-offline-audio-chunker.test.ts +++ b/src/main/speech/stt-offline-audio-chunker.test.ts @@ -14,25 +14,6 @@ function loudSignal(length: number): Float32Array { } describe('OfflineAudioChunker', () => { - it('buffers audio below the chunk limit without emitting chunks', () => { - const chunker = new OfflineAudioChunker(SAMPLE_RATE) - - expect(chunker.push(loudSignal(CHUNK_LIMIT - 1))).toEqual([]) - }) - - it('emits a bounded chunk once the limit is reached and keeps the remainder', () => { - const chunker = new OfflineAudioChunker(SAMPLE_RATE) - const total = CHUNK_LIMIT + 500 - - const ready = chunker.push(loudSignal(total)) - const remainder = chunker.flush() - - expect(ready).toHaveLength(1) - expect(ready[0].length).toBeLessThanOrEqual(CHUNK_LIMIT) - expect(ready[0].length).toBeGreaterThan(0) - expect(ready[0].length + (remainder?.length ?? 0)).toBe(total) - }) - it('never emits a chunk larger than the limit across many small pushes', () => { const chunker = new OfflineAudioChunker(SAMPLE_RATE) const emitted: Float32Array[] = [] @@ -51,17 +32,6 @@ describe('OfflineAudioChunker', () => { expect(totalOut).toBe(pushes * pushSize) }) - it('splits multiple chunks out of one oversized push', () => { - const chunker = new OfflineAudioChunker(SAMPLE_RATE) - - const ready = chunker.push(loudSignal(CHUNK_LIMIT * 2 + 100)) - - expect(ready.length).toBeGreaterThanOrEqual(2) - for (const chunk of ready) { - expect(chunk.length).toBeLessThanOrEqual(CHUNK_LIMIT) - } - }) - it('splits at a silent pause near the chunk boundary instead of mid-speech', () => { const chunker = new OfflineAudioChunker(SAMPLE_RATE) const samples = loudSignal(CHUNK_LIMIT + 200) @@ -88,12 +58,4 @@ describe('OfflineAudioChunker', () => { rejoined.set(remainder!, chunk.length) expect(rejoined).toEqual(samples) }) - - it('flush returns null when nothing is buffered', () => { - const chunker = new OfflineAudioChunker(SAMPLE_RATE) - - expect(chunker.flush()).toBeNull() - expect(chunker.push(new Float32Array(0))).toEqual([]) - expect(chunker.flush()).toBeNull() - }) }) diff --git a/src/main/ssh/legacy-relay/ssh-host-relay-windows-inventory.test.ts b/src/main/ssh/legacy-relay/ssh-host-relay-windows-inventory.test.ts index 886ce936cc1..62b4945cc24 100644 --- a/src/main/ssh/legacy-relay/ssh-host-relay-windows-inventory.test.ts +++ b/src/main/ssh/legacy-relay/ssh-host-relay-windows-inventory.test.ts @@ -1,5 +1,5 @@ import { execFileSync } from 'node:child_process' -import { Script } from 'node:vm' + import { mkdirSync, mkdtempSync, rmSync, writeFileSync } from 'node:fs' import { tmpdir } from 'node:os' import { join } from 'node:path' @@ -7,9 +7,9 @@ import { afterEach, describe, expect, it } from 'vitest' import { windowsPipesNotRunHere, parseWindowsRelayInventory, - WINDOWS_PIPE_ACCESS_JS, WINDOWS_RELAY_INVENTORY_JS } from './ssh-host-relay-windows-inventory' + import { relaySocketNameForInstanceId } from './ssh-relay-instance-id' import { windowsRelayPipePathsForSocketName } from './ssh-relay-endpoints' import { getRemoteHostPlatform, joinRemotePath } from '../ssh-remote-platform' @@ -51,10 +51,6 @@ describe('the Windows relay inventory', () => { }) }) - it('compiles the pipe access probe', () => { - expect(() => new Script(WINDOWS_PIPE_ACCESS_JS)).not.toThrow() - }) - it("maps another desktop's pipes to its own instance and credential", () => { const sockName = relaySocketNameForInstanceId('desktop-b') const [primary] = windowsRelayPipePathsForSocketName(host, DIR, sockName) diff --git a/src/main/worktree-create-preparation-activity.test.ts b/src/main/worktree-create-preparation-activity.test.ts deleted file mode 100644 index 08c4f9f1f2f..00000000000 --- a/src/main/worktree-create-preparation-activity.test.ts +++ /dev/null @@ -1,89 +0,0 @@ -import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest' -import { createPreparationActivity } from './worktree-create-preparation-activity' -import { - _resetWorktreeCreateConcurrencyForTests, - beginWorktreeCreate -} from './worktree-create-concurrency' - -let now = 0 - -beforeEach(() => { - now = 1_000 - vi.spyOn(performance, 'now').mockImplementation(() => now) -}) - -afterEach(() => { - _resetWorktreeCreateConcurrencyForTests() - vi.restoreAllMocks() -}) - -describe('createPreparationActivity', () => { - it('reports the origin, including a re-arm the prefetch then asked for', () => { - expect(createPreparationActivity('explicit').origin()).toBe('prefetch') - expect(createPreparationActivity('automatic').origin()).toBe('rearm') - const asked = createPreparationActivity('automatic') - asked.requestedByPrefetch() - expect(asked.origin()).toBe('rearm_then_prefetch') - }) - - it('keeps one piece of work for a tip refresh queued before the build finished', async () => { - const activity = createPreparationActivity('explicit') - const build = Promise.withResolvers() - activity.track(build.promise) - const refresh = Promise.withResolvers() - const chained = build.promise.then(() => refresh.promise) - activity.track(chained) - const observer = beginWorktreeCreate() - - now = 3_000 - build.resolve() - await build.promise - now = 5_000 - refresh.resolve() - await chained - - expect(activity.timesAt(9_000)).toEqual({ buildMs: 2_000, idleMs: 4_000 }) - expect(observer.end().preparations).toBe(1) - }) - - it('keeps the build time of the first build when a later refresh runs as new work', async () => { - const activity = createPreparationActivity('automatic') - const build = Promise.withResolvers() - activity.track(build.promise) - now = 41_000 - build.resolve() - await build.promise - const observer = beginWorktreeCreate() - - now = 101_000 - const refresh = Promise.withResolvers() - activity.track(refresh.promise) - now = 103_000 - refresh.resolve() - await refresh.promise - - expect(activity.timesAt(113_000)).toEqual({ buildMs: 40_000, idleMs: 10_000 }) - expect(observer.end().preparations).toBe(1) - }) - - it('reports no idle time while a refresh is still running at the claim', async () => { - const activity = createPreparationActivity('explicit') - const build = Promise.resolve() - activity.track(build) - now = 2_000 - await build - const refresh = Promise.withResolvers() - activity.track(refresh.promise) - expect(activity.timesAt(5_000)).toEqual({ buildMs: 1_000, idleMs: 0 }) - }) - - it('reports no idle time when the claim came before the work finished', async () => { - const activity = createPreparationActivity('automatic') - const build = Promise.withResolvers() - activity.track(build.promise) - now = 4_000 - build.resolve() - await build.promise - expect(activity.timesAt(2_000)).toEqual({ buildMs: 3_000, idleMs: 0 }) - }) -}) diff --git a/src/main/worktree-create-preparation-stale-cleanup.test.ts b/src/main/worktree-create-preparation-stale-cleanup.test.ts index 8fa06569718..f7cd76d34fb 100644 --- a/src/main/worktree-create-preparation-stale-cleanup.test.ts +++ b/src/main/worktree-create-preparation-stale-cleanup.test.ts @@ -39,12 +39,6 @@ describe('preparation lock reasons', () => { process.pid ) }) - - it('omits the machine when the writer cannot identify it', () => { - const reason = createWorktreePreparationLockReason('session', null) - expect(reason).toBe(`orca-create-preparation:v1:${process.pid}:session`) - expect(parseWorktreePreparationOwnerMachine(reason)).toBeNull() - }) }) describe('preparationOwnerExitedHere', () => { @@ -63,18 +57,6 @@ describe('preparationOwnerExitedHere', () => { ).toBe(false) }) - it('reads a dead owner on this machine as exited, and a live one as not', () => { - expect(preparationOwnerExitedHere(reasonFrom(MACHINE_A), REPO, {}, probe())).toBe(true) - expect( - preparationOwnerExitedHere( - reasonFrom(MACHINE_A), - REPO, - {}, - probe({ isProcessAlive: () => true }) - ) - ).toBe(false) - }) - it('judges a reason with no machine by pid only on a disk no other host sees', () => { expect(preparationOwnerExitedHere(reasonFrom(null), REPO, {}, probe())).toBe(true) expect( @@ -94,8 +76,4 @@ describe('preparationOwnerExitedHere', () => { ) ).toBe(true) }) - - it('ignores reasons that are not preparation locks', () => { - expect(preparationOwnerExitedHere('active agent session', REPO, {}, probe())).toBe(false) - }) }) diff --git a/src/renderer/src/components/browser-pane/navigate/browser-page-download-activity.test.ts b/src/renderer/src/components/browser-pane/navigate/browser-page-download-activity.test.ts index f2996e3a8ed..c019ff43e22 100644 --- a/src/renderer/src/components/browser-pane/navigate/browser-page-download-activity.test.ts +++ b/src/renderer/src/components/browser-pane/navigate/browser-page-download-activity.test.ts @@ -52,28 +52,6 @@ describe('browser page download activity', () => { expect(hasActiveBrowserPageDownload('page-1')).toBe(false) }) - it('scopes activity to the page that started the download', async () => { - const { hasActiveBrowserPageDownload, installBrowserPageDownloadActivityTracking } = - await import('./browser-page-download-activity') - installBrowserPageDownloadActivityTracking() - - requestedCallbacks[0]({ downloadId: 'dl-1', browserPageId: 'page-1' }) - expect(hasActiveBrowserPageDownload('page-2')).toBe(false) - }) - - it('ignores duplicate start events and unknown finish events', async () => { - const { hasActiveBrowserPageDownload, installBrowserPageDownloadActivityTracking } = - await import('./browser-page-download-activity') - installBrowserPageDownloadActivityTracking() - - requestedCallbacks[0]({ downloadId: 'dl-1', browserPageId: 'page-1' }) - requestedCallbacks[0]({ downloadId: 'dl-1', browserPageId: 'page-1' }) - finishedCallbacks[0]({ downloadId: 'dl-unknown' }) - expect(hasActiveBrowserPageDownload('page-1')).toBe(true) - finishedCallbacks[0]({ downloadId: 'dl-1' }) - expect(hasActiveBrowserPageDownload('page-1')).toBe(false) - }) - it('unsubscribes and clears tracked state on cleanup', async () => { const { hasActiveBrowserPageDownload, installBrowserPageDownloadActivityTracking } = await import('./browser-page-download-activity') diff --git a/src/renderer/src/components/browser-pane/navigate/chromium-error-page-poll-visibility.test.ts b/src/renderer/src/components/browser-pane/navigate/chromium-error-page-poll-visibility.test.ts index 582a08ff502..eb6f511405e 100644 --- a/src/renderer/src/components/browser-pane/navigate/chromium-error-page-poll-visibility.test.ts +++ b/src/renderer/src/components/browser-pane/navigate/chromium-error-page-poll-visibility.test.ts @@ -84,13 +84,4 @@ describe('chromium error page poll visibility gate', () => { unmount() expect(vi.getTimerCount()).toBe(0) }) - - it('polls unchanged while the window stays visible', () => { - let guestUrl = 'https://example.test/slow' - const { updates } = renderUrlSync(() => guestUrl) - - guestUrl = CHROMIUM_ERROR_URL - act(() => vi.advanceTimersByTime(250)) - expect(updates).toHaveLength(1) - }) }) diff --git a/src/renderer/src/components/editor/diff-section-preview.test.ts b/src/renderer/src/components/editor/diff-section-preview.test.ts deleted file mode 100644 index c419171c202..00000000000 --- a/src/renderer/src/components/editor/diff-section-preview.test.ts +++ /dev/null @@ -1,100 +0,0 @@ -import { describe, expect, it } from 'vitest' -import { canOpenDiffSectionPreviewToSide } from './diff-section-preview' - -describe('canOpenDiffSectionPreviewToSide', () => { - it('enables HTML working-tree sections that still exist on disk', () => { - expect( - canOpenDiffSectionPreviewToSide({ - path: 'docs/demo.html', - status: 'modified', - isCommitSurface: false, - canOpenWorkspaceFileBrowser: true - }) - ).toBe(true) - }) - - it('enables .htm paths', () => { - expect( - canOpenDiffSectionPreviewToSide({ - path: 'index.htm', - status: 'added', - isCommitSurface: false, - canOpenWorkspaceFileBrowser: true - }) - ).toBe(true) - }) - - it('enables untracked and renamed HTML files still present on disk', () => { - expect( - canOpenDiffSectionPreviewToSide({ - path: 'scratch.html', - status: 'untracked', - isCommitSurface: false, - canOpenWorkspaceFileBrowser: true - }) - ).toBe(true) - expect( - canOpenDiffSectionPreviewToSide({ - path: 'renamed.html', - status: 'renamed', - isCommitSurface: false, - canOpenWorkspaceFileBrowser: true - }) - ).toBe(true) - }) - - it('enables uppercase HTML extensions', () => { - expect( - canOpenDiffSectionPreviewToSide({ - path: 'Docs/DEMO.HTML', - status: 'modified', - isCommitSurface: false, - canOpenWorkspaceFileBrowser: true - }) - ).toBe(true) - }) - - it('disables deleted HTML files', () => { - expect( - canOpenDiffSectionPreviewToSide({ - path: 'gone.html', - status: 'deleted', - isCommitSurface: false, - canOpenWorkspaceFileBrowser: true - }) - ).toBe(false) - }) - - it('disables commit surfaces whose content may not match disk', () => { - expect( - canOpenDiffSectionPreviewToSide({ - path: 'docs/demo.html', - status: 'modified', - isCommitSurface: true, - canOpenWorkspaceFileBrowser: true - }) - ).toBe(false) - }) - - it('disables non-previewable languages', () => { - expect( - canOpenDiffSectionPreviewToSide({ - path: 'src/app.ts', - status: 'modified', - isCommitSurface: false, - canOpenWorkspaceFileBrowser: true - }) - ).toBe(false) - }) - - it('disables previews when the workspace browser provider is unavailable', () => { - expect( - canOpenDiffSectionPreviewToSide({ - path: 'docs/demo.html', - status: 'modified', - isCommitSurface: false, - canOpenWorkspaceFileBrowser: false - }) - ).toBe(false) - }) -}) diff --git a/src/renderer/src/components/editor/markdown-toc-collapse-state.test.ts b/src/renderer/src/components/editor/markdown-toc-collapse-state.test.ts deleted file mode 100644 index c24a9697dff..00000000000 --- a/src/renderer/src/components/editor/markdown-toc-collapse-state.test.ts +++ /dev/null @@ -1,93 +0,0 @@ -import { describe, expect, it } from 'vitest' -import type { MarkdownTocItem } from './markdown-table-of-contents' -import { - collapseMarkdownTocToLevel, - collectMarkdownTocParentIds, - isMarkdownTocItemExpanded, - pruneMarkdownTocCollapsedIds, - toggleMarkdownTocCollapsedId -} from './markdown-toc-collapse-state' - -const sampleToc: MarkdownTocItem[] = [ - { - id: 'intro', - level: 1, - title: 'Intro', - children: [ - { - id: 'setup', - level: 2, - title: 'Setup', - children: [ - { - id: 'install', - level: 3, - title: 'Install', - children: [ - { - id: 'configure', - level: 4, - title: 'Configure', - children: [ - { - id: 'options', - level: 5, - title: 'Options', - children: [] - } - ] - } - ] - } - ] - }, - { - id: 'usage', - level: 2, - title: 'Usage', - children: [] - } - ] - } -] - -describe('markdown toc collapse state', () => { - it('collects parent ids for nested headings', () => { - expect([...collectMarkdownTocParentIds(sampleToc)].sort()).toEqual([ - 'configure', - 'install', - 'intro', - 'setup' - ]) - }) - - it('collapses parents at and below the selected level', () => { - expect([...collapseMarkdownTocToLevel(sampleToc, 1)].sort()).toEqual([ - 'configure', - 'install', - 'intro', - 'setup' - ]) - expect([...collapseMarkdownTocToLevel(sampleToc, 2)].sort()).toEqual([ - 'configure', - 'install', - 'setup' - ]) - expect([...collapseMarkdownTocToLevel(sampleToc, 4)]).toEqual(['configure']) - expect([...collapseMarkdownTocToLevel(sampleToc, 5)]).toEqual([]) - }) - - it('toggles and prunes stale collapsed ids', () => { - const toggled = toggleMarkdownTocCollapsedId(new Set(['setup']), 'setup') - expect([...toggled]).toEqual([]) - - const pruned = pruneMarkdownTocCollapsedIds(new Set(['setup', 'missing']), sampleToc) - expect([...pruned]).toEqual(['setup']) - }) - - it('reports expanded state from collapsed ids', () => { - const collapsed = new Set(['intro']) - expect(isMarkdownTocItemExpanded(collapsed, sampleToc[0])).toBe(false) - expect(isMarkdownTocItemExpanded(collapsed, sampleToc[0].children[1])).toBe(true) - }) -}) diff --git a/src/renderer/src/components/editor/pdf-scale-preference-storage.test.ts b/src/renderer/src/components/editor/pdf-scale-preference-storage.test.ts deleted file mode 100644 index 0c0ce1b0f51..00000000000 --- a/src/renderer/src/components/editor/pdf-scale-preference-storage.test.ts +++ /dev/null @@ -1,99 +0,0 @@ -import { afterEach, describe, expect, it, vi } from 'vitest' -import { - buildPdfScalePreferenceKey, - PDF_SCALE_PREFERENCES_STORAGE_KEY, - readPdfScalePreference, - writePdfScalePreference -} from './pdf-scale-preference-storage' - -afterEach(() => { - vi.unstubAllGlobals() -}) - -describe('PDF scale preference storage', () => { - it('keeps identical paths isolated by worktree and remote owner', () => { - const localKey = buildPdfScalePreferenceKey({ worktreeId: 'worktree-a', filePath: '/doc.pdf' }) - const runtimeKey = buildPdfScalePreferenceKey({ - worktreeId: 'worktree-a', - runtimeEnvironmentId: 'runtime-b', - filePath: '/doc.pdf' - }) - const sshKey = buildPdfScalePreferenceKey({ - worktreeId: 'worktree-a', - externalSshTargetId: 'ssh-c', - filePath: '/doc.pdf' - }) - - expect(new Set([localKey, runtimeKey, sshKey]).size).toBe(3) - }) - - it('round-trips a preference by file path', () => { - const storage = createMemoryStorage() - vi.stubGlobal('localStorage', storage) - - writePdfScalePreference('/repo/report.pdf', 1.75) - - expect(readPdfScalePreference('/repo/report.pdf')).toBe(1.75) - expect(readPdfScalePreference('/repo/other.pdf')).toBeNull() - }) - - it('persists fit-to-width resets and keeps files isolated', () => { - const storage = createMemoryStorage() - vi.stubGlobal('localStorage', storage) - - writePdfScalePreference('/repo/report.pdf', 2) - writePdfScalePreference('/repo/other.pdf', 'page-width') - - expect(readPdfScalePreference('/repo/report.pdf')).toBe(2) - expect(readPdfScalePreference('/repo/other.pdf')).toBe('page-width') - }) - - it('ignores malformed stored values', () => { - const storage = createMemoryStorage() - vi.stubGlobal('localStorage', storage) - storage.setItem( - PDF_SCALE_PREFERENCES_STORAGE_KEY, - JSON.stringify({ '/repo/report.pdf': { scale: 2 } }) - ) - - expect(readPdfScalePreference('/repo/report.pdf')).toBeNull() - }) - - it('evicts the oldest entries after reaching the storage bound', () => { - const storage = createMemoryStorage() - vi.stubGlobal('localStorage', storage) - - for (let index = 0; index < 101; index += 1) { - writePdfScalePreference(`/repo/report-${index}.pdf`, index) - } - - expect(readPdfScalePreference('/repo/report-0.pdf')).toBeNull() - expect(readPdfScalePreference('/repo/report-100.pdf')).toBe(100) - }) - - it('ignores storage write failures', () => { - const storage = createMemoryStorage() - storage.setItem = () => { - throw new Error('storage unavailable') - } - vi.stubGlobal('localStorage', storage) - - expect(() => writePdfScalePreference('/repo/report.pdf', 1.5)).not.toThrow() - }) -}) - -function createMemoryStorage(): Storage { - const values = new Map() - return { - get length() { - return values.size - }, - clear: () => values.clear(), - getItem: (key) => values.get(key) ?? null, - key: (index) => [...values.keys()][index] ?? null, - removeItem: (key) => values.delete(key), - setItem: (key, value) => { - values.set(key, value) - } - } -} diff --git a/src/renderer/src/components/editor/rich-markdown-search-matches-cache.test.ts b/src/renderer/src/components/editor/rich-markdown-search-matches-cache.test.ts index 8859d8c4b2e..3ee1b0961e4 100644 --- a/src/renderer/src/components/editor/rich-markdown-search-matches-cache.test.ts +++ b/src/renderer/src/components/editor/rich-markdown-search-matches-cache.test.ts @@ -51,43 +51,4 @@ describe('rich markdown search match reuse', () => { expect(find(changedDoc, 'beta')).toEqual(findRichMarkdownSearchMatches(changedDoc, 'beta')) expect(find(doc, 'beta')).not.toBe(anyCase) }) - - it('bounds retained results to two queries for one document', () => { - const find = createRichMarkdownSearchMatchesCache() - const doc = createDoc() - const first = find(doc, 'beta') - find(doc, 'Beta') - find(doc, 'betas') - expect(find(doc, 'beta')).not.toBe(first) - }) }) - -it.skipIf(process.env.ORCA_SEARCH_CACHE_BENCH !== '1')( - 'benchmarks repeated live-match checks', - () => { - for (const blockCount of [250, 1000]) { - const doc = createDoc('Beta beta betas with searchable content', blockCount) - const find = createRichMarkdownSearchMatchesCache() - const expected = findRichMarkdownSearchMatches(doc, 'beta') - expect(find(doc, 'beta')).toEqual(expected) - const measure = (run: () => unknown) => { - const samples: number[] = [] - for (let round = 0; round < 5; round++) { - const start = performance.now() - for (let index = 0; index < 100; index++) { - run() - } - samples.push((performance.now() - start) / 100) - } - return samples.sort((a, b) => a - b)[2]! - } - const beforeMs = measure(() => - findRichMarkdownSearchMatches(doc, 'beta').some((match) => match.touchesReadOnlyAtom) - ) - const afterMs = measure(() => find(doc, 'beta').some((match) => match.touchesReadOnlyAtom)) - process.stdout.write( - `${JSON.stringify({ blockCount, matchCount: expected.length, beforeMs, afterMs })}\n` - ) - } - } -) diff --git a/src/renderer/src/components/editor/rich-markdown-terminal-path-paste.test.ts b/src/renderer/src/components/editor/rich-markdown-terminal-path-paste.test.ts index faf6b14ce39..0abfc9498eb 100644 --- a/src/renderer/src/components/editor/rich-markdown-terminal-path-paste.test.ts +++ b/src/renderer/src/components/editor/rich-markdown-terminal-path-paste.test.ts @@ -2,10 +2,7 @@ import type { Editor } from '@tiptap/react' import { describe, expect, it } from 'vitest' -import { - handleRichMarkdownTerminalPathPaste, - shouldPasteTerminalWindowsPathAsPlainText -} from './rich-markdown-terminal-path-paste' +import { handleRichMarkdownTerminalPathPaste } from './rich-markdown-terminal-path-paste' type InsertTransaction = { text: string } @@ -43,31 +40,6 @@ function makeEditor(): { editor: Editor; inserted: string[] } { } describe('rich markdown terminal path paste', () => { - it('detects terminal-style HTML links that would lose a Windows path', () => { - expect( - shouldPasteTerminalWindowsPathAsPlainText({ - plainText: 'Read C:\\Users\\neil\\.claude\\CLAUDE.md before editing.', - htmlText: - 'Read C:\\Users\\neil\\.claude\\CLAUDE.md' - }) - ).toBe(true) - }) - - it('does not claim ordinary links or non-Windows paths', () => { - expect( - shouldPasteTerminalWindowsPathAsPlainText({ - plainText: 'Open CLAUDE.md at https://example.test/CLAUDE.md', - htmlText: 'CLAUDE.md' - }) - ).toBe(false) - expect( - shouldPasteTerminalWindowsPathAsPlainText({ - plainText: '/Users/neil/.claude/CLAUDE.md', - htmlText: 'CLAUDE.md' - }) - ).toBe(false) - }) - it('inserts the plain clipboard text before TipTap can preserve broken link metadata', () => { const { editor, inserted } = makeEditor() const text = 'C:\\Users\\neil\\.claude\\CLAUDE.md' diff --git a/src/renderer/src/components/feature-wall/AgentCapabilitiesSetupAction.test.ts b/src/renderer/src/components/feature-wall/AgentCapabilitiesSetupAction.test.ts deleted file mode 100644 index 4f5aa79a15c..00000000000 --- a/src/renderer/src/components/feature-wall/AgentCapabilitiesSetupAction.test.ts +++ /dev/null @@ -1,100 +0,0 @@ -import { describe, expect, it } from 'vitest' -import { - getDefaultAgentCapabilitySetupSelection, - isAgentCapabilityReadinessComplete -} from './agent-capability-setup-status' - -const READY_INPUT = { - browserUseSkillInstalled: true, - browserUseSkillLoading: false, - computerUseSkillInstalled: true, - computerUseSkillLoading: false, - computerUseReady: true, - computerUseChecking: false, - computerUseUnavailable: false, - orchestrationSkillInstalled: true, - orchestrationSkillLoading: false -} - -describe('getDefaultAgentCapabilitySetupSelection', () => { - it('leaves already-ready capabilities unchecked by default', () => { - expect(getDefaultAgentCapabilitySetupSelection(READY_INPUT)).toEqual({ - browserUse: false, - computerUse: false, - orchestration: false, - linearTickets: false - }) - }) - - it('keeps missing skills selected by default', () => { - expect( - getDefaultAgentCapabilitySetupSelection({ - ...READY_INPUT, - browserUseSkillInstalled: false, - orchestrationSkillInstalled: false - }) - ).toEqual({ - browserUse: true, - computerUse: false, - orchestration: true, - linearTickets: false - }) - }) - - it('keeps Computer Use selected when permissions still need setup', () => { - expect( - getDefaultAgentCapabilitySetupSelection({ - ...READY_INPUT, - computerUseReady: false - }) - ).toEqual({ - browserUse: false, - computerUse: true, - orchestration: false, - linearTickets: false - }) - }) - - it('leaves Computer Use unchecked when this build cannot enable it', () => { - expect( - getDefaultAgentCapabilitySetupSelection({ - ...READY_INPUT, - computerUseReady: false, - computerUseUnavailable: true - }) - ).toEqual({ - browserUse: false, - computerUse: false, - orchestration: false, - linearTickets: false - }) - }) -}) - -describe('isAgentCapabilityReadinessComplete', () => { - it('is complete when every skill is ready, or Computer Use cannot run here', () => { - expect(isAgentCapabilityReadinessComplete(READY_INPUT)).toBe(true) - expect( - isAgentCapabilityReadinessComplete({ - ...READY_INPUT, - computerUseReady: false, - computerUseUnavailable: true - }) - ).toBe(true) - }) - - it('is incomplete while Computer Use still needs macOS access or a skill is missing', () => { - expect(isAgentCapabilityReadinessComplete({ ...READY_INPUT, computerUseReady: false })).toBe( - false - ) - expect( - isAgentCapabilityReadinessComplete({ ...READY_INPUT, orchestrationSkillInstalled: false }) - ).toBe(false) - }) - - it('does not claim completion while install probes are still running', () => { - expect( - isAgentCapabilityReadinessComplete({ ...READY_INPUT, browserUseSkillLoading: true }) - ).toBe(false) - }) -}) diff --git a/src/renderer/src/components/native-chat/native-chat-find-visibility.test.ts b/src/renderer/src/components/native-chat/native-chat-find-visibility.test.ts deleted file mode 100644 index ecf5d48145a..00000000000 --- a/src/renderer/src/components/native-chat/native-chat-find-visibility.test.ts +++ /dev/null @@ -1,91 +0,0 @@ -// @vitest-environment happy-dom -import { afterEach, describe, expect, it } from 'vitest' -import { nativeChatFindGeometry, nativeChatFindScrollDelta } from './native-chat-find-visibility' - -type Box = { top: number; bottom: number; left: number; right: number } - -function placeAt(target: Element | Range, box: Box): void { - Object.defineProperty(target, 'getBoundingClientRect', { - configurable: true, - value: () => - DOMRect.fromRect({ - x: box.left, - y: box.top, - width: box.right - box.left, - height: box.bottom - box.top - }) - }) -} - -const VIEW = { top: 100, bottom: 700, left: 0, right: 800 } -const BAR = { top: 108, bottom: 144, left: 444, right: 784 } - -function transcriptWith(...boxStyles: Partial[]): { - transcript: HTMLElement - boxes: HTMLElement[] - match: Range -} { - const transcript = document.createElement('div') - placeAt(transcript, VIEW) - let parent: HTMLElement = transcript - const boxes = boxStyles.map((style) => { - const box = document.createElement('div') - Object.assign(box.style, style) - parent.append(box) - parent = box - return box - }) - const text = document.createTextNode('alpha') - parent.append(text) - document.body.append(transcript) - const match = document.createRange() - match.selectNodeContents(text) - return { transcript, boxes, match } -} - -afterEach(() => { - document.body.replaceChildren() -}) - -describe('native chat find visibility', () => { - it('counts a match in the top band as visible when the bar is not over it', () => { - const { transcript, match } = transcriptWith() - placeAt(match, { top: 112, bottom: 130, left: 20, right: 60 }) - expect(nativeChatFindGeometry(transcript).inView(match, BAR)).toBe(true) - placeAt(match, { top: 112, bottom: 130, left: 500, right: 540 }) - expect(nativeChatFindGeometry(transcript).inView(match, BAR)).toBe(false) - placeAt(match, { top: 60, bottom: 78, left: 20, right: 60 }) - expect(nativeChatFindGeometry(transcript).inView(match, BAR)).toBe(false) - }) - - it('scrolls a code line sideways to a match past its right edge', () => { - const { transcript, boxes, match } = transcriptWith({ overflowX: 'auto' }) - placeAt(boxes[0], { top: 200, bottom: 260, left: 40, right: 640 }) - placeAt(match, { top: 220, bottom: 238, left: 900, right: 940 }) - const geometry = nativeChatFindGeometry(transcript) - expect(geometry.inView(match, BAR)).toBe(false) - expect(geometry.clippedAway(match)).toBe(false) - geometry.scrollIntoBoxes(match) - expect(boxes[0].scrollLeft).toBe(580) - }) - - it('drops text a box that cannot scroll cuts off, such as a folded prompt', () => { - const { transcript, boxes, match } = transcriptWith({ overflow: 'hidden' }) - placeAt(boxes[0], { top: 200, bottom: 376, left: 40, right: 640 }) - Object.defineProperty(boxes[0], 'scrollHeight', { value: 600 }) - Object.defineProperty(boxes[0], 'clientHeight', { value: 176 }) - placeAt(match, { top: 500, bottom: 518, left: 60, right: 100 }) - expect(nativeChatFindGeometry(transcript).clippedAway(match)).toBe(true) - placeAt(match, { top: 300, bottom: 318, left: 60, right: 100 }) - expect(nativeChatFindGeometry(transcript).clippedAway(match)).toBe(false) - }) - - it('centres a revealed match below the bar only when the bar shares its column', () => { - expect( - nativeChatFindScrollDelta({ top: 900, bottom: 920, left: 500, right: 540 }, VIEW, BAR) - ).toBe(910 - (144 + 700) / 2) - expect( - nativeChatFindScrollDelta({ top: 900, bottom: 920, left: 20, right: 60 }, VIEW, BAR) - ).toBe(910 - (100 + 700) / 2) - }) -}) diff --git a/src/renderer/src/components/native-chat/native-chat-shortcut.test.ts b/src/renderer/src/components/native-chat/native-chat-shortcut.test.ts index 725a110bb6a..753783a1750 100644 --- a/src/renderer/src/components/native-chat/native-chat-shortcut.test.ts +++ b/src/renderer/src/components/native-chat/native-chat-shortcut.test.ts @@ -1,55 +1,11 @@ -import { describe, it, expect } from 'vitest' +import { it, expect } from 'vitest' + import { getEffectiveKeybindingsForDefinition as effective, getKeybindingDefinition } from '../../../../shared/keybindings' import { matchesNativeChatToggleShortcut } from './native-chat-shortcut' -type Combo = Pick - -function combo(overrides: Partial): Combo { - return { key: 'j', metaKey: false, ctrlKey: false, shiftKey: false, altKey: false, ...overrides } -} - -describe('matchesNativeChatToggleShortcut', () => { - it('matches Cmd+Shift+J on Mac', () => { - expect( - matchesNativeChatToggleShortcut(combo({ metaKey: true, shiftKey: true }), 'darwin') - ).toBe(true) - }) - - it('does not match Ctrl+Shift+J on Mac (wrong primary modifier)', () => { - expect( - matchesNativeChatToggleShortcut(combo({ ctrlKey: true, shiftKey: true }), 'darwin') - ).toBe(false) - }) - - it('matches Ctrl+Shift+J on Windows/Linux', () => { - expect(matchesNativeChatToggleShortcut(combo({ ctrlKey: true, shiftKey: true }), 'win32')).toBe( - true - ) - }) - - it('requires the shift modifier', () => { - expect(matchesNativeChatToggleShortcut(combo({ metaKey: true }), 'darwin')).toBe(false) - }) - - it('rejects when alt is held', () => { - expect( - matchesNativeChatToggleShortcut( - combo({ metaKey: true, shiftKey: true, altKey: true }), - 'darwin' - ) - ).toBe(false) - }) - - it('rejects a different key', () => { - expect( - matchesNativeChatToggleShortcut(combo({ key: 'k', metaKey: true, shiftKey: true }), 'darwin') - ).toBe(false) - }) -}) - it('bounds warm saved-alias work and invalidates on snapshot replacement; dynamic definitions bypass memo', () => { const measure = (size: number) => { let reads = 0 diff --git a/src/renderer/src/components/native-chat/native-chat-tab-agent-entry.test.ts b/src/renderer/src/components/native-chat/native-chat-tab-agent-entry.test.ts deleted file mode 100644 index 7bb39ecc4d8..00000000000 --- a/src/renderer/src/components/native-chat/native-chat-tab-agent-entry.test.ts +++ /dev/null @@ -1,94 +0,0 @@ -import { describe, it, expect } from 'vitest' -import type { AgentStatusEntry } from '../../../../shared/agent-status-types' -import { resolveNativeChatSession } from './native-chat-pane-resolution' -import { findTabAgentEntry } from './native-chat-tab-agent-entry' - -function entry( - overrides: Partial & Pick -): AgentStatusEntry { - return { - state: 'working', - prompt: '', - updatedAt: 0, - stateStartedAt: 0, - stateHistory: [], - ...overrides - } -} - -// Keep narrowed selector resolution aligned with tab-level pane lookup (#19). -describe('findTabAgentEntry (#19 selector)', () => { - it('returns the entry whose paneKey carries the tab id prefix', () => { - const target = entry({ paneKey: 'tab-1:leaf-a', agentType: 'claude' }) - const map: Record = { - 'tab-0:leaf-z': entry({ paneKey: 'tab-0:leaf-z' }), - 'tab-1:leaf-a': target, - 'tab-2:leaf-b': entry({ paneKey: 'tab-2:leaf-b' }) - } - expect(findTabAgentEntry(map, 'tab-1')).toBe(target) - }) - - it('returns undefined when no pane matches the tab id', () => { - const map: Record = { - 'tab-0:leaf-z': entry({ paneKey: 'tab-0:leaf-z' }) - } - expect(findTabAgentEntry(map, 'tab-1')).toBeUndefined() - }) - - it('returns the first matching pane (deterministic insertion order)', () => { - const first = entry({ paneKey: 'tab-1:leaf-a' }) - const second = entry({ paneKey: 'tab-1:leaf-b' }) - const map: Record = { - 'tab-1:leaf-a': first, - 'tab-1:leaf-b': second - } - expect(findTabAgentEntry(map, 'tab-1')).toBe(first) - }) - - it('does not match a tab id that is only a substring of another tab id', () => { - const map: Record = { - 'tab-10:leaf-a': entry({ paneKey: 'tab-10:leaf-a' }) - } - expect(findTabAgentEntry(map, 'tab-1')).toBeUndefined() - }) - - it('resolves identically to the whole-map scan, including the empty-tabid fallback', () => { - const paneKey = 'tab-1:11111111-1111-4111-8111-111111111111' - const target = entry({ - paneKey, - agentType: 'claude', - providerSession: { key: 'session_id', id: 'sess-abc' } - }) - const map: Record = { - 'tab-0:other': entry({ paneKey: 'tab-0:other', agentType: 'codex' }), - [paneKey]: target - } - - const oldEntry = findTabAgentEntry(map, 'tab-1') - const oldResolution = resolveNativeChatSession({ - paneKey: oldEntry?.paneKey ?? 'tab-1:', - launchAgent: 'claude', - ...(oldEntry ? { agentStatusEntry: oldEntry } : {}), - ptyId: null - }) - - const newEntry = findTabAgentEntry(map, 'tab-1') - const newResolution = resolveNativeChatSession({ - paneKey: newEntry?.paneKey ?? 'tab-1:', - launchAgent: 'claude', - ...(newEntry ? { agentStatusEntry: newEntry } : {}), - ptyId: null - }) - - expect(newEntry).toBe(oldEntry) - expect(newResolution).toEqual(oldResolution) - }) - - it('falls back to `${terminalTabId}:` paneKey when the tab has no entry', () => { - const map: Record = {} - const found = findTabAgentEntry(map, 'tab-9') - const paneKey = found?.paneKey ?? 'tab-9:' - expect(found).toBeUndefined() - expect(paneKey).toBe('tab-9:') - }) -}) diff --git a/src/renderer/src/components/native-chat/native-chat-task-list-state.test.ts b/src/renderer/src/components/native-chat/native-chat-task-list-state.test.ts index 36eedff0a90..ee91d3621bb 100644 --- a/src/renderer/src/components/native-chat/native-chat-task-list-state.test.ts +++ b/src/renderer/src/components/native-chat/native-chat-task-list-state.test.ts @@ -11,22 +11,6 @@ function call(content: string, status = 'pending'): NativeChatBlock { } describe('nativeChatTaskListState', () => { - it('projects one latest snapshot, preserves prose and leaves source messages unchanged', () => { - const first = message('first', [call('Read')]) - const last = message('last', [ - { type: 'text', text: 'Here is the result' }, - call('Read', 'completed'), - { type: 'tool-result', output: 'Updated todos' } - ]) - const result = nativeChatTaskListState([first, last]) - expect(result.list?.tasks).toEqual([{ content: 'Read', status: 'completed' }]) - expect(result.messages[0]).toBe(first) - expect(result.messages[1]).toBe(last) - expect(first.blocks).toHaveLength(1) - expect(last.blocks).toHaveLength(3) - expect(nativeChatTaskListState([first, last]).messages[1]).toBe(result.messages[1]) - }) - it('preserves latest state across user follow-ups and clears it on an explicit empty list', () => { const first = message('first', [call('Read')]) const user = { ...message('user', [{ type: 'text', text: 'Continue' }]), role: 'user' as const } @@ -54,24 +38,6 @@ describe('nativeChatTaskListState', () => { expect(result.messages.slice(1)).toEqual([malformed, failed, failedCall]) }) - it('retains task history and unrelated errors while selecting the paired snapshot', () => { - const tasks: NativeChatBlock = call('Read') - const shell: NativeChatBlock = { - type: 'tool-call', - name: 'shell', - input: {} - } - const error: NativeChatBlock = { - type: 'tool-result', - output: 'Failed', - isError: true - } - const success: NativeChatBlock = { type: 'tool-result', output: 'Updated' } - const result = nativeChatTaskListState([message('mixed', [tasks, success, shell, error])]) - expect(result.list?.tasks[0].content).toBe('Read') - expect(result.messages[0].blocks).toEqual([tasks, success, shell, error]) - }) - it('preserves accepted tasks when named orphan failures remain visibly separate', () => { const tasks = { ...call('Accepted'), callId: 'accepted' } const rejected = { ...call('Rejected', 'completed'), callId: 'rejected' } diff --git a/src/renderer/src/components/native-chat/structured-agent-session-rail-outline.test.ts b/src/renderer/src/components/native-chat/structured-agent-session-rail-outline.test.ts index 032d0ecb5ce..18deeafaf00 100644 --- a/src/renderer/src/components/native-chat/structured-agent-session-rail-outline.test.ts +++ b/src/renderer/src/components/native-chat/structured-agent-session-rail-outline.test.ts @@ -23,15 +23,6 @@ function outline( const WINDOW = { epoch: 'epoch-1', oldestLoadedSequence: 50, hasOlder: true, contextFloor: 0 } describe('structured rail outline selection', () => { - it('needs no outline when nothing older is unloaded', () => { - expect( - selectStructuredRailOutline(outline(90, [1, 60]), { ...WINDOW, hasOlder: false }) - ).toEqual({ kind: 'complete' }) - expect(selectStructuredRailOutline(null, { ...WINDOW, oldestLoadedSequence: null })).toEqual({ - kind: 'complete' - }) - }) - it('uses only the entries older than the loaded window, which is authoritative for the rest', () => { const view = selectStructuredRailOutline(outline(90, [1, 20, 49, 50, 70]), WINDOW) expect(view).toEqual({ @@ -53,10 +44,6 @@ describe('structured rail outline selection', () => { }) }) - it('is stale, and so unused, while no outline has arrived', () => { - expect(selectStructuredRailOutline(null, WINDOW)).toEqual({ kind: 'stale' }) - }) - it('is stale across an epoch change', () => { expect(selectStructuredRailOutline(outline(90, [1], 'epoch-0'), WINDOW)).toEqual({ kind: 'stale' @@ -69,24 +56,4 @@ describe('structured rail outline selection', () => { // Covers through 49: the two sources abut, nothing is missing. expect(selectStructuredRailOutline(outline(49, [1]), WINDOW).kind).toBe('fresh') }) - - it('hands the rail one entries array until the window edge moves', () => { - const value = outline(90, [1, 20, 49]) - const first = selectStructuredRailOutline(value, WINDOW) - expect(selectStructuredRailOutline(value, { ...WINDOW })).toBe(first) - const paged = selectStructuredRailOutline(value, { ...WINDOW, oldestLoadedSequence: 20 }) - expect(paged).not.toBe(first) - expect(paged).toMatchObject({ kind: 'fresh', entries: [{ id: 'user-1' }] }) - }) - - it('keeps the same entries while a trimmed live window moves its edge past no user message', () => { - const value = outline(200, [1, 20, 49, 80]) - const first = selectStructuredRailOutline(value, WINDOW) - // Each new live row head-trims the window by one; none of these edges uncovers an entry. - for (const oldestLoadedSequence of [51, 60, 80]) { - expect(selectStructuredRailOutline(value, { ...WINDOW, oldestLoadedSequence })).toBe(first) - } - const passed = selectStructuredRailOutline(value, { ...WINDOW, oldestLoadedSequence: 81 }) - expect(passed).toMatchObject({ kind: 'fresh', entries: [{}, {}, {}, { id: 'user-80' }] }) - }) }) diff --git a/src/renderer/src/components/native-chat/use-native-chat-prompt-card-presentation.test.ts b/src/renderer/src/components/native-chat/use-native-chat-prompt-card-presentation.test.ts index 95d217c3ef7..40add63cfd4 100644 --- a/src/renderer/src/components/native-chat/use-native-chat-prompt-card-presentation.test.ts +++ b/src/renderer/src/components/native-chat/use-native-chat-prompt-card-presentation.test.ts @@ -60,15 +60,6 @@ describe('dismissed prompt occurrences outlive the view but not the prompt', () expect(renderPresentation().result.current.card).toBeNull() }) - it('re-shows a transcript-only question after the view stops observing it', () => { - const first = renderPresentation() - act(() => first.result.current.collapse()) - expect(first.result.current.collapsedCard).toBe(question) - first.unmount() - - expect(renderPresentation().result.current.card).toBe(question) - }) - it('shows an identical question again once the prompt cleared', () => { const view = renderPresentation() act(() => view.result.current.dismiss()) diff --git a/src/renderer/src/components/plugins/state/use-plugin-in-use.test.ts b/src/renderer/src/components/plugins/state/use-plugin-in-use.test.ts deleted file mode 100644 index c0aa404cfbb..00000000000 --- a/src/renderer/src/components/plugins/state/use-plugin-in-use.test.ts +++ /dev/null @@ -1,99 +0,0 @@ -import { describe, expect, it } from 'vitest' -import { getDefaultSettings } from '../../../../../shared/constants' -import type { GlobalSettings } from '../../../../../shared/global-settings-types' -import type { PluginThemeRegistration } from '../../../../../shared/plugins/artifacts/plugin-theme-artifact' -import type { PluginLanguagePackRegistration } from '../../../../../shared/plugins/artifacts/plugin-language-pack-artifact' -import { pluginInUse } from './use-plugin-in-use' - -const theme = (pluginKey: string, base: 'light' | 'dark'): PluginThemeRegistration => ({ - id: `plugin:${pluginKey}/${base}`, - pluginKey, - pluginName: pluginKey, - label: base, - revision: 'r1', - base, - tokens: {} -}) -const pack: PluginLanguagePackRegistration = { - id: 'plugin:acme.xa/en-XA', - resourceLanguage: 'plugin00', - pluginKey: 'acme.xa', - locale: 'en-XA', - catalog: {}, - coverage: 100 -} -const defaults = getDefaultSettings('/tmp') -const at = (changes: Partial): GlobalSettings => ({ ...defaults, ...changes }) -const settings = at({}) -const registered: Parameters[2] = { - appThemes: [theme('acme.pair', 'light'), theme('acme.pair', 'dark'), theme('acme.night', 'dark')], - terminalThemes: [], - iconThemes: [{ id: 'plugin:acme.icons/blocks', pluginKey: 'acme.icons', label: 'Blocks' }], - languagePacks: [pack] -} - -describe('pluginInUse', () => { - it('offers Use while installed but not active', () => { - expect(pluginInUse('acme.pair', settings, registered)).toEqual({ - kind: 'available', - languagePack: null - }) - expect(pluginInUse('acme.xa', settings, registered)).toEqual({ - kind: 'available', - languagePack: pack - }) - }) - - it('is in use without a slot when a pack fills both slots', () => { - const both = at({ - pluginAppThemeLight: 'plugin:acme.pair/light', - pluginAppThemeDark: 'plugin:acme.pair/dark' - }) - expect(pluginInUse('acme.pair', both, registered)).toEqual({ kind: 'in-use', slot: null }) - }) - - it('names the one slot each pack fills when the slots mix two packs', () => { - const mixed = at({ - pluginAppThemeLight: 'plugin:acme.pair/light', - pluginAppThemeDark: 'plugin:acme.night/dark' - }) - expect(pluginInUse('acme.pair', mixed, registered)).toEqual({ kind: 'in-use', slot: 'light' }) - expect(pluginInUse('acme.night', mixed, registered)).toEqual({ kind: 'in-use', slot: 'dark' }) - // Why: the pair's terminal colours still filling both slots don't make its app theme active. - const withTerminals: Parameters[2] = { - ...registered, - terminalThemes: (['dark', 'light'] as const).map((mode) => ({ - id: `plugin:acme.pair/term-${mode}`, - pluginKey: 'acme.pair', - pluginName: 'acme.pair', - label: mode, - mode, - terminal: {} - })) - } - expect( - pluginInUse( - 'acme.pair', - { - ...mixed, - terminalThemeDark: 'plugin:acme.pair/term-dark', - terminalThemeLight: 'plugin:acme.pair/term-light', - terminalUseSeparateLightTheme: true - } satisfies GlobalSettings, - withTerminals - ) - ).toEqual({ kind: 'in-use', slot: 'light' }) - }) - - it('is in use for the active icon theme and interface language', () => { - const active = at({ pluginIconTheme: 'plugin:acme.icons/blocks', uiLanguage: pack.id }) - expect(pluginInUse('acme.icons', active, registered)).toEqual({ kind: 'in-use', slot: null }) - expect(pluginInUse('acme.xa', active, registered)).toEqual({ kind: 'in-use', slot: null }) - }) - - it('offers nothing for a language pack too incomplete to switch to', () => { - expect( - pluginInUse('acme.xa', settings, { ...registered, languagePacks: [{ ...pack, coverage: 1 }] }) - ).toBeNull() - }) -}) diff --git a/src/renderer/src/components/right-sidebar/SourceControl.remote-action-errors.test.ts b/src/renderer/src/components/right-sidebar/SourceControl.remote-action-errors.test.ts deleted file mode 100644 index d6b1d93e35a..00000000000 --- a/src/renderer/src/components/right-sidebar/SourceControl.remote-action-errors.test.ts +++ /dev/null @@ -1,98 +0,0 @@ -import { describe, expect, it } from 'vitest' -import { clearRemoteActionErrorsForCompletedConflictOperations } from './source-control/sync/remote-refresh' - -describe('SourceControl remote action error reconciliation', () => { - it('clears a rebase failure after git status observes the rebase completed', () => { - const errors = { - 'wt-1': { - kind: 'rebase' as const, - message: 'Rebase failed. Could not apply abc123', - rawError: 'Rebase failed. Could not apply abc123' - } - } - - expect( - clearRemoteActionErrorsForCompletedConflictOperations({ - remoteActionErrors: errors, - previousConflictOperations: { 'wt-1': 'rebase' }, - currentConflictOperations: { 'wt-1': 'unknown' } - }) - ).toEqual({ 'wt-1': null }) - }) - - it('keeps a rebase failure while the rebase is still in progress', () => { - const errors = { - 'wt-1': { - kind: 'rebase' as const, - message: 'Rebase failed. Could not apply abc123', - rawError: 'Rebase failed. Could not apply abc123' - } - } - - expect( - clearRemoteActionErrorsForCompletedConflictOperations({ - remoteActionErrors: errors, - previousConflictOperations: { 'wt-1': 'rebase' }, - currentConflictOperations: { 'wt-1': 'rebase' } - }) - ).toBe(errors) - }) - - it('keeps immediate rebase failures that never entered a rebase operation', () => { - const errors = { - 'wt-1': { - kind: 'rebase' as const, - message: 'Rebase blocked - commit first.', - rawError: 'Rebase blocked - commit first.' - } - } - - expect( - clearRemoteActionErrorsForCompletedConflictOperations({ - remoteActionErrors: errors, - previousConflictOperations: { 'wt-1': 'unknown' }, - currentConflictOperations: { 'wt-1': 'unknown' } - }) - ).toBe(errors) - }) - - it('clears pull and sync conflict errors after their merge operation completes', () => { - const errors = { - 'wt-pull': { - kind: 'pull' as const, - message: 'Pull stopped with merge conflicts.', - rawError: 'Pull stopped with merge conflicts.' - }, - 'wt-sync': { - kind: 'sync' as const, - message: 'Sync stopped with merge conflicts.', - rawError: 'Sync stopped with merge conflicts.' - }, - 'wt-fetch': { - kind: 'fetch' as const, - message: 'Fetch failed. network timeout', - rawError: 'Fetch failed. network timeout' - } - } - - expect( - clearRemoteActionErrorsForCompletedConflictOperations({ - remoteActionErrors: errors, - previousConflictOperations: { - 'wt-pull': 'merge', - 'wt-sync': 'merge', - 'wt-fetch': 'merge' - }, - currentConflictOperations: { - 'wt-pull': 'unknown', - 'wt-sync': 'unknown', - 'wt-fetch': 'unknown' - } - }) - ).toEqual({ - 'wt-pull': null, - 'wt-sync': null, - 'wt-fetch': errors['wt-fetch'] - }) - }) -}) diff --git a/src/renderer/src/components/right-sidebar/checks-panel-async-result-key.test.ts b/src/renderer/src/components/right-sidebar/checks-panel-async-result-key.test.ts deleted file mode 100644 index a011344e609..00000000000 --- a/src/renderer/src/components/right-sidebar/checks-panel-async-result-key.test.ts +++ /dev/null @@ -1,90 +0,0 @@ -import { describe, expect, it } from 'vitest' -import { - checksPanelAsyncResultKey, - checksPanelHostedReviewAsyncResultKey, - shouldCommitChecksPanelAsyncResult -} from './checks-panel-async-result-key' - -describe('checksPanelAsyncResultKey', () => { - it('builds a stable repo-scoped key', () => { - expect(checksPanelAsyncResultKey('repo-id', 'feature/test', 12)).toBe( - 'repo-id::feature/test::none::12::none' - ) - }) - - it('uses explicit none marker when PR is absent', () => { - expect(checksPanelAsyncResultKey('repo-id', 'feature/test', null)).toBe( - 'repo-id::feature/test::none::none::none' - ) - }) - - it('normalizes PR repo identity', () => { - expect( - checksPanelAsyncResultKey('repo-id', 'feature/test', 12, { - owner: 'Acme', - repo: 'Widgets' - }) - ).toBe('repo-id::feature/test::acme/widgets::12::none') - }) - - it('includes non-default GitHub hosts in PR repo identity', () => { - const githubDotComKey = checksPanelAsyncResultKey('repo-id', 'feature/test', 12, { - owner: 'Acme', - repo: 'Widgets', - host: 'github.com' - }) - const enterpriseKey = checksPanelAsyncResultKey('repo-id', 'feature/test', 12, { - owner: 'Acme', - repo: 'Widgets', - host: 'github.acme-corp.com' - }) - - expect(githubDotComKey).toBe('repo-id::feature/test::acme/widgets::12::none') - expect(enterpriseKey).toBe('repo-id::feature/test::github.acme-corp.com/acme/widgets::12::none') - expect(enterpriseKey).not.toBe(githubDotComKey) - }) - - it('includes PR head SHA so stale checks cannot commit after a new head is discovered', () => { - expect(checksPanelAsyncResultKey('repo-id', 'feature/test', 12, null, 'head-a')).toBe( - 'repo-id::feature/test::none::12::head-a' - ) - }) - - it('includes hosted-review provider identity for non-GitHub review results', () => { - expect( - checksPanelHostedReviewAsyncResultKey( - 'local::repo-id::feature/test', - 'feature/test', - 'gitlab', - 12, - 'head-a' - ) - ).toBe('local::repo-id::feature/test::feature/test::gitlab::12::head-a') - }) -}) - -describe('shouldCommitChecksPanelAsyncResult', () => { - it('suppresses stale async completions', () => { - expect( - shouldCommitChecksPanelAsyncResult( - checksPanelAsyncResultKey('repo-id', 'feature/new', 99), - checksPanelAsyncResultKey('repo-id', 'feature/old', 12) - ) - ).toBe(false) - }) - - it('suppresses stale completions when the PR repo changes without a PR number change', () => { - expect( - shouldCommitChecksPanelAsyncResult( - checksPanelAsyncResultKey('repo-id', 'feature/test', 12, { - owner: 'upstream', - repo: 'orca' - }), - checksPanelAsyncResultKey('repo-id', 'feature/test', 12, { - owner: 'fork', - repo: 'orca' - }) - ) - ).toBe(false) - }) -}) diff --git a/src/renderer/src/components/right-sidebar/file-explorer-row-projection.test.ts b/src/renderer/src/components/right-sidebar/file-explorer-row-projection.test.ts deleted file mode 100644 index 942845946f4..00000000000 --- a/src/renderer/src/components/right-sidebar/file-explorer-row-projection.test.ts +++ /dev/null @@ -1,101 +0,0 @@ -import { describe, expect, it } from 'vitest' -import type { TreeNode } from './file-explorer-types' -import { createFileExplorerRowProjection } from './file-explorer-row-projection' - -function row(path: string, depth: number, isDirectory = false): TreeNode { - return { - name: path.split(/[\\/]/).at(-1) ?? path, - path, - relativePath: path.replace('/repo/', ''), - isDirectory, - depth - } -} - -describe('file explorer row projection', () => { - it('indexes visible rows by path and preserves tree order for selected paths', () => { - const rows = [ - row('/repo/src', 0, true), - row('/repo/src/a.ts', 1), - row('/repo/src/nested', 1, true), - row('/repo/src/nested/b.ts', 2), - row('/repo/root.ts', 0) - ] - const projection = createFileExplorerRowProjection(rows) - - expect(projection.getVisibleCount()).toBe(5) - expect(projection.getVisibleSlice(1, 2).map((entry) => entry.path)).toEqual([ - '/repo/src/a.ts', - '/repo/src/nested' - ]) - expect(projection.getRowAtIndex(2)?.path).toBe('/repo/src/nested') - expect(projection.getRowByPath('/repo/src/a.ts')?.name).toBe('a.ts') - expect(projection.getIndexByPath('/repo/src/nested/b.ts')).toBe(3) - expect(projection.getIndexByPath('/repo/missing.ts')).toBeNull() - expect( - projection - .getRowsByPaths(new Set(['/repo/root.ts', '/repo/src/a.ts'])) - .map((entry) => entry.path) - ).toEqual(['/repo/src/a.ts', '/repo/root.ts']) - }) - - it('finds inline create positions from visible subtree boundaries', () => { - const rows = [ - row('/repo/src', 0, true), - row('/repo/src/a.ts', 1), - row('/repo/src/nested', 1, true), - row('/repo/src/nested/b.ts', 2), - row('/repo/root.ts', 0) - ] - const projection = createFileExplorerRowProjection(rows) - - expect(projection.getInsertIndexAfterSubtree('/repo', '/repo')).toBe(5) - expect(projection.getInsertIndexAfterSubtree('/repo/src', '/repo')).toBe(4) - expect(projection.getInsertIndexAfterSubtree('/repo/src/nested', '/repo')).toBe(4) - expect(projection.getInsertIndexAfterSubtree('/repo/missing', '/repo')).toBe(0) - }) - - it('places inline create after collapsed directory rows', () => { - const projection = createFileExplorerRowProjection([ - row('/repo/src', 0, true), - row('/repo/root.ts', 0) - ]) - - expect(projection.getInsertIndexAfterSubtree('/repo/src', '/repo')).toBe(1) - }) - - it('walks backward to find the immediate parent row in the visible list', () => { - const projection = createFileExplorerRowProjection([ - row('/repo/src', 0, true), - row('/repo/src/nested', 1, true), - row('/repo/src/nested/deep', 2, true), - row('/repo/src/nested/deep/x.ts', 3), - row('/repo/root.ts', 0) - ]) - - expect(projection.getParentIndex(3)).toBe(2) - expect(projection.getParentIndex(2)).toBe(1) - expect(projection.getParentIndex(1)).toBe(0) - // Root directories are not rows, so their children have no visible parent. - expect(projection.getParentIndex(0)).toBeNull() - expect(projection.getParentIndex(4)).toBeNull() - expect(projection.getParentIndex(99)).toBeNull() - }) - - it('finds the first child row only when the folder is expanded', () => { - const projection = createFileExplorerRowProjection([ - row('/repo/src', 0, true), - row('/repo/src/a.ts', 1), - row('/repo/src/nested', 1, true), - row('/repo/src/nested/b.ts', 2), - row('/repo/root.ts', 0) - ]) - - expect(projection.getFirstChildIndex(0)).toBe(1) - expect(projection.getFirstChildIndex(2)).toBe(3) - // Files and collapsed folders expose no visible child. - expect(projection.getFirstChildIndex(1)).toBeNull() - expect(projection.getFirstChildIndex(4)).toBeNull() - expect(projection.getFirstChildIndex(99)).toBeNull() - }) -}) diff --git a/src/renderer/src/components/right-sidebar/file-explorer-selection.test.ts b/src/renderer/src/components/right-sidebar/file-explorer-selection.test.ts deleted file mode 100644 index 2601b077e13..00000000000 --- a/src/renderer/src/components/right-sidebar/file-explorer-selection.test.ts +++ /dev/null @@ -1,100 +0,0 @@ -import { describe, expect, it } from 'vitest' -import type { TreeNode } from './file-explorer-types' -import { - createSingleFileExplorerSelection, - formatFileExplorerPathsForClipboard, - getFileExplorerSelectionMode, - updateFileExplorerSelection, - updateFileExplorerSelectionPaths -} from './file-explorer-selection' - -function node(path: string, relativePath = path): TreeNode { - return { - name: path.split(/[\\/]/).at(-1) ?? path, - path, - relativePath, - isDirectory: false, - depth: 0 - } -} - -describe('file explorer selection', () => { - it('uses Ctrl for multi-selection on Windows and Linux', () => { - expect( - getFileExplorerSelectionMode({ ctrlKey: true, metaKey: false, shiftKey: false }, false) - ).toBe('toggle') - expect( - getFileExplorerSelectionMode({ ctrlKey: true, metaKey: false, shiftKey: true }, false) - ).toBe('additive-range') - }) - - it('uses Command for multi-selection on macOS', () => { - expect( - getFileExplorerSelectionMode({ ctrlKey: true, metaKey: false, shiftKey: false }, true) - ).toBe('replace') - expect( - getFileExplorerSelectionMode({ ctrlKey: false, metaKey: true, shiftKey: false }, true) - ).toBe('toggle') - }) - - it('selects a contiguous visible range from the anchor with Shift', () => { - const current = createSingleFileExplorerSelection('/repo/a.ts') - const next = updateFileExplorerSelection( - current, - ['/repo/a.ts', '/repo/b.ts', '/repo/c.ts'], - '/repo/c.ts', - 'range' - ) - - expect(Array.from(next.selectedPaths)).toEqual(['/repo/a.ts', '/repo/b.ts', '/repo/c.ts']) - expect(next.anchorPath).toBe('/repo/a.ts') - expect(next.activePath).toBe('/repo/c.ts') - }) - - it('toggles a selected path without losing the remaining visible selection', () => { - const current = updateFileExplorerSelection( - createSingleFileExplorerSelection('/repo/a.ts'), - ['/repo/a.ts', '/repo/b.ts', '/repo/c.ts'], - '/repo/c.ts', - 'range' - ) - const next = updateFileExplorerSelection( - current, - ['/repo/a.ts', '/repo/b.ts', '/repo/c.ts'], - '/repo/b.ts', - 'toggle' - ) - - expect(Array.from(next.selectedPaths)).toEqual(['/repo/a.ts', '/repo/c.ts']) - expect(next.activePath).toBe('/repo/a.ts') - }) - - it('formats copied nodes in the provided order', () => { - const rows = [ - node('/repo/b.ts', 'b.ts'), - node('/repo/a.ts', 'a.ts'), - node('/repo/c.ts', 'c.ts') - ] - - expect(formatFileExplorerPathsForClipboard(rows, 'absolute', 'local')).toBe( - '/repo/b.ts\n/repo/a.ts\n/repo/c.ts' - ) - expect(formatFileExplorerPathsForClipboard(rows, 'relative', 'local')).toBe('b.ts\na.ts\nc.ts') - }) - - it('applies legacy path cleanup across the selected set', () => { - const current = updateFileExplorerSelection( - createSingleFileExplorerSelection('/repo/a.ts'), - ['/repo/a.ts', '/repo/b.ts', '/repo/c.ts'], - '/repo/c.ts', - 'range' - ) - const next = updateFileExplorerSelectionPaths(current, (path) => - path === '/repo/b.ts' ? null : path - ) - - expect(Array.from(next.selectedPaths)).toEqual(['/repo/a.ts', '/repo/c.ts']) - expect(next.activePath).toBe('/repo/c.ts') - expect(next.anchorPath).toBe('/repo/a.ts') - }) -}) diff --git a/src/renderer/src/components/sidebar/worktree-header-section-boundaries.test.ts b/src/renderer/src/components/sidebar/worktree-header-section-boundaries.test.ts index 060b918a2c9..0d0c51f5e6e 100644 --- a/src/renderer/src/components/sidebar/worktree-header-section-boundaries.test.ts +++ b/src/renderer/src/components/sidebar/worktree-header-section-boundaries.test.ts @@ -46,17 +46,6 @@ describe('getRepoHeaderSectionEndByRepoId', () => { expect(ends.get('b')).toBe(startOfC) }) - it('falls back to the next header when a bucket has no successor', () => { - const ends = getRepoHeaderSectionEndByRepoId({ - rows, - firstHeaderIndex: 0, - sidebarRepoHeaderIdsByBucket: new Map([['ungrouped', ['a']]]), - repoHeaderBucketByRepoId: new Map([['a', 'ungrouped']]) - }) - - expect(ends.get('a')).toBe(startOfB) - }) - it('resolves a header id that renders twice to its first row, matching findIndex', () => { const ends = getRepoHeaderSectionEndByRepoId({ rows: [repoHeader('a'), item, repoHeader('b'), item, repoHeader('b')], diff --git a/src/renderer/src/components/sidebar/worktree-list-groups-host-collision.test.ts b/src/renderer/src/components/sidebar/worktree-list-groups-host-collision.test.ts index 8fca8d80337..0e3692e2bba 100644 --- a/src/renderer/src/components/sidebar/worktree-list-groups-host-collision.test.ts +++ b/src/renderer/src/components/sidebar/worktree-list-groups-host-collision.test.ts @@ -2,7 +2,7 @@ import { describe, expect, it } from 'vitest' import { buildRows } from './worktree-list/grouping/build-rows.test-fixture' import { repo, worktree } from './worktree-list-groups-test-fixtures' -import { getExecutionHostLabel } from '../../../../shared/execution-host' + import type { Repo } from '../../../../shared/repo-types' import type { Worktree } from '../../../../shared/worktree/types' @@ -62,20 +62,6 @@ describe('sidebar rows for a workspace id owned by two hosts', () => { expect(new Set(rowKeys).size).toBe(rowKeys.length) }) - it('labels each row with the host it lives on', () => { - const labels = buildCollidingRows() - .filter((row) => row.type === 'item') - .map((row) => row.hostContextLabel) - - expect(labels).toEqual([getExecutionHostLabel('local'), getExecutionHostLabel('ssh:build-box')]) - }) - - it('counts the two hosts separately in the group header', () => { - const header = buildCollidingRows().find((row) => row.type === 'header') - - expect(header?.count).toBe(2) - }) - it('keeps an unpinned host row visible when its same-id peer is pinned', () => { const itemRows = buildCollidingRows([{ ...localWorktree, isPinned: true }, sshWorktree]).filter( (row) => row.type === 'item' diff --git a/src/renderer/src/components/sidebar/worktree-list/viewport/use-row-removal-animation.test.ts b/src/renderer/src/components/sidebar/worktree-list/viewport/use-row-removal-animation.test.ts deleted file mode 100644 index 23980e38d39..00000000000 --- a/src/renderer/src/components/sidebar/worktree-list/viewport/use-row-removal-animation.test.ts +++ /dev/null @@ -1,99 +0,0 @@ -import { describe, expect, it } from 'vitest' -import { - buildVirtualRowRemovalMotions, - type VirtualRowLayoutSnapshot -} from './use-row-removal-animation' - -function snapshot(args: { - identities: string[] - scrollTop: number - starts: [string, number][] -}): VirtualRowLayoutSnapshot { - return { - rowIdentityKeys: new Set(args.identities), - scrollTop: args.scrollTop, - startsByKey: new Map(args.starts) - } -} - -describe('buildVirtualRowRemovalMotions', () => { - it('moves surviving rows from their pre-delete viewport positions', () => { - const motions = buildVirtualRowRemovalMotions({ - previous: snapshot({ - identities: ['wt:a', 'wt:b', 'wt:c'], - scrollTop: 100, - starts: [ - ['wt:a', 100], - ['wt:b', 220], - ['wt:c', 340] - ] - }), - current: snapshot({ - identities: ['wt:a', 'wt:c'], - scrollTop: 100, - starts: [ - ['wt:a', 100], - ['wt:c', 220] - ] - }), - rekeyedRowKeys: new Map() - }) - - expect(motions).toEqual([{ key: 'wt:c', deltaY: 120 }]) - }) - - it('does not double-move rows when anchor restoration offsets a deletion above the viewport', () => { - const motions = buildVirtualRowRemovalMotions({ - previous: snapshot({ - identities: ['wt:deleted', 'wt:a'], - scrollTop: 240, - starts: [['wt:a', 240]] - }), - current: snapshot({ - identities: ['wt:a'], - scrollTop: 120, - starts: [['wt:a', 120]] - }), - rekeyedRowKeys: new Map() - }) - - expect(motions).toEqual([]) - }) - - it('follows a surviving row through a lineage rekey', () => { - const motions = buildVirtualRowRemovalMotions({ - previous: snapshot({ - identities: ['wt:parent', 'wt:child'], - scrollTop: 0, - starts: [['lineage-group:parent', 100]] - }), - current: snapshot({ - identities: ['wt:parent'], - scrollTop: 0, - starts: [['wt:parent', 100]] - }), - rekeyedRowKeys: new Map([['lineage-group:parent', 'wt:parent']]) - }) - - expect(motions).toEqual([]) - }) - - it('ignores additions and measurement-only movement', () => { - const previous = snapshot({ - identities: ['wt:a'], - scrollTop: 0, - starts: [['wt:a', 100]] - }) - expect( - buildVirtualRowRemovalMotions({ - previous, - current: snapshot({ - identities: ['wt:a', 'wt:b'], - scrollTop: 0, - starts: [['wt:a', 140]] - }), - rekeyedRowKeys: new Map() - }) - ).toEqual([]) - }) -}) diff --git a/src/renderer/src/components/terminal-pane/terminal-clipboard-event-paste.test.ts b/src/renderer/src/components/terminal-pane/terminal-clipboard-event-paste.test.ts deleted file mode 100644 index 40a36e02c41..00000000000 --- a/src/renderer/src/components/terminal-pane/terminal-clipboard-event-paste.test.ts +++ /dev/null @@ -1,98 +0,0 @@ -import { describe, expect, it } from 'vitest' -import { - firesNativePasteEvent, - getClipboardEventText, - shouldUseClipboardEventPaste -} from './terminal-clipboard-event-paste' - -type KeyEventFields = Pick< - KeyboardEvent, - 'key' | 'code' | 'metaKey' | 'ctrlKey' | 'altKey' | 'shiftKey' -> - -function makeKeyEvent(overrides: Partial): KeyEventFields { - return { - key: '', - code: '', - metaKey: false, - ctrlKey: false, - altKey: false, - shiftKey: false, - ...overrides - } -} - -function makeClipboardEvent(text: string | null): ClipboardEvent { - return { - clipboardData: - text === null - ? null - : { - getData: (type: string) => (type === 'text/plain' ? text : '') - } - } as unknown as ClipboardEvent -} - -describe('shouldUseClipboardEventPaste', () => { - it('requires the fallback for web clients without navigator.clipboard.readText', () => { - expect( - shouldUseClipboardEventPaste({ isWebClient: true, clipboardReadTextAvailable: false }) - ).toBe(true) - }) - - it('keeps async clipboard reads for secure-context web clients', () => { - expect( - shouldUseClipboardEventPaste({ isWebClient: true, clipboardReadTextAvailable: true }) - ).toBe(false) - }) - - it('never applies to the Electron renderer, which reads the clipboard over IPC', () => { - expect( - shouldUseClipboardEventPaste({ isWebClient: false, clipboardReadTextAvailable: false }) - ).toBe(false) - expect( - shouldUseClipboardEventPaste({ isWebClient: false, clipboardReadTextAvailable: true }) - ).toBe(false) - }) -}) - -describe('getClipboardEventText', () => { - it('reads text/plain from the event clipboardData', () => { - expect(getClipboardEventText(makeClipboardEvent('echo hi'))).toBe('echo hi') - }) - - it('returns empty text when clipboardData is missing', () => { - expect(getClipboardEventText(makeClipboardEvent(null))).toBe('') - }) -}) - -describe('firesNativePasteEvent', () => { - it('recognizes the default native paste chords on macOS', () => { - expect(firesNativePasteEvent(makeKeyEvent({ key: 'v', metaKey: true }), true)).toBe(true) - }) - - it('recognizes the default native paste chords on Windows/Linux', () => { - expect(firesNativePasteEvent(makeKeyEvent({ key: 'v', ctrlKey: true }), false)).toBe(true) - // Ctrl+Shift+V is the default terminal paste and still dispatches a native event. - expect( - firesNativePasteEvent(makeKeyEvent({ key: 'v', ctrlKey: true, shiftKey: true }), false) - ).toBe(true) - expect(firesNativePasteEvent(makeKeyEvent({ key: 'Insert', shiftKey: true }), false)).toBe(true) - }) - - it('recognizes Ctrl+V on a non-Latin layout by its physical key', () => { - expect( - firesNativePasteEvent(makeKeyEvent({ key: 'м', code: 'KeyV', ctrlKey: true }), false) - ).toBe(true) - }) - - it('does not treat a remapped non-clipboard chord as a native paste event', () => { - // Remapped paste chords fire no native event and must stay consumed to avoid raw control characters. - expect(firesNativePasteEvent(makeKeyEvent({ key: 'y', ctrlKey: true }), false)).toBe(false) - expect(firesNativePasteEvent(makeKeyEvent({ key: 'd', ctrlKey: true }), false)).toBe(false) - // Cmd+V does not fire a native paste event on Windows/Linux. - expect(firesNativePasteEvent(makeKeyEvent({ key: 'v', metaKey: true }), false)).toBe(false) - // Ctrl+V does not fire a native paste event on macOS (readline quote-insert). - expect(firesNativePasteEvent(makeKeyEvent({ key: 'v', ctrlKey: true }), true)).toBe(false) - }) -}) diff --git a/src/renderer/src/components/terminal-pane/terminal-link-pointer-gesture.test.ts b/src/renderer/src/components/terminal-pane/terminal-link-pointer-gesture.test.ts index a98486fc2ad..2499e414dce 100644 --- a/src/renderer/src/components/terminal-pane/terminal-link-pointer-gesture.test.ts +++ b/src/renderer/src/components/terminal-pane/terminal-link-pointer-gesture.test.ts @@ -42,15 +42,6 @@ afterEach(() => { }) describe('terminal link pointer gesture', () => { - it('allows a stationary plain click', () => { - vi.stubGlobal('navigator', { userAgent: 'Macintosh' }) - const { element, gesture } = createGesture() - const down = mouse('mousedown', 20, 30) - element.dispatchEvent(down) - - expect(gesture.canRequestAction(down)).toBe(true) - }) - it('rejects a drag and a click that began with a selection', () => { vi.stubGlobal('navigator', { userAgent: 'Macintosh' }) const dragged = createGesture() diff --git a/src/renderer/src/components/terminal/active-terminal-repair.test.ts b/src/renderer/src/components/terminal/active-terminal-repair.test.ts deleted file mode 100644 index e6f642c128b..00000000000 --- a/src/renderer/src/components/terminal/active-terminal-repair.test.ts +++ /dev/null @@ -1,99 +0,0 @@ -import { describe, expect, it } from 'vitest' -import type { TerminalTab } from '../../../../shared/terminal-tab-types' -import { - resolveRepairedActiveTerminalTabId, - shouldRepairActiveTerminalTab -} from './active-terminal-repair' - -function tab(id: string): TerminalTab { - return { - id, - ptyId: null, - worktreeId: 'wt-1', - title: id, - customTitle: null, - color: null, - sortOrder: 0, - createdAt: 0 - } -} - -describe('shouldRepairActiveTerminalTab', () => { - it('does not repair while editor or browser content is active', () => { - expect( - shouldRepairActiveTerminalTab({ - activeTabType: 'editor', - activeTabId: 'missing', - tabs: [tab('cli-terminal')] - }) - ).toBe(false) - expect( - shouldRepairActiveTerminalTab({ - activeTabType: 'browser', - activeTabId: null, - tabs: [tab('cli-terminal')] - }) - ).toBe(false) - }) - - it('repairs stale terminal active ids only while terminal content is active', () => { - expect( - shouldRepairActiveTerminalTab({ - activeTabType: 'terminal', - activeTabId: 'missing', - tabs: [tab('terminal-1')] - }) - ).toBe(true) - expect( - shouldRepairActiveTerminalTab({ - activeTabType: 'terminal', - activeTabId: 'terminal-1', - tabs: [tab('terminal-1')] - }) - ).toBe(false) - }) -}) - -describe('resolveRepairedActiveTerminalTabId', () => { - it('returns null when no repair is needed', () => { - expect( - resolveRepairedActiveTerminalTabId({ - activeTabType: 'terminal', - activeTabId: 'terminal-2', - rememberedTabId: 'terminal-1', - tabs: [tab('terminal-1'), tab('terminal-2')] - }) - ).toBeNull() - }) - - it('restores the remembered tab instead of the first tab when repairing', () => { - // Transient workspace switches must preserve remembered selection instead of resetting to Terminal 1. - expect( - resolveRepairedActiveTerminalTabId({ - activeTabType: 'terminal', - activeTabId: 'stale-from-other-worktree', - rememberedTabId: 'terminal-2', - tabs: [tab('terminal-1'), tab('terminal-2')] - }) - ).toBe('terminal-2') - }) - - it('falls back to the first tab when the remembered tab is missing or stale', () => { - expect( - resolveRepairedActiveTerminalTabId({ - activeTabType: 'terminal', - activeTabId: 'missing', - rememberedTabId: null, - tabs: [tab('terminal-1'), tab('terminal-2')] - }) - ).toBe('terminal-1') - expect( - resolveRepairedActiveTerminalTabId({ - activeTabType: 'terminal', - activeTabId: 'missing', - rememberedTabId: 'no-longer-open', - tabs: [tab('terminal-1'), tab('terminal-2')] - }) - ).toBe('terminal-1') - }) -}) diff --git a/src/renderer/src/components/terminal/split-group-mount.test.ts b/src/renderer/src/components/terminal/split-group-mount.test.ts deleted file mode 100644 index 36e80999273..00000000000 --- a/src/renderer/src/components/terminal/split-group-mount.test.ts +++ /dev/null @@ -1,99 +0,0 @@ -import { describe, expect, it } from 'vitest' -import { getEffectiveLayoutForWorktree, anyMountedWorktreeHasLayout } from './split-group-mount' -import type { TabGroup, TabGroupLayoutNode } from '../../../../shared/tab-types' - -function makeGroup(id: string, worktreeId: string): TabGroup { - return { id, worktreeId, activeTabId: null, tabOrder: [] } -} - -describe('getEffectiveLayoutForWorktree', () => { - it('returns the explicit layout when one exists', () => { - const layout: TabGroupLayoutNode = { type: 'leaf', groupId: 'g1' } - const result = getEffectiveLayoutForWorktree('wt-1', { 'wt-1': layout }, {}, {}) - expect(result).toBe(layout) - }) - - it('falls back to a synthetic leaf from the active group', () => { - const result = getEffectiveLayoutForWorktree( - 'wt-1', - {}, - { 'wt-1': [makeGroup('g1', 'wt-1'), makeGroup('g2', 'wt-1')] }, - { 'wt-1': 'g2' } - ) - expect(result).toEqual({ type: 'leaf', groupId: 'g2' }) - }) - - it('falls back to the first group when no active group is set', () => { - const result = getEffectiveLayoutForWorktree( - 'wt-1', - {}, - { 'wt-1': [makeGroup('g1', 'wt-1')] }, - {} - ) - expect(result).toEqual({ type: 'leaf', groupId: 'g1' }) - }) - - it('returns undefined when the worktree has no layout and no groups', () => { - const result = getEffectiveLayoutForWorktree('wt-1', {}, {}, {}) - expect(result).toBeUndefined() - }) -}) - -describe('anyMountedWorktreeHasLayout', () => { - const layout: TabGroupLayoutNode = { type: 'leaf', groupId: 'g1' } - - it('returns true when the active worktree has a layout', () => { - const result = anyMountedWorktreeHasLayout( - ['wt-1'], - new Set(['wt-1']), - { 'wt-1': layout }, - {}, - {} - ) - expect(result).toBe(true) - }) - - it('returns true when only a non-active mounted worktree has a layout (the bug fix)', () => { - const result = anyMountedWorktreeHasLayout( - ['wt-1', 'wt-2'], - new Set(['wt-1', 'wt-2']), - { 'wt-1': layout }, - {}, - {} - ) - expect(result).toBe(true) - }) - - it('returns false when no mounted worktree has a layout', () => { - const result = anyMountedWorktreeHasLayout( - ['wt-1', 'wt-2'], - new Set(['wt-1', 'wt-2']), - {}, - {}, - {} - ) - expect(result).toBe(false) - }) - - it('ignores worktrees that exist but are not mounted', () => { - const result = anyMountedWorktreeHasLayout( - ['wt-1', 'wt-2'], - new Set(['wt-2']), - { 'wt-1': layout }, - {}, - {} - ) - expect(result).toBe(false) - }) - - it('considers fallback groups when no explicit layout exists', () => { - const result = anyMountedWorktreeHasLayout( - ['wt-1'], - new Set(['wt-1']), - {}, - { 'wt-1': [makeGroup('g1', 'wt-1')] }, - {} - ) - expect(result).toBe(true) - }) -}) diff --git a/src/renderer/src/hooks/useComposerState-decisions.test.ts b/src/renderer/src/hooks/useComposerState-decisions.test.ts deleted file mode 100644 index 862a1ff7589..00000000000 --- a/src/renderer/src/hooks/useComposerState-decisions.test.ts +++ /dev/null @@ -1,94 +0,0 @@ -import { describe, expect, it } from 'vitest' -import { - getInitialGitHubPrStartPointSelection, - getMatchingLinkedTaskSourceContext, - resolveInitialWorkspaceRunSeed, - resolveSmartGitHubCreateNames -} from './composer-state/composer-decisions' - -describe('useComposerState public decisions', () => { - it('preserves a user name for PR start points only when the fallback is non-empty', () => { - expect( - resolveSmartGitHubCreateNames({ - resolutionKind: 'pr-start-point', - smartWorkspaceName: 'smart-name', - smartDisplayName: 'Smart name', - fallbackWorkspaceName: 'user-name', - nameIsAutoManaged: false - }) - ).toEqual({ workspaceName: 'user-name', displayName: undefined }) - expect( - resolveSmartGitHubCreateNames({ - resolutionKind: 'pr-start-point', - smartWorkspaceName: 'smart-name', - smartDisplayName: 'Smart name', - fallbackWorkspaceName: '', - nameIsAutoManaged: false - }) - ).toEqual({ workspaceName: 'smart-name', displayName: 'Smart name' }) - }) - - it('accepts a nullable repo seed without manufacturing a PR start point', () => { - expect( - getInitialGitHubPrStartPointSelection({ - item: { - id: 'pr-42', - type: 'pr', - number: 42, - title: 'Fix it', - state: 'open', - url: 'https://github.com/orca/orca/pull/42', - labels: [], - updatedAt: '2026-08-23T00:00:00.000Z', - author: 'octocat', - repoId: 'repo-1' - }, - linkedWorkItem: { - provider: 'github', - type: 'pr', - number: 42, - title: 'Fix it', - url: 'https://github.com/orca/orca/pull/42' - }, - repoId: null - }) - ).toBeNull() - }) - - it('preserves host-qualified task context while draft host values take precedence', () => { - expect( - resolveInitialWorkspaceRunSeed({ - draftProjectId: 'draft-project', - draftHostId: 'ssh:draft', - draftProjectHostSetupId: 'draft-setup', - initialTaskSourceContext: { - projectId: 'task-project', - hostId: 'ssh:task', - projectHostSetupId: 'task-setup' - } - }) - ).toEqual({ - projectId: 'draft-project', - hostId: 'ssh:draft', - projectHostSetupId: 'draft-setup' - }) - }) - - it('drops a task source context whose provider identity no longer matches the linked item', () => { - const linkedItem = { - provider: 'github' as const, - type: 'issue' as const, - number: 42, - title: 'Fix it', - url: 'https://github.com/orca/orca/issues/42' - } - const context = { - kind: 'task-source' as const, - provider: 'jira' as const, - projectId: 'project-1', - hostId: 'local' as const, - providerIdentity: null - } - expect(getMatchingLinkedTaskSourceContext(linkedItem, context)).toBeNull() - }) -}) diff --git a/src/renderer/src/hooks/useIpcEvents-cmd-j-digit-chord.test.ts b/src/renderer/src/hooks/useIpcEvents-cmd-j-digit-chord.test.ts index 6bb62cdee9a..0306377ad01 100644 --- a/src/renderer/src/hooks/useIpcEvents-cmd-j-digit-chord.test.ts +++ b/src/renderer/src/hooks/useIpcEvents-cmd-j-digit-chord.test.ts @@ -84,16 +84,4 @@ describe('useIpcEvents digit-chord routing while Cmd+J is open', () => { expect(storeState.setActiveTab).not.toHaveBeenCalled() }) - - it('stops delivering row jumps after unsubscribe', async () => { - const { emitCmdJRowIndexJump, subscribeCmdJRowIndexJump } = await loadRowJumpBus() - const seen: number[] = [] - const unsubscribe = subscribeCmdJRowIndexJump((index) => seen.push(index)) - - emitCmdJRowIndexJump(0) - unsubscribe() - emitCmdJRowIndexJump(1) - - expect(seen).toEqual([0]) - }) }) diff --git a/src/renderer/src/runtime/web-session-close-intent.test.ts b/src/renderer/src/runtime/web-session-close-intent.test.ts index 759deb916fe..904ab10bef1 100644 --- a/src/renderer/src/runtime/web-session-close-intent.test.ts +++ b/src/renderer/src/runtime/web-session-close-intent.test.ts @@ -6,10 +6,8 @@ import { isWebSessionCloseIntentPending, reconcileWebSessionCloseIntents, recordWebSessionCloseIntent, - resetWebSessionCloseIntentForTests, - WEB_SESSION_CLOSE_INTENT_TTL_MS + resetWebSessionCloseIntentForTests } from './web-session-close-intent' -import { WEB_SESSION_TAB_RPC_TIMEOUT_MS } from './web-session-tab-rpc-timeout' const WT = 'repo::/wt' const OWNER = { environmentId: 'runtime-a', pairingRevision: 1 } @@ -26,23 +24,6 @@ describe('web session close intent', () => { expect(isWebSessionCloseIntentPending(OWNER, WT, 'host-tab-1', 1000)).toBe(false) }) - it('expires a never-confirmed close', () => { - recordWebSessionCloseIntent(OWNER, WT, 'host-tab-1', 1000) - expect( - isWebSessionCloseIntentPending( - OWNER, - WT, - 'host-tab-1', - 1000 + WEB_SESSION_CLOSE_INTENT_TTL_MS + 1 - ) - ).toBe(false) - }) - - // TTL must derive from RPC timeout: tab_not_found cannot make an intent durable after snapshot queries evict it. - it('outlives the tab RPC that can still answer tab_not_found', () => { - expect(WEB_SESSION_CLOSE_INTENT_TTL_MS).toBeGreaterThan(WEB_SESSION_TAB_RPC_TIMEOUT_MS) - }) - it('scopes intents by owner, pairing revision, and worktree', () => { recordWebSessionCloseIntent(OWNER, WT, 'host-tab-1', 1000) @@ -81,9 +62,4 @@ describe('web session close intent', () => { expect(isWebSessionCloseIntentPending(OWNER, 'other-wt', 'host-tab-3', 1000)).toBe(false) expect(isWebSessionCloseIntentPending(otherOwner, WT, 'host-tab-4', 1000)).toBe(true) }) - - it('ignores empty ids', () => { - recordWebSessionCloseIntent(OWNER, WT, ' ', 1000) - expect(isWebSessionCloseIntentPending(OWNER, WT, '', 1000)).toBe(false) - }) }) diff --git a/src/renderer/src/store/host-workspace-status-columns.test.ts b/src/renderer/src/store/host-workspace-status-columns.test.ts index 677262b9f81..0f2dae62e2c 100644 --- a/src/renderer/src/store/host-workspace-status-columns.test.ts +++ b/src/renderer/src/store/host-workspace-status-columns.test.ts @@ -3,8 +3,7 @@ import { getWorkspaceStatus } from '../../../shared/workspace-statuses' import { makeWorktree } from './slices/worktrees-slice-test-fixtures' import { isWorkspaceStatusAllowedOnHost, - selectWorkspaceBoardStatuses, - selectWorkspaceStatusesForHost + selectWorkspaceBoardStatuses } from './host-workspace-status-columns' const local = [{ id: 'todo', label: 'Todo' }] @@ -88,14 +87,3 @@ describe('isWorkspaceStatusAllowedOnHost', () => { ).toBe(true) }) }) - -describe('selectWorkspaceStatusesForHost', () => { - it("offers a host card its host's columns but not the host's copy of the default, matching the board", () => { - const state = { workspaceStatuses: local, hostWorkspaceStatuses } - - expect( - selectWorkspaceStatusesForHost(state, { hostId: 'runtime:env-1' }).map((status) => status.id) - ).toEqual(['todo', 'status-6', 'status-7']) - expect(selectWorkspaceStatusesForHost(state, { hostId: 'local' })).toBe(local) - }) -}) diff --git a/src/renderer/src/store/settled-sort-epoch.test.ts b/src/renderer/src/store/settled-sort-epoch.test.ts index bda7866f65d..0263aed5883 100644 --- a/src/renderer/src/store/settled-sort-epoch.test.ts +++ b/src/renderer/src/store/settled-sort-epoch.test.ts @@ -37,13 +37,6 @@ describe('settledSortEpoch', () => { expect(vi.getTimerCount()).toBe(0) }) - it('settles Manual bumps in the same write', () => { - useAppStore.setState({ sortBy: 'manual' }) - bump() - expect(settled()).toBe(true) - expect(vi.getTimerCount()).toBe(0) - }) - it('settles a web session sync patch that bumps sortEpoch', () => { useAppStore.setState({ sortBy: 'recent' }) applyWebSessionTabsStorePatch( @@ -72,22 +65,6 @@ describe('settledSortEpoch', () => { expect(vi.getTimerCount()).toBe(0) }) - it('ignores archived rows when detecting adds and removes', () => { - useAppStore.setState((s) => ({ - sortBy: 'recent', - worktreesByRepo: { 'repo-1': [makeWorktree('a', 'A')] }, - sortEpoch: s.sortEpoch + 1 - })) - expect(settled()).toBe(true) - useAppStore.setState((s) => ({ - worktreesByRepo: { - 'repo-1': [makeWorktree('a', 'A'), makeWorktree('b', 'B', { isArchived: true })] - }, - sortEpoch: s.sortEpoch + 1 - })) - expect(settled()).toBe(false) - }) - it('clears a pending settle when the store is reset', () => { useAppStore.setState({ sortBy: 'recent' }) bump() diff --git a/src/renderer/src/store/slices/agent-status/agent-status-program-status.test.ts b/src/renderer/src/store/slices/agent-status/agent-status-program-status.test.ts index 40918a8b2ae..97442ccf815 100644 --- a/src/renderer/src/store/slices/agent-status/agent-status-program-status.test.ts +++ b/src/renderer/src/store/slices/agent-status/agent-status-program-status.test.ts @@ -65,30 +65,4 @@ describe('agent status program-status facet', () => { expect(store.getState().setAgentProgramStatus(PANE, null)).toBe(true) expect(store.getState().agentStatusByPaneKey[PANE]).toEqual(entryBefore) }) - - it('ignores an equal facet and never creates a row', () => { - vi.useFakeTimers() - const store = createTestStore() - expect(store.getState().setAgentProgramStatus(PANE, FACET)).toBe(false) - expect(store.getState().agentStatusByPaneKey[PANE]).toBeUndefined() - - store.getState().setAgentStatus(PANE, { state: 'working', prompt: 'p', programStatus: FACET }) - const map = store.getState().agentStatusByPaneKey - expect(store.getState().setAgentProgramStatus(PANE, { ...FACET, observedAt: 2_000 })).toBe( - false - ) - expect(store.getState().agentStatusByPaneKey).toBe(map) - }) - - it('applies a facet patch inside a batch and reports whether it changed anything', () => { - vi.useFakeTimers() - const store = createTestStore() - store.getState().setAgentStatus(PANE, { state: 'working', prompt: 'p' }) - const outcomes = store.getState().setAgentStatuses([ - { kind: 'programStatus', paneKey: PANE, programStatus: FACET }, - { kind: 'programStatus', paneKey: PANE, programStatus: FACET } - ]) - expect(outcomes).toEqual([true, false]) - expect(store.getState().agentStatusByPaneKey[PANE].programStatus).toEqual(FACET) - }) }) diff --git a/src/renderer/src/store/slices/github-branch-mismatched-linked-pr.test.ts b/src/renderer/src/store/slices/github-branch-mismatched-linked-pr.test.ts index 408dc2e2050..d43a932f306 100644 --- a/src/renderer/src/store/slices/github-branch-mismatched-linked-pr.test.ts +++ b/src/renderer/src/store/slices/github-branch-mismatched-linked-pr.test.ts @@ -26,31 +26,6 @@ describe('shouldClearBranchMismatchedLinkedOpenPR', () => { pushTargetBranch: null } - it('clears when an open linked PR heads a different branch than the worktree', () => { - expect(shouldClearBranchMismatchedLinkedOpenPR(baseArgs)).toBe(true) - }) - - it('clears when the mismatched linked PR is a draft', () => { - expect( - shouldClearBranchMismatchedLinkedOpenPR({ ...baseArgs, pr: basePR({ state: 'draft' }) }) - ).toBe(true) - }) - - it('strips refs/heads/ from the worktree branch before comparing', () => { - expect( - shouldClearBranchMismatchedLinkedOpenPR({ ...baseArgs, branch: 'refs/heads/feature-one' }) - ).toBe(false) - expect( - shouldClearBranchMismatchedLinkedOpenPR({ ...baseArgs, branch: 'refs/heads/feature-two' }) - ).toBe(true) - }) - - it('keeps the link when the branch matches the PR head', () => { - expect(shouldClearBranchMismatchedLinkedOpenPR({ ...baseArgs, branch: 'feature-one' })).toBe( - false - ) - }) - it('keeps the link when the push target routes to the PR head branch', () => { expect( shouldClearBranchMismatchedLinkedOpenPR({ ...baseArgs, pushTargetBranch: 'feature-one' }) @@ -63,15 +38,6 @@ describe('shouldClearBranchMismatchedLinkedOpenPR', () => { ) }) - it('only applies to active PRs', () => { - expect( - shouldClearBranchMismatchedLinkedOpenPR({ ...baseArgs, pr: basePR({ state: 'merged' }) }) - ).toBe(false) - expect( - shouldClearBranchMismatchedLinkedOpenPR({ ...baseArgs, pr: basePR({ state: 'closed' }) }) - ).toBe(false) - }) - it('requires a known PR head branch and a current branch', () => { expect( shouldClearBranchMismatchedLinkedOpenPR({ diff --git a/src/renderer/src/store/slices/github-pr-refresh-hosted-review-cache-leak.test.ts b/src/renderer/src/store/slices/github-pr-refresh-hosted-review-cache-leak.test.ts index 32f79f8c6b3..c70dd1f3dfa 100644 --- a/src/renderer/src/store/slices/github-pr-refresh-hosted-review-cache-leak.test.ts +++ b/src/renderer/src/store/slices/github-pr-refresh-hosted-review-cache-leak.test.ts @@ -78,14 +78,4 @@ describe('hostedReviewCache stays bounded on the PR-refresh write path', () => { expect(cache[`local::/repo::branch-${total - 1}`]).toBeDefined() expect(cache['local::/repo::branch-0']).toBeUndefined() }) - - it('keeps every entry while under the cap', () => { - const store = createTestStore() - for (let i = 0; i < 10; i++) { - store.getState().applyGitHubPRRefreshEvent(foundEvent(`kept-${i}`, i + 1)) - } - const cache = store.getState().hostedReviewCache - expect(Object.keys(cache)).toHaveLength(10) - expect(cache['local::/repo::kept-0']).toBeDefined() - }) }) diff --git a/src/renderer/src/store/slices/github-pr-refresh-sequences-leak.test.ts b/src/renderer/src/store/slices/github-pr-refresh-sequences-leak.test.ts index ad78ef7f6d7..3419c6ca671 100644 --- a/src/renderer/src/store/slices/github-pr-refresh-sequences-leak.test.ts +++ b/src/renderer/src/store/slices/github-pr-refresh-sequences-leak.test.ts @@ -65,17 +65,6 @@ describe('prRefreshSequences stays bounded (leak regression)', () => { expect(sequences['seed-0']).toBeUndefined() }) - it('does not evict anything while under the cap', () => { - const store = createTestStore() - store.getState().applyGitHubPRRefreshEvent({ - sequence: 3, - reason: 'visible', - status: 'in-flight', - aliases: [{ cacheKey: 'only-key', repoPath: '/repo', branch: 'b' }] - }) - expect(store.getState().prRefreshSequences['only-key']).toBe(3) - }) - it('keeps a refreshed older key by moving it to most-recent before capping', () => { const store = createTestStore() const seeded: Record = {} diff --git a/src/renderer/src/store/slices/superseded-ssh-repo-rows.test.ts b/src/renderer/src/store/slices/superseded-ssh-repo-rows.test.ts index 42f89222f35..1b67877835d 100644 --- a/src/renderer/src/store/slices/superseded-ssh-repo-rows.test.ts +++ b/src/renderer/src/store/slices/superseded-ssh-repo-rows.test.ts @@ -1,6 +1,6 @@ import { describe, expect, it } from 'vitest' import type { Repo } from '../../../../shared/repo-types' -import { mergeSshRepoReadoptions, reconcileReadoptedSshRepoRows } from './superseded-ssh-repo-rows' +import { reconcileReadoptedSshRepoRows } from './superseded-ssh-repo-rows' function repo(overrides: Partial): Repo { return { @@ -31,12 +31,6 @@ describe('reconcileReadoptedSshRepoRows', () => { expect(result.pendingReadoptions).toEqual([]) }) - it('returns the input array when nothing is pruned', () => { - const repos = [repo({ id: 'shared', path: '/local' })] - - expect(reconcileReadoptedSshRepoRows(repos, []).repos).toBe(repos) - }) - it('keeps evidence pending when repos:changed has not delivered the new row yet', () => { const oldSsh = repo({ id: 'shared', connectionId: 'ssh-old' }) @@ -46,12 +40,6 @@ describe('reconcileReadoptedSshRepoRows', () => { expect(result.pendingReadoptions).toEqual([readoption]) }) - it('keeps a removed SSH ghost when a local repo shares its UUID without evidence', () => { - const repos = [repo({ id: 'shared' }), repo({ id: 'shared', connectionId: 'ssh-old' })] - - expect(reconcileReadoptedSshRepoRows(repos, []).repos).toEqual(repos) - }) - it('does not accept a local or runtime sibling as the mapped new SSH row', () => { const oldSsh = repo({ id: 'shared', connectionId: 'ssh-old' }) const local = repo({ id: 'shared' }) @@ -66,24 +54,4 @@ describe('reconcileReadoptedSshRepoRows', () => { expect(result.repos).toEqual([oldSsh, local, runtime]) expect(result.pendingReadoptions).toEqual([readoption]) }) - - it('leaves unrelated same-UUID SSH rows untouched', () => { - const other = repo({ id: 'shared', connectionId: 'ssh-other' }) - const newSsh = repo({ id: 'shared', connectionId: 'ssh-new' }) - - const result = reconcileReadoptedSshRepoRows([other, newSsh], [readoption]) - - expect(result.repos).toEqual([other, newSsh]) - }) -}) - -describe('mergeSshRepoReadoptions', () => { - it('combines repo ids for the same old-to-new migration', () => { - const result = mergeSshRepoReadoptions( - [{ ...readoption, repoIds: ['a'] }], - [{ ...readoption, repoIds: ['a', 'b'] }] - ) - - expect(result).toEqual([{ ...readoption, repoIds: ['a', 'b'] }]) - }) }) diff --git a/src/renderer/src/store/slices/worktrees/session/worktree-identity-rename-row-worktree-ids.test.ts b/src/renderer/src/store/slices/worktrees/session/worktree-identity-rename-row-worktree-ids.test.ts deleted file mode 100644 index 72896be47aa..00000000000 --- a/src/renderer/src/store/slices/worktrees/session/worktree-identity-rename-row-worktree-ids.test.ts +++ /dev/null @@ -1,95 +0,0 @@ -/** Rename must update worktree IDs inside tab-keyed close tombstones and environment-keyed browser intents or host snapshots resurrect closed surfaces. Main coverage: worktree-identity-migration-field-coverage.test.ts. */ -import { describe, expect, it } from 'vitest' -import type { AppState } from '../../../types' -import { createTestStore } from '../../worktrees-slice-test-harness' -import { buildWorktreeRenameState } from './worktree-identity-rename-state' - -const OLD = 'repo1::/ws/old' -const NEW = 'repo1::/ws/new' -const OTHER = 'repo1::/ws/other' - -/** Real worktree slice with explicit terminal/browser maps; omitted overrides exercise nullish fallback instead of masking regressions. */ -function appState(overrides: Partial): AppState { - const store = createTestStore() - store.setState(overrides) - return store.getState() -} - -describe('buildWorktreeRenameState value-owned worktree rows', () => { - it('re-points a closed-terminal-tab tombstone onto the new worktree id', () => { - const next = buildWorktreeRenameState( - appState({ - closedTerminalTabTombstonesByTabId: { - 'tab-1': { closedAt: 5, worktreeId: OLD, reason: 'user' }, - 'tab-2': { closedAt: 6, worktreeId: OTHER } - } - }), - OLD, - NEW - ) - expect(next.closedTerminalTabTombstonesByTabId).toEqual({ - 'tab-1': { closedAt: 5, worktreeId: NEW, reason: 'user' }, - 'tab-2': { closedAt: 6, worktreeId: OTHER } - }) - }) - - it('re-points a client-hosted browser close intent onto the new worktree id', () => { - const next = buildWorktreeRenameState( - appState({ - clientHostedBrowserCloseIntentsByEnvironment: { - 'env-1': [ - { browserPageId: 'page-1', worktreeId: OLD, closedAt: 3 }, - { browserPageId: 'page-2', worktreeId: OTHER, closedAt: 4 } - ], - 'env-2': [{ browserPageId: 'page-3', worktreeId: OTHER, closedAt: 5 }] - } - }), - OLD, - NEW - ) - expect(next.clientHostedBrowserCloseIntentsByEnvironment).toEqual({ - 'env-1': [ - { browserPageId: 'page-1', worktreeId: NEW, closedAt: 3 }, - { browserPageId: 'page-2', worktreeId: OTHER, closedAt: 4 } - ], - 'env-2': [{ browserPageId: 'page-3', worktreeId: OTHER, closedAt: 5 }] - }) - }) - - it('re-points a paired-host tab close intent onto the new worktree id', () => { - const next = buildWorktreeRenameState( - appState({ - pairedTerminalTabCloseIntentsByEnvironment: { - 'env-1': [ - { hostTabIds: ['host-1'], worktreeId: OLD, closedAt: 3, pairingRevision: 1 }, - { hostTabIds: ['host-2'], worktreeId: OTHER, closedAt: 4 } - ] - } - }), - OLD, - NEW - ) - expect(next.pairedTerminalTabCloseIntentsByEnvironment).toEqual({ - 'env-1': [ - { hostTabIds: ['host-1'], worktreeId: NEW, closedAt: 3, pairingRevision: 1 }, - { hostTabIds: ['host-2'], worktreeId: OTHER, closedAt: 4 } - ] - }) - }) - - it('emits neither map when no row names the renamed worktree', () => { - const next = buildWorktreeRenameState( - appState({ - closedTerminalTabTombstonesByTabId: { 'tab-2': { closedAt: 6, worktreeId: OTHER } }, - clientHostedBrowserCloseIntentsByEnvironment: { - 'env-1': [{ browserPageId: 'page-2', worktreeId: OTHER, closedAt: 4 }] - } - }), - OLD, - NEW - ) - expect(Object.hasOwn(next, 'closedTerminalTabTombstonesByTabId')).toBe(false) - expect(Object.hasOwn(next, 'clientHostedBrowserCloseIntentsByEnvironment')).toBe(false) - expect(Object.hasOwn(next, 'pairedTerminalTabCloseIntentsByEnvironment')).toBe(false) - }) -}) diff --git a/src/renderer/src/store/terminals/terminal-workspace-routing.scale.test.ts b/src/renderer/src/store/terminals/terminal-workspace-routing.scale.test.ts index c7a0075c91d..8d4b3d6b39c 100644 --- a/src/renderer/src/store/terminals/terminal-workspace-routing.scale.test.ts +++ b/src/renderer/src/store/terminals/terminal-workspace-routing.scale.test.ts @@ -72,26 +72,4 @@ describe('terminal workspace routing scales with tab count, not workspace count' expect(reads()).toBeLessThanOrEqual(WORKTREE_COUNT * 2) expect(reads()).toBeLessThan(CALLS * WORKTREE_COUNT) }) - - it('still resolves the owning repo and its connection', () => { - const { state, worktreeId } = buildCountingState() - const remoteState = { - ...state, - repos: state.repos.map((repo) => - repo.id === 'repo-9' ? { ...repo, connectionId: 'ssh-host-1' } : repo - ) - } as AppState - - expect(worktreeUsesRemoteConnection(remoteState, worktreeId)).toBe(true) - expect(getRemoteConnectionIdForWorktree(remoteState, worktreeId)).toBe('ssh-host-1') - expect(worktreeUsesRemoteConnection(state, worktreeId)).toBe(false) - expect(getRemoteConnectionIdForWorktree(state, worktreeId)).toBeNull() - expect(worktreeUsesWslPath(state, worktreeId)).toBe(false) - }) - - it('returns null for a worktree id that no repo owns', () => { - const { state } = buildCountingState() - expect(getRemoteConnectionIdForWorktree(state, 'ghost::/nowhere')).toBeNull() - expect(worktreeUsesRemoteConnection(state, 'ghost::/nowhere')).toBe(false) - }) }) diff --git a/src/renderer/src/store/workspace-record-selectors.test.ts b/src/renderer/src/store/workspace-record-selectors.test.ts index e6d967a759c..8c5ca10ea33 100644 --- a/src/renderer/src/store/workspace-record-selectors.test.ts +++ b/src/renderer/src/store/workspace-record-selectors.test.ts @@ -3,12 +3,7 @@ import { hostWorktreeTarget } from '../../../shared/worktree/host-qualified-iden import { folderWorkspaceKey } from '../../../shared/workspace-scope' import type { AppState } from './types' import { makeFolderWorkspace, makeWorktree } from './slices/worktrees-slice-test-fixtures' -import { - selectDetectedWorktreesByRepo, - selectFolderWorkspaces, - selectWorkspaceByHostTarget, - selectWorktreesByRepo -} from './workspace-record-selectors' +import { selectWorkspaceByHostTarget } from './workspace-record-selectors' const SHARED_ID = 'repo-1::/work/orca' const localRow = makeWorktree({ id: SHARED_ID, repoId: 'repo-1', hostId: 'local' }) @@ -27,15 +22,6 @@ function makeState( } } -describe('compatibility views', () => { - it('return the store fields by reference', () => { - const state = makeState() - expect(selectWorktreesByRepo(state)).toBe(state.worktreesByRepo) - expect(selectFolderWorkspaces(state)).toBe(state.folderWorkspaces) - expect(selectDetectedWorktreesByRepo(state)).toBe(state.detectedWorktreesByRepo) - }) -}) - describe('selectWorkspaceByHostTarget', () => { it('resolves the target host only', () => { const state = makeState() diff --git a/src/renderer/src/store/worktree-host-collision-index.test.ts b/src/renderer/src/store/worktree-host-collision-index.test.ts index 432a3d451db..fbc2ea90c96 100644 --- a/src/renderer/src/store/worktree-host-collision-index.test.ts +++ b/src/renderer/src/store/worktree-host-collision-index.test.ts @@ -3,12 +3,7 @@ import { describe, expect, it } from 'vitest' import type { Worktree } from '../../../shared/worktree/types' import type { AppState } from './types' import { getWorktreeOnHostFromState } from './selectors' -import { - getIndexedAllWorktrees, - getIndexedWorktreeMap, - getIndexedWorktreesById -} from './worktree-repo-index' -import { buildWorktreeByIdIndex } from './slices/worktree-by-id-index' +import { getIndexedAllWorktrees } from './worktree-repo-index' const SHARED_ID = 'repo-1::/work/orca' @@ -63,22 +58,6 @@ describe('id-keyed worktree projections keep distinct hosts distinct', () => { expect(all).toHaveLength(2) }) - - it('enumerates every host that publishes an id', () => { - const rows = getIndexedWorktreesById(byRepo(localRow, sshRow), SHARED_ID) - - expect(rows.map((entry) => entry.hostId)).toEqual(['local', 'ssh:build-box']) - }) - - it('agrees with the other id index on which row a bare id resolves to', () => { - const worktreesByRepo = byRepo(localRow, sshRow) - - // Both indices flatten the same data; disagreeing meant one caller saw the - // local row and another the SSH row for the same lookup. - expect(getIndexedWorktreeMap(worktreesByRepo).get(SHARED_ID)).toBe( - buildWorktreeByIdIndex(worktreesByRepo).get(SHARED_ID) - ) - }) }) describe('getWorktreeOnHostFromState refuses a lookup that still matches two copies', () => { @@ -91,10 +70,4 @@ describe('getWorktreeOnHostFromState refuses a lookup that still matches two cop it('answers the named host copy', () => { expect(getWorktreeOnHostFromState(colliding, SHARED_ID, 'ssh:build-box')).toBe(sshRow) }) - - it('answers a lone copy without a host', () => { - expect( - getWorktreeOnHostFromState({ worktreesByRepo: byRepo(sshRow) }, SHARED_ID, undefined) - ).toBe(sshRow) - }) }) diff --git a/src/shared/plugins/catalog/plugin-kill-list.test.ts b/src/shared/plugins/catalog/plugin-kill-list.test.ts index c89cbba2211..c85a1069801 100644 --- a/src/shared/plugins/catalog/plugin-kill-list.test.ts +++ b/src/shared/plugins/catalog/plugin-kill-list.test.ts @@ -1,10 +1,8 @@ import { describe, expect, it } from 'vitest' import { PLUGIN_KILL_LIST_ENTRY_LIMIT, - PLUGIN_KILL_LIST_FUTURE_SKEW_MS, findKilledPlugin, isPluginKillListTooFarInFuture, - pluginKillListEntrySchema, pluginKillListSchema, type PluginKillList } from './plugin-kill-list' @@ -29,22 +27,6 @@ describe('pluginKillListSchema', () => { expect(findKilledPlugin(parsed, 'community.unsafe')).toEqual(entry()) }) - it('parses a versioned revocation document', () => { - const parsed = pluginKillListSchema.parse({ - version: 1, - generatedAt: '2026-07-12T20:00:00Z', - plugins: [entry()] - }) - - expect(findKilledPlugin(parsed, 'community.unsafe')).toEqual(entry()) - }) - - it('rejects a list whose header is malformed', () => { - expect( - pluginKillListSchema.safeParse({ version: 1, generatedAt: 'not-a-date', plugins: [] }).success - ).toBe(false) - }) - it('drops only the entries it cannot read, and keeps one entry per plugin', () => { const parsed = pluginKillListSchema.parse({ version: 1, @@ -60,14 +42,6 @@ describe('pluginKillListSchema', () => { expect(parsed.plugins).toEqual([entry()]) }) - it('pins the published entry fields, which shipped clients parse strictly', () => { - expect(Object.keys(pluginKillListEntrySchema.shape)).toEqual([ - 'pluginKey', - 'reason', - 'advisoryUrl' - ]) - }) - it('caps the revocation document size by entry count', () => { const plugins = Array.from({ length: PLUGIN_KILL_LIST_ENTRY_LIMIT + 1 }, (_, index) => entry(`publisher.plugin-${index}`) @@ -89,11 +63,4 @@ describe('isPluginKillListTooFarInFuture', () => { it('flags a snapshot that would freeze out every later revocation', () => { expect(isPluginKillListTooFarInFuture(list('9999-12-31T23:59:59Z'))).toBe(true) }) - - it('allows a snapshot inside the clock-skew window', () => { - const generatedAt = new Date( - Date.now() + PLUGIN_KILL_LIST_FUTURE_SKEW_MS - 60_000 - ).toISOString() - expect(isPluginKillListTooFarInFuture(list(generatedAt))).toBe(false) - }) })