test: avoid unused imports while preserving export contracts

Preserve test behavior and public export coverage while removing unnecessary module loading from orchestration and pure-function suites.
This commit is contained in:
Neil
2026-10-15 00:29:33 -07:00
committed by GitHub
parent 2885bc3e92
commit 08257b94aa
35 changed files with 109 additions and 30 deletions
+1 -1
View File
@@ -6,7 +6,7 @@ import { mkdtemp, rm } from 'node:fs/promises'
import { tmpdir } from 'node:os'
import { join } from 'node:path'
import { describe, expect, it, vi } from 'vitest'
import { parseArgs } from './orcad-entry'
import { parseArgs } from './orcad-command-arguments'
import { ORCAD_EXIT_CONFIGURATION } from './orcad-configuration-exit'
import { ORCAD_EXIT_FAILED, resolveOrcadExitCode } from './orcad-exit-code'
import { startOrcadWithLifecycle } from './orcad-lifecycle'
+3 -1
View File
@@ -194,8 +194,10 @@ afterEach(() => {
it('refuses recovery overlap before initializing the browser provider or runtime', async () => {
state.root = mkdtempSync(join(tmpdir(), 'orca-headless-recovery-'))
const maintenance = acquireProfileStateMaintenance(state.root)
const { startOrcad } = await import('./orcad-entry')
const { startOrcad, parseArgs } = await import('./orcad-entry')
const commandArguments = await import('./orcad-command-arguments')
try {
expect(parseArgs).toBe(commandArguments.parseArgs)
await expect(startOrcad({ noPairing: true, json: true })).rejects.toThrow()
expect(state.browserProvider).not.toHaveBeenCalled()
expect(state.rpcStarted).toBe(false)
@@ -2,7 +2,7 @@ import { describe, expect, it } from 'vitest'
import {
ProfileStateAuthorityBootstrapError,
ProfileStateRecoveryRequiredError
} from './profile-state-authority-bootstrap'
} from './profile-state-recovery-required'
import {
formatProfileStateStartupFailure,
profileStateStartupFailureClass
@@ -1,3 +1,4 @@
import '../../../unused-default-rpc-methods.test-fixture'
import { afterEach, describe, expect, it } from 'vitest'
import {
cleanupLegacyCompatibilityDispatcherHarnesses,
@@ -1,3 +1,4 @@
import './unused-default-rpc-methods.test-fixture'
// Why: independent adversarial verification of every #11745 fix. Each case reproduces the ORIGINAL
// defect and asserts it is closed by observing state, not just the response envelope — a refusal
// that still mutated the graph is a failure, and so is a fix that fences a legitimate coordinator.
@@ -1,3 +1,4 @@
import './unused-default-rpc-methods.test-fixture'
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest'
import { ORCHESTRATION_SESSION_CALLER_ERROR_CODES as CODES } from '../../../shared/orchestration-session-caller-codes'
import {
@@ -1,3 +1,4 @@
import './unused-default-rpc-methods.test-fixture'
import { afterEach, describe, expect, it } from 'vitest'
import {
cleanupLegacyCompatibilityDispatcherHarnesses,
@@ -1,3 +1,4 @@
import './unused-default-rpc-methods.test-fixture'
import { afterEach, describe, expect, it } from 'vitest'
import type { OrchestrationCompatibilityEvidence } from '../../../shared/orchestration-compatibility-evidence'
import {
@@ -1,3 +1,4 @@
import './unused-default-rpc-methods.test-fixture'
import { afterEach, describe, expect, it } from 'vitest'
import {
cleanupLegacyCompatibilityDispatcherHarnesses,
@@ -1,3 +1,4 @@
import './unused-default-rpc-methods.test-fixture'
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest'
import type { OrchestrationDb } from '../orchestration/db'
import { migrateV43 } from '../orchestration/db/schema/migrate-v43'
@@ -1,3 +1,4 @@
import './unused-default-rpc-methods.test-fixture'
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest'
import { formatOrcaSessionAddress } from '../../../shared/orca-session-address'
import { testOrcaSessionId } from '../../../shared/orca-session-address-test-fixture'
@@ -1,3 +1,4 @@
import './unused-default-rpc-methods.test-fixture'
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest'
import { formatOrcaSessionAddress, type OrcaSessionId } from '../../../shared/orca-session-address'
import { testOrcaSessionId } from '../../../shared/orca-session-address-test-fixture'
@@ -1,3 +1,4 @@
import './unused-default-rpc-methods.test-fixture'
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest'
import {
mintStructuredWorkerHandle,
@@ -1,3 +1,4 @@
import './unused-default-rpc-methods.test-fixture'
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest'
import {
mintStructuredWorkerHandle,
@@ -1,3 +1,4 @@
import './unused-default-rpc-methods.test-fixture'
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest'
import {
mintStructuredWorkerHandle,
@@ -156,7 +156,8 @@ vi.mock('../macos-tcc-prompt-notice', () => ({
releasePendingTccPromptNotice: releasePendingTccPromptNoticeMock
}))
import { attachMainWindowServices } from './attach-main-window-services'
import { attachMainWindowServices, registerUpdaterHandlers } from './attach-main-window-services'
import { registerUpdaterHandlers as registerWindowUpdaterHandlers } from './main-window-updater'
type MockFn = ReturnType<typeof vi.fn>
@@ -198,6 +199,10 @@ async function fireReadyToShow(mainWindow: MainWindowStub): Promise<void> {
}
describe('attachMainWindowServices', () => {
it('exports the updater handlers exercised by the recovery tests', () => {
expect(registerUpdaterHandlers).toBe(registerWindowUpdaterHandlers)
})
afterEach(() => {
cancelHistoryGc()
})
@@ -67,7 +67,7 @@ vi.mock('../ipc/ui', async (importOriginal) => ({
isTrustedUIRenderer: (sender: unknown) => isTrustedUIRendererMock(sender)
}))
import { registerUpdaterHandlers } from './attach-main-window-services'
import { registerUpdaterHandlers } from './main-window-updater'
const RECOVERY_CHANNELS = [
'updater:getLinuxPackageInstallInstructions',
@@ -5,7 +5,15 @@ import { folderWorkspaceKey } from '../../../shared/workspace-scope'
import { QUICK_OPEN_LISTING_MAX_RESULTS } from '../../../shared/quick-open-listing-limits'
import { useAppStore } from '@/store'
import type { AppState } from '@/store/types'
import type { RuntimeFileListState } from './quick-open-file-list'
import {
getRuntimeFileListTarget,
getNestedWorktreeExcludeRequest,
getNestedWorktreeExcludePaths,
isNestedWorktreePath,
type RuntimeFileListState
} from './quick-open-file-list'
import * as fileListTarget from './quick-open-file-list-target'
import * as nestedWorktrees from './quick-open-nested-worktrees'
import { QUICK_OPEN_REMOTE_QUERY_MAX_CODE_UNITS } from './quick-open-search'
import {
listRuntimeFilesMock,
@@ -30,6 +38,13 @@ vi.mock('@/runtime/runtime-file-search-client', async () => {
}
})
it('keeps the pure file list functions available through the hook module', () => {
expect(getRuntimeFileListTarget).toBe(fileListTarget.getRuntimeFileListTarget)
expect(getNestedWorktreeExcludeRequest).toBe(fileListTarget.getNestedWorktreeExcludeRequest)
expect(getNestedWorktreeExcludePaths).toBe(nestedWorktrees.getNestedWorktreeExcludePaths)
expect(isNestedWorktreePath).toBe(nestedWorktrees.isNestedWorktreePath)
})
describe('useRuntimeFileListForWorktree', () => {
it('settles a Windows folder listing failure and recovers after reopening', async () => {
const workspaceKey = folderWorkspaceKey('folder-workspace-1')
@@ -3,10 +3,9 @@ import type { Worktree } from '../../../shared/worktree/types'
import { buildExcludePathPrefixes } from '../../../shared/quick-open-filter'
import {
getRuntimeFileListTarget,
getNestedWorktreeExcludePaths,
getNestedWorktreeExcludeRequest,
isNestedWorktreePath
} from './quick-open-file-list'
getNestedWorktreeExcludeRequest
} from './quick-open-file-list-target'
import { getNestedWorktreeExcludePaths, isNestedWorktreePath } from './quick-open-nested-worktrees'
function makeWorktree(id: string, path: string): Worktree {
return {
@@ -4,7 +4,7 @@ import type { Repo } from '../../../../shared/repo-types'
import type { WorktreeLineage } from '../../../../shared/worktree/lineage-types'
import type { Worktree } from '../../../../shared/worktree/types'
import { isDefaultBranchWorkspace } from '../../../../shared/worktree/workspace-kinds'
import { computeVisibleWorktreeIds } from './visible-worktrees'
import { computeVisibleWorktreeIds } from './compute-visible-worktrees'
function makeRepo(id: string, path: string, kind: Repo['kind']): Repo {
return { id, path, displayName: id, badgeColor: '#000', addedAt: 0, kind }
@@ -1,5 +1,5 @@
import { describe, expect, it } from 'vitest'
import { computeVisibleWorktreeIds } from './visible-worktrees'
import { computeVisibleWorktreeIds } from './compute-visible-worktrees'
import { isDefaultBranchWorkspace } from '../../../../shared/worktree/workspace-kinds'
import type { Repo } from '../../../../shared/repo-types'
import type { Worktree } from '../../../../shared/worktree/types'
@@ -1,9 +1,6 @@
import { describe, expect, it } from 'vitest'
import {
computeClearFilterActions,
isSleepingSweepExemptionNarrowingList,
sidebarHasActiveFilters
} from './visible-worktrees'
import { computeClearFilterActions, sidebarHasActiveFilters } from './sidebar-filter-actions'
import { isSleepingSweepExemptionNarrowingList } from './visible-worktree-kinds'
import { isDefaultBranchWorkspace } from '../../../../shared/worktree/workspace-kinds'
import type { Worktree } from '../../../../shared/worktree/types'
@@ -21,8 +21,8 @@ vi.mock('../../../../shared/resolved-worktree-lineage', async (importOriginal) =
}
})
import { computeVisibleWorktreeIds } from './visible-worktrees'
import type { computeVisibleWorktrees } from './visible-worktrees'
import { computeVisibleWorktreeIds } from './compute-visible-worktrees'
import type { computeVisibleWorktrees } from './compute-visible-worktrees'
import { getCyclicProjectedWorktreeLineageIds } from './worktree-lineage-projection'
import { getLineageAncestorIndex, getSortedWorktreeRankIndex } from './visible-worktree-indexes'
@@ -2,7 +2,7 @@ import { describe, expect, it } from 'vitest'
import type { ExecutionHostId } from '../../../../shared/execution-host'
import type { WorktreeLineage } from '../../../../shared/worktree/lineage-types'
import { worktree, repoMap } from './worktree-list-groups-test-fixtures'
import { computeVisibleWorktrees, type VisibleWorktreeOptions } from './visible-worktrees'
import { computeVisibleWorktrees, type VisibleWorktreeOptions } from './compute-visible-worktrees'
import { buildRows } from './worktree-list/grouping/build-rows'
function scenario(hostId: ExecutionHostId) {
@@ -1,5 +1,5 @@
import { describe, expect, it } from 'vitest'
import { computeVisibleWorktreeIds } from './visible-worktrees'
import { computeVisibleWorktreeIds } from './compute-visible-worktrees'
import { getPairedDeviceIdsByEnvironment } from '../../../../shared/workspace-creator-visibility'
import type { Repo } from '../../../../shared/repo-types'
import type { TerminalTab } from '../../../../shared/terminal-tab-types'
@@ -8,6 +8,12 @@ import { getWorktreeHostIdentity } from '../../../../../../shared/worktree/host-
import { makeRepo, makeWorktree } from '../../../worktree-jump-palette-test-fixtures'
import { useVisibleSidebarWorktrees } from './use-visible-worktrees'
import type * as visibleWorktreesModule from '../../visible-worktrees'
import { computeVisibleWorktreeIds, computeVisibleWorktrees } from '../../compute-visible-worktrees'
import { computeClearFilterActions, sidebarHasActiveFilters } from '../../sidebar-filter-actions'
import {
isSleepingSweepExemptWorkspace,
isSleepingSweepExemptionNarrowingList
} from '../../visible-worktree-kinds'
const computeVisibleWorktreesCalls = { count: 0 }
vi.mock('../../visible-worktrees', async (importOriginal) => {
@@ -35,6 +41,16 @@ describe('useVisibleSidebarWorktrees', () => {
useAppStore.setState(initialState, true)
})
it('keeps the pure filtering functions available through the sidebar module', async () => {
const facade = await vi.importActual<typeof visibleWorktreesModule>('../../visible-worktrees')
expect(facade.computeVisibleWorktreeIds).toBe(computeVisibleWorktreeIds)
expect(facade.computeVisibleWorktrees).toBe(computeVisibleWorktrees)
expect(facade.computeClearFilterActions).toBe(computeClearFilterActions)
expect(facade.sidebarHasActiveFilters).toBe(sidebarHasActiveFilters)
expect(facade.isSleepingSweepExemptWorkspace).toBe(isSleepingSweepExemptWorkspace)
expect(facade.isSleepingSweepExemptionNarrowingList).toBe(isSleepingSweepExemptionNarrowingList)
})
it('projects both host rows through the primary sidebar pipeline', () => {
const local = makeWorktree('shared', 'Local workspace', { hostId: 'local' })
const ssh = makeWorktree('shared', 'SSH workspace', { hostId: 'ssh:box' })
@@ -1,12 +1,27 @@
import { describe, expect, it, vi } from 'vitest'
import {
classifyTabEntryQuery,
getTabEntryOptions,
openTabEntryWithOperations,
TAB_ENTRY_ABSOLUTE_PATH_REMOTE_BLOCKED_MESSAGE,
validateNewTabEntryAbsolutePath,
validateNewTabEntryRelativePath,
type TabEntryOperations
} from './tab-create-entry-action'
import * as classifier from './tab-create-entry-classifier'
const readyFiles = (files: string[]) => ({ files, loading: false, loadError: null })
it('keeps the pure classifier available through the tab action module', () => {
expect(classifyTabEntryQuery).toBe(classifier.classifyTabEntryQuery)
expect(getTabEntryOptions).toBe(classifier.getTabEntryOptions)
expect(TAB_ENTRY_ABSOLUTE_PATH_REMOTE_BLOCKED_MESSAGE).toBe(
classifier.TAB_ENTRY_ABSOLUTE_PATH_REMOTE_BLOCKED_MESSAGE
)
expect(validateNewTabEntryAbsolutePath).toBe(classifier.validateNewTabEntryAbsolutePath)
expect(validateNewTabEntryRelativePath).toBe(classifier.validateNewTabEntryRelativePath)
})
describe('openTabEntryWithOperations', () => {
function makeOperations(overrides: Partial<TabEntryOperations> = {}): TabEntryOperations {
return {
@@ -6,7 +6,7 @@ import {
TAB_ENTRY_ABSOLUTE_PATH_REMOTE_BLOCKED_MESSAGE,
validateNewTabEntryAbsolutePath,
validateNewTabEntryRelativePath
} from './tab-create-entry-action'
} from './tab-create-entry-classifier'
const readyFiles = (files: string[]) => ({ files, loading: false, loadError: null })
@@ -1,5 +1,5 @@
import { describe, expect, it } from 'vitest'
import { fallbackParkedPaneCandidates } from './terminal-parked-tab-watchers'
import { fallbackParkedPaneCandidates } from './terminal-parked-watcher-reconciliation'
const TAB_ID = 'tab-1'
const PTY_ID = 'repo::/worktree@@session-1'
@@ -53,9 +53,11 @@ vi.mock('@/store', () => ({
import {
captureParkedTerminalPaneCandidates,
fallbackParkedPaneCandidates,
pruneParkedTerminalWatchers,
syncParkedTerminalTabWatchers
} from './terminal-parked-tab-watchers'
import { fallbackParkedPaneCandidates as directFallbackParkedPaneCandidates } from './terminal-parked-watcher-reconciliation'
function sync(): void {
syncParkedTerminalTabWatchers({
@@ -76,6 +78,10 @@ afterEach(() => {
pruneParkedTerminalWatchers(new Set())
})
it('keeps pane fallback available through the parked watcher module', () => {
expect(fallbackParkedPaneCandidates).toBe(directFallbackParkedPaneCandidates)
})
it('retains a continuing watcher and title while reconciling a reminted split leaf', () => {
captureParkedTerminalPaneCandidates(TAB_ID, WORKTREE_ID, [
{ ptyId: FIRST_PTY_ID, paneId: 1, leafId: FIRST_LEAF_ID, drivesTabTitle: true },
@@ -2,7 +2,11 @@ import type { IBufferLine, Terminal } from '@xterm/xterm'
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest'
import { registerHttpLinkStoreAccessor } from '@/lib/http-link-routing'
import { handleTerminalWebLinkClick } from './terminal-web-link-click'
import { installHttpLinkClickFallback } from './terminal-url-link-hit-testing'
import {
installHttpLinkClickFallback,
TERMINAL_HTTP_URL_MAX_LENGTH
} from './terminal-url-link-hit-testing'
import { TERMINAL_HTTP_URL_MAX_LENGTH as maximumHttpUrlLength } from './terminal-http-link-limits'
const COLS = 157
const ROWS = 59
@@ -157,6 +161,10 @@ function mouseEventForRow(
}
describe('hard-wrapped terminal HTTP clicks', () => {
it('exports the URL length limit exercised by the extraction tests', () => {
expect(TERMINAL_HTTP_URL_MAX_LENGTH).toBe(maximumHttpUrlLength)
})
beforeEach(() => {
vi.stubGlobal('navigator', { userAgent: 'Macintosh' })
vi.stubGlobal('window', { api: { shell: { openUrl: openUrlMock } } })
@@ -1,8 +1,6 @@
import { afterEach, describe, expect, it, vi } from 'vitest'
import {
extractTerminalHttpLinks,
TERMINAL_HTTP_URL_MAX_LENGTH
} from './terminal-url-link-hit-testing'
import { extractTerminalHttpLinks } from './terminal-http-url-extraction'
import { TERMINAL_HTTP_URL_MAX_LENGTH } from './terminal-http-link-limits'
afterEach(() => {
vi.restoreAllMocks()
@@ -1,5 +1,5 @@
import { describe, expect, it } from 'vitest'
import { isSleepingSweepExemptWorkspace } from './sidebar/visible-worktrees'
import { isSleepingSweepExemptWorkspace } from './sidebar/visible-worktree-kinds'
import type { Worktree } from '../../../shared/worktree/types'
function makeWorktree(overrides: Partial<Worktree> = {}): Worktree {
@@ -1,5 +1,5 @@
import { describe, expect, it } from 'vitest'
import { getLinkedWorkItemProvider } from './new-workspace'
import { getLinkedWorkItemProvider } from './linked-work-item-provider'
describe('getLinkedWorkItemProvider', () => {
it.each([
@@ -96,11 +96,17 @@ vi.mock('@/lib/agent-background-session-timeout-toast', () => ({
import {
canUseIssueCommandForLinkedItemProvider,
ensureAgentStartupInTerminal,
getLinkedWorkItemProvider,
getSetupConfig,
getWorkspaceSeedName,
isGitLabIssueUrl
} from './new-workspace'
import { resetAgentStartupDelayedDeliveryForTests } from './agent-startup-delayed-delivery'
import { getLinkedWorkItemProvider as directGetLinkedWorkItemProvider } from './linked-work-item-provider'
it('keeps linked item provider selection available through the workspace module', () => {
expect(getLinkedWorkItemProvider).toBe(directGetLinkedWorkItemProvider)
})
describe('linked-item issue commands', () => {
it('keeps Jira and Linear sentinel numbers out of repository issue templates', () => {