Skip to content

SP-1089: Command integration tests#374

Open
Thomas Neumüller (tneum-celonis) wants to merge 9 commits into
mainfrom
SP-1089-command-integration-tests
Open

SP-1089: Command integration tests#374
Thomas Neumüller (tneum-celonis) wants to merge 9 commits into
mainfrom
SP-1089-command-integration-tests

Conversation

@tneum-celonis

@tneum-celonis Thomas Neumüller (tneum-celonis) commented Jun 10, 2026

Copy link
Copy Markdown
Contributor

Description

Based on the plan in #373.

Drives Content CLI command tests through the real Commander parser instead of poking private action methods. The two existing "module" specs bypassed Commander's command registration, option parsing, defaults, type coercion, and validation. After this change, tests mirror what an end user types and run through the same parse path the content-cli binary uses.

  • src/content-cli.ts:
    • exposes a command factory and hides run() behind a module check to prevent running in test mode
    • add explicit providing of modules as an alternative to automatic discovery to facilitate testing / mocking
  • tests/utls/cli-program.ts: Wires testContext into createProgram and skips filesystem-based module discovery (which would conflict with fs mocks)
  • Move and rewrite the two module tests
    • Move test files to an integration folder for clarity
    • Invoke CLI through program.parseAsync
  • Validate logger output instead of working with the result of parse (now parseAsync)

Relevant links

Checklist

  • I have self-reviewed this PR
  • I have tested the change and proved that it works in different scenarios
  • I have updated docs if needed

Captures the implementation plan to drive Content CLI command tests
through the real Commander parser via parseAsync, including refactoring
src/content-cli.ts to expose a createProgram factory and relocating the
two existing module specs under tests/integration/commands.

Includes-AI-Code: true
Co-authored-by: Cursor <cursoragent@cursor.com>
Refactor the CLI bootstrap to expose a `createProgram(context, opts)`
factory and gate the runtime entry behind `if (require.main === module)`,
so tests can build isolated Commander programs and invoke commands via
`parseAsync` instead of poking private action methods. The bin entry
keeps the existing banner/debug behaviour by parsing global options
through a small bootstrap `Command` before context init.

Replace the two module-level specs with integration tests under
`tests/integration/commands/` that drive each command through real
Commander parsing, exercising option defaults/coercion. Action-body
validation errors are caught by `Configurator.action`, so tests now
assert on the in-memory winston transport rather than promise rejection.
A new `tests/utls/cli-program.ts` helper wires `testContext` into the
factory while skipping filesystem-based module discovery (incompatible
with the `jest.mock("fs")` setup).

Includes-AI-Code: true
Co-authored-by: Cursor <cursoragent@cursor.com>
@tneum-celonis Thomas Neumüller (tneum-celonis) marked this pull request as ready for review June 11, 2026 07:08
@sonarqubecloud

Copy link
Copy Markdown

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.

2 participants