Skip to content

test: fix CodeQL alert 1 and pass under jsdom 31 - #126

Merged
tempus2016 merged 3 commits into
mainfrom
test/ci-fixes
Nov 20, 2026
Merged

tempus2016 merged 3 commits into
mainfrom
test/ci-fixes

Conversation

@tempus2016

Copy link
Copy Markdown
Owner

Two test-only fixes. No change to the card or dist/, so no release.

Code scanning alert 1 (Incomplete multi-character sanitization). test/condition.test.ts stripped Lit's <!----> markers from outerHTML with a regex before comparing. It now clones the element and removes the comment nodes through the DOM, which does the same job without a regex.

Tests pass under jsdom 31 (unblocks #125). jsdom 31 behaves more like a browser in two ways that broke two tests:

  • A detached element has no computed style. The export-menu test built its cards outside the document, so the header padding read as 0 and the button landed at 22px instead of 20px. The test now attaches the cards and removes them after.
  • CSS percentages are rounded to six significant digits. The icicle test compared 66.66666666666666% as text; it now compares the number.

Full suite passes on jsdom 30 (current) and on jsdom 31 with #125's lockfile: 1539/1539.

CodeQL flagged the regex as incomplete multi-character sanitization
(code scanning alert 1). Removing comment nodes from a clone does the
same job without a regex.
jsdom 31 gives detached elements no computed style and rounds CSS
percentages to six significant digits, as browsers do. Attach the
export-menu test's cards to the document, and compare the icicle
offset as a number.
@tempus2016 tempus2016 self-assigned this Nov 20, 2026
@tempus2016 tempus2016 added compatibility Behaviour alongside other custom cards or a Home Assistant release tests The unit suite and coverage labels Nov 20, 2026
@tempus2016
tempus2016 merged commit c645d0b into main Nov 20, 2026
9 checks passed
@tempus2016
tempus2016 deleted the test/ci-fixes branch November 20, 2026 09:35
@github-project-automation github-project-automation Bot moved this from Todo to Done in Chartdeck Planner Nov 20, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

compatibility Behaviour alongside other custom cards or a Home Assistant release tests The unit suite and coverage

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

1 participant