Files
orca/tests/e2e/global-setup-cli-artifact.unit.test.ts
T
ff27338299 refactor(ssh): connect fails for hosts orcad can't serve; remove the relay client path (#27214)
* wip: connect fails for hosts the managed server can't serve; remove relay session, deploy and relay UI

* wip: delete relay-only client modules left unreachable, prune their tests and gates

* wip: format

* wip: exhaustive unserved message

* wip: drop relay attestation test for the deleted ownership proof

* fix: prune stale baselines; type the test transport stub

* fix(ssh): census proves leftover relay leases; name the remedy for older terminals; translate every connect-failure surface

* test(ssh): leftover leases defer to the host census

* test(e2e): remove relay-path SSH e2e specs and their CI lanes

* test(e2e): drop the auto-convert case that built its relay era through a live relay

* test(e2e): mark relay-era browser and catalog journeys fixme until they seed a profile

* test(e2e): seed relay-era browser and catalog journeys from a saved profile

The three journeys built their old-version state through a connect without an orcad template, which now refuses the host. They now start from a seeded relay-era profile, so the first connect converts the host as an upgrading user's would.

* chore(ci): drop shard timings for the deleted relay tests

* test(e2e): carry a relay-era login cookie across the browser conversion; own every launch

* test(ci): drop the deleted SSH layout oracle from its route

* test(e2e): open the retained browser after conversion, retrying a pre-connect card

* test(e2e): bind the relay-era browser partition before seeding its cookie

A relay-era build always recorded the partition binding before a page stored
data in it. Seeding the cookie into an unbound partition made the binding store
refuse it (browser_route_partition_binding_store_invalid), so the retained tab
showed the generic routing card and Retry could never clear it.

Co-Authored-By: Claude <noreply@anthropic.com>

---------

Co-authored-by: m4air <m4air@Mac.localdomain>
Co-authored-by: Claude <noreply@anthropic.com>
2026-10-10 22:10:33 -07:00

96 lines
3.1 KiB
TypeScript

import path from 'node:path'
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest'
const fixture = vi.hoisted(() => ({
exec: vi.fn(),
exists: vi.fn(),
write: vi.fn()
}))
vi.mock('node:child_process', () => ({ execSync: fixture.exec }))
vi.mock('node:fs', () => ({
existsSync: fixture.exists,
mkdirSync: vi.fn(),
mkdtempSync: (prefix: string) => `${prefix}fixture`,
realpathSync: (value: string) => value,
writeFileSync: fixture.write
}))
vi.mock('./helpers/docker-ssh-relay-image', () => ({ prepareDockerSshRelayImage: vi.fn() }))
import globalSetup, { workerTestRepositoryPathFile } from './global-setup'
beforeEach(() => {
vi.resetAllMocks()
fixture.exists.mockReturnValue(true)
for (const name of [
'SKIP_BUILD',
'ORCA_E2E_WEB_CLIENT',
'ORCA_E2E_SSH_DOCKER',
'ORCA_E2E_SKILL_STAGING',
'ORCA_E2E_TEST_REPO_PATH_FILE'
]) {
vi.stubEnv(name, '')
}
})
afterEach(() => vi.unstubAllEnvs())
function commands(): string[] {
return fixture.exec.mock.calls.map(([command]) => command)
}
describe('E2E shared CLI artifact', () => {
it('keeps worker publications separate from the run seed and from other workers', () => {
const runPath = path.join('temporary', 'run.txt')
expect(workerTestRepositoryPathFile(runPath)).toBe(runPath)
expect(workerTestRepositoryPathFile(runPath, '0')).not.toBe(runPath)
expect(workerTestRepositoryPathFile(runPath, '0')).not.toBe(
workerTestRepositoryPathFile(runPath, '1')
)
expect(() => workerTestRepositoryPathFile(runPath, '../other')).toThrow(
'Invalid Playwright worker index'
)
})
it('repairs downloaded permissions and installs the local launcher without recompiling', () => {
vi.stubEnv('SKIP_BUILD', '1')
globalSetup()
const prepare = commands().find((command) => command.includes('prepare:cli-output'))
expect(prepare).toBe('pnpm run prepare:cli-output')
expect(commands()).not.toContain('pnpm run build:cli')
expect(commands()).toContain('git init')
expect(fixture.exec.mock.calls.find(([command]) => command === prepare)?.[1]).toEqual({
cwd: process.cwd(),
stdio: 'inherit',
timeout: 120_000
})
})
it('builds a missing CLI even when the other artifacts exist', () => {
vi.stubEnv('SKIP_BUILD', '1')
fixture.exists.mockImplementation(
(file) => file !== path.join(process.cwd(), 'out', 'cli', 'index.js')
)
globalSetup()
expect(commands()).toContain('pnpm run build:cli')
expect(commands().some((command) => command.includes('prepare:cli-output'))).toBe(false)
})
it('rebuilds existing artifacts when reuse is not requested', () => {
globalSetup()
expect(commands()).toContain('npx electron-vite build --mode e2e')
expect(commands()).toContain('pnpm run build:cli')
})
it('fails setup if the downloaded CLI cannot be verified', () => {
vi.stubEnv('SKIP_BUILD', '1')
fixture.exec.mockImplementation((command) => {
if (command.includes('prepare:cli-output')) {
throw new Error('Invalid CLI artifact')
}
})
expect(() => globalSetup()).toThrow('Invalid CLI artifact')
expect(commands()).not.toContain('git init')
})
})