Skip to content

[Testing] Add unit tests for useIncomingStreams / useWithdrawIncomingStream (query key, enabled gating, invalidation, null-session error) #855

Description

@grantfox-oss

Telegram (ask questions / claim the issue here first): https://t.me/+DOylgFv1jyJlNzM0

Labels: frontend, testing, Stellar Wave

frontend/src/hooks/useIncomingStreams.ts has no tests, and it holds a fair amount of react-query behavior that we're currently trusting blind.

The bits worth pinning down: incomingStreamsQueryKey, the enabled gating on publicKey, onSuccess invalidating exactly that key, and the mutation throwing "connect your wallet first" when the session is null.

Done when

  • Test that the query stays disabled (no fetch) when publicKey is null/undefined
  • Test the key shape returned by incomingStreamsQueryKey
  • Test that useWithdrawIncomingStream rejects when session is null, and invalidates incomingStreamsQueryKey(publicKey) on success
  • fetchIncomingStreams/withdrawFromStream mocked, with a QueryClientProvider wrapper
  • lint + typecheck + tests green

Where to start
Test file next to useIncomingStreams.ts. Tests for lib/api/_shared.ts are out of scope. Small, self-contained.

Metadata

Metadata

Assignees

Labels

GrantFox OSSIssue tracked in GrantFox OSSMaybe RewardedIssue may be eligible for a GrantFox rewardOfficial Campaign | FWC26Campaign: Official Campaign | FWC26Stellar WaveIssues in the Stellar wave programfrontendFrontend related taskstestingTesting related tasks

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions