Skip to content

[Testing] fetchIncomingStreams endpoint-fallback loop and backend-to-frontend mapping are untested #884

Description

@grantfox-oss

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

Why this matters

src/lib/api/streams.ts fetchIncomingStreams() powers the Incoming Streams page that feeds the withdraw flow: it iterates getStreamsEndpointCandidates(), skips on 404 to try the next candidate, accepts both array and {data:[]} payload shapes, and maps each via mapBackendStream (token-label resolution, toTokenAmount stroop scaling, status). With a mocked fetch this is fully testable, yet nothing covers the 404-then-succeed fallback or the status/scale mapping.

Acceptance criteria

  • Mock global fetch; test it advances to the next endpoint on 404 and returns mapped results from the first 2xx
  • Test both array and {data:[]} response shapes are handled
  • Test mapBackendStream output: token label resolution + fallback, toTokenAmount scaling, and status
  • Test it throws the last error when all candidates fail

Files to touch

  • frontend/src/lib/api/streams.ts

Out of scope

  • _shared.ts helpers already covered
  • Live backend integration

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Stellar 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