Files
orca/config/scripts/main-entry-facade.test.ts
T
OrcaWinandOrcaWin 633da07af5 test: audit CLI dispatch and mobile host boundaries (#32576)
* test: verify independent CLI quoting and screenshot bytes

* test: audit CLI registration and offline hook boundaries

* test: record CLI automation fence review

* test: audit computer CLI dispatch and exported files

* test: record CLI enrollment and emulator contract review

* test: audit file command path and navigation contracts

* test: bracket login shutdown grace and fallback deadlines

* test: keep managed server timeout expectations independent

* test: record Linear CLI input and dispatch review

* test: verify legacy completion dispatch boundary

* test: replace copied config and browser controls

* test: isolate gate refusal from inherited caller identity

* test: exercise real mobile host admission and teardown boundaries

* docs: reconcile audit entrypoints and refresh completed reviews

* test: fix mobile audit React Doctor findings

---------

Co-authored-by: OrcaWin <293788423+OrcaWin@users.noreply.github.com>
2026-10-23 07:34:51 -07:00

64 lines
2.7 KiB
TypeScript

import { mkdtemp, readFile, rm, writeFile } from 'node:fs/promises'
import { tmpdir } from 'node:os'
import { join } from 'node:path'
import { expect, it } from 'vitest'
import { build } from 'vite'
import { runProcess } from '@orca/process-host'
import { electronViteConfig } from '../../electron.vite.config'
it('keeps main code and asset paths working after a CLI build replaces its public entry', async () => {
const root = await mkdtemp(join(tmpdir(), 'orca-main-entry-facade-'))
try {
await writeFile(join(root, 'package.json'), '{"type":"commonjs"}')
await writeFile(join(root, 'tracker.ts'), 'export const createTracker = () => ({ count: 0 })')
await writeFile(
join(root, 'boot-label.ts'),
'export const getBootLabel = () => process.env.ORCA_FIXTURE_BOOT_LABEL || "boot"'
)
await writeFile(
join(root, 'late.ts'),
'import { getBootLabel } from "./boot-label"; export const readLabel = () => getBootLabel()'
)
await writeFile(
join(root, 'controls.ts'),
'import { createTracker } from "./tracker"; export const getStatus = () => createTracker().count'
)
await writeFile(
join(root, 'main.ts'),
'import { writeFileSync } from "node:fs"; import { join } from "node:path"; import { getStatus } from "./controls"; import { createTracker } from "./tracker"; import { getBootLabel } from "./boot-label"; import("./late").then(({ readLabel }) => writeFileSync(join(__dirname, "result.json"), JSON.stringify({ status: getStatus(), tracker: createTracker(), directory: __dirname, label: getBootLabel(), lateLabel: readLabel() })))'
)
const options = electronViteConfig.main?.build?.rollupOptions
await build({
configFile: false,
root,
logLevel: 'silent',
build: {
ssr: true,
minify: electronViteConfig.main?.build?.minify,
rolldownOptions: {
...options,
plugins: [],
input: { index: join(root, 'main.ts'), controls: join(root, 'controls.ts') }
}
}
})
// tsc emits public names only, replacing the bundler's entry at this same path.
await writeFile(join(root, 'dist', 'controls.js'), 'exports.getStatus = () => 0')
const result = await runProcess({
program: process.execPath,
args: [join(root, 'dist', 'index.js')],
env: { ...process.env, ORCA_FIXTURE_BOOT_LABEL: 'fixture-boot' }
})
expect(result.code, result.stderr).toBe(0)
expect(JSON.parse(await readFile(join(root, 'dist', 'result.json'), 'utf8'))).toEqual({
status: 0,
tracker: { count: 0 },
directory: join(root, 'dist'),
label: 'fixture-boot',
lateLabel: 'fixture-boot'
})
} finally {
await rm(root, { recursive: true, force: true })
}
})