|
1 | 1 | import assert from 'node:assert/strict'; |
2 | | -import { readFileSync } from 'node:fs'; |
| 2 | +import { readdirSync, readFileSync } from 'node:fs'; |
3 | 3 | import test from 'node:test'; |
4 | 4 | import audit from '../../../../scripts/audit-context-region-consumers.cjs'; |
5 | 5 |
|
6 | 6 | // Exercises the audit's pure checks directly: a consumer override is decided by |
7 | 7 | // specificity and value, never by bundle order, so the allow/deny contract can |
8 | 8 | // be pinned without touching the real stylesheets. |
9 | | -const { collectRules, overrideFailures, propertiesOf, seamFailures } = audit; |
| 9 | +const { |
| 10 | + FOUNDATION_FILE, |
| 11 | + collectRules, |
| 12 | + foundationCss, |
| 13 | + overrideFailures, |
| 14 | + propertiesOf, |
| 15 | + seamFailures, |
| 16 | +} = audit; |
10 | 17 |
|
11 | 18 | const owned = (css: string, foundationClass: string) => |
12 | 19 | propertiesOf(collectRules(css), foundationClass); |
@@ -63,15 +70,23 @@ test('the stack seam requires an inset', () => { |
63 | 70 | assert.deepEqual(seamFailures('Demo', 'mine', placed), []); |
64 | 71 | }); |
65 | 72 |
|
| 73 | +// The audit reads the foundation by name, and a wrong-case name still resolves |
| 74 | +// on macOS but not on the case-sensitive CI disk. Pin the exact on-disk case. |
| 75 | +test('the foundation filename matches its on-disk case', () => { |
| 76 | + const entries = readdirSync(new URL('.', import.meta.url)); |
| 77 | + assert.ok( |
| 78 | + entries.includes(FOUNDATION_FILE), |
| 79 | + `${FOUNDATION_FILE} is not the exact on-disk filename` |
| 80 | + ); |
| 81 | +}); |
| 82 | + |
66 | 83 | test('the real fanout consumer clears the audit over the real stylesheets', () => { |
67 | 84 | // The same pure checks as above, but over the actual files on disk: the |
68 | 85 | // foundation plus the SubAgentFanoutDiagram consumer with the exact role |
69 | 86 | // classes its <ContextRegionScene> usage hands over (className, |
70 | 87 | // stackClassName, companionClassName). Zero failures, or the audit CLI |
71 | 88 | // would fail the same way. |
72 | | - const foundation = collectRules( |
73 | | - readFileSync(new URL('./ContextRegions.module.css', import.meta.url), 'utf8') |
74 | | - ); |
| 89 | + const foundation = collectRules(foundationCss); |
75 | 90 | const consumer = collectRules( |
76 | 91 | readFileSync( |
77 | 92 | new URL('./SubAgentFanoutDiagram.module.css', import.meta.url), |
|
0 commit comments