Skip to content

UN-4074 [FIX] Stub npx presence in the two rig node-command tests - #2271

Open
muhammad-ali-e wants to merge 1 commit into
mainfrom
fix/UN-4074-FIX_rig_cli_npx_guard
Open

UN-4074 [FIX] Stub npx presence in the two rig node-command tests#2271
muhammad-ali-e wants to merge 1 commit into
mainfrom
fix/UN-4074-FIX_rig_cli_npx_guard

Conversation

@muhammad-ali-e

Copy link
Copy Markdown
Contributor

What

Stub shutil.which present in the two rig node-command tests, so they assert
command construction rather than whether the host happens to have Node installed.

Why

_node_command deliberately degrades when Node is absent:

if not shutil.which("npx"):
    # "so a machine without Node does not turn the whole run red"
    return ["sh", "-c", "exit 5"]

Both tests assert the real npx invocation, but neither required npx to be
present. On a machine without Node they compare against the sentinel and fail:

AssertionError: assert ['sh', '-c', 'exit 5'] == ['npx', '--no-install', 'vitest', 'run']

CI here is green because GitHub-hosted runners ship Node, so this is invisible
upstream. It surfaces downstream: the enterprise repo's test job runs on a
self-hosted runner with no Node, against a tree merged with this repo's main,
so every PR there currently goes red on these two tests. Because that merge pins
main, it cannot be fixed from any branch in either repo — it has to land here.

How

Stub present, rather than skipif.

A skipif would stop these running on exactly the machine that reported the
problem. These assert argument shape — reporter flags, argv order, that
Playwright takes its JUnit path from env rather than a flag — none of which
depends on Node being installed.

This mirrors the existing test_node_command_without_npx_collects_nothing, which
stubs the same hook to absent to cover the other branch. Both branches are now
covered deterministically, and neither depends on the environment.

Can this PR break any existing features?

No. Test-only, scoped to two functions in one file, and it adds determinism
rather than removing coverage — the Node-less branch keeps its own dedicated
test.

Database Migrations

None.

Env Config

None.

Notes on Testing

Reproduced the downstream failure locally by running with npx removed from
PATH:

Condition Result
Without this fix, npx absent 2 failed — matches the CI failure
With this fix, npx absent 3 passed
Full test_cli.py, npx absent 32 passed
Full test_cli.py, npx present 32 passed

The mutation check (reverting the stub and re-running with npx absent) reproduces
the original failure, so the change is load-bearing rather than incidental.

Related Issues or PRs

UN-4074. Found while investigating two red checks on an unrelated enterprise
chart PR; the tests themselves came in with the frontend Ant Design removal work.

Checklist

  • I have added an appropriate PR title and description
  • My code follows the style guidelines of this project
  • I have performed a self-review of my code
  • I have commented on my code, particularly in hard-to-understand areas
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes
  • I have checked my code and corrected any misspellings

`_node_command` deliberately short-circuits when Node is absent, returning the
rig's `["sh", "-c", "exit 5"]` "nothing collected" sentinel so a machine without
Node does not turn a whole run red. Both of these tests assert the real npx
invocation but never required npx to be there, so on such a machine they compare
against the sentinel and fail:

    AssertionError: assert ['sh', '-c', 'exit 5'] == ['npx', ... 'vitest', 'run']

OSS CI is green because GitHub-hosted runners ship Node. It surfaces downstream:
the cloud repo's test job runs on a self-hosted runner with no Node, over a tree
merged against OSS main, so every cloud PR goes red on these two.

Stub `shutil.which` PRESENT rather than skipping. A skipif would stop them
running on exactly the machine that reported the problem; these assert command
*construction*, which should not depend on the host having Node at all. This
mirrors `test_node_command_without_npx_collects_nothing`, which stubs the same
hook to absent for the other branch — so both branches are now covered
deterministically and neither depends on the environment.

Verified with npx removed from PATH: 2 failed before, 32 passed after, and the
whole file passes both with and without npx.
@sonarqubecloud

sonarqubecloud Bot commented Sep 1, 2026

Copy link
Copy Markdown

@greptile-apps

greptile-apps Bot commented Sep 1, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR makes two node-command unit tests independent of whether the host has Node installed.

  • Stubs shutil.which to report npx as present in the Vitest command-construction test.
  • Applies the same deterministic setup to the Playwright command-construction test.
  • Preserves separate coverage of the missing-npx sentinel branch.

Confidence Score: 5/5

The PR appears safe to merge because it changes only test setup and deterministically selects the command-construction branches already under test.

The stubs patch the exact shutil.which("npx") lookup used by _node_command, while the existing missing-npx test continues to cover the fallback sentinel.

Important Files Changed

Filename Overview
tests/rig/tests/test_cli.py Adds correctly targeted executable-discovery stubs so Vitest and Playwright command assertions consistently exercise their intended branches.

Reviews (1): Last reviewed commit: "UN-4074 [FIX] Stub npx presence in the t..." | Re-trigger Greptile

@github-actions

github-actions Bot commented Sep 1, 2026

Copy link
Copy Markdown
Contributor

Unstract test results

Per-group results

Status Group Tier Passed Failed Errors Skipped Duration (s)
e2e-api-deployment e2e 3 0 0 0 22.5
e2e-coowners e2e 1 0 0 0 1.8
e2e-etl e2e 1 0 0 0 8.5
e2e-login e2e 2 0 0 0 1.4
e2e-prompt-studio e2e 1 0 0 0 4.9
e2e-smoke e2e 2 0 0 0 1.4
e2e-workflow e2e 1 0 0 0 16.7
frontend unit 0 1 0 0 0.0
integration-backend integration 310 0 0 26 44.4
integration-connectors integration 1 0 0 7 7.7
integration-workers integration 157 0 0 1 51.4
ui e2e 0 1 0 0 0.0
unit-backend unit 1158 0 0 1 41.3
unit-connectors unit 63 0 0 0 9.8
unit-core unit 33 0 0 0 1.4
unit-platform-service unit 15 0 0 0 2.7
unit-rig unit 120 0 0 0 4.6
unit-runner unit 5 0 0 0 2.9
unit-sdk1 unit 563 0 0 0 31.5
unit-workers unit 1397 0 0 1 129.4
TOTAL 3833 2 0 36 384.3

Critical paths

⚠️ Critical paths not yet covered

  • workflow-execution-fan-out — Multi-file workflow execution fans out to file-processing workers and rejoins. (declared coverage: no groups declared)
✅ Covered critical paths
  • auth-login — covered by e2e-login
  • adapter-register-llm — covered by integration-backend
  • workflow-author — covered by integration-backend
  • co-owner-manage — covered by integration-backend, e2e-coowners
  • workflow-create-execute — covered by e2e-workflow
  • api-deployment-provision — covered by integration-backend
  • api-deployment-auth — covered by integration-backend
  • api-deployment-run — covered by e2e-api-deployment
  • mcp-server-auth — covered by integration-backend
  • mcp-platform-auth — covered by integration-backend
  • prompt-studio-author — covered by integration-backend
  • prompt-studio-fetch-response — covered by e2e-prompt-studio
  • connector-register-test — covered by integration-backend
  • pipeline-etl-execute — covered by e2e-etl
  • usage-aggregate-read — covered by integration-backend
  • usage-token-tracking — covered by e2e-api-deployment
  • callback-result-delivery — covered by e2e-api-deployment

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