Skip to content

Recovered: feat: support TESTSPRITE_PROJECT_ID default (#144 by @naufalfx805-source)#249

Open
jangjos-128 wants to merge 2 commits into
TestSprite:mainfrom
naufalfx805-source:fix/issue-76-project-env-default
Open

Recovered: feat: support TESTSPRITE_PROJECT_ID default (#144 by @naufalfx805-source)#249
jangjos-128 wants to merge 2 commits into
TestSprite:mainfrom
naufalfx805-source:fix/issue-76-project-env-default

Conversation

@jangjos-128

@jangjos-128 jangjos-128 commented Jul 13, 2026

Copy link
Copy Markdown
Contributor

Refs #76

Discord: npall_805

Summary:

  • add TESTSPRITE_PROJECT_ID fallback for test list, test create, and test run --all
  • keep explicit --project precedence and preserve existing VALIDATION_ERROR behavior when neither is set
  • document the env var and add regression coverage for list/create/run-all paths

Validation:

  • npm test -- src/commands/test.test.ts src/commands/test.run.spec.ts
  • npm run typecheck
  • npm run lint
  • npm run build
  • npx prettier --check src/commands/test.ts src/commands/test.test.ts src/commands/test.run.spec.ts DOCUMENTATION.md
  • git diff --check

Summary by CodeRabbit

  • New Features

    • Added support for using TESTSPRITE_PROJECT_ID as the default project for test listing, creation, and running all tests.
    • Explicit --project values continue to take precedence over the environment setting.
    • Improved project-related validation messages to identify the required environment variable.
  • Documentation

    • Documented TESTSPRITE_PROJECT_ID and its supported command usage.

@coderabbitai

coderabbitai Bot commented Jul 13, 2026

Copy link
Copy Markdown

Review Change Stack

Walkthrough

The CLI now falls back to TESTSPRITE_PROJECT_ID when --project is omitted or blank for test list, test create, and test run --all. Explicit project flags take precedence, with validation, request propagation, tests, and documentation updated.

Changes

Project ID fallback

Layer / File(s) Summary
List and create project resolution
src/commands/test.ts, src/commands/test.test.ts, DOCUMENTATION.md
List and create commands resolve project identifiers from flags or TESTSPRITE_PROJECT_ID, propagate them through API requests and dashboard URLs, and document the environment variable.
Batch run project resolution
src/commands/test.ts, src/commands/test.run.spec.ts
test run --all resolves and validates the effective project identifier, then includes it in batch requests and related messages.
Estimated code review effort: 3 (Moderate) ~20 minutes

Possibly related issues

  • #76 — Directly implements the requested TESTSPRITE_PROJECT_ID fallback for listing, creating, and running tests.

Suggested reviewers: ruili-testsprite, zeshi-du

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title matches the main change by describing the new TESTSPRITE_PROJECT_ID fallback default.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
⚔️ Resolve merge conflicts
  • Resolve merge conflict in branch fix/issue-76-project-env-default

Warning

There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.

🔧 ESLint

If the error stems from missing dependencies, add them to the package.json file. For unrecoverable errors (e.g., due to private dependencies), disable the tool in the CodeRabbit configuration.

ESLint install failed: private package registry requires authentication. Disable ESLint in CodeRabbit settings or use public packages.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@src/commands/test.ts`:
- Around line 7471-7475: Update the test run --all command’s option description
and usage examples to state that the project ID may come from --project or
TESTSPRITE_PROJECT_ID, including that the explicit --project value takes
precedence. Keep the requireProjectId validation in the handler aligned with
this documented behavior and ensure user-facing help no longer says --project is
mandatory.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: b27c056e-6cd7-4f12-b55c-1a32d6a73d49

📥 Commits

Reviewing files that changed from the base of the PR and between 60d55e4 and c70e2ad.

📒 Files selected for processing (4)
  • DOCUMENTATION.md
  • src/commands/test.run.spec.ts
  • src/commands/test.test.ts
  • src/commands/test.ts

Comment thread src/commands/test.ts
Comment on lines +7471 to +7475
const projectId = resolveProjectId(cmdOpts.project, deps);
requireProjectId(
projectId,
'--all requires a project id - pass --project <id> or set TESTSPRITE_PROJECT_ID',
);

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win

Update test run --all help text for the environment fallback.

The handler now accepts --project or TESTSPRITE_PROJECT_ID, but the command descriptions still say --project is required. This contradicts the new validation behavior and hides the supported environment-based invocation; update the option description and examples to mention both sources and flag precedence.

As per path instructions, CLI correctness includes clear user-facing error and usage behavior.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/commands/test.ts` around lines 7471 - 7475, Update the test run --all
command’s option description and usage examples to state that the project ID may
come from --project or TESTSPRITE_PROJECT_ID, including that the explicit
--project value takes precedence. Keep the requireProjectId validation in the
handler aligned with this documented behavior and ensure user-facing help no
longer says --project is mandatory.

Source: Path instructions

@jangjos-128

Copy link
Copy Markdown
Contributor Author

Hi @naufalfx805-source 👋 — this is the recovery of your PR #144 , which was auto-closed by an error in our 2026-07-09 release process. Your commits are intact — thank you for the contribution!

It currently shows merge conflicts because main has moved on since your branch was cut. To clear them, update your PR branch (BRANCH) against the latest main — either option works and both update this PR in place:

Option A — merge (no force-push):

git checkout BRANCH
git fetch upstream          # your remote for TestSprite/testsprite-cli (may be "origin")
git merge upstream/main     # resolve conflicts, commit
git push

Option B — rebase (cleaner history, needs force):

git checkout BRANCH
git fetch upstream
git rebase upstream/main    # resolve conflicts
git push --force-with-lease

Once you push, the conflicts here resolve automatically and we'll take it into review.

Sorry again for the extra step!

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