Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion src/components/Claim/Claim.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,10 @@ export const Claim = ({}) => {
initials: getInitialsFromName(recipientName),
memo: claimLinkData.textContent,
attachmentUrl: claimLinkData.fileUrl,
cancelledDate: status === 'cancelled' ? new Date(claimLinkData.events[0]?.timestamp) : undefined,
cancelledDate:
status === 'cancelled' && claimLinkData.events?.[0]
? new Date(claimLinkData.events[0].timestamp)
: undefined,
txHash: claimLinkData.claim?.txHash,
extraDataForDrawer: {
isLinkTransaction: true,
Expand Down
30 changes: 30 additions & 0 deletions src/components/Claim/__tests__/claim-states.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -385,6 +385,36 @@ describe('GROUP 3: Already Claimed / Cancelled', () => {
})
})

// GET /send-links/:pubKey answers a cache hit with the raw Prisma row, which
// carries `intents` instead of the projected `claim` + `events`. Claim.tsx read
// `events[0]` unguarded and took the whole page down (PEANUT-UI-SJ0).
test('CANCELLED link renders when the API omits claim/events (cache-hit shape)', async () => {
mockUseAuth.mockReturnValue({
user: { user: { userId: 'sender-123' } },
isFetchingUser: false,
fetchUser: jest.fn(),
})

const {
events: _events,
claim: _claim,
...unprojected
} = makeSendLink({
status: 'CANCELLED',
sender: { userId: 'sender-123', username: 'alice' },
})
mockSendLinksApi.get.mockResolvedValue(unprojected)

renderClaim()

// Gates on the receipt, which only renders once the transaction memo has
// produced a value — asserting on ClaimedView settles too early to catch
// a throw inside the memo.
await waitFor(() => {
expect(screen.getByTestId('transaction-details-receipt')).toBeInTheDocument()
})
})

test('CLAIMING link (in progress) shows as already claimed', async () => {
const link = makeSendLink({ status: 'CLAIMING' })
mockSendLinksApi.get.mockResolvedValue(link)
Expand Down
3 changes: 2 additions & 1 deletion src/services/services.types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -374,7 +374,8 @@ export type SendLink = {
}[]
}
}
events: {
/** Absent post-ledger-collapse: the API no longer selects the `events` relation. */
events?: {
timestamp: Date
status: SendLinkStatus
reason?: string
Expand Down
Loading