Skip to content

test(shipping): answer the shipping tests from one fake GitHub - #240

Merged
michael-denyer merged 2 commits into
mainfrom
shipping-shared-fake
Oct 8, 2026
Merged

michael-denyer merged 2 commits into
mainfrom
shipping-shared-fake

Conversation

@michael-denyer

@michael-denyer michael-denyer commented Oct 8, 2026 •

Copy link
Copy Markdown
Owner
  • Add watch-pr/shipping.test-helper.ts with fakeGitHub(pullRequest, argv), one fake of gh api graphql that both shipping test files call. A two-row table holds the contract. Each row names a mutation's required input field and the pull request field the mutation clears.
  • The fake answers the way the endpoint does. A query gets back only the fields it selects. The fake refuses a mutation unless the mutation declares $id as ID!, names a known mutation and its input field, and carries the pull request's node id. The fake ignores whitespace.
  • shipping.test.ts and shipping-cli.test.ts drop their own dispatchers and call the fake. That replaces the two guards fix(shipping): use GitHub dequeue input id #239 added, which compared the query text byte for byte, and removes a .calls log that no test read.

Why

The guards from #239 catch the dequeue bug. They pass the same wrong-field mistake on disablePullRequestAutoMerge, and they fail a query that differs only in spacing.

Verification

All of these ran on this branch, rebased onto main at fee271b after #239 merged.

  • Six source mutations of shipping.ts, each run against bun test shipping. The fix(shipping): use GitHub dequeue input id #239 guards classify 2 of 6 correctly. The fake classifies 6 of 6. Four invalid queries fail, and the unmodified query and the reformatted query pass.
  • Two mutations added after review also classify correctly. An inspect query that drops the pull request's own id fails, and a dequeue mutation with an operation name passes.
  • bun test orch watch-pr reports 225 pass, 0 fail.
  • bun run typecheck prints no diagnostics.
  • bunx prettier@3.6.2 --check passes on the three changed files.
  • bun tools/generate.mjs --check reports 81 generated files current.

Open risk

The contract table is a hand-kept copy of GitHub's schema, so no test fails if GitHub renames a field. The helper's header comment has the introspection command that regenerates the table.

Both shipping test files dispatched on the query text themselves, and each compared the dequeue mutation with a fixed string. That check failed a query that differed only in spacing and passed a wrong input field on disablePullRequestAutoMerge.

fakeGitHub holds each mutation's required input field in one table and answers the way the endpoint does: a query gets back only the fields it selects, and a mutation needs the right name, input field, variable type, and pull request id.
The field filter matched the nested id in mergeQueueEntry { id }, so the fake still returned the pull request id to a query that no longer selected it. The mutation pattern also refused a named operation, which GitHub accepts.
@michael-denyer
michael-denyer merged commit f0c752c into main Oct 8, 2026
14 checks passed
@michael-denyer
michael-denyer deleted the shipping-shared-fake branch October 8, 2026 21:32
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