test(cloudflare): Run server tests under vitest-pool-workers#678
Merged
test(cloudflare): Run server tests under vitest-pool-workers#678
Conversation
55ef231 to
e153270
Compare
e153270 to
36fbd4d
Compare
1972c3f to
a88ac3e
Compare
e43ea9e to
1972c3f
Compare
1972c3f to
ad7cd28
Compare
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Set up @cloudflare/vitest-pool-workers for testing mcp-cloudflare routes with real Cloudflare bindings via Miniflare. Tests are organized into separate modules per route group: - static.integration.test.ts - robots.txt, llms.txt, SSE deprecation - mcp-discovery.integration.test.ts - /.mcp discovery endpoints - api-metadata.integration.test.ts - /api/metadata auth - api-search.integration.test.ts - /api/search validation and AI binding - api-auth.integration.test.ts - /api/auth/* status, logout - chat-oauth.integration.test.ts - OAuth callback error handling - api-chat.integration.test.ts - /api/chat auth Key configuration: - wrangler.test.jsonc with observability disabled for OTel compatibility - vitest.integration.config.ts using vitest-pool-workers - tsconfig.test.json with cloudflare:test module types Co-Authored-By: Claude Code <noreply@anthropic.com>
Tests the MCP endpoint behavior through OAuthProvider without Sentry wrapper: - Unauthenticated requests return 401 - Invalid Bearer tokens return 401 - OAuth discovery endpoint returns proper metadata - Dynamic client registration works at /oauth/register Uses OAuthProvider directly to avoid vitest-pool-workers compatibility issues with @sentry/cloudflare dependencies. Co-Authored-By: Claude Code <noreply@anthropic.com>
Replace the two-config approach (MSW for Node.js, workers pool for workerd) with a unified vitest-pool-workers config using fetchMock from cloudflare:test. Changes: - Create payloads.ts in mcp-server-mocks for MSW-free fixture exports - Add fetch-mock-setup.ts with comprehensive Sentry API mocking - Consolidate vitest.config.ts to use workers pool for all tests - Remove vitest.integration.config.ts (no longer needed) - Rename integration tests to standard .test.ts naming - Extract inline payload constants to JSON fixture files Key fix: fetchMock requires explicit Content-Type headers in reply() for the API client to properly parse JSON responses. Note: mcp-handler.test.ts excluded from workers pool due to CJS dependency (ajv) incompatibility with workerd runtime. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
Refactor mcp-handler.test.ts to properly test the MCP handler without mocking agents/mcp. Tests now exercise the real handler with fetchMock for Sentry API mocking only. Key changes: - Add ajv-stub.ts to bypass CJS require() issues in workerd - Configure vitest with resolve.alias and ssr.noExternal for ajv - Add jsonSchemaValidator option to buildServer() for edge runtimes - Use CfWorkerJsonSchemaValidator in mcp-handler for workerd compat - Parse SSE responses in tests (MCP handler returns SSE format) - Fix Accept header and initialize params for MCP protocol 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Delete mcp-endpoint.test.ts as it tested third-party library behavior (@cloudflare/workers-oauth-provider), not our code. Per docs/testing.md: "Don't test third-party library behavior". The tests verified: - OAuthProvider returns 401 for unauthenticated requests - OAuthProvider returns 401 for invalid tokens - OAuthProvider exposes OAuth discovery metadata - OAuthProvider handles dynamic client registration mcp-handler.test.ts already covers our authentication logic: - Handler rejects requests without auth context - Handler rejects legacy tokens without grantedSkills - Handler rejects tokens with no valid skills 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
- Remove codecov.yml configuration file - Remove codecov steps from test.yml workflow - Remove codecov steps from eval.yml workflow - Remove codecov badge from README.md Co-Authored-By: Claude Code <noreply@anthropic.com>
Fixed undici MockAgent interceptor ordering issues where general patterns were registered before specific handlers, causing wrong fixtures to be returned. Changes: - Move PERF-N1-001/events/latest handler before general /events/latest handler so performance events return the correct fixture - Add PERF-N1 and PEATED to org issues exclusion pattern to prevent incorrect list responses for these specific issues - Add section comments throughout file for maintainability - Add documentation about undici's first-match-wins behavior Co-Authored-By: Claude Code <noreply@anthropic.com>
Update the Cloudflare route assertions to match the current static and discovery responses after rebasing onto main. Restore the missing mock fixtures needed by mcp-core tests and record the dependency state required to run the worker test pool locally. Co-Authored-By: Codex <noreply@openai.com>
Replace mocked provider behavior in the callback suite with a real workers-oauth-provider instance so client, grant, and redirect validation follow the library contract. Add worker-level /mcp coverage that authenticates through the mounted OAuth flow before issuing MCP requests. This keeps the tests closer to production behavior while still mocking the upstream Sentry boundary. Co-Authored-By: Codex <noreply@openai.com>
Bump the shared vitest-pool-workers catalog to 0.9.14 so the lockfile no longer pulls the vulnerable wrangler 4.35.0 dependency flagged by dependency-review. Clamp the Cloudflare test package to a single Vitest worker to avoid the workerd loopback runtime failures that showed up after the upgrade while keeping the existing test coverage intact. Co-Authored-By: Codex GPT-5 <codex@openai.com>
Raise the workspace and Cloudflare package wrangler range to a release that includes the GHSA-36p8-mvp6-cv38 fix so dependency-review no longer flags the lockfile. Keep the previously-stabilized vitest worker settings intact and refresh the lockfile against the safe wrangler line. Co-Authored-By: Codex GPT-5 <codex@openai.com>
Pin vitest pool workers and wrangler to exact patched versions so the Cloudflare test stack resolves away from vulnerable transitive packages. Keep the lockfile on a single reviewed dependency set instead of letting caret ranges drift into dependency-review failures. Co-Authored-By: OpenAI Codex <noreply@openai.com>
Clear the inherited server exclude list so the test tsconfig actually resolves its declared test inputs. This keeps the config usable for direct typechecking instead of resolving to no files. Co-Authored-By: OpenAI Codex <noreply@openai.com>
Restore the worker runtime fetch shim after OAuth helper tests so the new\nvitest-pool-workers suite does not leak a file-local fetch mock into other\nCloudflare tests.\n\nRegister the shared cloudflare:test fetchMock interceptors only once and\nreactivate them per test. This keeps the suite from stacking duplicate\npersistent interceptors as it runs under the worker pool.\n\nCo-Authored-By: Codex <noreply@openai.com>
Restore the OAuth helper fetch stub for the whole test file so both token refresh paths run against the intended mock in the worker runtime. Move the shared secondary issue fixture into the mocks payload exports so the Cloudflare fetch mock setup and the MSW server use the same data instead of drifting. Co-Authored-By: Codex <noreply@openai.com>
Re-export flamegraphFixture from both the main mocks entrypoint and the payload-only module so consumers keep the same fixture surface after the refactor. Add a regression test that imports from @sentry/mcp-server-mocks to catch future export drift at the package boundary. Co-Authored-By: Codex GPT-5 <codex@openai.com>
Keep the MSW-free payloads entrypoint aligned with the main mocks package exports so fixture helpers are available in worker-safe consumers. Add regression coverage for the payloads subpath to catch future export drift. Co-Authored-By: Codex GPT-5 <codex@openai.com>
Document why the internal use_sentry server does not currently thread a JSON schema validator and call out the Cloudflare follow-up needed if elicitation is added later. Co-Authored-By: Codex GPT-5 <codex@openai.com>
Tighten the worker fetchMock handler for the errors dataset so it validates fields and sort the same way as the shared MSW mocks and normalizes query allowlist matching. Add a focused regression test for the worker fetch mock contract. Local workerd Vitest execution is currently failing in this environment before test output is surfaced, so verification here is limited to biome checks on the changed files. Co-Authored-By: Codex GPT-5 <codex@openai.com>
dbe5467 to
5f9337d
Compare
Member
Author
|
yolo i need reliability and i think this is the path |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Move the
mcp-cloudflareserver tests onto@cloudflare/vitest-pool-workersso they run inside the same workerd-style runtime we ship in production.This replaces the split test setup with a single Vitest configuration, switches HTTP mocking to Cloudflare-native
fetchMock, and adds route-level coverage for the app surface that now depends on that worker runtime behavior. The branch also updates the shared mocks package so the new tests and the existing core tests can reuse the same fixture payloads.I kept the worker-specific compatibility pieces that were needed to make the MCP SDK load correctly in tests, including the AJV stub and the worker JSON schema validator path in the handler. After rebasing onto
main, I also aligned the static-route expectations and restored the mock fixtures needed for the full repo test suite to pass.Coverage-specific setup was removed as part of this migration because it was conflicting with the worker pool setup and was not needed for the current CI path.