test(claim): cover the unprojected send-link payload that crashed the claim page - #2892
test(claim): cover the unprojected send-link payload that crashed the claim page#2892innolope-dev wants to merge 1 commit into
Conversation
… claim page GET /send-links/:pubKey answers a cache hit (30s TTL) with the raw Prisma row, which carries `intents` instead of the `claim` + `events` shape `sanitizeSendLink` projects on the DB path. The existing CANCELLED test never caught PEANUT-UI-SJ0 because its fixture hard-codes `events: []`, and `[][0]?.timestamp` is safe where `undefined[0]` throws. Add a case built from the cache-hit shape. It gates on the drawer effect rather than the rendered view: the view settles before the transaction memo runs, so asserting on it alone passes even against the crashing code.
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
Included review availability: 0 reviews are currently available. Your included PR review attempts over the past 7 days set your current allowance at 2 reviews per hour. 📝 WalkthroughWalkthroughAdded a regression test for cancelled send links returned without ChangesCancelled claim link handling
Estimated code review effort: 2 (Simple) | ~10 minutes Merge Risk: ⚪ Minimal · up to This PR adds localized regression coverage for the claim-page crash without changing production behavior. No actionable merge-blocking risk remains, and it is merge-ready after normal checks. Suggested reviewers: 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
Full details: Docstring CoverageExplanation No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff. Analyzed 0 functions across 1 files. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment |
Code-analysis diffPainscore total: 7753.44 → 7753.44 (0) |
🧪 UI test report — ✅ all greenSuites
📊 Coverage (unit)
⏱ 10 slowest test cases
|
There was a problem hiding this comment.
Chip review — no blocking findings — this is not an approval
Clean. The regression test models a send-link response without claim/events and waits for the transaction drawer effect, so it reaches the previously crashing memo path.
Checked clean
- Pinned worktree HEAD and merge base matched the supplied head and base SHAs; PR metadata matched the trusted author and main base.
- Reviewed the only diff, the Claim transaction memo, and the preceding fix: omitting events reaches the formerly unsafe index access, while the drawer assertion waits past asynchronous link processing.
- Exact-head unit, typecheck, eslint, format, e2e, CodeQL, analysis, reporting, and preview checks completed successfully.
- Correctness, security, adversarial, and slop passes found no runtime behavior change, trust-boundary change, or actionable test defect.
- A targeted local Jest rerun was unavailable because dependencies are not installed in the detached worktree; the exact-head unit CI job passed.
Second opinion by moonshotai/kimi-k3: 0 finding(s), marked with the model name. It reads the diff only, so treat its findings as advice.
Exact head: 6192ca05f92c · Context: repo
Follow-up to #2889 (already merged) — adds the regression coverage that fix lacked.
Why the existing test didn't catch it
claim-states.test.tsxalready had the right test — "CANCELLED link shows ClaimedView", rendering the realClaimcomponent withstatus: 'CANCELLED'. It passed anyway, because of one line in the fixture factory:[][0]isundefinedandundefined?.timestampis safe. Production sends noeventskey at all, andundefined[0]throws. The fixture modelled a shape the endpoint doesn't return.Where the unprojected shape comes from
GET /send-links/:pubKeyhas two response paths:reply.send(sanitizeSendLink(sendLink))— projectsintentsinto the legacyclaim+eventsshape.send-links/index.ts:905, 30s TTL) →reply.send(cached.sendLink)— the raw Prisma row, withintentsand noclaim/events.So the crash needed a cache hit on a cancelled link, which is why it was rare and intermittent rather than constant.
I've filed the backend half separately — that side also skips
toWireUser, so the cache path is a data-exposure issue, not just a shape mismatch.The test
Builds the payload by stripping
claimandevents, matching the cache-hit response.It gates on the drawer effect rather than the rendered view. That matters:
claimLinkDatais populated by an async effect that awaitsfetchTokenDetails, so the view settles before the transaction memo ever runs — asserting onclaimed-viewalone passes even against the crashing code. Gating onopenTransactionDetailsforces the wait until the memo has produced a value.Verified
Claim.tsx(c020f6b57^1): fails withTypeError: Cannot read properties of undefined (reading '0'), in isolation as well as in the full suite.main: 16/16 pass.The default fixture keeps
events: []so the projected shape stays covered too — this adds the second shape rather than swapping one blind spot for another.Summary by CodeRabbit
Bug Fixes
Tests