Skip to content

test(fake-dom): cover the four uncovered regions in the fake document - #708

Closed
hivecommons-hive[bot] wants to merge 1 commit into
mainfrom
quality/test-fake-dom-regions
Closed

hivecommons-hive[bot] wants to merge 1 commit into
mainfrom
quality/test-fake-dom-regions

Conversation

@hivecommons-hive

Copy link
Copy Markdown
Contributor

Test Improvement

tests/tools/fake-dom.mjs is the stand-in document every focus-trap test
mounts against, and four of its sub-line regions were unexercised. This adds
tests/fake-dom-harness.test.mjs with one test per region:

  • removing a listener for a type that was never registered is a no-op, and
    removing an unregistered handler leaves the registered one in place
  • keydownListenerCount() and dispatchKeyDown() behave on a document that
    never saw a listener
  • restore() puts back a document that existed before the install
  • restore() deletes the global when none existed

The focus-trap suite cannot reach these: it registers exactly one keydown
listener and runs only where no global document exists. The restore arm is
what keeps a fake document from leaking into later tests under a DOM-providing
runner, and nothing proved it worked.

Files touched: tests/fake-dom-harness.test.mjs (new) only. No production
code, no changes to existing tests, so this is disjoint from the open test PRs
(#678, #680, #686, #688, #693, #702, #706), which claim scripts/ fixtures and
tests/{import-architectures,svg-active-content,fetch-community-people,validate-*,collect-*,coverage-report-collect,react-harness}.

Region coverage for tests/tools/fake-dom.mjs: 92.00% -> 100.00%
(TZ=UTC node tests/tools/coverage-report.mjs). Line coverage was already
100%, so this is a pure region gain.

Related Issue

Closes #707


Filed by quality agent (hold-gated mode). Human review required.

— hive: agent=quality backend=copilot model=claude-opus-5 copilot=1.0.88

tests/tools/fake-dom.mjs is the stand-in document every focus-trap test
mounts against, and four of its sub-line regions were unexercised: the
removeEventListener path for a type that was never registered, the empty
fallbacks in keydownListenerCount and dispatchKeyDown, and the restore arm
that puts back a document which existed before the install.

The focus-trap suite never reaches them because it registers exactly one
keydown listener and only runs where no global document exists. A regression
there surfaces as a confusing failure in an unrelated suite, or as a leaked
global document that quietly changes how a later test behaves.

Region coverage for tests/tools/fake-dom.mjs goes from 92.00% to 100%.

Signed-off-by: hivecommons-hive[bot] <hivecommons-hive@hive.kubestellar.io>
@hivecommons-hive

Copy link
Copy Markdown
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 outreach agent is always held because it publishes project-facing communication.

Hive will automatically remove the hold label once current policy no longer requires a level hold for "quality". If this is an outreach PR, a human must review it and remove the label.

@mrbobbytables

Copy link
Copy Markdown
Member

Superseded by #750, which consolidates this and 14 other test-only coverage PRs into a single reviewable change (commit cherry-picked unmodified, authorship and DCO preserved).

@mrbobbytables
mrbobbytables deleted the quality/test-fake-dom-regions branch September 28, 2026 14:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

hold quality Approved by a Hive merger/owner for auto-merge on green CI testing Approved by a Hive merger/owner for auto-merge on green CI

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[quality] tests/tools/fake-dom.mjs has four uncovered sub-line regions

1 participant