Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> --- Build: pass | Tests: pass — Tests 414 passed | 10 skipped (424)
2.1 KiB
2.1 KiB
preflight.test.ts — test suite summary
Smoke tests for the preflight orchestrator (setup/preflight.ts), which runs
the 12 setup steps before installation.
Setup / mocks
spawnSyncis stubbed so no real subprocesses run — every call returns exit 0 by defaultfs.writeFileSync/mkdirSyncare stubbed to capture what gets written without touching diskprocess.exitis spied on so a failing preflight does not kill the test runner- Two helpers extract the outputs:
getSummaryJson()andgetSummaryEnv()parse what was written tosummary.json/summary.env
5 describe blocks, 17 tests
basic run (no flags)
All 12 steps run in the correct order:
environment → pi-config → jails → db → git → cms →
hosts → mounts → telegram-auth → service → verify → doctor
summary.jsonhasoverallStatus: successsummary.envhasOVERALL_STATUS=success,WITH_ONBOARDING=false,CAPTURE_PASSWORD_STEP=falseprocess.exitis not called
failure handling
- A single failing step does not abort the run — all 12 still execute
overallStatusbecomesfailedprocess.exit(1)is called--fail-faststops after the first failure (only 1 npm call, then exit 1)
--with-onboarding
- The interactive onboarding step skips gracefully in a non-TTY environment (test runner has no TTY)
- All 12 non-interactive steps still run
overallStatusisfailedbecause onboarding itself fails without a TTYWITH_ONBOARDING=trueappears insummary.env
--capture-password-step
- Implies
--with-onboarding(verified viasummary.jsonargs) - The Python screenshot capture does NOT run when onboarding failed (no TTY)
CAPTURE_PASSWORD_STEP=trueappears insummary.env
summary output structure
- Every step result in
summary.jsonhas all required fields:id,label,commandLine,exitCode,status,startedAt,finishedAt,logFile - Log file paths are bare filenames with no path separator (e.g.
environment.log) summary.envcontains a*_STATUS=and*_EXIT_CODE=line for every step