Skip to content

SP-1089: Command integration tests#374

Merged
Jing Sun (kuvia) merged 10 commits into
mainfrom
SP-1089-command-integration-tests
Jun 17, 2026
Merged

SP-1089: Command integration tests#374
Jing Sun (kuvia) merged 10 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
Comment thread src/content-cli.ts Outdated
@kuvia Jing Sun (kuvia) dismissed stale reviews from Eszter Galicz (celeszter) and themself via adedaf0 June 17, 2026 09:15
@sonarqubecloud

Copy link
Copy Markdown

@kuvia Jing Sun (kuvia) merged commit 644dbdf into main Jun 17, 2026
6 checks passed
@kuvia Jing Sun (kuvia) deleted the SP-1089-command-integration-tests branch June 17, 2026 12:04
Zgjim Haziri (ZgjimHaziri) added a commit that referenced this pull request Jun 17, 2026
Resolve modify/delete conflict in the configuration-management tests.
SP-1089 (#374) deleted the per-module unit spec
(tests/commands/configuration-management/module.spec.ts) in favor of an
integration spec. Port the `config package export` handler tests into
tests/integration/commands/configuration-management.spec.ts (driven via
the CLI parser, so the unzipped default asserts zip=false) and accept the
deletion of the old unit spec.

Includes-AI-Code: true
Co-authored-by: Cursor <cursoragent@cursor.com>
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.

4 participants