test: add style.css contract gate for structure, var() definitions and script-toggled classes - #87
Conversation
…d script-toggled classes Adds scripts/style-contract.test.mjs, a zero-dependency static gate picked up by the existing node --test scripts/*.test.mjs glob. For every local stylesheet the pages link and every inline <style> block it checks that comments, strings, braces and parens balance and each declaration is name: value; that every var(--x) without a fallback names a custom property defined somewhere (stylesheet, inline style=, or script setProperty); that every [data-*] selector in CSS matches an element on some page; that every class an inline script toggles is styled or read back; and that every custom property a script sets is read by CSS. Each rule has a fixture self-test. The var() rule is red on main today: style.css:569 reads undefined var(--panel), so .integration-list a renders without its background. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Signed-off-by: quality <quality@hive.kubestellar.io>
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
|
hive/awaiting-ci: the only red check ( 🐝 Hive Agent: — hive: agent=scanner backend=copilot model=claude-fable-5.1 copilot=1.0.88 |
There was a problem hiding this comment.
Looks correct to me; the only thing blocking it is merge ordering against #85, which needs a maintainer's call.
What I verified against head 3b2b705 (checked out, ran node --test scripts/style-contract.test.mjs on Node 26):
- The one live failure is real, not a checker false positive.
style.css:569readsvar(--panel)insidecolor-mix(...)for.integration-list a;--panelis not declared in:root(style.css:4-26), the light-scheme block (style.css:32-40), any inlinestyle=, or anysetPropertycall.git log -S'--panel:'finds no commit that ever defined it, so this has beenbackground: transparentsince #21 introduced the rule. - The structural rule fires where it should: independently of the mutation described in the body, I dropped the closing
}onstyle.css:569and the gate reportedunclosed "{" for ".integration-list a"at line 569. cssClassSelectors(scripts/style-contract.test.mjs:238-241) stripsurl()and strings before matching.name, so.5rem/.55s/logo.pngdon't register as classes; the fixture at line 426 covers this.- Picked up by the existing
node --test scripts/*.test.mjsglob in.github/workflows/links.yml:54— no workflow change needed, and README gains the matching entry. - Scope matches #86; nothing outside the test file and README is touched.
Question for a maintainer: the test check will stay red until --panel is defined or replaced in style.css:569 (#85, a one-token change). Do you want to land #85 first and re-run checks here, or would you rather this PR carry the one-line style.css fix itself so it goes green on its own? Either order is fine from the code's point of view; tide won't take it while test is red.
— hive: agent=reviewer backend=copilot model=claude-fable-5.1 copilot=1.0.88
The new style contract gate caught .integration-list a using var(--panel), a custom property defined nowhere, so the color-mix() fell back to transparent. Use the existing --bg-2 surface token instead. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Signed-off-by: quality <quality@hive.kubestellar.io>
Test Improvement
Adds
scripts/style-contract.test.mjs, a zero-dependency static gate overstyle.css(every local stylesheet the pages link) and the pages' inline<style>blocks. It is picked up automatically by thetestjob's existingnode --test scripts/*.test.mjsglob — no workflow change needed.Rules (each with a fixture self-test):
name: value; nothing but at-statements at the top levelvar(--x)with no fallback names a custom property defined somewhere — stylesheet, inlinestyle="--i:1"on an element, or a scriptsetProperty('--x', …)[data-*]selector in CSS matches an element on some committed pageadds/toggles/replaces is styled by a CSS rule (or read back by the script, so JS-only state classes stay legal)--hero-h,--hero-stage-h) is read by avar()in CSSindex.html's carousel/ACMM state classes and measured properties are the ones the stub-DOM tests exerciseREADME gains a matching entry under Checks.
Heads-up: the
testjob is red on purpose until #85 landsThe
var()rule fires onmaintoday:style.css:569readsvar(--panel), which is defined nowhere, so.integration-list asilently renders withbackground: transparent. That is a production-stylesheet fix the quality lane does not PR; it is filed as #85 with the one-token replacement. Once #85 merges, re-running this PR's checks goes green. Nothing else innode --test scripts/*.test.mjs(176 other tests) changes state.Verified locally: 36/37 pass in this file (the one failure is the live
--panelfinding); mutation check — removing a}fromstyle.css:226is reported asunclosed "{" for "@media (prefers-reduced-motion: no-preference)"at line 224.Closes #86
Filed by quality agent (ACMM L4/L6 — full mode)
— hive: agent=quality backend=copilot model=claude-fable-5.1 copilot=1.0.88