test: cover the CSS custom-property resolution contract (tests/css-variables.test.mjs) - #347
Merged
Merged
Conversation
Nothing in the test suite reads a CSS custom-property name. An unresolved var(--x) is not an error anywhere in the pipeline: the declaration is dropped, the property falls back to its initial value, and the build stays green, so a typo in a token name ships as a silently unstyled element. Add tests/css-variables.test.mjs, asserting in both directions that: - extraction is non-vacuous, so a regex regression cannot empty the sets the other assertions iterate over; - every var(--x) under src/ resolves to a CSS declaration, a JS inline-style declaration, or the Infima/Docusaurus vendor namespace; - the vendor allowlist never swallows a project-owned --cncf-* token; - every declared --cncf-* token is read by at least one var(); - every --cncf-* token themed on :root is redeclared under [data-theme='dark'], so a new brand token cannot be added light-only. The scan covers JS inline styles because --bar-width is declared from MetricsDashboard/index.js and read from its stylesheet; a stylesheet-only scan would report a false positive there. Test-only change. Green on main: 60 tests, 60 pass (55 before). Closes #346 Signed-off-by: kubestellar-hive[bot] <kubestellar-hive@hive.kubestellar.io>
Contributor
Author
|
Important Held for human review by the hive's ACMM level gate. This PR was opened by the "quality" agent while Hive policy required a human checkpoint for that agent. Non-outreach agents are held at ACMM L3–L5; the Hive will automatically remove the |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Test Improvement
Adds
tests/css-variables.test.mjs— the only file this PR touches. Noproduction change, no new dependency.
Nothing in the test suite reads a CSS custom-property name. An unresolved
var(--x)is not an error anywhere in the pipeline: the browser drops thedeclaration, the property falls back to its initial/inherited value,
docusaurus buildsucceeds, and the element renders unstyled. A typo in atoken name ships green.
Under
src/today: 10 stylesheets, 15 declared custom properties, 15var()references, 1 property declared from a JS inline style, 0 references carrying
a fallback. All of it currently resolves — this is a guard for a clean
invariant, not a bug report.
What it asserts
non-empty, so a regression in the extractors cannot silently pass the rest.
var(--x)resolves to a CSS declaration undersrc/,a JS inline-style declaration, or the Infima/Docusaurus vendor namespace.
--ifm-*/--docusaurus-*exemption maynever swallow a project-owned
--cncf-*token.--cncf-*token is read by at least onevar()(orphan detection).--cncf-*token themed on:rootis redeclaredunder
[data-theme='dark'], so a new brand token cannot be addedlight-only and silently inherit the wrong value in dark mode.
Two repo-specific details the scan handles, both of which break a naive
implementation:
--bar-widthis declared in JavaScript, not CSS —src/components/MetricsDashboard/index.js:52sets it as a style-object keyand
MetricsDashboard/styles.module.css:16reads it. A stylesheet-only scanreports a false positive.
:rootby substring because the selector insrc/css/custom.csscarries a:not(#\#):not(#\#)specificity hack.Verification
Mutation-tested; each mutation is caught by the intended assertion, and no
assertion is redundant:
var(--cncf-button-text)->--cncf-button-txt--cncf-button-textfrom the[data-theme='dark']blockvar(--cncf-button-background-hover)to its hex literal'--bar-width'inline-style key inMetricsDashboard/index.jsnpm run test:unit-> 60 tests, 60 pass (55 before this PR).prettier --checkclean.Scope and disjointness
Claimed ground:
tests/css-variables.test.mjsonly; the invariant is CSScustom-property (
var(--x)) name resolution acrosssrc/**/*.cssplusinline-style declarations in
src/**/*.{js,jsx,ts,tsx}.No open PR reads CSS custom properties. #289 covers
/imgasset paths, #343covers JSX
href/srchygiene, #229 and #268 cover React modules, #253 /#260 / #287 cover
data/*.json, and #185 / #197 / #208 / #214 / #216 / #221 /#231 cover
scripts/. Issues #317 (url()refs againststatic/fonts/) and#319 (
*.module.cssclass names) are adjacent but neither is a customproperty and neither has a PR; their proposed test files are
tests/css-assets.test.mjsandtests/css-modules.test.mjs, so there is nofile collision either.
Related Issue
Closes #346 — merging this lands the sole deliverable that issue tracks
(
tests/css-variables.test.mjs), leaving nothing for it to track.Filed by quality agent (hold-gated mode). Human review required.
— hive: agent=quality backend=copilot model=claude-opus-5