Skip to content

anchorsApi.ts's and settlementsApi.ts's functions accept an AbortSignal but neither test suite verifies it's forwarded, unlike metricsApi.test.ts #322

Description

@Jagadeeshftw

📌 Description

metricsApi.test.ts has a dedicated test, "passes the abort signal through", asserting fetchMetrics(controller.signal) forwards the signal to the underlying fetch call. anchorsApi.ts's fetchAnchors(signal?) and fetchAnchor(id, signal?), and settlementsApi.ts's fetchSettlements(options) (whose options.signal is documented as forwarded) and fetchSettlement(id, signal?), all accept and are expected to forward an AbortSignal the exact same way fetchMetrics does — each is used with a signal from useAsync's abortable loader elsewhere in the app (e.g. AnchorDetail, AnchorsPanel, SettlementDetail). Yet neither anchorsApi.test.ts nor settlementsApi.test.ts has any test asserting the signal actually reaches the outgoing fetch call for any of these functions — a regression that silently broke cancellation (e.g. a request no longer aborting on unmount/reload) would go unnoticed by either suite.

🧩 Requirements and context

  • Add test coverage verifying that fetchAnchors, fetchAnchor, registerAnchor/deregisterAnchor (where applicable), fetchSettlements, and fetchSettlement each forward a supplied AbortSignal to the underlying fetch call, mirroring metricsApi.test.ts's existing pattern for fetchMetrics.
  • No production code changes are expected; this is purely closing a test-coverage gap on already-shipped signal-forwarding behavior.

🛠️ Suggested execution

  • In src/lib/anchorsApi.test.ts and src/lib/settlementsApi.test.ts, add a test per function that accepts a signal, passing a real AbortController's signal and asserting the mocked fetch's second argument's signal property is that same object — following metricsApi.test.ts's existing "passes the abort signal through" test as the template.

✅ Acceptance criteria

  • anchorsApi.ts's signal-accepting functions have test coverage asserting the signal reaches fetch.
  • settlementsApi.ts's signal-accepting functions have test coverage asserting the signal reaches fetch.
  • Coverage follows the same assertion style as metricsApi.test.ts's existing test.

🔒 Security notes

No new attack surface; a test-coverage task on already-shipped request-cancellation plumbing.

📋 Guidelines

  • Minimum 95% test coverage
  • Clear documentation
  • Timeframe: 96 hours

Metadata

Metadata

Assignees

Labels

GrantFox OSSIssue tracked in GrantFox OSSMaybe RewardedIssue may be eligible for a GrantFox rewardOfficial Campaign | FWC26Campaign: Official Campaign | FWC26frontendFrontend / UI worktestingTests and coverage

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions