Skip to content

test(mimo): add advanced streaming scenario tests for Mimo provider#220

Open
proyectoauraorg wants to merge 1 commit into
Zoo-Code-Org:mainfrom
proyectoauraorg:test/mimo-completePrompt-tests
Open

test(mimo): add advanced streaming scenario tests for Mimo provider#220
proyectoauraorg wants to merge 1 commit into
Zoo-Code-Org:mainfrom
proyectoauraorg:test/mimo-completePrompt-tests

Conversation

@proyectoauraorg
Copy link
Copy Markdown
Contributor

@proyectoauraorg proyectoauraorg commented May 20, 2026

Summary

  • Adds comprehensive unit tests for the Mimo provider's completePrompt method and advanced streaming behavior
  • Covers edge cases including multipart messages, cache control, tool definitions, usage tracking, and error handling
  • Tests streaming completion, stop reasons, and provider-specific behaviors
  • Complements PR test: add comprehensive unit tests for MimoHandler provider #210 which tests the core MimoHandler

Test Coverage

  • completePrompt with various message types (text, image, PDF, cache control)
  • Multipart system prompts with multiple content blocks
  • Tool definition handling and conversion
  • Usage tracking (cached input tokens, reasoning tokens)
  • Stop reason mapping (toolUse → tool_use, etc.)
  • Error handling (AuthenticationError, NetworkError, RateLimitError)
  • Base URL configuration and model ID reporting

Summary by CodeRabbit

  • Tests
    • Added streaming-focused tests to verify concatenation of streamed text into a final result.
    • Added tests for mixed streams combining reasoning, text, and partial tool-call segments.
    • Added checks ensuring no usage entries are emitted when the final stream reports null usage.
    • Added checks to omit usage-related fields when their values are zero.

Review Change Stack

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented May 20, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: ad1fc707-9687-4d04-a97b-240192d3c321

📥 Commits

Reviewing files that changed from the base of the PR and between c30b488 and f5060db.

📒 Files selected for processing (1)
  • src/api/providers/__tests__/mimo.spec.ts

📝 Walkthrough

Walkthrough

Adds streaming-focused tests to MiMoHandler that validate multi-chunk text concatenation, mixed reasoning/text/tool-call delta handling, suppression of usage when final chunk's usage is null, and omission of zero-valued cache-token fields.

Changes

MiMoHandler streaming tests

Layer / File(s) Summary
Concatenate multiple text deltas
src/api/providers/__tests__/mimo.spec.ts
Mocks a stream with three delta.content chunks and asserts emitted text concatenates to "Hello world!".
Mixed reasoning/text/tool-call deltas
src/api/providers/__tests__/mimo.spec.ts
Adds a stream test combining reasoning deltas, text deltas, and partial tool_call deltas; verifies concatenated reasoning/text and emitted sanitized partial tool-call events.
No usage when final chunk usage is null
src/api/providers/__tests__/mimo.spec.ts
Verifies that if the final streamed chunk has usage: null, no usage chunks are emitted while text content is still emitted.
Omit zero-valued cache token fields
src/api/providers/__tests__/mimo.spec.ts
Checks emitted usage omits cache_write_tokens and cached_tokens when both are zero in streamed usage output.

Estimated Code Review Effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

  • Zoo-Code-Org/Zoo-Code#210: Extends mimo.spec.ts with MiMoHandler streaming tests around combining streamed text + tool_call_partial deltas and suppressing/omitting usage output when usage: null or cache-token fields are zero.

Suggested reviewers

  • taltas
  • navedmerchant
  • hannesrudolph
  • JamesRobert20

Poem

🐇 A stream of tokens stitched so neat,
Chunks that converge where messages meet.
No stray usage when null comes through,
And zero tokens quietly bid adieu.
Hooray — the handler hops to something new!

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Description check ⚠️ Warning The PR description is missing critical required sections from the template including Related GitHub Issue (no issue number provided), Test Procedure (no testing steps), and Pre-Submission Checklist. Add the Related GitHub Issue section with the issue number, provide detailed Test Procedure steps, and complete the Pre-Submission Checklist. Ensure all template sections are filled out.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely describes the main contribution: adding advanced streaming scenario tests for the Mimo provider.
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.

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

✨ 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.

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)
src/api/providers/__tests__/mimo.spec.ts (1)

734-739: ⚡ Quick win

Tighten the “without stream option” assertion to enforce omission.

This currently passes for stream: false, which is different from omitting stream. Assert toBeUndefined() to match the test intent.

Suggested diff
 			it("should call create without stream option", async () => {
 				await handler.completePrompt("What is 2+2?")

 				const params = mockCreate.mock.calls[0][0]
-				expect(params.stream).toBeFalsy()
+				expect(params.stream).toBeUndefined()
 			})
🤖 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/api/providers/__tests__/mimo.spec.ts` around lines 734 - 739, The test
currently asserts params.stream is falsy which allows stream: false; change the
assertion to require the property be omitted by asserting params.stream is
undefined. In the "should call create without stream option" test that calls
handler.completePrompt("What is 2+2?"), replace
expect(params.stream).toBeFalsy() with an assertion that params.stream ===
undefined (e.g., expect(params.stream).toBeUndefined()) so mockCreate's first
call payload truly omits the stream field.
🤖 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.

Nitpick comments:
In `@src/api/providers/__tests__/mimo.spec.ts`:
- Around line 734-739: The test currently asserts params.stream is falsy which
allows stream: false; change the assertion to require the property be omitted by
asserting params.stream is undefined. In the "should call create without stream
option" test that calls handler.completePrompt("What is 2+2?"), replace
expect(params.stream).toBeFalsy() with an assertion that params.stream ===
undefined (e.g., expect(params.stream).toBeUndefined()) so mockCreate's first
call payload truly omits the stream field.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 11ea96de-b39f-4470-9377-8aa8a745c05a

📥 Commits

Reviewing files that changed from the base of the PR and between 79ed8b5 and c30b488.

📒 Files selected for processing (1)
  • src/api/providers/__tests__/mimo.spec.ts

@codecov
Copy link
Copy Markdown

codecov Bot commented May 21, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

Rebased onto main. The completePrompt coverage from the original PR is now
provided by the merged Zoo-Code-Org#210, so this focuses on its net-new contribution:
4 advanced streaming resilience tests (multi-chunk text concatenation,
interleaved reasoning + tool calls, missing usage in final chunk, and
zero-valued cache tokens). 49 tests pass.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
@proyectoauraorg proyectoauraorg force-pushed the test/mimo-completePrompt-tests branch from c30b488 to f5060db Compare May 21, 2026 08:05
@proyectoauraorg proyectoauraorg changed the title test(mimo): add completePrompt and advanced streaming tests for Mimo provider test(mimo): add advanced streaming scenario tests for Mimo provider May 21, 2026
@proyectoauraorg
Copy link
Copy Markdown
Contributor Author

Rebased onto latest `main` to resolve the conflict with the now-merged #210.

Since #210 already lands comprehensive `completePrompt` coverage, I dropped the overlapping `completePrompt` block from this PR and kept its net-new contribution: 4 advanced streaming resilience tests (multi-chunk text concatenation, interleaved reasoning + tool calls, missing usage in the final chunk, and zero-valued cache tokens). 49 tests pass locally. Ready for review.

@proyectoauraorg
Copy link
Copy Markdown
Contributor Author

Re: the `toBeFalsy()` → `toBeUndefined()` nitpick — that assertion lived in the `completePrompt` block, which I dropped during the rebase since #210 already covers it. The remaining `advanced streaming` tests use `toBeUndefined()` already, so this one is moot now. Thanks @coderabbitai 🙏

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented May 21, 2026

Tip

For best results, initiate chat on the files or code changes.

@proyectoauraorg: Thanks for the clear explanation! Since the completePrompt block was dropped entirely, the nitpick is indeed moot. The remaining advanced streaming tests are already using toBeUndefined() — all good. 🙏

(ノ◕ヮ◕)ノ*:・゚✧🐰

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