Repository navigation
test(SW-041): add Basic App package metadata conformance - #262
Merged
Merged
Conversation
Validate that the generated Basic App package.json conforms to the frozen template contract after running : - name is set to the project name supplied by the developer - scripts (start/check/test) match the frozen entries exactly - no extra script keys beyond the frozen set - engines.node matches the frozen minimum (>=22.13.0) - no dependencies field - no devDependencies field - no secret/seed/private-key values in the generated manifest - the generated project's check script exits with code 0 Relates-to: SW-041 Depends-on: SW-015, SW-039
|
Important
This repository does not receive automatic reviews because it has fewer than 10 stars. ⚙️ Run configuration
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
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 #143
test(SW-041): Add Basic App package metadata conformance
Summary
Adds a dedicated conformance test suite that validates the
package.jsongenerated by
stellarforge newfor the Basic App template against thefrozen template contract.
The Basic App template's
package.jsonis a well-defined, intentionallyminimal manifest. Until this PR there was no test that pinned the exact
shape of that manifest — individual fields (
scripts,engines,dependencies) were checked incidentally inside the broader smoke-test inbasic-app-template.test.ts, but nothing asserted them exhaustively or inisolation. This PR fills that gap by treating the template manifest as a
named contract and asserting every field in it.
Related Issue
Closes #143
Scope
Added
tests/basic-app-package-metadata.test.ts— 8 focused conformance testcases that together cover every acceptance criterion for SW-041.
Intentionally not changed
published behaviour or the public API surface.
Testing
The new test file (
tests/basic-app-package-metadata.test.ts) containsone
describeblock — "Basic App package metadata conformance (SW-041)"— with the following 8
itcases:sets the package name to the generated project namenameis correct after generationretains all frozen script entries without modificationscriptsentries match the frozen contract exactlyretains only the frozen script keys and no extrasstart,check,testsets the engines.node constraint to the frozen minimum versionengines.nodeequals>=22.13.0generates no dependencies fielddependenciesgenerates no devDependencies fielddevDependenciesdoes not embed secret, seed, or private-key values in the generated package.jsonSECRET,SEED,PRIVATE_KEY, Stellar strkey pattern)passes the repository check script after generationcheckscript exits with code0Each test uses
withTempDirectoryto run in complete isolation inside athrowaway directory, consistent with the patterns used in
api-service-template.test.tsandfull-stack-template.test.ts.Helpers / infrastructure used (no new helpers introduced)
createNewCommand— exercises the real generator code pathcreateCapturedTerminalOutput/withTempDirectory— standard test helperscreateNpmInvocation+spawnSync(shell: false) — safe child-processexecution for the
checkscript runTests added/updated where applicable
Existing relevant tests pass (blocked by pre-existing
package.jsonJSONsyntax error on
main— missing comma on line 16 — unrelated to this PR)Lint/type/build checks pass where available (same blocker;
node --checkon the new file itself passes cleanly)
Security Impact
Security notes:
This PR adds tests only. The new test that exercises secret detection
(
does not embed secret, seed, or private-key values) explicitly assertsthat the generated
package.jsoncontains noSECRET,SEED,PRIVATE_KEYliteral strings and no Stellar secret-key strkey pattern(
S[A-Z0-9]{55}). All child-process invocations useshell: falseinline with the project security model (ADR-0004). No network access,
no environment variable reflection, no file paths outside the temporary
directory.
Release Impact
No published/user-visible behavior change
Changeset not required; reason explained below
Release notes: Test-only change. No runtime code, template files, or
documented CLI behaviour is altered. No changeset is needed.
Documentation
This PR validates an existing, already-documented template contract.
The frozen contract constants in the test file (
FROZEN_SCRIPTS,FROZEN_NODE_ENGINE) serve as living inline documentation of thebasic-appmanifest shape and are annotated with a comment directingfuture maintainers to update them only when the template itself changes
intentionally.
Checklist
docs/contributing/wave-architecture.mdfor Stellar Wave work