/** * Integration test for runChecks — wires every checker together against * a real in-tree module (caddy). The in-tree modules are guaranteed * healthy by virtue of CI running their build/import flow on every PR; * a regression in runChecks would surface as fail/warn here. * * The npm fetch is stubbed to keep the test offline. */ import { describe, expect, test } from 'bun:test'; import { resolve } from 'node:path'; import { runChecks } from '.'; const REPO_ROOT = resolve(__dirname, '../../../../..'); const CADDY_MODULE_PATH = resolve(REPO_ROOT, 'modules/caddy'); describe('runChecks (orchestrator)', () => { // celilo#804: this test timed out at 60000ms on a docs-only CI run yet // measures ~500ms end-to-end locally (all 3 tests in this file, combined). // The work here is a handful of synchronous `git`/`spawnSync` calls // (checkGitHygiene) with nothing to cut without dropping the git_hygiene // check this test exists to exercise — so this was a saturated CI runner // stalling those spawns, not this suite sitting close to its budget. // Raising the timeout further wouldn't shrink that margin (a real stall // would blow through any budget); left at the file's default (60000ms, // ~100x the measured runtime) rather than bumped without evidence it helps. test('healthy in-tree module produces all-ok report', async () => { const checks = await runChecks(CADDY_MODULE_PATH, { noBuild: true, fetchNpmMetadata: async () => null, }); // git_hygiene is environment-dependent — the in-tree caddy module's // git state varies during dev. Stale-version drift, dirty-tree, etc. // are real publish gates but not what this test is asserting (which // is "the orchestrator wires every checker up cleanly"). const fails = checks.filter((c) => c.status === 'fail' && c.category !== 'git_hygiene'); expect(fails).toEqual([]); // Must include checks from every category we expect to fire. const categories = new Set(checks.map((c) => c.category)); expect(categories.has('manifest_schema')).toBe(true); expect(categories.has('contract_version')).toBe(true); expect(categories.has('capability')).toBe(true); expect(categories.has('workspace_dep')).toBe(true); expect(categories.has('git_hygiene')).toBe(true); expect(categories.has('typescript_build')).toBe(true); }); test('returns checks in stable category order', async () => { const checks = await runChecks(CADDY_MODULE_PATH, { noBuild: true, fetchNpmMetadata: async () => null, }); const seenCategories: string[] = []; for (const c of checks) { if (seenCategories[seenCategories.length - 1] !== c.category) { seenCategories.push(c.category); } } expect(seenCategories[0]).toBe('manifest_schema'); expect(seenCategories[seenCategories.length - 1]).toBe('typescript_build'); }); test('nonexistent path produces a failed manifest_schema check', async () => { const checks = await runChecks('/tmp/celilo-runChecks-doesnotexist', { noBuild: true, fetchNpmMetadata: async () => null, }); const schemaCheck = checks.find((c) => c.category === 'manifest_schema'); expect(schemaCheck?.status).toBe('fail'); }); });