test(worker): configure CIMD compatibility in Vitest - #950
Conversation
|
3 clusters identified |
Reviewer's guide (collapsed on small PRs)Reviewer's GuideConfigures Vitest to load a Cloudflare runtime shim for Node-based tests so that the OAuth provider sees CIMD-related compatibility flags as enabled without affecting production/preview worker configurations. File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
PR Summary by QodoConfigure Cloudflare CIMD compatibility flag for Vitest/Node unit tests
AI Description
Diagram
High-Level Assessment
Files changed (2)
|
|
|
Overall Grade |
Security Reliability Complexity Hygiene |
Code Review Summary
| Analyzer | Status | Updated (UTC) | Details |
|---|---|---|---|
| JavaScript | Aug 9, 2026 7:18a.m. | Review ↗ |
Important
AI Review is run only on demand for your team. We're only showing results of static analysis review right now. To trigger AI Review, comment @deepsourcebot review on this thread.
There was a problem hiding this comment.
Hey - I've left some high level feedback:
- The global
Cloudflaredefinition intests/setup/cloudflare-runtime.tswill apply to all tests; consider scoping or resetting this in a per-suite setup (e.g. viabeforeAll/afterAll) to avoid unintentionally affecting tests that don’t rely on this runtime flag. - When defining
globalThis.Cloudflare, you currently overwrite any existing value; consider checking for and merging with an existingCloudflareobject to avoid clobbering other runtime configuration used in tests.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- The global `Cloudflare` definition in `tests/setup/cloudflare-runtime.ts` will apply to all tests; consider scoping or resetting this in a per-suite setup (e.g. via `beforeAll/afterAll`) to avoid unintentionally affecting tests that don’t rely on this runtime flag.
- When defining `globalThis.Cloudflare`, you currently overwrite any existing value; consider checking for and merging with an existing `Cloudflare` object to avoid clobbering other runtime configuration used in tests.Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
Cloudflare Worker preview
|
MCP tool token costMCP tool token costMeasured with
Component totals
Change from baseline
Per-tool changes
Component changes
Per-tool breakdown
Per-component counts are diagnostic and non-additive because keys and separators live in complete tool objects. Per-tool counts encode each complete tool object independently. The total encodes the complete |
There was a problem hiding this comment.
✨ PR Review
LGTM
Generated by LinearB AI and added by gitStream.
AI-generated content may contain inaccuracies. Please verify before using.
💡 Tip: You can customize your AI Review using Guidelines Learn how
Bundle ReportChanges will increase total bundle size by 18.46kB (7.05%) ⬆️
Affected Assets, Files, and Routes:view changes for bundle: hevy-mcp-esmAssets Changed:
|
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (3)
🚧 Files skipped from review as they are similar to previous changes (1)
📝 WalkthroughWalkthroughVitest now loads a setup file that defines a frozen Wrangler-compatible ChangesCloudflare test runtime
Estimated code review effort: 2 (Simple) | ~10 minutes 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 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 |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 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.
Inline comments:
In `@vitest.config.ts`:
- Line 15: Add a Changesets entry for the test configuration change in
vitest.config.ts, using the repository’s documented empty changeset format if no
published package is affected; otherwise identify the affected package and
include the appropriate non-empty release metadata.
🪄 Autofix
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro Plus
Run ID: e35eed81-146d-4322-afcb-32e03cb97a5b
📒 Files selected for processing (2)
tests/setup/cloudflare-runtime.tsvitest.config.ts
| }, | ||
| }, | ||
| test: { | ||
| setupFiles: ["./tests/setup/cloudflare-runtime.ts"], |
There was a problem hiding this comment.
📐 Maintainability & Code Quality | 🟠 Major | ⚡ Quick win
Add a Changesets entry before merge.
This change affects tracked test configuration and internal runtime behavior. The supplied change set does not include a Changesets file. If the change has no published package impact, use the repository’s documented empty changeset format. Otherwise, add a non-empty changeset for the affected package.
As per coding guidelines, changes affecting tests or internal behavior must include an appropriate Changesets file.
🤖 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 `@vitest.config.ts` at line 15, Add a Changesets entry for the test
configuration change in vitest.config.ts, using the repository’s documented
empty changeset format if no published package is affected; otherwise identify
the affected package and include the appropriate non-empty release metadata.
Source: Coding guidelines
Code Review by Qodo
1.
|
Unit Test Results 1 files 82 suites 25s ⏱️ Results for commit 5a9ce59. ♻️ This comment has been updated with latest results. |
Code Review ✅ ApprovedConfigures Vitest to provide the Cloudflare runtime compatibility flag and global setup required for OAuth provider unit tests. No issues found.
OptionsAuto-apply is off → Gitar will not commit updates to this branch. Comment with these commands to change the behavior for this request:
Was this helpful? React with 👍 / 👎 | Powered by Gitar — free for open source |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #950 +/- ##
==========================================
+ Coverage 82.58% 82.66% +0.07%
==========================================
Files 84 91 +7
Lines 5738 6160 +422
Branches 1620 1731 +111
==========================================
+ Hits 4739 5092 +353
- Misses 458 490 +32
- Partials 541 578 +37 ☔ View full report in Codecov by Harness. |
* refactor: reduce root package scripts * docs: publish runtime architecture review (#940) * docs: attach architecture review to issue 937 * style: format issue 937 architecture report * docs: attach runtime architecture review to issue 941 * chore: scope architecture report PR to issue 941 * fix: apply CodeRabbit auto-fixes Fixed 2 file(s) based on 2 unresolved review comments. Co-authored-by: CodeRabbit <noreply@coderabbit.ai> * fix: format runtime-architecture-review HTML report Co-authored-by: Christoph Kieslich <9047291+chrisdoc@users.noreply.github.com> --------- Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com> Co-authored-by: CodeRabbit <noreply@coderabbit.ai> Co-authored-by: Gitar <noreply@gitar.ai> Co-authored-by: Christoph Kieslich <9047291+chrisdoc@users.noreply.github.com> * refactor: centralize Hevy endpoint policy (#944) * refactor: centralize Hevy endpoint policy * refactor(client): simplify retry failure transition * feat(operations): route routine listing through shared operation (#946) * feat(operations): route routine listing through shared operation * refactor(cli): split command dispatchers * fix(cli): avoid async dispatch wrappers * refactor(node): separate embedding from runtime bootstrap (#947) * refactor(node): separate embedding from runtime bootstrap * fix(node): clean up embedding test diagnostics * fix(node): include runtime chunk in Sentry source maps * refactor(node): centralize process lifecycle (#948) * refactor(node): centralize process lifecycle * fix(node): satisfy lifecycle static analysis * feat(worker): add safe tool observation (#949) * feat(worker): add safe tool observation * refactor(worker): simplify safe observation projection * feat(node): bound HTTP session admission (#951) * feat(node): bound HTTP session admission * refactor(node): split HTTP request admission paths * fix(node): satisfy HTTP admission lint * fix(node): remove HTTP handler lint regressions * test(core): add initial runtime contract matrix (#952) * test(core): add initial runtime contract matrix * fix(test): satisfy contract matrix lint * fix(test): remove redundant async wrappers * style(test): format contract fixture * feat(operations): add routine retrieval operation (#953) * feat(operations): add routine retrieval operation * fix(test): remove redundant routine async wrapper * feat(operations): add workout retrieval operation (#954) * feat(operations): add workout retrieval operation * fix(test): remove redundant workout async wrappers * style(test): format workout fixture * fix(deps): bump hono from 4.12.31 to 4.13.1 (#955) Bumps [hono](https://github.com/honojs/hono) from 4.12.31 to 4.13.1. - [Release notes](https://github.com/honojs/hono/releases) - [Commits](honojs/hono@v4.12.31...v4.13.1) --- updated-dependencies: - dependency-name: hono dependency-version: 4.13.1 dependency-type: indirect ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * test(worker): configure CIMD compatibility in Vitest (#950) * test(worker): configure CIMD compatibility in Vitest * fix(test): harden Cloudflare Vitest runtime setup --------- Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com> Co-authored-by: CodeRabbit <noreply@coderabbit.ai> Co-authored-by: Gitar <noreply@gitar.ai> Co-authored-by: Christoph Kieslich <9047291+chrisdoc@users.noreply.github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
* ci: accelerate build and test workflows * ci: isolate package performance validation * ci: address validation helper findings * ci: align Node 26 coverage output * fix: apply CodeRabbit auto-fixes Fixed 3 file(s) based on 2 unresolved review comments. Co-authored-by: CodeRabbit <noreply@coderabbit.ai> * ci: install mise in build-and-test workflow jobs Co-authored-by: Christoph Kieslich <9047291+chrisdoc@users.noreply.github.com> * test: align control-plane config test with mise-wrapped script commands Co-authored-by: Christoph Kieslich <9047291+chrisdoc@users.noreply.github.com> * fix: correct oxfmt formatting in control-plane config test Co-authored-by: Christoph Kieslich <9047291+chrisdoc@users.noreply.github.com> * ci: enable optional Nx remote cache * docs: publish runtime architecture review (#940) * docs: attach architecture review to issue 937 * style: format issue 937 architecture report * docs: attach runtime architecture review to issue 941 * chore: scope architecture report PR to issue 941 * fix: apply CodeRabbit auto-fixes Fixed 2 file(s) based on 2 unresolved review comments. Co-authored-by: CodeRabbit <noreply@coderabbit.ai> * fix: format runtime-architecture-review HTML report Co-authored-by: Christoph Kieslich <9047291+chrisdoc@users.noreply.github.com> --------- Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com> Co-authored-by: CodeRabbit <noreply@coderabbit.ai> Co-authored-by: Gitar <noreply@gitar.ai> Co-authored-by: Christoph Kieslich <9047291+chrisdoc@users.noreply.github.com> * refactor: centralize Hevy endpoint policy (#944) * refactor: centralize Hevy endpoint policy * refactor(client): simplify retry failure transition * feat(operations): route routine listing through shared operation (#946) * feat(operations): route routine listing through shared operation * refactor(cli): split command dispatchers * fix(cli): avoid async dispatch wrappers * refactor(node): separate embedding from runtime bootstrap (#947) * refactor(node): separate embedding from runtime bootstrap * fix(node): clean up embedding test diagnostics * fix(node): include runtime chunk in Sentry source maps * refactor(node): centralize process lifecycle (#948) * refactor(node): centralize process lifecycle * fix(node): satisfy lifecycle static analysis * feat(worker): add safe tool observation (#949) * feat(worker): add safe tool observation * refactor(worker): simplify safe observation projection * feat(node): bound HTTP session admission (#951) * feat(node): bound HTTP session admission * refactor(node): split HTTP request admission paths * fix(node): satisfy HTTP admission lint * fix(node): remove HTTP handler lint regressions * test(core): add initial runtime contract matrix (#952) * test(core): add initial runtime contract matrix * fix(test): satisfy contract matrix lint * fix(test): remove redundant async wrappers * style(test): format contract fixture * feat(operations): add routine retrieval operation (#953) * feat(operations): add routine retrieval operation * fix(test): remove redundant routine async wrapper * feat(operations): add workout retrieval operation (#954) * feat(operations): add workout retrieval operation * fix(test): remove redundant workout async wrappers * style(test): format workout fixture * fix(deps): bump hono from 4.12.31 to 4.13.1 (#955) Bumps [hono](https://github.com/honojs/hono) from 4.12.31 to 4.13.1. - [Release notes](https://github.com/honojs/hono/releases) - [Commits](honojs/hono@v4.12.31...v4.13.1) --- updated-dependencies: - dependency-name: hono dependency-version: 4.13.1 dependency-type: indirect ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * test(worker): configure CIMD compatibility in Vitest (#950) * test(worker): configure CIMD compatibility in Vitest * fix(test): harden Cloudflare Vitest runtime setup * refactor: reduce root package scripts by 31% (#939) * refactor: reduce root package scripts * docs: publish runtime architecture review (#940) * docs: attach architecture review to issue 937 * style: format issue 937 architecture report * docs: attach runtime architecture review to issue 941 * chore: scope architecture report PR to issue 941 * fix: apply CodeRabbit auto-fixes Fixed 2 file(s) based on 2 unresolved review comments. Co-authored-by: CodeRabbit <noreply@coderabbit.ai> * fix: format runtime-architecture-review HTML report Co-authored-by: Christoph Kieslich <9047291+chrisdoc@users.noreply.github.com> --------- Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com> Co-authored-by: CodeRabbit <noreply@coderabbit.ai> Co-authored-by: Gitar <noreply@gitar.ai> Co-authored-by: Christoph Kieslich <9047291+chrisdoc@users.noreply.github.com> * refactor: centralize Hevy endpoint policy (#944) * refactor: centralize Hevy endpoint policy * refactor(client): simplify retry failure transition * feat(operations): route routine listing through shared operation (#946) * feat(operations): route routine listing through shared operation * refactor(cli): split command dispatchers * fix(cli): avoid async dispatch wrappers * refactor(node): separate embedding from runtime bootstrap (#947) * refactor(node): separate embedding from runtime bootstrap * fix(node): clean up embedding test diagnostics * fix(node): include runtime chunk in Sentry source maps * refactor(node): centralize process lifecycle (#948) * refactor(node): centralize process lifecycle * fix(node): satisfy lifecycle static analysis * feat(worker): add safe tool observation (#949) * feat(worker): add safe tool observation * refactor(worker): simplify safe observation projection * feat(node): bound HTTP session admission (#951) * feat(node): bound HTTP session admission * refactor(node): split HTTP request admission paths * fix(node): satisfy HTTP admission lint * fix(node): remove HTTP handler lint regressions * test(core): add initial runtime contract matrix (#952) * test(core): add initial runtime contract matrix * fix(test): satisfy contract matrix lint * fix(test): remove redundant async wrappers * style(test): format contract fixture * feat(operations): add routine retrieval operation (#953) * feat(operations): add routine retrieval operation * fix(test): remove redundant routine async wrapper * feat(operations): add workout retrieval operation (#954) * feat(operations): add workout retrieval operation * fix(test): remove redundant workout async wrappers * style(test): format workout fixture * fix(deps): bump hono from 4.12.31 to 4.13.1 (#955) Bumps [hono](https://github.com/honojs/hono) from 4.12.31 to 4.13.1. - [Release notes](https://github.com/honojs/hono/releases) - [Commits](honojs/hono@v4.12.31...v4.13.1) --- updated-dependencies: - dependency-name: hono dependency-version: 4.13.1 dependency-type: indirect ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * test(worker): configure CIMD compatibility in Vitest (#950) * test(worker): configure CIMD compatibility in Vitest * fix(test): harden Cloudflare Vitest runtime setup --------- Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com> Co-authored-by: CodeRabbit <noreply@coderabbit.ai> Co-authored-by: Gitar <noreply@gitar.ai> Co-authored-by: Christoph Kieslich <9047291+chrisdoc@users.noreply.github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * refactor: remove brittle configuration tests (#959) * chore: enforce type-aware async linting (#958) * chore: enforce type-aware async linting * fix: apply CodeRabbit auto-fixes Fixed 1 file(s) based on 1 unresolved review comment. Co-authored-by: CodeRabbit <noreply@coderabbit.ai> --------- Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com> Co-authored-by: CodeRabbit <noreply@coderabbit.ai> * fix: apply CodeRabbit auto-fixes Fixed 5 file(s) based on 6 unresolved review comments. Co-authored-by: CodeRabbit <noreply@coderabbit.ai> * test: verify real session-signal independence in lifecycle test Co-authored-by: Christoph Kieslich <9047291+chrisdoc@users.noreply.github.com> * fix(test): provide operation descriptors in workout fixture Align the typed operation fixture with the descriptors required by the operations interfaces. --------- Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com> Co-authored-by: CodeRabbit <noreply@coderabbit.ai> Co-authored-by: Gitar <noreply@gitar.ai> Co-authored-by: Christoph Kieslich <9047291+chrisdoc@users.noreply.github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Summary
Cloudflare.compatibilityFlags.global_fetch_strictly_publicruntime global to Node/Vitest unit tests.@cloudflare/workers-oauth-providerfrom reporting CIMD as disabled while importing the Worker in unit tests.Validation
mise exec -- npm run test:unitmise exec -- npm run test:workermise exec -- npm run test:worker-httpmise exec -- npm run checkmise exec -- npm run check:typesmise exec -- npm run worker:dry-runmise exec -- npm run check:changesetSummary by Sourcery
Configure Vitest to mirror the Cloudflare worker runtime compatibility flag used in production so OAuth-related unit tests correctly detect CIMD support.
New Features:
Tests:
Summary by CodeRabbit
✨ PR Description
Purpose: Configure Cloudflare Worker runtime compatibility flags in Vitest to enable OAuth provider testing in Node environment.
Main changes:
Generated by LinearB AI and added by gitStream.
AI-generated content may contain inaccuracies. Please verify before using.
💡 Tip: You can customize your AI Description using Guidelines Learn how