fix(tests): unblock 14 pre-existing failures in ai-models test suite - #90
Conversation
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.
|
Warning Rate limit exceeded
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 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 configurationConfiguration used: Path: .coderabbit.yaml Review profile: ASSERTIVE Plan: Pro Run ID: π Files selected for processing (3)
β¨ Finishing Touchesπ§ͺ Generate unit tests (beta)
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. Comment |
|
@coderabbitai review |
β Actions performedReview triggered.
|
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)
Mock drift from configure route's real imports. The route now calls
applyModelOverrideToAllAgentSessionsandparseFullyQualifiedModel(added in fix(ai-provider): sweep sessions + show switch progress + green bannerΒ #83 for session sweeping), plus four getters from@/lib/llamacppand 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.vitest-under-bun clears mock implementations along with call history. Factory defaults set inside
vi.mock(...)survivevi.resetModulesbut notvi.clearAllMocks(). Tests passed in isolation, failed in sequence. Re-apply the implementations inbeforeEach.ai-models-step.test.tsxrelied onllamaCppIsActivedefaulting true. The panel only sets it true whencurrentProviderId === "llamacpp". Added the prop.Simplifier findings applied
parseFullyQualifiedModelbyte-for-byte (idx <= 0 || idx === fq.length - 1) so trailing-slash inputs reject as expected. Fixed the same drift inchat-model.test.ts.vi.hoistedto 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 locallytest: SUCCESSfor the first time in weeks