Skip to content

[Refactor] Roll out stream helpers to base OpenAI specs - #1092

Merged
edelauna merged 1 commit into
mainfrom
refactor/base-openai-usage-stream-test-utils-06q4nypl2c73c
Aug 1, 2026
Merged

[Refactor] Roll out stream helpers to base OpenAI specs#1092
edelauna merged 1 commit into
mainfrom
refactor/base-openai-usage-stream-test-utils-06q4nypl2c73c

Conversation

@zoomote

@zoomote zoomote Bot commented Aug 1, 2026

Copy link
Copy Markdown
Contributor

Created by Roomote. Follow up by mentioning @roomote, in the web UI, or in Discord.

What changed

  • Refactored base-openai-compatible-provider.spec.ts to replace custom async-iterator mock objects with asyncStreamFrom and pure collect loops with collectStream.
  • Refactored openai-usage-tracking.spec.ts to use the same shared helpers and adjusted the final usage assertion to stay type-safe on the chunk union.
  • Removed the stale openai-usage-tracking.spec.ts ESLint suppressions entry after its explicit-any suppressions dropped to zero.

Why this change was made

This continues the approved test-utils rollout with another multi-file batch. openai.spec.ts was intentionally deferred as a larger standalone follow-up so this batch stays reviewable.

Impact

No user-facing behavior change. Two more provider specs use the shared stream-helper idiom, targeted tests passed, src lint/typecheck passed, and the full Zoo-Code test suite passed.

Related PRs

@zoomote

zoomote Bot commented Aug 1, 2026

Copy link
Copy Markdown
Contributor Author

No code issues found. See task

Review summary

The refactor is a faithful mechanical swap of custom async-iterator mocks for asyncStreamFrom and manual collect loops for collectStream across both specs. Verified in context:

  • asyncStreamFrom returns an AsyncGenerator, which is itself async-iterable, so it is a drop-in replacement for the previous [Symbol.asyncIterator] mock objects; each stream is consumed exactly once per test, so the single-use nature of generators is not an issue.
  • All chunk sequences, expected outputs, and assertions are preserved 1:1, including tool-call, reasoning-tag, and usage-tracking cases. The toMatchObject change on the final usage assertion in openai-usage-tracking.spec.ts is equivalent in coverage.
  • The removed ESLint suppression entry for openai-usage-tracking.spec.ts is correct: the file no longer contains any explicit any. The remaining base-openai-compatible-provider.spec.ts suppression (count 1) still matches the pre-existing (c: any) on line 375.
  • Verified locally: both specs pass (18 tests) and eslint --prune-suppressions --max-warnings=0 passes on both files.

Reviewed 58d38c7

@codecov

codecov Bot commented Aug 1, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@edelauna
edelauna marked this pull request as ready for review August 1, 2026 16:28
@edelauna
edelauna enabled auto-merge August 1, 2026 16:29
@edelauna
edelauna added this pull request to the merge queue Aug 1, 2026
Merged via the queue into main with commit 979b174 Aug 1, 2026
24 checks passed
@edelauna
edelauna deleted the refactor/base-openai-usage-stream-test-utils-06q4nypl2c73c branch August 1, 2026 16:42
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.

2 participants