Skip to content

test(rules): restore the real fetch when a graphql test stubs twice - #599

Merged
nc9 merged 1 commit into
mainfrom
fix/graphql-stub-restore
Oct 9, 2026
Merged

nc9 merged 1 commit into
mainfrom
fix/graphql-stub-restore

Conversation

@nc9

@nc9 nc9 commented Oct 9, 2026

Copy link
Copy Markdown
Contributor

The release quality gate for v0.0.107 failed: 96 fetch-based tests in other files got 404 pages. The graphql test helper's stubFetch saved the previous stub as its original, so a test that stubbed twice left a fake fetch installed for the rest of the single-process run. It now captures the real fetch once and always restores it.

Checked: the three graphql test files plus apps/cli/tests/fetchers/document-fetcher.test.ts fail 3 before and pass 57 after, in one bun invocation.

Test-only change. No docs or skill change needed.

The stub saved the previous stub as its original, so a test that stubbed twice left a fake fetch installed. The release gate runs one bun process over every file, so later suites got its 404 pages.

Signed-off-by: Nik Cubrilovic <[email protected]>
@claude

claude Bot commented Oct 9, 2026

Copy link
Copy Markdown

Reviewed the one-file, test-only change. The fix looks correct and I found nothing that should block the merge.

  • The fetch captured by realFetch ??= is always the real one, because restore() clears it. Stub, stub, restore, and a late restore of the first stub all end with the real fetch installed. The late restore is a no-op.
  • (nit) restore() now always goes back to the real fetch, never to the previous stub. If a test deliberately nests stubs and expects the inner restore() to bring back the outer stub, it will see the real fetch instead. That seems acceptable for these helpers, but a short comment saying so would help.
  • (nit) A guard that fails when stubFetch is called while a stub is already installed would catch double-stubbing at the source. This isn't needed for the PR.
  • (nit) I didn't run the tests. The PR description reports 3 failures before and 57 passes after in a single bun invocation.

Co-Authored-By: Claude Sonnet 5.5 [email protected]

@nc9
nc9 merged commit b2f0e38 into main Oct 9, 2026
15 checks passed
@nc9
nc9 deleted the fix/graphql-stub-restore branch October 9, 2026 02:45
nc9 pushed a commit that referenced this pull request Oct 9, 2026
* origin/main:
  feat(core-contracts): audit levels definition (quick, surface, full) (#602)
  test(rules): restore the real fetch when a graphql test stubs twice (#599)
  chore(release): v0.0.107 (#595)
  docs(changelog): release notes for v0.0.107 (#594)
  feat(rules): add GraphQL introspection and GET mutation probing rules (#593)
  fix(audit-engine): keep paid cloud prefetch results when the phase is abandoned (#582)
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.

1 participant