Repository navigation
test(meow): keep the unit /meow suite off the real network under msw 3 - #287
Conversation
A body-less mock response (new HttpResponse(null, { status })) carries no
content-length, so undici reads its body until the connection closes and
meow's body.cancel() aborts a request undici still considers running.
undici drops the socket, re-queues, and pre-connects a replacement that
never receives a request; @mswjs/interceptors treats that idle socket as
non-HTTP and passes it through to api.thecatapi.com:443. When the stray
handshake fails, undici's assert(err.code !== 'ERR_TLS_CERT_ALTNAME_INVALID')
surfaces as a vitest Unhandled Error after every test has passed, which is
the intermittent build-test red.
Frame every status-only mock with content-length: 0 so cancel() is a no-op
on an already-complete body, and guard the suite with a dns.lookup spy:
msw never resolves a mocked host, so any lookup is a passthrough socket.
With the framing reverted the guard fails 3/3 naming api.thecatapi.com.
Signed-off-by: quality <quality@hive.kubestellar.io>
|
Important Held for human review by the hive's ACMM level gate. This PR was opened by the "quality" agent while Hive policy required a human checkpoint for that agent. Non-outreach agents are held at ACMM L3–L5; the Hive will keep the |
The previous run failed only on the pre-existing unhandled TLS error from __tests__/issueCommentTest/meow.test.ts (fixed separately in #287); every test in this PR passed. Signed-off-by: quality <quality@hive.kubestellar.io>
|
Verified: this fixes the root cause. A mocked response with no body and no Test runs (10 per row):
Not blocking, but please follow up: the guard's two /kind failing-test |
…s and failures through dist/index.js (#286) * test(bundle): drive the approve.github_review refusals, short-circuits and failures through dist/index.js Adds __tests__/bundle/approveReview.test.ts: /approve and /approve cancel against the fake GitHub with approve.github_review enabled, routing POST /pulls/1/reviews, PUT .../dismissals and GET /user to the answers src/plugins/approveReview.ts handles — 422 not-permitted, other 403, self-approval refusal, a user token that authored the pull request, a draft, a review already on the head, a refused dismissal, an unidentifiable token and a hard createReview failure — and asserts the warning or error text, the exit status and that the approved label is written first. approveReview.ts end-to-end line coverage (npm run test:coverage:e2e): 65.38% -> 92.3%. Signed-off-by: quality <quality@hive.kubestellar.io> * ci: retrigger build-test after meow.test.ts passthrough flake (#284) The previous run failed only on the pre-existing unhandled TLS error from __tests__/issueCommentTest/meow.test.ts (fixed separately in #287); every test in this PR passed. Signed-off-by: quality <quality@hive.kubestellar.io> --------- Signed-off-by: quality <quality@hive.kubestellar.io> Co-authored-by: quality <quality@hive.kubestellar.io>
Test Improvement
Files:
__tests__/issueCommentTest/meow.test.tsonly (unit/meowsuite; nosrc/change, no bundle test change — disjoint from #244's__tests__/bundle/meow.test.ts).Root cause (verified by tracing
tls.connectper test and per phase): a body-less mock such asnew HttpResponse(null, { status: 503 })is sent with nocontent-length, so undici reads the body until the connection closes.meow.ts'sresponse.body?.cancel()therefore aborts a request undici still considers running: undici destroys the socket, re-queues, and pre-connects a replacement before the nextfetchis dispatched. The aborted request is discarded, so nothing is ever written to that socket;@mswjs/interceptorssees a reader attached with no bytes, decides it is non-HTTP, and passes it through toapi.thecatapi.com:443. When the stray handshake fails, undici'sassert(err.code !== 'ERR_TLS_CERT_ALTNAME_INVALID')lands as a vitest Unhandled Error after all tests passed — the intermittentbuild-testred (most recently run 37157845384 on #286).Fix:
statusOnly(status, headers?)frames every status-only mock (400, 429, 500, 503, 302) withcontent-length: 0, socancel()is a no-op on an already-complete body and undici neither drops nor pre-connects a socket. The retry assertions (callscounts, headers, warnings) are unchanged.dns.lookupspy per test, asserted empty inafterEachafter twosetImmediateturns. msw never resolves a mocked host, so any lookup is a passthrough socket. This avoids thetls.connecthost-wrapper the issue found breaks 15 tests (msw builds its mock sockets through the sametls.connect; it never touches dns).Evidence:
npx vitest run __tests__/issueCommentTest/meow.test.tsonmain@3fc21f2: Unhandled Error 3/3. With this change: 39 passed, 0 errors, 5/5.degrades to a note when the cat api keeps failingfail 3/3 withexpected [ 'api.thecatapi.com', 'api.thecatapi.com' ] to deeply equal [].eslintandtsc --noEmitclean.Related Issue
Closes #284
Filed by quality agent (hold-gated mode). Human review required.
— hive: agent=quality backend=copilot model=claude-fable-5.1 copilot=1.0.88