test: remove low-value metadata and registration inventories (#36066)

Co-authored-by: OrcaWin <293788423+OrcaWin@users.noreply.github.com>
This commit is contained in:
OrcaWin
2026-10-29 13:27:15 -07:00
committed by GitHub
co-authored by OrcaWin
parent db9cfbdb0a
commit a01568e08c
9 changed files with 2 additions and 361 deletions
-2
View File
@@ -2925,7 +2925,6 @@
"src/main/ipc/jira/cancellable-requests.test.ts": 71,
"src/main/ipc/jira/ipc-params.test.ts": 59,
"src/main/ipc/jira/issue-summary-generation.test.ts": 124,
"src/main/ipc/jira/project-metadata-registration.test.ts": 194,
"src/main/ipc/linear/register-handlers.test.ts": 131,
"src/main/ipc/local-file-access-resolution-network-path.test.ts": 198,
"src/main/ipc/local-file-access-resolution.test.ts": 535,
@@ -6499,7 +6498,6 @@
"src/main/startup/gpu-fallback-marker.test.ts": 48,
"src/main/startup/gpu-fallback-switches.test.ts": 39,
"src/main/startup/gpu-lifecycle-install-dir-acl-guard.test.ts": 605,
"src/main/startup/headless-serve-ssh-registration.test.ts": 3582,
"src/main/startup/headless-serve-x11-reexec.test.ts": 48,
"src/main/startup/http1-compatibility-profile-state.test.ts": 56,
"src/main/startup/hydrate-shell-path.test.ts": 471,
@@ -1,5 +1,4 @@
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest'
import { RemoteRuntimeClientError } from '../../shared/remote-runtime/remote-runtime-client-error'
const mocks = vi.hoisted(() => ({
handlers: new Map<string, (event: unknown, args: unknown) => unknown>(),
@@ -61,21 +60,6 @@ afterEach(() => {
})
describe('browser:publishClientPageMetadata', () => {
it('forwards a valid publish and returns what the runtime answered', async () => {
await expect(
publishMetadata({ environmentId: 'environment-a', params: PARAMS })
).resolves.toEqual({ status: 'published', accepted: true })
expect(mocks.publish).toHaveBeenCalledWith('environment-a', PARAMS)
})
it('carries an un-accepted answer through rather than reporting success', async () => {
mocks.publish.mockResolvedValue({ accepted: false })
await expect(
publishMetadata({ environmentId: 'environment-a', params: PARAMS })
).resolves.toEqual({ status: 'published', accepted: false })
})
// Untrusted renderer identities must not reach the paired runtime lease.
it('refuses an untrusted renderer before touching the lease', async () => {
mocks.isTrusted.mockReturnValue(false)
@@ -108,14 +92,4 @@ describe('browser:publishClientPageMetadata', () => {
await expect(publishMetadata(args)).resolves.toEqual({ status: 'refused' })
expect(mocks.publish).not.toHaveBeenCalled()
})
it('reports a lease failure with its runtime error code', async () => {
mocks.publish.mockRejectedValue(
new RemoteRuntimeClientError('remote_runtime_unavailable', 'no lease')
)
await expect(
publishMetadata({ environmentId: 'environment-a', params: PARAMS })
).resolves.toEqual({ status: 'failed', errorCode: 'remote_runtime_unavailable' })
})
})
@@ -1,128 +0,0 @@
import { beforeEach, describe, expect, it, vi } from 'vitest'
const mocks = vi.hoisted(() => ({
handle: vi.fn(),
listProjects: vi.fn(),
listIssueTypes: vi.fn(),
listCreateFields: vi.fn(),
listPriorities: vi.fn(),
listFavouriteFilters: vi.fn()
}))
vi.mock('electron', () => ({ ipcMain: { handle: mocks.handle } }))
vi.mock('../../preflight/agent-detection', () => ({ _resetPreflightCache: vi.fn() }))
vi.mock('../../jira/favourite-filters', () => ({
listFavouriteFilters: mocks.listFavouriteFilters
}))
vi.mock('../../jira/client', () => ({
connect: vi.fn(),
disconnect: vi.fn(),
getStatus: vi.fn(),
selectSite: vi.fn(),
testConnection: vi.fn()
}))
vi.mock('../../jira/jira-issue-mutations', () => ({
addIssueComment: vi.fn(),
createIssue: vi.fn(),
updateIssue: vi.fn()
}))
vi.mock('../../jira/jira-issue-read', () => ({
getIssue: vi.fn(),
getIssueSummary: vi.fn()
}))
vi.mock('../../jira/jira-issue-comments', () => ({
getIssueComments: vi.fn()
}))
vi.mock('../../jira/jira-transition-queries', () => ({
getProjectStatusOrder: vi.fn(),
listTransitions: vi.fn()
}))
vi.mock('../../jira/jira-issue-create-metadata', () => ({
listCreateFields: mocks.listCreateFields,
listIssueTypes: mocks.listIssueTypes,
listPriorities: mocks.listPriorities,
listAssignableUsers: vi.fn(),
listAssignableUsersForProject: vi.fn(),
searchUsers: vi.fn()
}))
vi.mock('../../jira/jira-project-queries', () => ({
listProjects: mocks.listProjects
}))
vi.mock('../../jira/jira-issue-search', () => ({
listIssues: vi.fn(),
searchIssues: vi.fn()
}))
import { registerJiraHandlers } from './register-handlers'
function handler(channel: string) {
const callback = mocks.handle.mock.calls.find(([name]) => name === channel)?.[1]
if (typeof callback !== 'function') {
throw new Error(`Missing handler: ${channel}`)
}
return callback
}
beforeEach(() => {
vi.clearAllMocks()
registerJiraHandlers()
})
describe('Jira project metadata IPC registration', () => {
it('registers each metadata channel once through the main Jira registration', () => {
for (const channel of [
'jira:listProjects',
'jira:listIssueTypes',
'jira:listCreateFields',
'jira:listPriorities',
'jira:listFavouriteFilters'
]) {
expect(mocks.handle.mock.calls.filter(([name]) => name === channel)).toHaveLength(1)
}
})
it('requires one explicit site for favourite filters and preserves failures', async () => {
for (const args of [undefined, {}, { siteId: 'all' }, { siteId: ' ' }]) {
await expect(handler('jira:listFavouriteFilters')(undefined, args)).rejects.toThrow()
}
expect(mocks.listFavouriteFilters).not.toHaveBeenCalled()
const error = new Error('catalogue unavailable')
mocks.listFavouriteFilters.mockRejectedValueOnce(error)
await expect(
handler('jira:listFavouriteFilters')(undefined, { siteId: ' site-1 ' })
).rejects.toBe(error)
expect(mocks.listFavouriteFilters).toHaveBeenCalledExactlyOnceWith('site-1')
})
it('retains all-sites selection and site normalization', async () => {
await handler('jira:listProjects')(undefined, { siteId: ' all ' })
expect(mocks.listProjects).toHaveBeenLastCalledWith('all')
await handler('jira:listProjects')(undefined, { siteId: ' ' })
expect(mocks.listProjects).toHaveBeenLastCalledWith(undefined)
await handler('jira:listPriorities')(undefined, { siteId: ' site-1 ' })
expect(mocks.listPriorities).toHaveBeenCalledWith('site-1')
})
it('preserves invalid project and issue type sentinels', async () => {
await expect(
handler('jira:listIssueTypes')(undefined, { projectIdOrKey: ' ' })
).resolves.toEqual([])
await expect(
handler('jira:listCreateFields')(undefined, { projectIdOrKey: 'ABC', issueTypeId: 1 })
).resolves.toEqual([])
expect(mocks.listIssueTypes).not.toHaveBeenCalled()
expect(mocks.listCreateFields).not.toHaveBeenCalled()
})
it('forwards trimmed project and issue type identifiers to the same site', async () => {
await handler('jira:listIssueTypes')(undefined, {
projectIdOrKey: ' ABC ',
siteId: ' site-1 '
})
expect(mocks.listIssueTypes).toHaveBeenCalledWith('ABC', 'site-1')
await handler('jira:listCreateFields')(undefined, {
projectIdOrKey: ' ABC ',
issueTypeId: ' 10001 ',
siteId: ' site-1 '
})
expect(mocks.listCreateFields).toHaveBeenCalledWith('ABC', '10001', 'site-1')
})
})
@@ -1,5 +1,4 @@
import { describe, expect, it } from 'vitest'
import { canonicalWorktreeIdentity } from '../../shared/worktree/identity'
import type { GitWorktreeInfo } from '../../shared/worktree/types'
import { mergeWorktree } from './worktree-metadata-merge'
@@ -52,55 +51,4 @@ describe('mergeWorktree identity projection', () => {
expect(worktree.displayNameMode).toBe('fixed')
})
it('publishes canonical identity when host and instance metadata are known', () => {
const worktree = mergeWorktree('repo-1', git, {
instanceId: '11111111-1111-4111-8111-111111111111',
hostId: 'ssh:build-box',
displayName: 'Feature',
comment: '',
linkedIssue: null,
linkedPR: null,
linkedLinearIssue: null,
isArchived: false,
isUnread: false,
isPinned: false,
sortOrder: 0,
lastActivityAt: 0
})
expect(worktree.identity).toEqual({
key: canonicalWorktreeIdentity({
worktreeId: worktree.id,
executionHostId: 'ssh:build-box',
instanceId: '11111111-1111-4111-8111-111111111111'
}),
executionHostId: 'ssh:build-box',
instanceId: '11111111-1111-4111-8111-111111111111'
})
})
it('omits canonical identity for legacy metadata without a proven host', () => {
const worktree = mergeWorktree('repo-1', git, undefined)
expect(worktree.identity).toBeUndefined()
})
it('projects optional GitHub PR suppression metadata', () => {
const worktree = mergeWorktree('repo-1', git, {
displayName: 'Feature',
comment: '',
linkedIssue: null,
linkedPR: null,
suppressedGitHubPR: 42,
linkedLinearIssue: null,
isArchived: false,
isUnread: false,
isPinned: false,
sortOrder: 0,
lastActivityAt: 0
})
expect(worktree.suppressedGitHubPR).toBe(42)
})
})
@@ -26,12 +26,6 @@ describe('readLinkPreviewMetadata', () => {
})
})
it('decodes the named entities titles use', () => {
const html = `<title>Docs&nbsp;&ndash;&nbsp;Guide &hellip; &ldquo;Orca&rdquo;</title>`
expect(readLinkPreviewMetadata(html, PAGE_URL).title).toBe('Docs – Guide … “Orca”')
})
it('keeps a > inside a quoted attribute value as part of the value', () => {
const html = `<meta content="Home > Docs" property="og:description"><meta property="og:title" content="A > B">`
@@ -14,10 +14,6 @@ describe('local worktree metadata prune gate', () => {
__resetLocalWorktreeMetadataPruneGateForTests()
})
it('is due for a repo it has never seen', () => {
expect(isLocalWorktreeMetadataPruneDue('repo-1')).toBe(true)
})
it('stays undue indefinitely once a pass ran and nothing changed', () => {
markLocalWorktreeMetadataPruneStarted('repo-1')
@@ -56,14 +52,6 @@ describe('local worktree metadata prune gate', () => {
expect(isLocalWorktreeMetadataPruneDue('repo-1')).toBe(false)
})
it('does not re-arm on the first listing it observes', () => {
markLocalWorktreeMetadataPruneStarted('repo-1')
recordLocalWorktreeListingForPruneGate('repo-1', ['/a'])
expect(isLocalWorktreeMetadataPruneDue('repo-1')).toBe(false)
})
it('re-arms when a later listing differs from the one the last pass ran against', () => {
recordLocalWorktreeListingForPruneGate('repo-1', ['/a', '/b'])
markLocalWorktreeMetadataPruneStarted('repo-1')
@@ -1,74 +0,0 @@
import { beforeEach, describe, expect, it, vi } from 'vitest'
const mocks = await vi.hoisted(async () => {
const { createSshIpcMocks } = await import('../ipc/ssh/ssh-ipc-module-mocks')
return createSshIpcMocks()
})
vi.mock('../ssh/config/ssh-config-host-picker', () => mocks.sshConfigHostPicker)
vi.mock('electron', () => mocks.electron)
vi.mock('../ssh/connection/ssh-connection-store', () => mocks.sshConnectionStore)
vi.mock('../ipc/ssh/ssh-host-server-connect', () => mocks.hostServerConnect)
vi.mock('../ssh/connection/ssh-connection-manager', () => mocks.sshConnectionManager)
vi.mock('../ssh/ssh-channel-multiplexer', () => mocks.sshChannelMultiplexer)
vi.mock('../ssh/port-forwarding/ssh-port-forward', () => mocks.sshPortForward)
vi.mock('../ssh/ssh-port-scanner', () => mocks.sshPortScanner)
import { resetSshHandlerStateForTests } from '../ipc/ssh/ssh'
import {
connectRegisteredSshTarget,
listRegisteredSshTargets,
SSH_TARGET_MANAGEMENT_UNSERVED_MESSAGE
} from '../ssh/targets/ssh-target-registry'
import { createSshIpcHarness } from '../ipc/ssh/ssh-ipc-test-harness'
import type { SshTarget } from '../../shared/ssh-types'
import { mainProcessState } from './main-process-state'
import { registerHeadlessServeSshHandlers } from './headless-serve-ssh-registration'
const { mockSshStore, mockConnectionManager } = mocks
const target: SshTarget = {
id: 'ssh-1',
label: 'build box',
host: 'build.example',
port: 22,
username: 'deploy'
}
describe('SSH registration on a headless `orca serve`', () => {
const harness = createSshIpcHarness(mocks)
beforeEach(async () => {
await harness.reset()
await resetSshHandlerStateForTests()
mainProcessState.mainWindow = null
})
it('reproduces the unregistered host before bootstrap (#25886, #8489)', async () => {
expect(listRegisteredSshTargets()).toEqual([])
await expect(connectRegisteredSshTarget('ssh-1')).rejects.toThrow(
SSH_TARGET_MANAGEMENT_UNSERVED_MESSAGE
)
})
it('lists and connects persisted SSH targets with no window', async () => {
mockSshStore.listTargets.mockReturnValue([target])
mockSshStore.getTarget.mockReturnValue(target)
mockConnectionManager.connect.mockResolvedValue({})
mockConnectionManager.getState.mockReturnValue({
targetId: 'ssh-1',
status: 'connected',
error: null,
reconnectAttempt: 0
})
// oxlint-disable-next-line typescript/consistent-type-assertions -- SAFETY: the SSH harness store implements every method registerSshHandlers reads.
registerHeadlessServeSshHandlers(harness.mockStore as never, {} as never)
expect(listRegisteredSshTargets()).toEqual([target])
await expect(connectRegisteredSshTarget('ssh-1')).resolves.toMatchObject({
targetId: 'ssh-1',
status: 'connected'
})
expect(harness.mockWindow.webContents.send).not.toHaveBeenCalled()
})
})
+1 -38
View File
@@ -1,22 +1,7 @@
import { describe, expect, it } from 'vitest'
import {
isWslConfInteropDisabled,
parseWslInteropProbeOutput,
parseWslInteropRepairOutput,
WSL_INTEROP_PROBE_SCRIPT,
WSL_INTEROP_REPAIR_SCRIPT
} from './wsl-interop-registration'
import { isWslConfInteropDisabled, parseWslInteropProbeOutput } from './wsl-interop-registration'
describe('parseWslInteropProbeOutput', () => {
it('reads present, unmounted and garbage', () => {
expect(parseWslInteropProbeOutput('orca-wsl-interop:present\n')).toEqual({ state: 'present' })
expect(parseWslInteropProbeOutput('motd\r\norca-wsl-interop:unmounted\r\n')).toEqual({
state: 'unmounted'
})
expect(parseWslInteropProbeOutput('')).toEqual({ state: 'unknown' })
expect(parseWslInteropProbeOutput('Exec format error')).toEqual({ state: 'unknown' })
})
it('carries the wsl.conf interop setting when the entry is missing', () => {
expect(
parseWslInteropProbeOutput(
@@ -47,25 +32,3 @@ describe('isWslConfInteropDisabled', () => {
expect(isWslConfInteropDisabled(conf)).toBe(expected)
})
})
describe('scripts', () => {
it('accepts either interop entry name and never flushes binfmt', () => {
for (const script of [WSL_INTEROP_PROBE_SCRIPT, WSL_INTEROP_REPAIR_SCRIPT]) {
expect(script).toContain('/proc/sys/fs/binfmt_misc/WSLInterop-late')
expect(script).not.toMatch(/systemd-binfmt|\/status/)
// --exec passes argv verbatim, but keep the payload free of guest expansions anyway.
expect(script).not.toContain('$')
}
expect(WSL_INTEROP_REPAIR_SCRIPT).toContain(
"printf ':WSLInterop:M::MZ::/init:P' > /proc/sys/fs/binfmt_misc/register"
)
// A failed write must not decide the verdict; only the re-check does.
expect(WSL_INTEROP_REPAIR_SCRIPT).not.toContain('|| exit')
})
it('parses repair results', () => {
expect(parseWslInteropRepairOutput('orca-wsl-interop:repaired\n')).toBe('repaired')
expect(parseWslInteropRepairOutput('orca-wsl-interop:present\n')).toBe('present')
expect(parseWslInteropRepairOutput('sh: permission denied')).toBe('unknown')
})
})
@@ -1,7 +1,7 @@
import { describe, expect, it } from 'vitest'
import { PLUGIN_MANIFEST_V2_SINCE } from './plugin-schema-field-docs'
import { parsePluginManifest } from './plugin-manifest'
import { formatPluginSchemaPath, pluginSchemaIssueLines } from './plugin-schema-issues'
import { pluginSchemaIssueLines } from './plugin-schema-issues'
function v2Manifest(overrides: Record<string, unknown> = {}): Record<string, unknown> {
return {
@@ -25,13 +25,6 @@ function manifestError(raw: unknown): string {
}
describe('plugin schema issues', () => {
it('formats paths with bracketed indexes', () => {
expect(formatPluginSchemaPath(['contributes', 'themes', 0, 'path'])).toBe(
'contributes.themes[0].path'
)
expect(formatPluginSchemaPath([])).toBe('(root)')
})
it('reports every mistake in one pass with author-facing wording', () => {
const error = manifestError(
v2Manifest({
@@ -58,21 +51,6 @@ describe('plugin schema issues', () => {
])
})
it('keeps messages the schema states itself', () => {
expect(manifestError(v2Manifest({ engines: { orca: '^1.4.0' } }))).toBe(
'engines.orca: must be a ">=x.y.z" version range'
)
expect(manifestError(v2Manifest({ execution: 'trusted-worker' }))).toBe(
'main: trusted-worker requires a Node entry'
)
})
it('names the supported manifest formats', () => {
expect(manifestError(v2Manifest({ manifestVersion: 7 }))).toBe(
'manifestVersion: must be one of 1, 2'
)
})
it('dedupes identical lines and caps the count', () => {
const issue = (index: number) => ({
code: 'custom' as const,