Skip to content

fix(tests): unblock 14 pre-existing failures in ai-models test suite - #90

Merged
KrasimirKralev merged 1 commit into
ID-Robots:betafrom
KrasimirKralev:fix/ai-models-test-suite
Apr 19, 2026
Merged

fix(tests): unblock 14 pre-existing failures in ai-models test suite#90
KrasimirKralev merged 1 commit into
ID-Robots:betafrom
KrasimirKralev:fix/ai-models-test-suite

Conversation

@KrasimirKralev

Copy link
Copy Markdown
Contributor

Summary

14 tests had been red on beta since the Gemma / provider-switch work in PRs #82/#83 landed. CI was useless as a signal β€” every PR inherited 14 failures regardless of actual correctness. This PR is test-only β€” no production code changes β€” and gets CI back to green so real regressions stop hiding in the noise.

Root causes (three independent)

  1. Mock drift from configure route's real imports. The route now calls applyModelOverrideToAllAgentSessions and parseFullyQualifiedModel (added in fix(ai-provider): sweep sessions + show switch progress + green bannerΒ #83 for session sweeping), plus four getters from @/lib/llamacpp and one from @/lib/local-ai-runtime. The test mocked none of these. First request-time call threw, outer catch returned 500, every test asserting 200 cascaded red. Added the missing mocks with real-shape implementations.

  2. vitest-under-bun clears mock implementations along with call history. Factory defaults set inside vi.mock(...) survive vi.resetModules but not vi.clearAllMocks(). Tests passed in isolation, failed in sequence. Re-apply the implementations in beforeEach.

  3. ai-models-step.test.tsx relied on llamaCppIsActive defaulting true. The panel only sets it true when currentProviderId === "llamacpp". Added the prop.

Simplifier findings applied

  • Mirror real parseFullyQualifiedModel byte-for-byte (idx <= 0 || idx === fq.length - 1) so trailing-slash inputs reject as expected. Fixed the same drift in chat-model.test.ts.
  • Extract shared proxy-URL constant via vi.hoisted to avoid duplicating a magic string across two mock factories.

Result

Before: 14 failed / 1055 passed (93 files, 2 red)
After: 1069 passed (93 files, all green)

Test plan

  • bun run test β€” 1069/1069 pass locally
  • CI should now show test: SUCCESS for the first time in weeks

14 tests had been red on beta since before the Gemma/provider-switch
work in PRs ID-Robots#82/ID-Robots#83 landed. Three separate root causes:

1. Test mocks drifted from the configure route's real imports.
   The route now calls `applyModelOverrideToAllAgentSessions` and
   `parseFullyQualifiedModel` (added in ID-Robots#83 for session sweeping),
   plus four functions from `@/lib/llamacpp` and one from
   `@/lib/local-ai-runtime`. Tests mocked none of these, so the
   first request-time call to any of them threw and the route
   returned 500 β€” producing the "expected 200 to be 500" cascade.
   Added the missing mocks with real-shape implementations.

2. vitest-under-bun clears mock implementations along with call
   history in `vi.clearAllMocks()`. Factory defaults set inside
   `vi.mock(...)` survive `vi.resetModules` but not `mockClear`.
   Tests passed in isolation, failed in sequence. Re-apply the
   implementations in `beforeEach` so each test starts with a
   consistent mock surface.

3. The ai-models-step component test relied on `llamaCppIsActive`
   defaulting true, but the panel only sets it true when
   `currentProviderId === "llamacpp"`. Without that prop the
   "Gemma 4 is already configured" pill never rendered. Added the
   prop.

Extras during simplifier pass:
- Mirror real `parseFullyQualifiedModel` logic byte-for-byte
  (`idx <= 0 || idx === fq.length - 1`) so trailing-slash inputs
  reject as expected. Fixed drift in `chat-model.test.ts` too.
- Extract shared proxy-URL constant via `vi.hoisted` to avoid
  duplicating the magic string across two mock factories.

Result: 93/93 files, 1069/1069 tests pass β€” CI signal restored.
@KrasimirKralev
KrasimirKralev requested a review from a team as a code owner April 19, 2026 17:10
@coderabbitai

coderabbitai Bot commented Apr 19, 2026

Copy link
Copy Markdown

Warning

Rate limit exceeded

@KrasimirKralev has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 26 minutes and 4 seconds before requesting another review.

Your organization is not enrolled in usage-based pricing. Contact your admin to enable usage-based pricing to continue reviews beyond the rate limit, or try again in 26 minutes and 4 seconds.

βŒ› How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

ℹ️ Review info
βš™οΈ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

Run ID: e98976c1-9d7a-43e5-8321-aa1f56eb6e18

πŸ“₯ Commits

Reviewing files that changed from the base of the PR and between 08259bb and 036a343.

πŸ“’ Files selected for processing (3)
  • src/tests/components/ai-models-step.test.tsx
  • src/tests/routes/ai-models/configure.test.ts
  • src/tests/routes/chat-model.test.ts
✨ Finishing Touches
πŸ§ͺ Generate unit tests (beta)
  • Create PR with unit tests

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.

@KrasimirKralev

Copy link
Copy Markdown
Contributor Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Apr 19, 2026

Copy link
Copy Markdown
βœ… Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@KrasimirKralev
KrasimirKralev merged commit a18c338 into ID-Robots:beta Apr 19, 2026
5 checks passed
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