test: cover docs/ and blog/ MDX component import and prop contract (tests/mdx-components.test.mjs) - #298
Open
kubestellar-hive[bot] wants to merge 1 commit into
Open
test: cover docs/ and blog/ MDX component import and prop contract (tests/mdx-components.test.mjs)#298kubestellar-hive[bot] wants to merge 1 commit into
kubestellar-hive[bot] wants to merge 1 commit into
Conversation
Adds tests/mdx-components.test.mjs (5 tests) over every docs/**/*.md{,x} and
blog/**/*.md{,x}:
- every capitalized JSX tag used in a file is imported in that same file
- every @site/ import specifier resolves to a file on disk
- every <CNCFProjectCard /> supplies name and href
- no <CNCFProjectCard /> passes a prop the component does not destructure
- the scan is non-empty, so the assertions cannot pass vacuously
Fenced and inline code is stripped before scanning so the literal
src/components/<Name>/index.js in docs/skills/ui-standards.md is not read as a
component usage.
The accepted CNCFProjectCard prop set is parsed out of the component's own
destructuring rather than hardcoded, so renaming a prop there cannot silently
diverge from the 50 hand-authored usages in docs/architectures/.
Test-only: no production code, no content, no workflow, no package.json, no
lockfile and no new dependency.
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 one new test-only file,
tests/mdx-components.test.mjs(5 tests), thefirst test in the repo that reads MDX component imports or JSX props out of
docs/andblog/. It uses onlynode:test,node:assert/strict,node:fsand
node:path.Files claimed by this PR:
tests/mdx-components.test.mjs(new). Nothingelse — no production code, no content, no workflow file, no
package.json, nolockfile, no dependency.
What is asserted
MDX renders an un-imported capitalized tag as an unknown element.
@site/import specifier resolves to a file on disk, withindex.js/.jsx/.tsxdirectory resolution.<CNCFProjectCard />suppliesnameandhref.nameisdereferenced unconditionally (
name.slice(0, 1)in the fallback-logo branch)and
hrefis the card's only navigation target, so neither has a usabledefault.
<CNCFProjectCard />passes a prop the component does not destructure.The accepted set is parsed out of
src/components/CNCFProjectCard/index.jsitself, so renaming a prop there cannot silently diverge from the 50
hand-authored usages in
docs/architectures/*.md.Fenced and inline code is stripped before scanning — otherwise the literal
`src/components/<Name>/index.js`indocs/skills/ui-standards.mdreads asa component usage.
Why this is not already covered
.github/workflows/ci.ymlrunsnpm run build:productionon every PR, so anun-imported tag or a moved component directory is caught — but late, as a
webpack error wall after
npm ciplus a full production build, rather than anamed assertion.
A misspelled prop is caught by nothing at all. MDX passes unknown props
straight through and
CNCFProjectCarddestructures a fixed set, sodescripton="..."orurl="..."is dropped silently: the card renders withoutthe text or the link, the build stays green, and no validator reports it.
Verification
node --testat rev00b44df: 60 tests pass, 0 fail (55 existing + 5 new).Every assertion was mutation-checked to confirm it bites — removing the
AwardsTimelineimport fromdocs/awards/index.md, repointing that import at anonexistent
@site/src/components/NopeTimeline, and renamingname=tonmae=and
href=tohrefx=on a card indocs/architectures/adobe.mdeach turnedthe corresponding test red. The working tree was restored clean after each.
npx prettier --check tests/mdx-components.test.mjspasses.Scope / non-overlap
Claims exactly one file and one cluster: MDX component import and prop wiring in
docs/andblog/. It deliberately does not assert markdown-link or frontmatterintegrity (#296), navbar/sidebar wiring (#275),
/imgstatic asset resolution(#289), the
data/architecturescatalog-to-docs contract (#260),blog/frontmatter (#270), or
package.json/workflow command wiring (#278). It adds noJSX transpilation helper and does not import any
src/React module, so it doesnot touch the component-test infrastructure in #229 or #268.
Related Issue
Closes #297 — this PR lands every box on that issue's task list, 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