test: assert the src/ and scripts/ module-resolution contract (tests/module-imports.test.mjs) - #328
Open
kubestellar-hive[bot] wants to merge 1 commit into
Open
kubestellar-hive[bot] wants to merge 1 commit into
kubestellar-hive[bot] wants to merge 1 commit into
Conversation
Adds tests/module-imports.test.mjs, which reads every import specifier in
src/**/*.js and scripts/**/*.mjs and asserts it resolves to something real.
No test previously opened a source file to read an import statement.
Five assertions, each mutation-validated:
- node: specifiers name real builtins
- relative imports in src/ resolve under webpack's optional-extension
and /index rules
- relative imports in scripts/ resolve exactly, extension included,
matching plain Node ESM (./lib/github would throw ERR_MODULE_NOT_FOUND)
- @site/ aliases resolve from the repository root
- bare specifiers are declared in package.json, with @docusaurus/*
subpath aliases satisfied by @docusaurus/core
A sixth guard asserts the scan found files and specifiers, so a regex
regression cannot silently empty the other five.
Scope is src/ and scripts/ only; MDX imports and named-export identity are
deliberately not read. Test-only, no new dependencies, green on main.
Closes #326
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/module-imports.test.mjs— the only file this PR touches.Nothing in the suite previously opened a source file to read an
importstatement. This test reads every specifier in
src/**/*.jsandscripts/**/*.mjs(22 files, 26 distinct specifiers at00b44df) andasserts each one resolves to something real.
Assertions
the import scan finds source files and specifiersevery node: specifier names a real Node builtinmodule.isBuiltinevery relative import in src/ resolves to a file/indexentryevery relative import in scripts/ resolves exactly, extension included./lib/githubthrowsERR_MODULE_NOT_FOUNDeven though webpack accepts itevery @site/ alias resolves from the repository rootevery bare import is declared in package.jsondependencies/devDependencies;@docusaurus/*subpath aliases are satisfied by@docusaurus/coreVerification
main:node --test→ 61 tests pass (55 before, 6 added),node v26.8.2 at parent rev
00b44df. No production change; the contractalready holds.
fail, with a precise message, against a deliberately broken tree —
node:fs→node:fsx,../hooks/useFocusTrap→...Trapp,./lib/validate-utils.mjs→./lib/validate-utils,@site/data/projects-born.json→...projects-gone.json,react→reakt.All mutations reverted; the diff is the one new test file.
npx prettier --checkclean. No new dependencies.Scope and disjointness
This PR claims exactly one cluster: module specifier resolution in
src/**/*.jsandscripts/**/*.mjs, filetests/module-imports.test.mjs.tests/workflow-scripts.test.mjs) checks the wiring contract —npm runtargets,node scripts/...paths named inpackage.json, linterconfig files. It never opens a source file or reads an
import. Disjoint.importstatements insidedocs//blog/MDX. This testreads no MDX. Disjoint.
filterArchitecturesbehaviour and adds a JSX loader; thisPR checks only that specifiers resolve, never which named exports a module
provides, and adds no loader or harness. Disjoint.
/imgstatic asset paths),[quality] src/css/custom.css <-> static/fonts/ contract is untested; 27 italic faces (764K) shipped but never declared #317 (
static/fonts/), [quality] static/images (16M) and static/social (148K) ship unreferenced on every deploy; static/ has no orphan guard #321 (static/orphans) all concern assets orCSS, not module graphs. Disjoint.
tests/module-imports.test.mjs, and this PR modifies nofile any other open PR touches — including
tests/helpers.mjs([quality] test: cover validate-architecture-assets.mjs --fix write mode (tests/helpers.mjs args/readBack + tests/validate-architecture-assets.test.mjs) #231, [quality] test: report coverage of fixture-sandbox runs (tests/tools/coverage-report.mjs) #225).Related Issue
Closes #326 — merging this lands every box in that issue's recommendation, so
nothing is left for it to track.
Filed by quality agent (hold-gated mode). Human review required.
— hive: agent=quality backend=copilot model=claude-opus-5