mirror of
https://github.com/stablyai/orca.git
synced 2026-10-30 16:47:34 +00:00
test: remove redundant checks and tighten runtime query coverage (#33583)
Co-authored-by: OrcaWin <293788423+OrcaWin@users.noreply.github.com>
This commit is contained in:
@@ -16,7 +16,7 @@ function markSshInventoryUnverifiable(
|
||||
}
|
||||
|
||||
export async function listProcessesWithHostScopeFromRuntimeController(
|
||||
deps: PtyRuntimeControllerDeps,
|
||||
deps: Pick<PtyRuntimeControllerDeps, 'runtime'>,
|
||||
opts?: { deadlineMs?: number; includeForegroundProcessEvidence?: boolean }
|
||||
): Promise<{ processes: PtyProcessInfo[]; hostIds: ExecutionHostId[] }> {
|
||||
const providerSessions = await Promise.all(
|
||||
|
||||
@@ -1,14 +1,24 @@
|
||||
import { describe, expect, it } from 'vitest'
|
||||
import { afterEach, describe, expect, it, vi } from 'vitest'
|
||||
import { listProcessesWithHostScopeFromRuntimeController } from './inventory-operations'
|
||||
import type { PtyRuntimeControllerDeps } from './controller-deps'
|
||||
import { localProvider } from '../provider/registry'
|
||||
|
||||
afterEach(() => vi.restoreAllMocks())
|
||||
|
||||
/** Inventory coverage must name only queried hosts; this process has no paired-runtime provider to query runtime: hosts. */
|
||||
describe('the hosts a PTY inventory can report having queried', () => {
|
||||
it('emits only this machine, never a paired-runtime host', async () => {
|
||||
const { hostIds } = await listProcessesWithHostScopeFromRuntimeController({
|
||||
runtime: null
|
||||
} as unknown as PtyRuntimeControllerDeps)
|
||||
it('reports the local query results and propagates a failed query', async () => {
|
||||
const listProcesses = vi
|
||||
.spyOn(localProvider, 'listProcesses')
|
||||
.mockResolvedValue([{ id: 'pty-local', cwd: '/workspace', title: 'Local terminal' }])
|
||||
|
||||
expect(hostIds).toEqual(['local'])
|
||||
expect(await listProcessesWithHostScopeFromRuntimeController({})).toEqual({
|
||||
processes: [{ id: 'pty-local', cwd: '/workspace', title: 'Local terminal' }],
|
||||
hostIds: ['local']
|
||||
})
|
||||
expect(listProcesses).toHaveBeenCalledOnce()
|
||||
|
||||
listProcesses.mockRejectedValueOnce(new Error('Local inventory unavailable'))
|
||||
await expect(listProcessesWithHostScopeFromRuntimeController({})).rejects.toThrow(
|
||||
'Local inventory unavailable'
|
||||
)
|
||||
})
|
||||
})
|
||||
|
||||
@@ -16,10 +16,16 @@ describe('migrationUnsupportedToAgentStatusEntry', () => {
|
||||
const second = migrationUnsupportedToAgentStatusEntry(unsupported)
|
||||
|
||||
expect(second).toBe(first)
|
||||
expect(first?.updatedAt).toBe(Number.MAX_SAFE_INTEGER)
|
||||
expect(first).toMatchObject({
|
||||
state: 'blocked',
|
||||
agentType: 'unknown',
|
||||
paneKey: unsupported.paneKey,
|
||||
stateStartedAt: 1234,
|
||||
updatedAt: Number.MAX_SAFE_INTEGER
|
||||
})
|
||||
})
|
||||
|
||||
it('caches null for records that cannot be projected to a pane key', () => {
|
||||
it('returns null for records that cannot be projected to a pane key', () => {
|
||||
const unsupported: MigrationUnsupportedPtyEntry = {
|
||||
ptyId: 'pty-1',
|
||||
reason: 'legacy-numeric-pane-key',
|
||||
@@ -28,6 +34,5 @@ describe('migrationUnsupportedToAgentStatusEntry', () => {
|
||||
}
|
||||
|
||||
expect(migrationUnsupportedToAgentStatusEntry(unsupported)).toBeNull()
|
||||
expect(migrationUnsupportedToAgentStatusEntry(unsupported)).toBeNull()
|
||||
})
|
||||
})
|
||||
|
||||
@@ -4,7 +4,7 @@ import { PhysicalExitTracker } from './physical-exit-tracker'
|
||||
describe('PhysicalExitTracker', () => {
|
||||
afterEach(() => vi.useRealTimers())
|
||||
|
||||
it('removes timed-out waiters while later retries can still observe exit', async () => {
|
||||
it('lets a later retry observe exit after an earlier wait times out', async () => {
|
||||
vi.useFakeTimers()
|
||||
const tracker = new PhysicalExitTracker()
|
||||
const first = tracker.waitForExit(10, () => new Error('first deadline'))
|
||||
|
||||
@@ -2,7 +2,7 @@ import { describe, expect, it } from 'vitest'
|
||||
import { pluginConsentRequestSchema } from './plugin-consent-request'
|
||||
|
||||
describe('pluginConsentRequestSchema', () => {
|
||||
it('requires the exact reviewed consent fingerprint', () => {
|
||||
it('requires a nonempty reviewed consent fingerprint', () => {
|
||||
expect(
|
||||
pluginConsentRequestSchema.safeParse({
|
||||
pluginKey: 'orca-samples.demo',
|
||||
|
||||
@@ -31,18 +31,35 @@ describe('pluginInstallSourceSchema marketplace provenance', () => {
|
||||
})
|
||||
|
||||
it('requires pinned refs and an exact marketplace snapshot commit', () => {
|
||||
const source = {
|
||||
kind: 'marketplace',
|
||||
marketplace: {
|
||||
url: 'https://github.com/stablyai/orca-plugins.git',
|
||||
ref: 'main',
|
||||
resolvedCommit: 'a'.repeat(40)
|
||||
},
|
||||
plugin: {
|
||||
url: 'https://github.com/stablyai/orca-skills.git',
|
||||
ref: 'v1.0.0'
|
||||
}
|
||||
}
|
||||
|
||||
expect(
|
||||
pluginInstallSourceSchema.safeParse({
|
||||
kind: 'marketplace',
|
||||
marketplace: {
|
||||
url: 'https://github.com/stablyai/orca-plugins.git',
|
||||
ref: '',
|
||||
resolvedCommit: 'main'
|
||||
},
|
||||
plugin: {
|
||||
url: 'https://github.com/stablyai/orca-skills.git',
|
||||
ref: ''
|
||||
}
|
||||
...source,
|
||||
marketplace: { ...source.marketplace, ref: '' }
|
||||
}).success
|
||||
).toBe(false)
|
||||
expect(
|
||||
pluginInstallSourceSchema.safeParse({
|
||||
...source,
|
||||
marketplace: { ...source.marketplace, resolvedCommit: 'main' }
|
||||
}).success
|
||||
).toBe(false)
|
||||
expect(
|
||||
pluginInstallSourceSchema.safeParse({
|
||||
...source,
|
||||
plugin: { ...source.plugin, ref: '' }
|
||||
}).success
|
||||
).toBe(false)
|
||||
})
|
||||
|
||||
@@ -2,7 +2,7 @@ import { describe, expect, it } from 'vitest'
|
||||
import { createPluginPanelCallAdmission } from './plugin-panel-call-admission'
|
||||
|
||||
describe('createPluginPanelCallAdmission', () => {
|
||||
it('shares the rate budget across panel sessions for one plugin', () => {
|
||||
it('shares the rate budget across calls for one plugin', () => {
|
||||
let now = 0
|
||||
const admission = createPluginPanelCallAdmission({
|
||||
limits: { maxMessages: 2, perMs: 1_000 },
|
||||
|
||||
@@ -15,8 +15,9 @@ describe('SharedControlReconnectScheduler', () => {
|
||||
expect(scheduler.retryNow()).toBe(true)
|
||||
expect(scheduler.retryNow()).toBe(false)
|
||||
expect(open).toHaveBeenCalledTimes(1)
|
||||
expect(vi.getTimerCount()).toBe(0)
|
||||
|
||||
await vi.advanceTimersByTimeAsync(30_000)
|
||||
await vi.advanceTimersByTimeAsync(36_000)
|
||||
expect(open).toHaveBeenCalledTimes(1)
|
||||
})
|
||||
|
||||
|
||||
@@ -1,28 +0,0 @@
|
||||
import { describe, expect, it } from 'vitest'
|
||||
import { gitLabPipelineJobsToPRChecks } from './gitlab-pipeline-checks'
|
||||
import type { GitLabPipelineJob } from './gitlab-types'
|
||||
|
||||
// GitLab job traces require the numeric jobId preserved by check-row mapping (#7732).
|
||||
function numericHandles(value: Record<string, unknown>): number[] {
|
||||
return Object.values(value).filter((v): v is number => typeof v === 'number')
|
||||
}
|
||||
|
||||
describe('#7732 GitLab pipeline job -> check row mapping', () => {
|
||||
const failedJob: GitLabPipelineJob = {
|
||||
id: 42,
|
||||
name: 'Purchase API Component Tests',
|
||||
stage: 'Component Tests',
|
||||
status: 'failed',
|
||||
webUrl: 'https://gitlab.com/acme/orca/-/jobs/42',
|
||||
duration: 31
|
||||
}
|
||||
|
||||
it('keeps the GitLab job id so the panel can fetch the job trace', () => {
|
||||
const [check] = gitLabPipelineJobsToPRChecks([failedJob])
|
||||
|
||||
expect(check.name).toBe('Component Tests: Purchase API Component Tests')
|
||||
expect(check.conclusion).toBe('failure')
|
||||
// The id is the only handle gitlab:jobTrace accepts; without it the expand path has nothing to send.
|
||||
expect(numericHandles(check)).toContain(42)
|
||||
})
|
||||
})
|
||||
@@ -1,5 +1,5 @@
|
||||
import { describe, expect, it } from 'vitest'
|
||||
import { REVIEW_REFRESH_COOLDOWN_MS, reviewRefreshIntervalMs } from './review-refresh-policy'
|
||||
import { reviewRefreshIntervalMs } from './review-refresh-policy'
|
||||
|
||||
describe('review refresh intervals', () => {
|
||||
it.each([
|
||||
@@ -22,8 +22,4 @@ describe('review refresh intervals', () => {
|
||||
] as const)('uses %j → %s', (input, expected) => {
|
||||
expect(reviewRefreshIntervalMs(input)).toBe(expected)
|
||||
})
|
||||
|
||||
it('keeps exposure cooldown separate from periodic refresh cadence', () => {
|
||||
expect(REVIEW_REFRESH_COOLDOWN_MS).toBe(10_000)
|
||||
})
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user