Skip to content

Commit b2f2f95

Browse files
committed
Guard foundation CSS filename casing
1 parent 49dfda8 commit b2f2f95

2 files changed

Lines changed: 27 additions & 6 deletions

File tree

‎scripts/audit-context-region-consumers.cjs‎

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,12 @@ const root = path.resolve(
1919
"components",
2020
"VisualElements",
2121
);
22+
// The one owner of the foundation filename: the contract test reuses it and
23+
// guards its exact on-disk case, because a wrong-case path only fails on the
24+
// case-sensitive CI disk, not on the maintainer's macOS checkout.
25+
const FOUNDATION_FILE = "contextRegions.module.css";
2226
const foundationCss = fs.readFileSync(
23-
path.join(root, "ContextRegions.module.css"),
27+
path.join(root, FOUNDATION_FILE),
2428
"utf8",
2529
);
2630

@@ -284,8 +288,10 @@ function main() {
284288
if (require.main === module) main();
285289

286290
module.exports = {
291+
FOUNDATION_FILE,
287292
SEAM,
288293
collectRules,
294+
foundationCss,
289295
specificity,
290296
propertiesOf,
291297
overrideFailures,

‎website/src/components/VisualElements/contextRegionConsumers.test.ts‎

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,19 @@
11
import assert from 'node:assert/strict';
2-
import { readFileSync } from 'node:fs';
2+
import { readdirSync, readFileSync } from 'node:fs';
33
import test from 'node:test';
44
import audit from '../../../../scripts/audit-context-region-consumers.cjs';
55

66
// Exercises the audit's pure checks directly: a consumer override is decided by
77
// specificity and value, never by bundle order, so the allow/deny contract can
88
// 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;
1017

1118
const owned = (css: string, foundationClass: string) =>
1219
propertiesOf(collectRules(css), foundationClass);
@@ -63,15 +70,23 @@ test('the stack seam requires an inset', () => {
6370
assert.deepEqual(seamFailures('Demo', 'mine', placed), []);
6471
});
6572

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+
6683
test('the real fanout consumer clears the audit over the real stylesheets', () => {
6784
// The same pure checks as above, but over the actual files on disk: the
6885
// foundation plus the SubAgentFanoutDiagram consumer with the exact role
6986
// classes its <ContextRegionScene> usage hands over (className,
7087
// stackClassName, companionClassName). Zero failures, or the audit CLI
7188
// 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);
7590
const consumer = collectRules(
7691
readFileSync(
7792
new URL('./SubAgentFanoutDiagram.module.css', import.meta.url),

0 commit comments

Comments
 (0)