mirror of
https://github.com/stablyai/orca.git
synced 2026-11-19 04:23:57 +00:00
test: remove six low-value label and preparation suites (#43545)
Co-authored-by: OrcaWin <293788423+OrcaWin@users.noreply.github.com>
This commit is contained in:
@@ -2882,11 +2882,9 @@
|
||||
"src/main/workspaces/creation/worktree-create-candidates.test.ts": 47,
|
||||
"src/main/workspaces/creation/worktree-create-in-flight.test.ts": 252,
|
||||
"src/main/workspaces/creation/preparation/worktree-create-preparation-cancellation.test.ts": 407,
|
||||
"src/main/workspaces/creation/preparation/worktree-create-preparation-claim.test.ts": 52,
|
||||
"src/main/workspaces/creation/preparation/worktree-create-preparation-wsl-root.test.ts": 402,
|
||||
"src/main/workspaces/creation/preparation/worktree-create-preparation.test.ts": 393,
|
||||
"src/main/workspaces/catalog/worktree-identity-persistence.test.ts": 1994,
|
||||
"src/main/workspaces/creation/preparation/worktree-preparation-tip-refresh.test.ts": 574,
|
||||
"src/main/workspaces/removal/worktree-removal-close-records.test.ts": 1941,
|
||||
"src/main/workspaces/removal/worktree-removal-safety.test.ts": 290,
|
||||
"src/main/workspaces/removal/worktree-removal-session-partition-fencing.test.ts": 2627,
|
||||
|
||||
@@ -1,39 +0,0 @@
|
||||
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest'
|
||||
|
||||
const wsl = vi.hoisted(() => ({
|
||||
readRunningHomes: vi.fn(async () => ({
|
||||
homes: ['\\\\wsl.localhost\\Ubuntu\\home\\u', '\\\\wsl.localhost\\Debian\\home\\u'],
|
||||
confirmed: true
|
||||
}))
|
||||
}))
|
||||
|
||||
vi.mock('../../wsl/discovery/distro-catalog', () => ({
|
||||
hasCachedWslDistros: () => true,
|
||||
getCachedWslDistros: () => ['Ubuntu', 'Debian']
|
||||
}))
|
||||
vi.mock('../../wsl/discovery/wsl-home-unless-stopped', () => ({
|
||||
readRunningWslHomeDirsUnlessStopped: wsl.readRunningHomes,
|
||||
listLastKnownRunningWslHomeDirs: async () => []
|
||||
}))
|
||||
|
||||
import { getAiVaultWslScanHomeDirs } from './ai-vault-scan-roots'
|
||||
|
||||
const realPlatform = process.platform
|
||||
|
||||
// Review repro for #43496: sessions in a running distro must never vanish because no saved
|
||||
// project, tab or mapped drive names it (per-tab WSL shells, worktrees elsewhere, `net use`).
|
||||
describe('AI vault WSL scan homes', () => {
|
||||
beforeEach(() => {
|
||||
Object.defineProperty(process, 'platform', { value: 'win32' })
|
||||
})
|
||||
afterEach(() => {
|
||||
Object.defineProperty(process, 'platform', { value: realPlatform })
|
||||
})
|
||||
|
||||
it('scans every running distro, whatever the saved projects use', async () => {
|
||||
await expect(getAiVaultWslScanHomeDirs()).resolves.toEqual([
|
||||
'\\\\wsl.localhost\\Ubuntu\\home\\u',
|
||||
'\\\\wsl.localhost\\Debian\\home\\u'
|
||||
])
|
||||
})
|
||||
})
|
||||
@@ -1,55 +0,0 @@
|
||||
import { afterEach, describe, expect, it } from 'vitest'
|
||||
import { existsSync, mkdtempSync, readFileSync, rmSync } from 'node:fs'
|
||||
import { tmpdir } from 'node:os'
|
||||
import { join } from 'node:path'
|
||||
import { agentSessionRecordFixture } from '../../../../shared/agent-session/lifecycle/records/agent-session-record.test-fixture'
|
||||
import type { AgentSessionRecord } from '../../../../shared/agent-session/lifecycle/agent-session-record'
|
||||
import { createPiRpcLaunchResolver } from '../../../runtime/agent-session/launch/structured-agent-launch-composition.test-support'
|
||||
import { PI_NATIVE_CHAT_SUBAGENTS_STATUS_KEY } from '../../managed-extensions/agent-status/agent-status-subagent-roster-source'
|
||||
import { ORCA_PI_AGENT_STATUS_EXTENSION_FILE } from '../../managed-extensions/agent-status/agent-status-extension-source'
|
||||
|
||||
const accountDirs: string[] = []
|
||||
afterEach(() => {
|
||||
for (const dir of accountDirs.splice(0)) {
|
||||
rmSync(dir, { recursive: true, force: true })
|
||||
}
|
||||
})
|
||||
|
||||
async function launchPi(managedExtensionsEnabled: boolean): Promise<string> {
|
||||
const accountDir = mkdtempSync(join(tmpdir(), 'orca-pi-chat-agent-'))
|
||||
accountDirs.push(accountDir)
|
||||
const record: AgentSessionRecord = {
|
||||
...agentSessionRecordFixture(),
|
||||
provider: 'pi',
|
||||
providerHandleChain: [],
|
||||
accountHome: { variable: 'PI_CODING_AGENT_DIR', path: accountDir }
|
||||
}
|
||||
const resolve = createPiRpcLaunchResolver({
|
||||
managedExtensionsEnabled: () => managedExtensionsEnabled,
|
||||
store: { getRecord: () => record, pinLaunchDirectory: async () => record },
|
||||
resolveWorkspacePath: async () => accountDir,
|
||||
resolveCommand: () => '/host/bin/pi',
|
||||
probeVersion: async () => ({ version: '0.84.0' }),
|
||||
ensureBackgroundWorkBridge: async () => null
|
||||
})
|
||||
await resolve({
|
||||
sessionId: record.sessionId,
|
||||
workspaceId: record.location.workspaceId,
|
||||
hostId: record.location.executionHostId,
|
||||
agent: 'pi',
|
||||
providerHandle: null
|
||||
})
|
||||
return join(accountDir, 'extensions', ORCA_PI_AGENT_STATUS_EXTENSION_FILE)
|
||||
}
|
||||
|
||||
describe('Pi chat managed extensions', () => {
|
||||
it('installs the status extension that reports subagents into the chat agent dir', async () => {
|
||||
const statusExtension = await launchPi(true)
|
||||
expect(readFileSync(statusExtension, 'utf8')).toContain(PI_NATIVE_CHAT_SUBAGENTS_STATUS_KEY)
|
||||
})
|
||||
|
||||
it('writes nothing when agent status hooks are off', async () => {
|
||||
const statusExtension = await launchPi(false)
|
||||
expect(existsSync(statusExtension)).toBe(false)
|
||||
})
|
||||
})
|
||||
@@ -1,39 +0,0 @@
|
||||
import { describe, expect, it } from 'vitest'
|
||||
import { parseAntigravityUsageEnvelope } from './antigravity-usage-response'
|
||||
|
||||
describe('parseAntigravityUsageEnvelope', () => {
|
||||
it("strips agy's 'Limit Remaining' suffix from bucket names", () => {
|
||||
const reading = parseAntigravityUsageEnvelope({
|
||||
status: 'SUCCESS',
|
||||
command: {
|
||||
name: 'usage',
|
||||
data: {
|
||||
groups: [
|
||||
{
|
||||
name: 'Gemini Models',
|
||||
buckets: [
|
||||
{
|
||||
id: 'gemini-weekly',
|
||||
name: 'Weekly Limit Remaining',
|
||||
window: 'weekly',
|
||||
remaining_fraction: 0.58
|
||||
},
|
||||
{
|
||||
id: 'gemini-5h',
|
||||
name: 'Five Hour Limit Remaining',
|
||||
window: '5h',
|
||||
remaining_fraction: 1
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
expect(reading?.buckets.map((bucket) => bucket.name)).toEqual([
|
||||
'Gemini Models · Weekly',
|
||||
'Gemini Models · Five Hour'
|
||||
])
|
||||
})
|
||||
})
|
||||
@@ -1,79 +0,0 @@
|
||||
import { describe, expect, it } from 'vitest'
|
||||
import {
|
||||
selectPreparationForCreate,
|
||||
type PreparationCandidate,
|
||||
type PreparationRequest
|
||||
} from './worktree-create-preparation-claim'
|
||||
|
||||
function candidate(overrides: Partial<PreparationCandidate> = {}): PreparationCandidate {
|
||||
return {
|
||||
repoPathKey: '/repo',
|
||||
workspaceRootKey: '/workspace',
|
||||
wslDistro: '',
|
||||
baseBranch: 'origin/main',
|
||||
canonicalBase: 'refs/remotes/origin/main',
|
||||
createdAt: 1_000,
|
||||
...overrides
|
||||
}
|
||||
}
|
||||
|
||||
function request(overrides: Partial<PreparationRequest> = {}): PreparationRequest {
|
||||
return {
|
||||
repoPathKey: '/repo',
|
||||
workspaceRootKey: '/workspace',
|
||||
wslDistro: '',
|
||||
baseBranch: 'origin/main',
|
||||
canonicalBase: 'refs/remotes/origin/main',
|
||||
...overrides
|
||||
}
|
||||
}
|
||||
|
||||
describe('selectPreparationForCreate', () => {
|
||||
it('retargets a local base onto the armed remote-tracking base of the same branch', () => {
|
||||
const selection = selectPreparationForCreate(
|
||||
[candidate()],
|
||||
request({ baseBranch: 'main', canonicalBase: 'refs/heads/main' })
|
||||
)
|
||||
|
||||
expect(selection).toEqual({
|
||||
kind: 'retarget',
|
||||
candidate: candidate(),
|
||||
canonicalBase: 'refs/heads/main'
|
||||
})
|
||||
})
|
||||
|
||||
it('refuses to retarget onto a different branch', () => {
|
||||
const selection = selectPreparationForCreate(
|
||||
[candidate()],
|
||||
request({ baseBranch: 'origin/release', canonicalBase: 'refs/remotes/origin/release' })
|
||||
)
|
||||
|
||||
expect(selection).toEqual({ kind: 'miss', reason: 'base_mismatch' })
|
||||
})
|
||||
|
||||
it('refuses to retarget onto a bare commit id, whose divergence is unbounded', () => {
|
||||
const selection = selectPreparationForCreate(
|
||||
[candidate()],
|
||||
request({ baseBranch: '1f2e3d4c5b6a7988', canonicalBase: '1f2e3d4c5b6a7988' })
|
||||
)
|
||||
|
||||
expect(selection).toEqual({ kind: 'miss', reason: 'base_mismatch' })
|
||||
})
|
||||
|
||||
it('names the key field that disagreed', () => {
|
||||
expect(selectPreparationForCreate([], request())).toEqual({
|
||||
kind: 'miss',
|
||||
reason: 'none_armed'
|
||||
})
|
||||
expect(
|
||||
selectPreparationForCreate([candidate()], request({ repoPathKey: '/other-repo' }))
|
||||
).toEqual({ kind: 'miss', reason: 'repo_mismatch' })
|
||||
expect(selectPreparationForCreate([candidate()], request({ wslDistro: 'Ubuntu' }))).toEqual({
|
||||
kind: 'miss',
|
||||
reason: 'wsl_distro_mismatch'
|
||||
})
|
||||
expect(
|
||||
selectPreparationForCreate([candidate()], request({ workspaceRootKey: '/other' }))
|
||||
).toEqual({ kind: 'miss', reason: 'workspace_root_mismatch' })
|
||||
})
|
||||
})
|
||||
@@ -1,211 +0,0 @@
|
||||
import { describe, expect, it, vi } from 'vitest'
|
||||
import {
|
||||
flushBackgroundWork,
|
||||
mocks,
|
||||
repo,
|
||||
store
|
||||
} from '../../../__mocks__/worktree-create-preparation'
|
||||
import { WorktreePreparationLockOwnershipError } from '../../../git/worktrees/creation/worktree-preparation-lock'
|
||||
import {
|
||||
consumePreparedWorktreeCreate,
|
||||
prepareWorktreeCreateForRepo
|
||||
} from './worktree-create-preparation'
|
||||
import {
|
||||
listPreparations,
|
||||
WORKTREE_CREATE_PREPARATION_TTL_MS
|
||||
} from './worktree-create-preparation-pool'
|
||||
|
||||
const beforeMaterialization = Promise.resolve()
|
||||
|
||||
function consume() {
|
||||
return consumePreparedWorktreeCreate({
|
||||
repoPath: repo.path,
|
||||
workspaceRoot: '/workspace',
|
||||
worktreePath: '/workspace/new',
|
||||
branch: 'new',
|
||||
baseBranch: 'origin/main'
|
||||
})
|
||||
}
|
||||
|
||||
describe('prepared checkout tip refresh', () => {
|
||||
it('lets consume join an in-flight refresh before finalizing', async () => {
|
||||
await prepareWorktreeCreateForRepo(store, repo, 'origin/main')
|
||||
let release!: () => void
|
||||
mocks.refreshTip.mockImplementationOnce(
|
||||
() => new Promise<void>((resolve) => (release = resolve))
|
||||
)
|
||||
const refresh = prepareWorktreeCreateForRepo(store, repo, 'origin/main', beforeMaterialization)
|
||||
await vi.waitFor(() => expect(mocks.refreshTip).toHaveBeenCalledOnce())
|
||||
const create = consume()
|
||||
await flushBackgroundWork()
|
||||
expect(mocks.finalize).not.toHaveBeenCalled()
|
||||
release()
|
||||
await refresh
|
||||
expect(await create).toMatchObject({ status: 'hit' })
|
||||
expect(mocks.finalize).toHaveBeenCalledOnce()
|
||||
})
|
||||
|
||||
it('cancels an expired tip refresh before cleanup', async () => {
|
||||
vi.useFakeTimers()
|
||||
let signal: AbortSignal | undefined
|
||||
try {
|
||||
await prepareWorktreeCreateForRepo(store, repo, 'origin/main')
|
||||
const entry = listPreparations()[0]!
|
||||
mocks.refreshTip.mockImplementationOnce((_repo, _path, _base, _lock, _options, operation) => {
|
||||
signal = operation.signal
|
||||
return new Promise<void>((_resolve, reject) => {
|
||||
operation.signal.addEventListener('abort', () => reject(operation.signal.reason), {
|
||||
once: true
|
||||
})
|
||||
})
|
||||
})
|
||||
const refresh = prepareWorktreeCreateForRepo(
|
||||
store,
|
||||
repo,
|
||||
'origin/main',
|
||||
beforeMaterialization
|
||||
)
|
||||
const settled = Promise.allSettled([refresh])
|
||||
await vi.advanceTimersByTimeAsync(0)
|
||||
expect(signal?.aborted).toBe(false)
|
||||
await vi.advanceTimersByTimeAsync(WORKTREE_CREATE_PREPARATION_TTL_MS)
|
||||
expect(signal?.aborted).toBe(true)
|
||||
expect((await settled)[0]?.status).toBe('rejected')
|
||||
expect(mocks.discard).toHaveBeenCalledOnce()
|
||||
expect(mocks.discard).toHaveBeenCalledWith(
|
||||
repo.path,
|
||||
entry.preparedPath,
|
||||
expect.anything(),
|
||||
entry.lockReason,
|
||||
null
|
||||
)
|
||||
expect(listPreparations()).toEqual([])
|
||||
} finally {
|
||||
vi.useRealTimers()
|
||||
}
|
||||
})
|
||||
|
||||
it('cancels an evicted tip refresh and preserves its original cleanup scope', async () => {
|
||||
await prepareWorktreeCreateForRepo(store, repo, 'origin/main')
|
||||
const entry = listPreparations()[0]!
|
||||
let signal: AbortSignal | undefined
|
||||
mocks.refreshTip.mockImplementationOnce((_repo, _path, _base, _lock, _options, operation) => {
|
||||
signal = operation.signal
|
||||
return new Promise<void>((_resolve, reject) => {
|
||||
operation.signal.addEventListener('abort', () => reject(operation.signal.reason), {
|
||||
once: true
|
||||
})
|
||||
})
|
||||
})
|
||||
const settled = Promise.allSettled([
|
||||
prepareWorktreeCreateForRepo(store, repo, 'origin/main', beforeMaterialization)
|
||||
])
|
||||
await vi.waitFor(() => expect(mocks.refreshTip).toHaveBeenCalledOnce())
|
||||
for (const base of ['origin/one', 'origin/two', 'origin/three']) {
|
||||
await prepareWorktreeCreateForRepo(store, repo, base)
|
||||
}
|
||||
expect(signal?.aborted).toBe(true)
|
||||
expect((await settled)[0]?.status).toBe('rejected')
|
||||
await flushBackgroundWork()
|
||||
expect(mocks.discard).toHaveBeenCalledOnce()
|
||||
expect(mocks.discard).toHaveBeenCalledWith(
|
||||
repo.path,
|
||||
entry.preparedPath,
|
||||
expect.anything(),
|
||||
entry.lockReason,
|
||||
null
|
||||
)
|
||||
})
|
||||
|
||||
it('preserves a checkout whose lock was taken over', async () => {
|
||||
await prepareWorktreeCreateForRepo(store, repo, 'origin/main')
|
||||
mocks.refreshTip.mockRejectedValueOnce(new WorktreePreparationLockOwnershipError())
|
||||
await expect(
|
||||
prepareWorktreeCreateForRepo(store, repo, 'origin/main', beforeMaterialization)
|
||||
).rejects.toThrow('lock owner changed')
|
||||
await flushBackgroundWork()
|
||||
expect(listPreparations()).toEqual([])
|
||||
expect(mocks.discard).not.toHaveBeenCalled()
|
||||
expect(await consume()).toMatchObject({ status: 'miss', reason: 'none_armed' })
|
||||
})
|
||||
|
||||
it('waits only for the active refresh and skips the redundant queued one', async () => {
|
||||
await prepareWorktreeCreateForRepo(store, repo, 'origin/main')
|
||||
const order: string[] = []
|
||||
let release!: () => void
|
||||
mocks.refreshTip
|
||||
.mockImplementationOnce(
|
||||
() =>
|
||||
new Promise<void>((resolve) => {
|
||||
release = () => {
|
||||
order.push('first-tip')
|
||||
resolve()
|
||||
}
|
||||
})
|
||||
)
|
||||
.mockImplementationOnce(async () => {
|
||||
order.push('second-tip')
|
||||
})
|
||||
mocks.finalize.mockImplementationOnce(async () => {
|
||||
order.push('finalize')
|
||||
return {}
|
||||
})
|
||||
const first = prepareWorktreeCreateForRepo(store, repo, 'origin/main', beforeMaterialization)
|
||||
await vi.waitFor(() => expect(mocks.refreshTip).toHaveBeenCalledOnce())
|
||||
const second = prepareWorktreeCreateForRepo(store, repo, 'origin/main', beforeMaterialization)
|
||||
await flushBackgroundWork()
|
||||
const create = consume()
|
||||
await flushBackgroundWork()
|
||||
expect(mocks.refreshTip).toHaveBeenCalledOnce()
|
||||
expect(mocks.finalize).not.toHaveBeenCalled()
|
||||
release()
|
||||
const results = await Promise.all([first, second, create])
|
||||
expect(results[2]).toMatchObject({ status: 'hit' })
|
||||
expect(order).toEqual(['first-tip', 'finalize'])
|
||||
expect(mocks.refreshTip).toHaveBeenCalledOnce()
|
||||
expect(mocks.prepareCheckout).toHaveBeenCalledOnce()
|
||||
})
|
||||
|
||||
it('discards a claimed checkout once when successive queued refreshes fail', async () => {
|
||||
await prepareWorktreeCreateForRepo(store, repo, 'origin/main')
|
||||
let rejectRefresh = (_error: Error) => {}
|
||||
mocks.refreshTip.mockImplementationOnce(
|
||||
() =>
|
||||
new Promise<void>((_resolve, reject) => {
|
||||
rejectRefresh = reject
|
||||
})
|
||||
)
|
||||
const first = prepareWorktreeCreateForRepo(store, repo, 'origin/main', beforeMaterialization)
|
||||
await vi.waitFor(() => expect(mocks.refreshTip).toHaveBeenCalledOnce())
|
||||
const second = prepareWorktreeCreateForRepo(store, repo, 'origin/main', beforeMaterialization)
|
||||
await flushBackgroundWork()
|
||||
const create = consume()
|
||||
const settled = Promise.allSettled([first, second])
|
||||
await flushBackgroundWork()
|
||||
const finishes: (() => void)[] = []
|
||||
mocks.discard.mockImplementation(
|
||||
() =>
|
||||
new Promise<void>((resolve) => {
|
||||
finishes.push(resolve)
|
||||
})
|
||||
)
|
||||
rejectRefresh(new Error('first tip reset failed'))
|
||||
await settled
|
||||
const attempt = await create
|
||||
expect(attempt).toMatchObject({ status: 'miss', reason: 'prepare_failed' })
|
||||
await vi.waitFor(() => expect(mocks.discard).toHaveBeenCalled())
|
||||
await flushBackgroundWork()
|
||||
try {
|
||||
expect(mocks.discard).toHaveBeenCalledOnce()
|
||||
expect(mocks.finalize).not.toHaveBeenCalled()
|
||||
} finally {
|
||||
for (const finish of finishes) {
|
||||
finish()
|
||||
}
|
||||
if (attempt.status === 'miss') {
|
||||
attempt.rearm?.()
|
||||
}
|
||||
await flushBackgroundWork()
|
||||
}
|
||||
})
|
||||
})
|
||||
@@ -1,51 +0,0 @@
|
||||
import { describe, expect, it } from 'vitest'
|
||||
import type {
|
||||
ProviderRateLimits,
|
||||
RateLimitBucket
|
||||
} from '../../../../../shared/agent-usage/rate-limits/rate-limit-types'
|
||||
import { getWindowSections } from './provider-usage-panel'
|
||||
import { shortUsageLabel, usedSections } from './usage-headline-sections'
|
||||
|
||||
function pool(group: string, windowName: string, windowMinutes: number): RateLimitBucket {
|
||||
return {
|
||||
name: `${group} · ${windowName}`,
|
||||
group,
|
||||
windowName,
|
||||
usedPercent: 0,
|
||||
windowMinutes,
|
||||
resetsAt: null,
|
||||
resetDescription: null
|
||||
}
|
||||
}
|
||||
|
||||
describe('Antigravity pool labels', () => {
|
||||
it('labels pools by group and window length instead of agy remaining-limit names', () => {
|
||||
const p: ProviderRateLimits = {
|
||||
provider: 'antigravity',
|
||||
session: { usedPercent: 0, windowMinutes: 300, resetsAt: null, resetDescription: null },
|
||||
weekly: { usedPercent: 0, windowMinutes: 10_080, resetsAt: null, resetDescription: null },
|
||||
buckets: [
|
||||
pool('Gemini Models', 'Weekly Limit Remaining', 10_080),
|
||||
pool('Gemini Models', 'Five Hour Limit Remaining', 300),
|
||||
pool('Claude and GPT models', 'Weekly Limit Remaining', 10_080),
|
||||
pool('Claude and GPT models', 'Five Hour Limit Remaining', 300)
|
||||
],
|
||||
updatedAt: 1_000,
|
||||
error: null,
|
||||
status: 'ok'
|
||||
}
|
||||
|
||||
expect(getWindowSections(p).map((s) => s.label)).toEqual([
|
||||
'Gemini · Weekly',
|
||||
'Gemini · 5h',
|
||||
'Claude/GPT · Weekly',
|
||||
'Claude/GPT · 5h'
|
||||
])
|
||||
expect(usedSections(p).map((s) => shortUsageLabel(p, s))).toEqual([
|
||||
'Gemini wk',
|
||||
'Gemini 5h',
|
||||
'Claude/GPT wk',
|
||||
'Claude/GPT 5h'
|
||||
])
|
||||
})
|
||||
})
|
||||
Reference in New Issue
Block a user