Skip to content

Harden non-streaming fallback tests for fetchWithCorsProxy#3495

Draft
ashfame wants to merge 1 commit intotrunkfrom
fix/non-streaming-fallback-tests
Draft

Harden non-streaming fallback tests for fetchWithCorsProxy#3495
ashfame wants to merge 1 commit intotrunkfrom
fix/non-streaming-fallback-tests

Conversation

@ashfame
Copy link
Copy Markdown
Member

@ashfame ashfame commented Apr 15, 2026

Summary

Follow-up to #3440 addressing Brandon's review feedback about strengthening the non-streaming fallback tests.

  • The beforeEach() in the "non-streaming fallback" describe block now explicitly forces supportsReadableStreamBody() to return false (via a new __testing.setStreamBodySupported() setter) and asserts it, so every test positively confirms it's running in non-streaming mode.
  • Previously, the tests just reset the cached probe result, which on Node.js/V8 (where streaming is supported) meant the GET test wasn't actually exercising the non-streaming path.
  • Simplified mock ordering in the "preserves POST body" test from [direct, probe, proxy] to [direct, proxy] since the probe no longer fires when the result is pre-cached.

Test plan

  • All 15 existing tests in fetch-with-cors-proxy.spec.ts pass

Made with Cursor

Follow-up to #3440. The non-streaming fallback tests relied on
implicit mock ordering to simulate an unsupported streaming
environment. On Node.js/V8 (where streaming IS supported), the
GET test was not actually exercising the non-streaming path.

Force `supportsReadableStreamBody()` to return `false` via a new
`__testing.setStreamBodySupported()` setter and assert it in
beforeEach, so every test positively confirms it runs in
non-streaming mode.

Made-with: Cursor
@ashfame ashfame requested review from a team, bgrgicak and Copilot April 15, 2026 07:57
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Note

Copilot was unable to run its full agentic suite in this review.

Strengthens the “non-streaming fallback” test suite for fetchWithCorsProxy by deterministically forcing supportsReadableStreamBody() to report “unsupported”, ensuring tests actually exercise the intended fallback path.

Changes:

  • Added a __testing.setStreamBodySupported(false) hook to force non-streaming mode in tests.
  • Updated the non-streaming fallback test setup to assert the forced mode and simplified fetch mock ordering/call counts accordingly.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
packages/php-wasm/web-service-worker/src/utils.ts Adds a test-only setter to control the cached supportsReadableStreamBody() result.
packages/php-wasm/web-service-worker/src/fetch-with-cors-proxy.spec.ts Forces non-streaming mode in beforeEach and updates mocks/assertions to match the new deterministic behavior.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

__testing.setStreamBodySupported(false);
expect(await supportsReadableStreamBody()).toBe(false);
});

Copy link

Copilot AI Apr 15, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This beforeEach mutates module-level cached state (streamBodySupported) but there’s no corresponding cleanup after the describe block. That can leak into later tests in the same file (or other files) that rely on the default probe behavior. Add an afterEach/afterAll in this describe to call __testing.resetStreamBodySupported() (or otherwise restore the previous value) to keep the suite hermetic.

Suggested change
afterEach(() => {
__testing.resetStreamBodySupported();
});

Copilot uses AI. Check for mistakes.
@ashfame ashfame marked this pull request as draft April 16, 2026 18:53
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