mirror of
https://github.com/stablyai/orca.git
synced 2026-11-19 04:23:57 +00:00
test: drop redundant form driver and lease recipes
This commit is contained in:
@@ -1,6 +1,5 @@
|
||||
import assert from 'node:assert/strict'
|
||||
import { test } from 'node:test'
|
||||
import { createAccessTokenSource } from './gcloud-access-token.mjs'
|
||||
import {
|
||||
CloudSqlRolloutLease,
|
||||
LEASE_TTL_MS,
|
||||
@@ -102,26 +101,6 @@ const HOLDER = {
|
||||
runAttempt: '1'
|
||||
}
|
||||
|
||||
test('acquires a lease on an empty object with ifGenerationMatch=0', async () => {
|
||||
const storage = fakeStorage()
|
||||
const claim = await leaseFor(storage).acquire(HOLDER)
|
||||
|
||||
assert.equal(claim.state, 'created')
|
||||
const upload = storage.state.requests.find((request) => request.path.startsWith('/upload/'))
|
||||
assert.equal(upload.search.get('ifGenerationMatch'), '0')
|
||||
assert.equal(upload.search.get('name'), OBJECT)
|
||||
assert.deepEqual(storage.state.object.body, {
|
||||
repository: 'stablyai/orca-cloud',
|
||||
workflow: 'Deploy Relay Production Same-Cap',
|
||||
run_id: '42',
|
||||
run_url: 'https://github.com/stablyai/orca-cloud/actions/runs/42',
|
||||
run_attempt: '1',
|
||||
acquired_at: NOW,
|
||||
expires_at: NOW + LEASE_TTL_MS,
|
||||
holder_key: 'stablyai/orca-cloud/42'
|
||||
})
|
||||
})
|
||||
|
||||
test('refuses a live lease held by another run and never writes', async () => {
|
||||
const storage = fakeStorage({
|
||||
object: {
|
||||
@@ -247,19 +226,6 @@ test('treats an unreadable record as held, not free', async () => {
|
||||
assert.equal(storage.state.object.generation, '1500')
|
||||
})
|
||||
|
||||
test('reports a 412 during acquisition as a conflict', async () => {
|
||||
const storage = fakeStorage({
|
||||
faults: [{ when: (request) => request.path.startsWith('/upload/'), status: 412 }]
|
||||
})
|
||||
|
||||
const error = await leaseFor(storage)
|
||||
.acquire(HOLDER)
|
||||
.catch((thrown) => thrown)
|
||||
|
||||
assert.ok(error instanceof LeaseConflict)
|
||||
assert.match(error.message, /changed concurrently/)
|
||||
})
|
||||
|
||||
test('renewal rewrites only expires_at on the observed generation', async () => {
|
||||
const storage = fakeStorage()
|
||||
const lease = leaseFor(storage)
|
||||
@@ -287,23 +253,3 @@ test('renewal stops once the object belongs to someone else', async () => {
|
||||
reason: 'foreign'
|
||||
})
|
||||
})
|
||||
|
||||
test('the access token source re-mints only after the reuse window', () => {
|
||||
let clock = 0
|
||||
let mints = 0
|
||||
const source = createAccessTokenSource({
|
||||
run: () => `token-${++mints}`,
|
||||
now: () => clock
|
||||
})
|
||||
|
||||
assert.equal(source(), 'token-1')
|
||||
clock = 39 * 60 * 1_000
|
||||
assert.equal(source(), 'token-1')
|
||||
clock = 41 * 60 * 1_000
|
||||
assert.equal(source(), 'token-2')
|
||||
})
|
||||
|
||||
test('the access token source rejects an empty gcloud response', () => {
|
||||
const source = createAccessTokenSource({ run: () => '' })
|
||||
assert.throws(() => source(), /empty token/)
|
||||
})
|
||||
|
||||
@@ -7142,7 +7142,6 @@
|
||||
"tests/e2e/helpers/remote-skill-cloud-fixture.unit.test.ts": 269,
|
||||
"tests/e2e/helpers/wsl-terminate-retry.unit.test.ts": 60,
|
||||
"tests/e2e/host-agent-launch-preferences-work.unit.test.ts": 3882,
|
||||
"tests/e2e/host-agent-launch-settings-hook-bookkeeping.unit.test.ts": 21972,
|
||||
"tests/e2e/host-cold-park-remote-subscriber.unit.test.ts": 5314,
|
||||
"tests/e2e/launch-agent-background-session-remote.unit.test.ts": 1016,
|
||||
"tests/e2e/linear-cli-recovery.unit.test.ts": 7592,
|
||||
|
||||
@@ -60,7 +60,6 @@ const NODE_RUNTIME_INCLUDE = [
|
||||
'src/main/runtime/construction/orca-runtime.test.ts',
|
||||
'src/main/runtime/workspaces/startup/worktree-agent-first-surface.test.ts',
|
||||
'src/main/runtime/client/settings/runtime-client-agent-launch-settings-durability.test.ts',
|
||||
'tests/e2e/host-agent-launch-settings-hook-bookkeeping.unit.test.ts',
|
||||
'src/cli/**/*.test.ts',
|
||||
'src/main/persistence/**/*.test.ts',
|
||||
'src/main/persistence*.test.ts',
|
||||
|
||||
@@ -1,103 +0,0 @@
|
||||
// @vitest-environment happy-dom
|
||||
import { createElement } from 'react'
|
||||
import { cleanup, fireEvent, render, screen, waitFor } from '@testing-library/react'
|
||||
import { afterEach, describe, expect, it, vi } from 'vitest'
|
||||
import {
|
||||
deferred,
|
||||
fixture
|
||||
} from '../../src/main/persistence/loading-store/profile-writing/profile-state-delayed-authority-fixture'
|
||||
import { RuntimeClientSettingsController } from '../../src/main/runtime/client/settings/runtime-client-settings'
|
||||
import { HostAgentLaunchSettings } from '../../src/renderer/src/components/settings/agents/launch/HostAgentLaunchSettings'
|
||||
import { TooltipProvider } from '../../src/renderer/src/components/ui/tooltip'
|
||||
import { getAgentCatalog } from '../../src/renderer/src/lib/agent-catalog/agent-catalog'
|
||||
|
||||
const transport = vi.hoisted(() => ({ read: vi.fn(), mutate: vi.fn() }))
|
||||
const hooks = vi.hoisted(() => ({ apply: vi.fn(async () => {}) }))
|
||||
vi.mock('../../src/main/telemetry/client', () => ({ track: vi.fn() }))
|
||||
vi.mock('../../src/main/telemetry/cohort-classifier', () => ({
|
||||
getCohortAtEmit: () => ({ nth_repo_added: 2 })
|
||||
}))
|
||||
vi.mock('../../src/main/ssh/config/ssh-config-parser', () => ({
|
||||
loadUserSshConfig: () => ({ hosts: [] }),
|
||||
sshConfigHostsToTargets: () => []
|
||||
}))
|
||||
vi.mock('../../src/main/agent-hooks/installation/managed-agent-hook-controls', () => ({
|
||||
applyAgentStatusHooksEnabled: hooks.apply
|
||||
}))
|
||||
vi.mock(
|
||||
'../../src/renderer/src/runtime/agent-launch-settings/agent-launch-settings-transport',
|
||||
() => ({
|
||||
readHostAgentLaunchSettings: transport.read,
|
||||
mutateHostAgentLaunchSettings: transport.mutate,
|
||||
hostSupportsLaunchChoices: async () => false,
|
||||
hostSupportsOwnChatPermissions: async () => true,
|
||||
hostSupportsAutoPermissions: async () => true,
|
||||
hostSupportsNativeChatPermissions: async () => true
|
||||
})
|
||||
)
|
||||
vi.mock('@/hooks/useDetectedAgents', () => ({
|
||||
useDetectedAgents: () => ({
|
||||
detectedIds: ['claude'],
|
||||
detectionFailed: false,
|
||||
isRefreshing: false,
|
||||
refresh: vi.fn()
|
||||
})
|
||||
}))
|
||||
|
||||
afterEach(cleanup)
|
||||
describe('host form and committed-settings contract', () => {
|
||||
it('commits a following form edit while availability hook bookkeeping is still pending', async () => {
|
||||
const { store, readState } = await fixture()
|
||||
const controller = new RuntimeClientSettingsController(store)
|
||||
await controller.mutateAgentLaunch({
|
||||
type: 'arguments',
|
||||
agent: 'claude',
|
||||
value: '--host-marker'
|
||||
})
|
||||
transport.read.mockResolvedValue(controller.getAgentLaunch())
|
||||
transport.mutate.mockImplementation((_owner, mutation) =>
|
||||
controller.mutateAgentLaunch(mutation)
|
||||
)
|
||||
const started = deferred<void>()
|
||||
const finish = deferred<void>()
|
||||
hooks.apply.mockImplementationOnce(async () => {
|
||||
started.resolve()
|
||||
await finish.promise
|
||||
})
|
||||
render(
|
||||
createElement(
|
||||
TooltipProvider,
|
||||
null,
|
||||
createElement(HostAgentLaunchSettings, {
|
||||
environmentId: 'ssh-host',
|
||||
pairingRevision: 17,
|
||||
hostName: 'SSH host',
|
||||
renderPermissions: () => createElement('span')
|
||||
})
|
||||
)
|
||||
)
|
||||
await screen.findByDisplayValue('--host-marker')
|
||||
const label = getAgentCatalog().find((agent) => agent.id === 'claude')?.label
|
||||
fireEvent.click(screen.getByRole('switch', { name: `${label} availability` }))
|
||||
try {
|
||||
await started.promise
|
||||
expect(readState().settings.disabledTuiAgents).toContain('claude')
|
||||
const args = screen.getByDisplayValue('--host-marker')
|
||||
fireEvent.change(args, { target: { value: '--unblocked-followup' } })
|
||||
fireEvent.blur(args)
|
||||
await waitFor(() =>
|
||||
expect(readState().settings.agentDefaultArgs.claude).toBe('--unblocked-followup')
|
||||
)
|
||||
await waitFor(() =>
|
||||
expect(screen.getByDisplayValue('--unblocked-followup')).toHaveProperty('readOnly', false)
|
||||
)
|
||||
expect(transport.mutate).toHaveBeenCalledTimes(2)
|
||||
expect(screen.queryByRole('alert')).toBeNull()
|
||||
} finally {
|
||||
finish.resolve()
|
||||
await waitFor(() =>
|
||||
expect(readState().settings.agentDefaultArgs.claude).toBe('--unblocked-followup')
|
||||
)
|
||||
}
|
||||
})
|
||||
})
|
||||
Reference in New Issue
Block a user