Repository navigation
test(dev): add malformed package-script metadata matrix (SW-220) - #453
Open
yunus-dev-codecrafter wants to merge 1 commit into
Open
yunus-dev-codecrafter wants to merge 1 commit into
yunus-dev-codecrafter wants to merge 1 commit into
Conversation
Add a focused dev-only test file covering all invalid shapes of the scripts object and individual script values so that malformed metadata cannot reach npm. Coverage added: - scripts: null, boolean, number, string, array -- all rejected with 'package.json must define a scripts object.' before process-plan creation. - Null, boolean, number, array, object script values on dev/start/ start:backend -- skipped (not an immediate error) so a lower-precedence candidate with a valid string can still be selected. - All three candidates non-string -> ValidationCliError 'No supported development script'. - Error message contains candidate names and 'package.json' so it is actionable. - Explicit distinction between missing/null scripts (guard) vs blank string values (selector). - Positive regression guards confirm valid scripts still resolve. - Precedence rule (dev > start > start:backend) is documented in the file header as the single authoritative statement. No runtime-dependency or npm-invocation changes. Closes DigiNodes#402
|
Important
This repository does not receive automatic reviews because it has fewer than 10 stars.
|
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.
closes #402
Add a focused dev-only test file covering all invalid shapes of the scripts object and individual script values so that malformed metadata cannot reach npm.
Coverage added:
No runtime-dependency or npm-invocation changes.
Closes #402
Summary
Adds a focused, dev-only malformed-manifest test matrix for the dev resolver (
project.ts
). The resolver already rejects invalid scripts shapes and skips non-string script values, but no tests pinned that behavior exhaustively. This PR adds deterministic regression coverage for every invalid scripts shape (null, boolean, number, string, array) and every non-string script value type (null, boolean, number, float, array, plain object) so that malformed metadata cannot silently reach npm.
Related Issue
Closes #402
Scope
Completed:
New test file
dev-project-malformed-scripts-metadata.test.ts
with three describe blocks:
Malformed scripts object shapes — null, true, false, 0, 42, "start", [], ['dev','start'] are all rejected with 'package.json must define a scripts object.' before any process-plan is created. Includes a test that explicitly distinguishes a missing scripts key from a null value.
Non-string individual script values — a 10-type matrix (null, true, false, 0, 42, -1, 3.14, [], ['node','dev.js'], {command:'...'}) tests the skip-then-fallthrough path and the all-candidates-exhausted rejection path for each type.
Malformed shapes and precedence interaction — mixed scenarios confirm the skip/reject distinction holds across combinations, and that error messages are actionable (name the candidates and reference package.json).
The precedence rule (dev → start → start:backend; non-string = skip; blank string = skip; reject only when no candidate survives) is stated once in the file header as the authoritative documented form.
Positive regression guards in each section confirm valid scripts continue to resolve unchanged.
Intentionally left out (per issue scope):
Test-project detection and Node/Cargo ambiguity (covered by #119).
New script names or npm invocation behavior changes.
No runtime dependencies added.
Testing
New test file:
dev-project-malformed-scripts-metadata.test.ts
The test runner (vitest run) is blocked repo-wide by a pre-existing parse error in
template-generation.ts
(lines 257–530, 9 TS errors, present on main before this PR). tsc --noEmit confirms all 9 errors are in that pre-existing file — zero errors introduced by this PR. The new test file is structurally and type-correctly consistent with the existing dev-project.test.ts and dev-project-diagnostics.test.ts files, which are blocked by the same pre-existing issue.
Tests added/updated where applicable
Existing relevant tests pass (blocked by pre-existing template-generation.ts parse error on main; not introduced by this PR)
Lint/type/build checks pass where available (tsc --noEmit shows zero new errors)
Security Impact
No security-sensitive behavior is changed
Security notes: This PR adds tests only. No source files, child-process invocations, filesystem writes, secrets handling, or network behavior are modified. The test file uses the same withTempDirectory helper as the rest of the test suite, which cleans up after itself.
Release Impact
No published/user-visible behavior change
Changeset not required; reason explained below
Release notes: Test-only change. No behavior visible to end users or downstream consumers is modified.
Documentation
No documentation change required
The precedence rule is documented inline in the new test file header. No ADR or architecture doc update is needed for a test-only addition.
Checklist
I read
wave-architecture.md
for Stellar Wave work
I stayed within the agreed issue scope
I checked for overlapping open contributor PRs
I did not include secrets or sensitive data
I reviewed new/updated dependencies if any (none added)
I considered failure/error paths, not only the happy path
I am not disclosing an unresolved vulnerability publicly