Skip to content

Commit 6c3db54

Browse files
Bill LeoutsakosBill Leoutsakos
authored andcommitted
test(design): colocate conformance suites
1 parent 8d6fcb4 commit 6c3db54

15 files changed

Lines changed: 26 additions & 24 deletions

‎package.json‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,10 @@
1818
"test:setup": "bun run --cwd packages/sim-setup test",
1919
"test:integration": "bun --no-env-file scripts/test-integration.ts",
2020
"test:search-performance": "KNOWLEDGE_SEARCH_PERFORMANCE_TEST=true bun --no-env-file scripts/test-integration.ts search-latency",
21-
"format": "biome format --write scripts/design-conformance scripts/design-scan scripts/design-studio tools/design-studio scripts/check-design-conformance*.ts scripts/generate-design-contracts*.ts && turbo run format",
22-
"format:check": "biome format scripts/design-conformance scripts/design-scan scripts/design-studio tools/design-studio scripts/check-design-conformance*.ts scripts/generate-design-contracts*.ts && turbo run format:check",
23-
"lint": "biome check --write scripts/design-conformance scripts/design-scan scripts/design-studio tools/design-studio scripts/check-design-conformance*.ts scripts/generate-design-contracts*.ts && turbo run lint",
24-
"lint:check": "biome check scripts/design-conformance scripts/design-scan scripts/design-studio tools/design-studio scripts/check-design-conformance*.ts scripts/generate-design-contracts*.ts && turbo run lint:check",
21+
"format": "biome format --write scripts/design-conformance scripts/design-scan scripts/design-studio tools/design-studio scripts/check-design-conformance.ts && turbo run format",
22+
"format:check": "biome format scripts/design-conformance scripts/design-scan scripts/design-studio tools/design-studio scripts/check-design-conformance.ts && turbo run format:check",
23+
"lint": "biome check --write scripts/design-conformance scripts/design-scan scripts/design-studio tools/design-studio scripts/check-design-conformance.ts && turbo run lint",
24+
"lint:check": "biome check scripts/design-conformance scripts/design-scan scripts/design-studio tools/design-studio scripts/check-design-conformance.ts && turbo run lint:check",
2525
"lint:helm": "helm lint helm/sim --strict --values helm/sim/ci/default-values.yaml",
2626
"lint:all": "bun run lint && bun run lint:helm",
2727
"check": "bun run format:check",

‎scripts/check-script-test-coverage.ts‎

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
#!/usr/bin/env bun
22
/**
3-
* Asserts every `scripts/*.test.ts` file is collected by the scripts Vitest config.
3+
* Asserts script tests are collected by the scripts Vitest config.
44
*
55
* The root `test` script once chained a hand-maintained list of `test:*` entries, and a
66
* hand-maintained list silently drifts from the files on disk: a test added without a matching
77
* entry never runs, in CI or locally, and nothing reports it. `scripts/check-migrations-safety.test.ts`
88
* sat unreferenced and green for exactly that reason. `scripts/vitest.config.ts` now collects
9-
* the directory by glob, so drift can only come from a file the glob does not match (a test in a
10-
* subdirectory, a different suffix) or from the `test` script no longer chaining `test:scripts`.
9+
* the root and tooling directories by glob. This guard walks script subdirectories so a new
10+
* test outside those globs cannot be silently skipped. `scripts/openapi` has its own suite.
1111
* This guard checks both by asking Vitest which files it would run.
1212
*
1313
* `run-audits.ts` derives its own list from the `check:*` namespace precisely so a new audit is
@@ -57,10 +57,15 @@ const collected = new Set(
5757
)
5858
)
5959

60-
const onDisk = readdirSync(path.join(ROOT, 'scripts'))
61-
.filter((file) => file.endsWith('.test.ts'))
62-
.map((file) => `scripts/${file}`)
63-
.sort()
60+
function scriptTests(directory: string): string[] {
61+
return readdirSync(path.join(ROOT, directory), { withFileTypes: true }).flatMap((entry) => {
62+
const file = `${directory}/${entry.name}`
63+
if (entry.isDirectory()) return file === 'scripts/openapi' ? [] : scriptTests(file)
64+
return entry.isFile() && /\.test\.(?:ts|mjs)$/.test(entry.name) ? [file] : []
65+
})
66+
}
67+
68+
const onDisk = scriptTests('scripts').sort()
6469

6570
const orphaned = onDisk.filter((file) => !collected.has(file))
6671
if (orphaned.length > 0) {

scripts/check-design-conformance-colour-assignments.test.ts renamed to scripts/design-conformance/colour-assignments.test.ts

File renamed without changes.

scripts/check-design-conformance-command.test.ts renamed to scripts/design-conformance/command.test.ts

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,8 @@ import { GitSource } from '#design-conformance/worktree-source'
2222

2323
const temp = mkdtempSync(path.join(os.tmpdir(), 'design-command-'))
2424
afterAll(() => rmSync(temp, { recursive: true, force: true }))
25-
const cli = fileURLToPath(new URL('./check-design-conformance.ts', import.meta.url))
26-
const ci = fileURLToPath(new URL('./design-conformance/ci.ts', import.meta.url))
25+
const cli = fileURLToPath(new URL('../check-design-conformance.ts', import.meta.url))
26+
const ci = fileURLToPath(new URL('./ci.ts', import.meta.url))
2727
const ui = 'apps/sim/components/example.tsx'
2828

2929
function fixture() {
@@ -1167,10 +1167,7 @@ test('the relocated registry remains a central-system change and formatting stay
11671167
const file = 'scripts/design-conformance/contracts.json'
11681168
expect(isRegistry(file)).toBe(true)
11691169
expect(isRegistry('scripts/other/contracts.json')).toBe(false)
1170-
const registry = readFileSync(
1171-
new URL('./design-conformance/contracts.json', import.meta.url),
1172-
'utf8'
1173-
)
1170+
const registry = readFileSync(new URL('./contracts.json', import.meta.url), 'utf8')
11741171
expect(hash(registry)).toBe(contractsHash)
11751172
const entry = { path: TOKEN_FILE, blob: 'a'.repeat(40), mode: '100644' }
11761173
const compare = (before: string, after: string) =>
File renamed without changes.
File renamed without changes.

scripts/check-design-conformance-control-comparison.test.ts renamed to scripts/design-conformance/control-comparison.test.ts

File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 commit comments

Comments
 (0)