testing: migrate http.test.ts response-handling → stub HttpClient (comms-e5vm.8) - #16
Merged
Merged
Conversation
…mms-e5vm.8) Move ZulipHttp request-shape and response-handling off the shared Bun.serve fixture onto the owned-fake stub HttpClient + effectTest (the comms-e5vm.2 pattern), so status/error/parsing/response-shape and the 429 retry policy run deterministically with no socket. - request-shape (URL build, Basic auth, query string, form-encode, host override, trailing-slash, bare DELETE) reads the stub's captured request - response-handling (error envelopes, non-JSON non-2xx, schema-mismatch ParseError, download/upload shape+errors) drives canned responses - 429-retry end-to-end runs on stub + TestClock via a deterministic settle loop (no real socket off the test clock, unlike the old runUnderTestClock) - delete two happy-path cases that merely duplicated the live contract (GET-parses-success-envelope, POST-returns-success-body) Two tests deliberately stay off the stub: the pure-unit cases (rate-limit policy replay, brand validators, decodeUserUploadPath, the ZulipApiError tag) that never touch HTTP, and the one irreducible real-socket case — a transport failure from a refused connection producing a genuine platform RequestError, which the in-memory stub cannot fabricate without lowering fidelity. The brief's reference to an AbortSignal/long-poll teardown test in this file was a conflation: that residue is the event-pump's (comms-4lz5), not here.
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.
Tier-2 migration (comms-e5vm.8), following the event-pump proof (#12, comms-e5vm.2).
Moves
ZulipHttprequest-shape and response-handling off the sharedBun.servefixture onto the owned-fake stub HttpClient +effectTest, so status/error/parsing/response-shape handling and the 429 retry policy run deterministically with no socket.What moved
HttpClientRequest.ParseError,downloadRaw/uploadRawshape + errors) drives canned responses keyed by(method, path).runUnderTestClockadjust-against-the-wire is gone (the multi-retry budget case still advances the clock per retry because each sleep only registers once its 429 lands).What was deleted
Two happy-path cases that merely duplicated the contract-against-real run (
contract.live.test.ts): GET-parses-success-envelope and POST-returns-success-body.What deliberately stays off the stub
RealmUrl/BotEmail/ApiKeybrand validators,decodeUserUploadPath, theZulipApiErrortag) — never touch HTTP, keep their plainEffect.runPromiseshape.RequestError(status 0). The in-memory stub can't fabricate a realRequestErrorwithout lowering fidelity, so this keeps a realFetchHttpClientagainst a claimed-then-released port (orchestrator ruling).The brief referenced an AbortSignal→TCP-teardown long-poll test in this file; that was a conflation —
http.test.tshas no long-poll test. That residue belongs to the event-pump (comms-4lz5), not here.Out of scope (untouched):
adapter.test.ts(e5vm.3),bot-dm-guard.test.ts(e5vm.7), the stateful-fake deletion (e5vm.6).