Skip to content

[Chore][Fix]: Skip Failing CLI Tests, Rework Failing AI Endpoint Validation test#1258

Merged
nams1570 merged 2 commits intodevfrom
fix-cli-create-tests
Mar 16, 2026
Merged

[Chore][Fix]: Skip Failing CLI Tests, Rework Failing AI Endpoint Validation test#1258
nams1570 merged 2 commits intodevfrom
fix-cli-create-tests

Conversation

@nams1570
Copy link
Copy Markdown
Collaborator

@nams1570 nams1570 commented Mar 16, 2026

Context

In a previous PR, we hardcoded the mode to link because local emulator wasn't in a ready state yet. Soon after, we started encountering three failing tests on dev

The three cli tests that were failing on dev were failing because they required the create mode flag to be set. The hardcode to link made the create paths unreachable. Since we don't have local emulator working, allowing users to pass in opts.mode would be bad practice- they'd be triggering local emulator actions without the local emulator being set up.

Also, there was a failing AI endpoint test. The unified AI endpoint tests are set up so that if certain env variables are not present, certain tests aren't run. In practice, if the openrouter key isn't set, the tests that require actually processing a full AI endpoint result without forwarding to prod will be skipped. The failing test was meant to just check schema validation but it performed a full request instead.

Summary of Changes

We just skip the tests for now. They'll only become relevant when "create" is a legitimate workflow, which necessitates the function of local emulator. There is no regression risk because the flow they're testing isn't active yet, and so the only thing we could possibly test is that passing the create mode will invoke a certain function which isn't helpful at this state.

The unified AI endpoint failing test was reworked, another test accomplishes the same schema validation effect. We don't lose coverage by axing the failing test because other AI tests already test valid request bodies (if they weren't valid, they wouldn't get a response).

Summary by CodeRabbit

  • Tests
    • Strengthened an API validation test to use a deterministic payload and assert a clear "Invalid tool names" error for invalid tool inputs.
    • Deferred several CLI initialization tests (skipped with TODOs) related to stack configuration creation and setup instruction output for future re-enablement.

The three cli tests that were failing on dev were failing because they required the create mode flag to be set.
The hardcode to link made the create paths unreachable.
Since we don't have local emulator working, allowing users to pass in opts.mode would be bad practice- they'd be triggering local emulator actions without the local emulator being set up.
@vercel
Copy link
Copy Markdown

vercel Bot commented Mar 16, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
stack-auth-hosted-components Ready Ready Preview, Comment Mar 16, 2026 9:43pm
stack-backend Ready Ready Preview, Comment Mar 16, 2026 9:43pm
stack-dashboard Ready Ready Preview, Comment Mar 16, 2026 9:43pm
stack-demo Ready Ready Preview, Comment Mar 16, 2026 9:43pm
stack-docs Ready Ready Preview, Comment Mar 16, 2026 9:43pm

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Mar 16, 2026

📝 Walkthrough

Walkthrough

Removed a production-forwarding AI query test and replaced it with a deterministic schema-level invalid-tool test that asserts 400 with "Invalid tool names". Additionally, three CLI init end-to-end tests were marked as skipped with TODO comments.

Changes

Cohort / File(s) Summary
AI Query Endpoint Test
apps/e2e/tests/backend/endpoints/api/v1/ai-query.test.ts
Removed the long/forward-production validation test; updated test to perform deterministic route-level tool-name validation and assert a 400 response containing "Invalid tool names".
Skipped CLI Tests
apps/e2e/tests/general/cli.test.ts
Marked three CLI init-related tests as skipped (init create writes stack.config.ts with selected apps, init create with single app, init outputs setup instructions) and added TODO comments for re-enablement.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Possibly related PRs

  • CLI init #1242 — Overlaps changes to CLI init tests and related test behavior in apps/e2e/tests/general/cli.test.ts.

Poem

🐰 I swapped a long hop for a small, sure stride,
Validating tools on the deterministic side.
Three CLI tests now rest with a TODO sign,
Quiet for now—I'll wake them when it's time.
Tiny paws, tidy tests, and a carrot-lined rhyme. 🥕

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately reflects the main changes: skipping failing CLI tests and reworking the AI endpoint validation test, with clear categorization as chore and fix.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Description check ✅ Passed The pull request description is comprehensive and well-structured, providing clear context, reasoning, and a detailed summary of changes.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
  • 📝 Generate docstrings (stacked PR)
  • 📝 Generate docstrings (commit on current branch)
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch fix-cli-create-tests
📝 Coding Plan
  • Generate coding plan for human review comments

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 and usage tips.

@nams1570 nams1570 marked this pull request as ready for review March 16, 2026 20:32
Copilot AI review requested due to automatic review settings March 16, 2026 20:32
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Skips three CLI tests that test "create" mode functionality, which is currently unreachable because the init mode was hardcoded to "link" in a previous PR (#1258) while the local emulator isn't ready.

Changes:

  • Skip three it() test cases by changing them to it.skip() with a TODO comment explaining why

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@greptile-apps
Copy link
Copy Markdown
Contributor

greptile-apps Bot commented Mar 16, 2026

Greptile Summary

Skips three CLI e2e tests that test the init --mode create flow, which is currently unreachable because the mode was hardcoded to "link" in packages/stack-cli/src/commands/init.ts (line 59) while the local emulator feature is not yet ready. The TODO comment explains these will be re-enabled once init mode handling is finalized.

  • All three skipped tests (it.skip) use --mode create, which cannot reach handleCreate() due to the hardcoded mode
  • The remaining link-config and link-cloud tests are correctly left active since handleLink() internally routes based on opts.mode
  • No regression risk since the "create" code path is already unreachable in production

Confidence Score: 5/5

  • This PR is safe to merge — it only skips tests for an already-unreachable code path
  • The change is minimal and well-justified: three tests are skipped with it.skip (not deleted), the code path they test is confirmed unreachable due to the hardcoded mode in init.ts, and all active link-mode tests remain unchanged
  • No files require special attention

Important Files Changed

Filename Overview
apps/e2e/tests/general/cli.test.ts Skips three tests that use --mode create which is unreachable due to hardcoded mode = "link" in init.ts. The link-config and link-cloud tests remain active. No issues found.

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart TD
    A["stack init --mode X"] --> B["runInit()"]
    B --> C{"mode = 'link' (hardcoded)"}
    C -->|"mode == link/link-config/link-cloud"| D["handleLink()"]
    C -->|"mode == create"| E["handleCreate() ❌ UNREACHABLE"]
    D --> F{"opts.mode?"}
    F -->|"link-config"| G["handleLinkFromConfigFile()"]
    F -->|"link-cloud or default"| H["handleLinkFromCloud()"]
    E --> I["Writes stack.config.ts"]
    
    style E fill:#ff6b6b,color:#fff
    style I fill:#ff6b6b,color:#fff
Loading

Last reviewed commit: 0f78042

@nams1570 nams1570 requested a review from N2D4 March 16, 2026 21:30
@nams1570 nams1570 changed the title [Chore][Fix]: Skip Failing CLI Tests While Local-Emulator isn't Setup [Chore][Fix]: Skip Failing CLI Tests, Rework Failing AI Endpoint Validation test Mar 16, 2026
Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

🧹 Nitpick comments (1)
apps/e2e/tests/backend/endpoints/api/v1/ai-query.test.ts (1)

201-220: Consider consolidating with existing test at lines 116-131.

The test at lines 116-131 ("rejects invalid tool names") already covers the same scenario—invalid tool names causing a 400 response. Both tests:

  • Are in non-AI describe blocks (run without AI key)
  • Use invalid tool names in an otherwise valid request body
  • Assert the same response (400 + "Invalid tool names")

If the intent is to have an explicitly "deterministic" test, consider either:

  1. Moving the existing test (116-131) into this new describe block, or
  2. Adding a comment explaining how this test differs from the existing one

Also, the comment on line 203 ("for schema validation") is slightly misleading since this test specifically verifies schema validation passes and then business logic validation fails.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@apps/e2e/tests/backend/endpoints/api/v1/ai-query.test.ts` around lines 201 -
220, There's a duplicate test scenario: the "AI Query Endpoint - Validation
(deterministic)" test that posts an invalid tool name overlaps with the existing
"rejects invalid tool names" test; either consolidate by moving the "rejects
invalid tool names" test into the "AI Query Endpoint - Validation
(deterministic)" describe block (or remove the newer duplicate), or explicitly
document how the deterministic test differs; also update the misleading inline
comment that says "for schema validation" to state that schema validation passes
and business-logic validation (invalid tool names) is expected to fail so the
test intent is clear.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@apps/e2e/tests/backend/endpoints/api/v1/ai-query.test.ts`:
- Around line 201-220: There's a duplicate test scenario: the "AI Query Endpoint
- Validation (deterministic)" test that posts an invalid tool name overlaps with
the existing "rejects invalid tool names" test; either consolidate by moving the
"rejects invalid tool names" test into the "AI Query Endpoint - Validation
(deterministic)" describe block (or remove the newer duplicate), or explicitly
document how the deterministic test differs; also update the misleading inline
comment that says "for schema validation" to state that schema validation passes
and business-logic validation (invalid tool names) is expected to fail so the
test intent is clear.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: b6c0b14b-1e99-432d-a07e-56a0ce5505a3

📥 Commits

Reviewing files that changed from the base of the PR and between 46cacd4 and 423f87f.

📒 Files selected for processing (2)
  • apps/e2e/tests/backend/endpoints/api/v1/ai-query.test.ts
  • apps/e2e/tests/general/cli.test.ts

Previously, this test was flaky because it involved a call to the AI endpoint when it didn't need to.
The test's previous comments indicated it was just for schema validation.
This test was in a block that was run even when there was no key for the job.
Now it's pure validation
@nams1570 nams1570 merged commit db6bd03 into dev Mar 16, 2026
32 of 34 checks passed
@nams1570 nams1570 deleted the fix-cli-create-tests branch March 16, 2026 22:35
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.

3 participants