Repository navigation
test(backend): route and service tests for the invite API - #265
Merged
Merged
Conversation
Moves the invite tests out of game.routes.test.ts into their own file and adds the permission cases: a stranger cannot see, decline or delete an invite, the sender cannot decline their own, and the recipient cannot delete one sent to them. The service tests reach the calls only the acceptance facade makes and D1 failing at each step of a send.
arrzdev
commented
Nov 2, 2026
arrzdev
left a comment
Owner
Author
There was a problem hiding this comment.
Approve. Checked against the task's list: each route has success, 401 and 400 cases, plus every permission case (stranger, sender declining their own invite, recipient deleting). Each refusal also checks the invite is unchanged. Service tests reach only what HTTP can't. Ran both files 10 times in a row: 45/45 passed every run.
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.
What and why
The invite API (
invite.routes.ts,invite.service.ts) was only tested as a side section ofgame.routes.test.ts, with nothing on who may see, decline or delete an invite. A change to those rules could reach a deploy without a failing test.invite.routes.test.ts(Workers pool, real local D1): every route's success path, 401 without a session, 400 on a bad body or id, and the permission cases. A stranger does not see the invite in their list and getsnot_foundon decline and delete. The sender getsnot_foundwhen declining their own invite, and the recipient getsnot_foundwhen deleting one sent to them. Each refusal also checks the invite is unchanged. Also covers inviting yourself (invite_self), a handle nobody holds (player_not_found), a second invite while one is pending (invite_exists, 409), asking again after a decline (same row, back to pending) and inviting back in the other direction (allowed).game.routes.test.tsinto the new file. The game file keeps itsinvitehelper for opening games.invite.service.test.tscovers what HTTP cannot reach:findAddressedToanddiscard(called only by the acceptance facade), and D1 failing at each step of a send, using a local D1 proxy that fails from the nth query.No permission bug found, and no production code changes.
Line coverage from
test:coverage:invite.service.tsinvite.routes.tsHow to verify
Ran the two new files 10 times in a row: 45/45 passed every time.