blob: 6c37a7ff850cdf66d7fc7f767a91be86700eff80 [file]
import assert from 'node:assert/strict';
import test from 'node:test';
import { loadWorkspaceGraph, planTests } from './ci-test-plan.mjs';
const graph = loadWorkspaceGraph();
test('impact planning distinguishes docs, UI, and backend changes', () => {
const docs = planTests(['README.md', 'docs/testing.md'], { graph });
assert.equal(docs.code, false);
assert.deepEqual(docs.workspaces, []);
const ui = planTests(['packages/ui/src/button.tsx'], { graph });
assert.equal(ui.e2e, true);
assert.equal(ui.scriptMode, 'none');
assert.deepEqual(ui.workspaces, ['packages/ui', 'apps/desktop']);
// .storybook/preview.tsx reads THEME_PALETTES from @maka/core, and the e2e
// job now builds and smokes Storybook, so a core change must reach it.
assert.equal(planTests(['packages/core/src/settings.ts'], { graph }).e2e, true);
// A script the e2e job RUNS must re-run it; a script it does not stays off.
// Otherwise the smoke runner is the one file that can stop guarding without
// the guard ever running against the change.
const smoke = planTests(['scripts/storybook-visual-smoke.mjs'], { graph });
assert.equal(smoke.e2e, true);
assert.equal(smoke.scriptMode, 'fast');
assert.equal(planTests(['scripts/check-story-annotations.mjs'], { graph }).e2e, false);
const backend = planTests(['packages/storage/src/session-store.ts'], { graph });
assert.equal(backend.e2e, false);
for (const workspace of ['packages/storage', 'packages/runtime', 'apps/desktop']) {
assert.ok(backend.workspaces.includes(workspace));
}
});
test('stress and specialized script checks run only for their owning surfaces', () => {
assert.equal(
planTests(['packages/storage/src/agent-run-store.ts'], { graph }).storageStress,
true,
);
for (const path of [
'scripts/fixture-env.mjs',
'scripts/ci-test-plan.test.mjs',
'scripts/run-workspace-tests-parallel.test.mjs',
]) {
const plan = planTests([path], { graph });
assert.equal(plan.full, false, path);
assert.equal(plan.scriptMode, 'fast', path);
}
const measurement = planTests(['scripts/measure-session-bundle.mjs'], { graph });
assert.equal(measurement.scriptMode, 'extended');
assert.deepEqual(measurement.workspaces, []);
});
test('sandbox is flagged whenever the cli workspace runs in the closure', () => {
// packages/cli/src/__tests__/runtime-bootstrap.test.ts executes real sandboxed
// shell tools, so any change whose dependency closure selects packages/cli must
// provision the sandbox — not only direct cli/runtime edits.
for (const path of [
'packages/cli/src/__tests__/runtime-bootstrap.test.ts',
'packages/runtime/src/shell-tools.ts',
'packages/storage/src/session-store.ts',
'packages/headless/src/cell-output.ts',
]) {
assert.equal(planTests([path], { graph }).runtimeSandbox, true, path);
}
});
test('global and unknown production changes fail safe to the complete suite', () => {
for (const path of ['package-lock.json', 'scripts/ci-test-plan.mjs', 'new-root/file.ts']) {
const plan = planTests([path], { graph });
assert.equal(plan.full, true);
assert.equal(plan.e2e, true);
assert.deepEqual(plan.workspaces, graph.dirs);
}
});