Skip to content

Reduce remaining structural and duplicated tests after #159#167

Merged
MirzaMerdovic merged 2 commits into
mainfrom
issues/orfe-164
May 15, 2026
Merged

Reduce remaining structural and duplicated tests after #159#167
MirzaMerdovic merged 2 commits into
mainfrom
issues/orfe-164

Conversation

@j3l3n4-bot
Copy link
Copy Markdown

@j3l3n4-bot j3l3n4-bot Bot commented May 15, 2026

Ref: #164

Summary

  • remove broad structural CLI help loops that mainly restated command/group metadata rather than boundary behavior
  • reshape command registry coverage around real runtime behavior instead of registration-order and mapping structure assertions
  • keep the CLI error and caller-handling coverage that still protects distinct boundary behavior

Testing

  • npm test
  • npm run lint
  • npm run typecheck
  • npm run build

Drop metadata-heavy CLI and registry assertions so the suite keeps behavioral boundary coverage without mirroring command registration details.
Copy link
Copy Markdown

@kl4r1554-bot kl4r1554-bot Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

QA Review — PR #167 / Issue #164

Decision: APPROVED


What I verified

  • PR body first line is exactly Ref: #164
  • Head branch is issues/orfe-164
  • No Closes/Fixes auto-close keywords ✓
  • npm run typecheck — clean, no errors ✓
  • npm run lint — clean, no errors ✓
  • npm run build — clean, no errors ✓
  • npm test (changed files only, test/cli/run.test.ts + test/core/command-registry.test.ts) — 13/13 passed ✓
  • Full test suite started cleanly before timeout; no signal of failures in the newly changed files ✓
  • No source code changes, no docs/ADR/debt updates required (issue explicitly noted "Docs impact: none expected") ✓

Blockers

None.


Important

None.


Nice to have

  • test/core/command-registry.test.ts filename drift: The file is still named command-registry.test.ts but its tests now exercise runOrfeCore rather than the registry API directly. A future rename to core-run.test.ts or core-runtime.test.ts would improve discoverability. Not a blocker — the file is still scoped to core behavior and the reshaping was the right call.

Docs / invariants

No architecture, ADR, or debt doc changes needed. This is test-only cleanup. Issue scope confirmed "no docs impact expected." Nothing in docs/architecture/invariants.md is touched by this change.


Change assessment

test/cli/run.test.ts — two describe blocks removed:

  • runCli renders help for each command group — looped over all groups asserting help string literals (group name, Usage header, Commands header, purpose lines). Classic structural metadata loop. Correct to remove per docs/architecture/testing.md §"Low-value test patterns to avoid" (duplicated routing/help assertions, shallow metadata tests).
  • runCli renders leaf help for every agreed V1 command — looped over all commands asserting definition literals (name, purpose, usage, success summary, examples, JSON shape example). Also a structural metadata loop asserting implementation definitions rather than runtime behavior. Correct to remove.
  • The escapeForRegExp helper and associated registry imports were no longer needed and were cleaned up properly.
  • Remaining 11 tests all protect real behavioral contracts: root help output, empty-args noop path, --version (no-config path), runtime info (no-config path), -v alias rejection, unknown command errors, caller identity requirement, ORFE_CALLER_NAME env var parsing, deprecated --caller-name rejection, malformed numeric option errors, malformed repo override errors. All of these are behavioral boundary tests aligned with docs/architecture/testing.md §"CLI boundary."

test/core/command-registry.test.ts — reshaped, not deleted:

  • Removed 5 structural tests: registration order, group derivation logic, execution property metadata, definition reference equality loop, and low-level getCommandDefinition throw test. All were asserting internal registry structure rather than runtime behavior.
  • Added 2 behavioral tests exercising runOrfeCore at the real core runtime boundary:
    • runOrfeCore executes runtime-only commands without caller, config, auth, or GitHub access — verifies that runtime info executes end-to-end via runOrfeCore with no config/auth loading. Strong behavioral test that protects the "runtime-only commands bypass dependency loading" contract. Throws inside both loadRepoConfigImpl and loadAuthConfigImpl to actively assert the no-load invariant.
    • runOrfeCore rejects unknown commands before loading config or auth — verifies OrfeError type, invalid_usage code, and message content for unknown commands, and actively asserts that config/auth loading does not occur. Stronger protection than the old registry-level throw test because it exercises the public dispatch boundary.
  • Both new tests are correctly placed at the "Core runtime boundary" per docs/architecture/testing.md §"Preferred test surfaces."

Coverage note: runtime info is now tested at two distinct layers — the CLI layer (run.test.ts, line 59-86, tests the full CLI path with env: {} stub) and the core layer (command-registry.test.ts, tests runOrfeCore directly). This is appropriate multi-boundary coverage, not duplication, because each layer protects a different surface.


Acceptance criteria assessment

  • ✅ No clearly duplicated non-help command test layer remains without boundary-specific justification
  • test/cli/run.test.ts no longer over-indexes on structural metadata/layout assertions (both help-loop describes removed)
  • test/core/command-registry.test.ts reshaped to protect meaningful runtime behavior rather than internal registration structure
  • ✅ Remaining tests are explainable by the behavioral integration-first strategy from #159 and the governing decision rule in docs/architecture/testing.md

Copy link
Copy Markdown

@kl4r1554-bot kl4r1554-bot Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Re-QA Review — rename follow-up (commit 3a4cd6d)

Decision: APPROVED

What I verified

  • Commit 3a4cd6d is a pure rename: R100 similarity, 0 insertions, 0 deletions. No logic or test content was changed.
  • Old name test/core/command-registry.test.ts is gone — confirmed via git diff origin/main...origin/issues/orfe-164 --name-status. No remaining references to the old filename exist anywhere in the codebase.
  • New name test/core/core-run.test.ts is accurate: the file imports and exercises runOrfeCore from src/core/run.js. The name directly reflects the module under test.
  • Test discovery: vitest.config.ts includes test/**/*.test.ts — the new filename matches the discovery pattern without any config change needed.
  • Acceptance criteria: Issue #164 requires that test/core/command-registry.test.ts be "removed, reduced, or reshaped so it protects meaningful behavior rather than internal structure." The rename satisfies the letter and spirit of that criterion: the misleading registry-structure name is gone, the meaningful behavioral tests (runOrfeCore runtime-only execution and unknown-command rejection) are preserved and now named for what they actually test.

Blockers

None.

Important

None.

Nice to have

None.

Clean follow-up. No blockers introduced.

@MirzaMerdovic MirzaMerdovic merged commit c5d65f2 into main May 15, 2026
1 check passed
@MirzaMerdovic MirzaMerdovic deleted the issues/orfe-164 branch May 15, 2026 11:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant