Skip to content

test(RHIDP-14570): add intent-based CLI unit gaps and e2e scaffold - #218

Open
HusneShabbir wants to merge 7 commits into
redhat-developer:mainfrom
HusneShabbir:RHIDP-14570-intent-cli-tests
Open

HusneShabbir wants to merge 7 commits into
redhat-developer:mainfrom
HusneShabbir:RHIDP-14570-intent-cli-tests

Conversation

@HusneShabbir

@HusneShabbir HusneShabbir commented Sep 23, 2026 •

Copy link
Copy Markdown
Member

Summary

Adds automated coverage for intent-based CLI commands (RHIDP-14570) without requiring a live RHDH instance for CI.

Unit tests — validation and error-path gaps for catalog, search, and template commands (required inputs, bad flags, etc.).

Mocked-client integration suite — src/commands/intent-based-actions/intent-commands.integration.test.ts runs real Commander wiring, helpers, formatters, and error handling; only ./client is mocked (no network, no live RHDH):

  • catalog — list (human/json, incl. --instance), get, validate (--entity / --entity-file), register, unregister
  • api — list, get-spec (incl. missing spec.definition)
  • search — happy path + action failure → non-zero exit (incl. --instance)
  • docs — search scoped to techdocs; list; get (techdocs-mcp-extras, incl. merged unresolved-entity cases)
  • template — list, execute, dry-run

Offline e2e scaffold — e2e-tests/intent-based-cli.test.ts checks process contracts (--help, invalid usage, empty-dir standalone). Optional live catalog list when RHDH_CLI_E2E_URL is set (auth must already be configured).

Redundancy / review cleanup (latest: 1183480):

  • Removed overlapping unit happy-path coverage; dropped api.test.ts (covered by integration).
  • Dropped redundant docs search unit tests; folded dedicated --instance integration cases into catalog list + search.
  • Merged overlapping docs get unresolved cases.
  • CI hygiene: jest/no-standalone-expect, Prettier, Sonar duplication trims.

Review (@yangcao77) — --instance, catalog validate/register/unregister, and docs list/get are covered in the mocked integration suite above (--instance exercised on catalog list and search, not as a separate-only test).

Out of scope / follow-up — Full live-RHDH e2e for epic acceptance criteria (install → auth → query across catalog/api/search/docs/template) remains optional via RHDH_CLI_E2E_URL or a follow-up ticket.

Jira: RHIDP-14570 · Epic: RHIDP-14254 · Plan: RHDHPLAN-1131

Test plan

  • yarn test --watchAll=false --coverage=false under src/commands/intent-based-actions/ (unit + mocked integration)
  • yarn test:e2e --testPathPattern=intent-based-cli (offline help/error/empty-dir; live RHDH skipped unless RHDH_CLI_E2E_URL)
  • yarn prettier:check / yarn lint:check
  • Optional: with RHDH_CLI_E2E_URL + configured auth, confirm live catalog list --output json --kind Component

HusneShabbir and others added 4 commits September 23, 2026 11:23
Fill search/api unit coverage, expand catalog/template command tests,
and add help/error contract e2e that skips live RHDH unless configured.

Co-authored-by: Cursor <cursoragent@cursor.com>
Use describe.skip for optional live RHDH e2e to satisfy
jest/no-standalone-expect, collapse duplicated help/error and command
cases to cut Sonar duplication, and keep unique failure coverage.

Co-authored-by: Cursor <cursoragent@cursor.com>
Exercise real commander/helpers/format paths with client mocked so
catalog/api/search/docs/template cover integration ACs without live
RHDH. Slim overlapping unit happy-path tests to validation-only cases.

Co-authored-by: Cursor <cursoragent@cursor.com>
Format intent-commands.integration.test.ts for CI prettier:check, fold
missing get-spec.definition coverage into the mocked integration suite,
and remove the overlapping api.test.ts.

Co-authored-by: Cursor <cursoragent@cursor.com>

@yangcao77 yangcao77 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

the changes generally looks good.
recommand to introduce more tests for more coverage, i.e. --instance switch, catalog validate/register/unregister and docs list/get integration paths remain gaps.

Address review feedback: assert --instance forwarding, catalog
validate/register/unregister action wiring, and docs list/get
techdocs-mcp-extras integration paths with a mocked client.

Co-authored-by: Cursor <cursoragent@cursor.com>
@HusneShabbir

Copy link
Copy Markdown
Member Author

Thanks @yangcao77 — addressed in the latest commit:

  • --instance forwarding covered on catalog list + search (also used on catalog mutate / docs paths)
  • catalog validate (--entity and --entity-file), register, unregister mocked integration paths
  • docs list + get techdocs-mcp-extras integration paths

Fold --instance into existing catalog/search integration cases and remove
docs unit tests already covered by mocked client integration.

Co-authored-by: Cursor <cursoragent@cursor.com>

@yangcao77 yangcao77 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

The changes look good to me.

I do not have approver's permission.
@kadel can you help take a quick look on this PR as well?

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