blob: 189fbed4fcee3a200cc7a8c2ca8a8dc4b8ea45cb [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);
// Product UI work is not a Storybook catalog change — typecheck/unit/e2e own it.
assert.equal(ui.storybook, false);
assert.equal(ui.scriptMode, 'none');
assert.deepEqual(ui.workspaces, ['packages/ui', 'apps/desktop']);
// Ordinary desktop product files must not drag Storybook Chromium.
assert.equal(planTests(['apps/desktop/src/main/main.ts'], { graph }).storybook, false);
assert.equal(planTests(['apps/desktop/e2e/settings.spec.ts'], { graph }).storybook, false);
// Catalog + harness only.
assert.equal(
planTests(['apps/desktop/stories/app-shell.stories.tsx'], { graph }).storybook,
true,
);
assert.equal(planTests(['apps/desktop/.storybook/preview.tsx'], { graph }).storybook, true);
assert.equal(planTests(['packages/ui/stories/composer.stories.tsx'], { graph }).storybook, true);
// .storybook/preview.tsx reads THEME_PALETTES from this one core module.
// Other core paths must not force Storybook.
const coreSettings = planTests(['packages/core/src/settings.ts'], { graph });
assert.equal(coreSettings.storybook, true);
assert.equal(coreSettings.e2e, false);
assert.equal(planTests(['packages/core/src/index.ts'], { graph }).storybook, false);
// A script the Storybook job RUNS must re-run Storybook, not Electron e2e.
const smoke = planTests(['scripts/storybook-visual-smoke.mjs'], { graph });
assert.equal(smoke.storybook, true);
assert.equal(smoke.e2e, false);
assert.equal(smoke.scriptMode, 'fast');
assert.equal(planTests(['scripts/check-story-annotations.mjs'], { graph }).e2e, false);
assert.equal(planTests(['scripts/check-story-annotations.mjs'], { graph }).storybook, false);
// Alignment auditor drives the e2e job (not Storybook).
const alignment = planTests(['scripts/audit-alignment.mjs'], { graph });
assert.equal(alignment.e2e, true);
assert.equal(alignment.storybook, false);
const backend = planTests(['packages/storage/src/session-store.ts'], { graph });
assert.equal(backend.e2e, false);
assert.equal(backend.storybook, 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.equal(plan.storybook, true);
assert.deepEqual(plan.workspaces, graph.dirs);
}
});