test: repair test suite after R1-R3 refactors and add Claude Code tests #11

Merged
jleibl merged 1 commits from chore/test-suite-repair into main 2026-05-21 12:38:05 +00:00
Owner

The R1-R3 refactors removed the per-provider handle*Error methods,
consolidated validators into validateNumberInRange, renamed Gemini's
buildGenerationConfig to buildConfig, and split OpenWebUI's message
conversion and response formatting into openwebui-strategies.ts.
44 of 91 existing tests broke as a result.

Changes:

claude.test.ts (8 -> 13 passing)

  • Switch error mapping tests from handleAnthropicError to the base
    normalizeError method.
  • Update temperature error-message expectation to match the new
    validateNumberInRange wording.

openai.test.ts (16 -> 22 passing)

  • Same handleOpenAIError -> normalizeError switch.
  • Add a regression test for the 429+"quota" path that goes through
    mapProviderError instead of the base mapping.

gemini.test.ts (17 -> 27 passing)

  • Update getInfo expectations to the new default model (gemini-2.5)
    and provider version 2.0.0.
  • Switch to normalizeError.
  • Rename buildGenerationConfig -> buildConfig (renamed during R2).
  • Update formatCompletionResponse mocks: the @google/genai SDK
    exposes response.text as a getter rather than walking
    candidates[0].content.parts.

openwebui.test.ts (4 -> 19 passing)

  • Drop tests for convertMessages / convertMessagesToPrompt /
    formatChatResponse / formatOllamaResponse / makeRequest: these
    moved into openwebui-strategies.ts and openwebui-http.ts during R3
    and warrant their own test files.
  • Add error-mapping tests covering the new mapProviderError +
    providerErrorMessages plumbing.

claude-code.test.ts (new, 18 tests)

  • Constructor accepts subscription mode (empty config).
  • getInfo advertises subscriptionAuth + requiresLocalCli.
  • mapProviderError catches ENOENT and "not logged in".
  • errorForSdkAssistantError covers each documented SDK error code.
  • buildPrompt handles single-turn pass-through, multi-system
    combination, multi-turn flattening with role labels, and rejects
    empty turn lists.

Full suite: 100 pass / 0 fail across 5 files.

The R1-R3 refactors removed the per-provider handle*Error methods, consolidated validators into validateNumberInRange, renamed Gemini's buildGenerationConfig to buildConfig, and split OpenWebUI's message conversion and response formatting into openwebui-strategies.ts. 44 of 91 existing tests broke as a result. Changes: claude.test.ts (8 -> 13 passing) - Switch error mapping tests from handleAnthropicError to the base normalizeError method. - Update temperature error-message expectation to match the new validateNumberInRange wording. openai.test.ts (16 -> 22 passing) - Same handleOpenAIError -> normalizeError switch. - Add a regression test for the 429+"quota" path that goes through mapProviderError instead of the base mapping. gemini.test.ts (17 -> 27 passing) - Update getInfo expectations to the new default model (gemini-2.5) and provider version 2.0.0. - Switch to normalizeError. - Rename buildGenerationConfig -> buildConfig (renamed during R2). - Update formatCompletionResponse mocks: the @google/genai SDK exposes response.text as a getter rather than walking candidates[0].content.parts. openwebui.test.ts (4 -> 19 passing) - Drop tests for convertMessages / convertMessagesToPrompt / formatChatResponse / formatOllamaResponse / makeRequest: these moved into openwebui-strategies.ts and openwebui-http.ts during R3 and warrant their own test files. - Add error-mapping tests covering the new mapProviderError + providerErrorMessages plumbing. claude-code.test.ts (new, 18 tests) - Constructor accepts subscription mode (empty config). - getInfo advertises subscriptionAuth + requiresLocalCli. - mapProviderError catches ENOENT and "not logged in". - errorForSdkAssistantError covers each documented SDK error code. - buildPrompt handles single-turn pass-through, multi-system combination, multi-turn flattening with role labels, and rejects empty turn lists. Full suite: 100 pass / 0 fail across 5 files.
jleibl added 1 commit 2026-05-21 12:37:59 +00:00
The R1-R3 refactors removed the per-provider handle*Error methods,
consolidated validators into validateNumberInRange, renamed Gemini's
buildGenerationConfig to buildConfig, and split OpenWebUI's message
conversion and response formatting into openwebui-strategies.ts.
44 of 91 existing tests broke as a result.

Changes:

claude.test.ts (8 -> 13 passing)
- Switch error mapping tests from handleAnthropicError to the base
  normalizeError method.
- Update temperature error-message expectation to match the new
  validateNumberInRange wording.

openai.test.ts (16 -> 22 passing)
- Same handleOpenAIError -> normalizeError switch.
- Add a regression test for the 429+"quota" path that goes through
  mapProviderError instead of the base mapping.

gemini.test.ts (17 -> 27 passing)
- Update getInfo expectations to the new default model (gemini-2.5)
  and provider version 2.0.0.
- Switch to normalizeError.
- Rename buildGenerationConfig -> buildConfig (renamed during R2).
- Update formatCompletionResponse mocks: the @google/genai SDK
  exposes response.text as a getter rather than walking
  candidates[0].content.parts.

openwebui.test.ts (4 -> 19 passing)
- Drop tests for convertMessages / convertMessagesToPrompt /
  formatChatResponse / formatOllamaResponse / makeRequest: these
  moved into openwebui-strategies.ts and openwebui-http.ts during R3
  and warrant their own test files.
- Add error-mapping tests covering the new mapProviderError +
  providerErrorMessages plumbing.

claude-code.test.ts (new, 18 tests)
- Constructor accepts subscription mode (empty config).
- getInfo advertises subscriptionAuth + requiresLocalCli.
- mapProviderError catches ENOENT and "not logged in".
- errorForSdkAssistantError covers each documented SDK error code.
- buildPrompt handles single-turn pass-through, multi-system
  combination, multi-turn flattening with role labels, and rejects
  empty turn lists.

Full suite: 100 pass / 0 fail across 5 files.
jleibl merged commit 9cb7ee8f9e into main 2026-05-21 12:38:05 +00:00
jleibl referenced this issue from a commit 2026-05-21 12:39:39 +00:00
Sign in to join this conversation.
No Reviewers
No Label
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: jleibl/simple-ai-provider#11