mirror of
https://github.com/stablyai/orca.git
synced 2026-10-30 16:47:34 +00:00
Extract subprocess execution and process contracts into @orca/process-host with explicit public entry points, independent checks, and one Node 18 compatible CommonJS runtime. Migrate application consumers and integrate package builds, dependency selection, import enforcement, and runtime resource staging. Preserve daemon startup ownership and profile isolation, and qualify development rebuild recovery and concurrent output publication. Remove unnecessary aliases, test forwarding exports, and a duplicate output scan. Validation: full typechecks, changed-code quality, package and artifact checks, native Windows builds/types plus 306 runtime tests, and independent native reviews. Matched full E2E controls on original main and unchanged reviewed head both pass all 17 applicable tests (nine skips). Earlier intermittent E2E failures are documented in the PR; no assertions were weakened. The final combined-tree audit preserves both branches with no import-boundary violations.
106 lines
4.0 KiB
JavaScript
106 lines
4.0 KiB
JavaScript
import { mkdirSync, mkdtempSync, readFileSync, realpathSync, rmSync, writeFileSync } from 'node:fs'
|
|
import { createRequire } from 'node:module'
|
|
import { tmpdir } from 'node:os'
|
|
import { dirname, join, resolve } from 'node:path'
|
|
import { expect, it } from 'vitest'
|
|
import { parse } from 'yaml'
|
|
import { runProcess } from '@orca/process-host'
|
|
|
|
const require = createRequire(import.meta.url)
|
|
const projectDir = resolve(import.meta.dirname, '../..')
|
|
|
|
function assertGoldenPlatformCommands(workflow) {
|
|
const fresh = [
|
|
'tests/e2e/golden-fresh-profile-terminal.spec.ts',
|
|
'tests/e2e/golden-shell-command.spec.ts'
|
|
]
|
|
const core = ['tests/e2e/golden-core-flows.spec.ts']
|
|
for (const [platform, expected] of Object.entries({
|
|
Linux: [core, fresh],
|
|
macOS: [core, fresh],
|
|
Windows: [fresh]
|
|
})) {
|
|
const step = workflow.jobs['golden-e2e'].steps.find(
|
|
(candidate) => candidate.name === `Run golden E2E tests on ${platform}`
|
|
)
|
|
expect(step, platform).toMatchObject({ if: `runner.os == '${platform}'` })
|
|
const args = [...step.run.matchAll(/\bpnpm run test:e2e\s+([^\n]+)/g)].map((match) =>
|
|
match[1].trim().split(/\s+/)
|
|
)
|
|
expect(args, platform).toEqual(expected)
|
|
}
|
|
}
|
|
|
|
function focusedArguments() {
|
|
const commands = []
|
|
for (const filename of ['terminal-ime-e2e.yml', 'golden-e2e-experiment.yml']) {
|
|
const workflow = parse(readFileSync(join(projectDir, '.github/workflows', filename), 'utf8'))
|
|
if (filename === 'golden-e2e-experiment.yml') {
|
|
assertGoldenPlatformCommands(workflow)
|
|
}
|
|
for (const job of Object.values(workflow.jobs)) {
|
|
for (const step of job.steps) {
|
|
for (const match of (step.run ?? '').matchAll(/\bpnpm run test:e2e\s+([^\n]+)/g)) {
|
|
commands.push(match[1].trim().split(/\s+/))
|
|
}
|
|
}
|
|
}
|
|
}
|
|
const runner = readFileSync(
|
|
join(projectDir, 'config/scripts/run-terminal-ibus-hangul-e2e.mjs'),
|
|
'utf8'
|
|
)
|
|
const native = runner.match(/\[\s*'run',\s*'test:e2e:headful',([\s\S]*?)\]/)
|
|
expect(native).not.toBeNull()
|
|
expect(native[1].replace(/'[^']*'|[\s,]/g, '')).toBe('')
|
|
commands.push([...native[1].matchAll(/'([^']*)'/g)].map((match) => match[1]))
|
|
return [...new Map(commands.map((args) => [JSON.stringify(args), args])).values()]
|
|
}
|
|
|
|
it('focused IME and golden commands discover only their requested files with the installed Playwright CLI', async () => {
|
|
const commands = focusedArguments()
|
|
expect(commands).toHaveLength(4)
|
|
const directory = realpathSync(mkdtempSync(join(tmpdir(), 'orca-playwright-focused-')))
|
|
const config = join(directory, 'playwright.config.cjs')
|
|
const testPackage = JSON.stringify(require.resolve('@stablyai/playwright-test'))
|
|
try {
|
|
mkdirSync(join(directory, 'tests/e2e'), { recursive: true })
|
|
writeFileSync(config, "module.exports = { testDir: '.', testMatch: '**/*.spec.ts' }")
|
|
const requestedFiles = commands.flatMap((args) =>
|
|
args.filter((arg) => arg.endsWith('.spec.ts'))
|
|
)
|
|
for (const filename of new Set([...requestedFiles, 'tests/e2e/unrelated.spec.ts'])) {
|
|
writeFileSync(
|
|
join(directory, filename),
|
|
`const { test } = require(${testPackage}); test('selected', () => {});`
|
|
)
|
|
}
|
|
for (const args of commands) {
|
|
const result = await runProcess({
|
|
program: process.execPath,
|
|
cwd: directory,
|
|
args: [
|
|
join(dirname(require.resolve('playwright/package.json')), 'cli.js'),
|
|
'test',
|
|
'--config',
|
|
config,
|
|
'--list',
|
|
'--reporter=json',
|
|
...args
|
|
],
|
|
env: { ...process.env, ORCA_BACKGROUND_LAUNCH: '1' },
|
|
timeoutMs: 20_000
|
|
})
|
|
expect(result.code, result.stderr).toBe(0)
|
|
const report = JSON.parse(result.stdout)
|
|
const expected = args.filter((arg) => arg.endsWith('.spec.ts')).sort()
|
|
expect(
|
|
report.suites.map((suite) => suite.file.replaceAll('\\', '/')).sort(),
|
|
JSON.stringify(args)
|
|
).toEqual(expected)
|
|
}
|
|
} finally {
|
|
rmSync(directory, { recursive: true, force: true })
|
|
}
|
|
}, 30_000)
|