Skip to content

[quality] test: cover validate-architecture-assets.mjs --fix write mode (tests/helpers.mjs args/readBack + tests/validate-architecture-assets.test.mjs) - #231

Open
kubestellar-hive[bot] wants to merge 1 commit into
mainfrom
quality/test-architecture-assets-fix
Open

kubestellar-hive[bot] wants to merge 1 commit into
mainfrom
quality/test-architecture-assets-fix

Conversation

@kubestellar-hive

Copy link
Copy Markdown
Contributor

Test Improvement

scripts/validate-architecture-assets.mjs has two modes. Read-only validation was
already covered by tests/validate-architecture-assets.test.mjs. The --fix write
mode — the only path in this repository that rewrites checked-in assets in place —
was exercised by no test at all. This PR covers it.

Files claimed by this PR (test-only; no production file is touched):

  • tests/helpers.mjsrunScriptWithFixtures(script, fixtures, options) gains an
    optional third argument: options.args (extra argv, e.g. ['--fix']) and
    options.readBack (repo-relative paths whose contents are captured after the run
    and returned as result.files, with null for a path the script never wrote).
    Read-back is necessary because the sandbox is deleted before the helper returns,
    so write-mode behaviour was previously unobservable. The change is additive and
    backwards compatible: every existing caller passes two arguments and is unchanged.
  • tests/validate-architecture-assets.test.mjs — 11 new --fix tests, appended
    below the existing ten. They split into three groups:
    • repairs that land: DOCTYPE stripped (and its error suppressed), viewBox
      synthesized from width/height including fractional and unit-suffixed values
      (640.5px), draw.io mxfile metadata stripped so the warning disappears,
      multiple repairs in one file reported as Fixed 2 issue(s), and repairs written
      to every asset in a walked directory tree.
    • findings --fix must not suppress: missing xmlns, embedded raster data,
      and a missing viewBox with no resolvable dimensions each still exit 1 and
      leave the file byte-identical.
    • scope: a valid SVG is left untouched, and a non-SVG asset is walked but not
      rewritten.

Verification

node --test: 66 tests pass, 0 fail (55 before). npx prettier --check is
clean on both files. Local clone of cncf/endusers at parent revision 00b44df
after npm ci, 2026-09-17.

Note on the coverage percentage

--experimental-test-coverage still reports validate-architecture-assets.mjs at
57.43% line after this PR, unchanged. That is the fixture-sandbox attribution gap
being addressed in #225 — the profile only counts the in-process smoke run against
real repo data, not the subprocess runs where the behaviour is actually exercised.
The gap this PR closes is behavioural and verifiable by inspection: before it, no
test anywhere in tests/ passed --fix to this script; now eleven do.

Coverage evidence

Left open deliberately

The --fix run prints No fixes were needed. immediately after Fixed N issue(s):
lists the repairs it just made, because issues is empty once a finding is
repaired. These tests assert the Fixed N issue(s) output and deliberately do not
cement the contradictory line. Correcting it is a production change, out of scope
for the quality agent; it is written up in #230 so it is not lost.

Related Issue

Refs #230


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

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

The --fix branch of scripts/validate-architecture-assets.mjs — the only path
in the repository that rewrites checked-in assets in place — was exercised by
no test, because tests/helpers.mjs runScriptWithFixtures() could neither pass
argv nor read a fixture back after the sandbox was torn down.

Give the helper an optional third argument (args, readBack), backwards
compatible with every existing caller, and add 11 --fix cases: repairs that
land (DOCTYPE strip, viewBox synthesis, mxfile strip), findings --fix must not
suppress (missing xmlns, embedded raster data, unresolvable dimensions),
multi-repair and multi-file runs, and non-SVG assets left alone.

Signed-off-by: kubestellar-hive[bot] <kubestellar-hive@hive.kubestellar.io>
@kubestellar-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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

0 participants