Skip to content

Fix: 4 issues (#937, #939, #940, #941) - #1018

Merged
Austinaminu2 merged 2 commits into
FlowwStar:mainfrom
topsonDev:simple/937-939-940-941
Oct 18, 2026
Merged

Austinaminu2 merged 2 commits into
FlowwStar:mainfrom
topsonDev:simple/937-939-940-941

Conversation

@topsonDev

Copy link
Copy Markdown
Contributor

Closes #937
Closes #939
Closes #940
Closes #941

Issues

#937 Test verified token list helpers

Description

The verified-token list and merged token list currently has no test coverage (0 calls in the Vitest coverage report).

Location

lib/stellar.ts (loadVerifiedTokens, isVerifiedToken, getAllTokens)

Task

Add tests under __tests__/ (Vitest + Testing Library; only __tests__/** is collected). Cover at least:

  • verified tokens load (mock fetch)
  • load failure falls back gracefully
  • getAllTokens merges built-in, verified and custom tokens without duplicates

Acceptance criteria

  • Tests live under __tests__/ and pass with npm test
  • Listed cases are covered
  • No production code changes needed (unless a bug is found — then note it in the PR)

Good for contributors because

Self-contained test task with clear inputs/outputs; a great way to learn the codebase.

#939 Test formatTimeAgo

Description

Relative time formatting currently has no test coverage (0 calls in the Vitest coverage report).

Location

lib/stream-utils.ts (formatTimeAgo, ~line 203)

Task

Add tests under __tests__/ (Vitest + Testing Library; only __tests__/** is collected). Cover at least:

  • seconds / minutes / hours / days
  • future timestamps
  • boundary values (59s, 60s, 24h)

Acceptance criteria

  • Tests live under __tests__/ and pass with npm test
  • Listed cases are covered
  • No production code changes needed (unless a bug is found — then note it in the PR)

Good for contributors because

Self-contained test task with clear inputs/outputs; a great way to learn the codebase.

#940 Add tests for the Tabs UI component

Description

The Tabs primitive wrapper currently has no test coverage (0 calls in the Vitest coverage report).

Location

components/ui/tabs.tsx

Task

Add tests under __tests__/ (Vitest + Testing Library; only __tests__/** is collected). Cover at least:

  • renders triggers and panels
  • clicking a trigger switches panels
  • keyboard arrow navigation

Acceptance criteria

  • Tests live under __tests__/ and pass with npm test
  • Listed cases are covered
  • No production code changes needed (unless a bug is found — then note it in the PR)

Good for contributors because

Self-contained test task with clear inputs/outputs; a great way to learn the codebase.

#941 Contract: test remove_delegate is rejected while paused

Description

remove_delegate (lib.rs ~1439) calls require_not_paused, but no test covers the paused case.

Location

contracts/streaming/src/lib.rs; tests in contracts/streaming/src/test*.rs.

Task

Pause the contract as admin, then assert try_remove_delegate returns the paused error.

Run cargo test from contracts/.

Acceptance criteria

  • Test asserts the exact StreamError variant
  • cargo test, cargo clippy --all-targets -- -D warnings and cargo fmt --check pass

Good for contributors because

Small, isolated Soroban test using existing fixtures — a gentle intro to the contract.

Summary

All frontend tests must live under tests/ (only that directory is collected by Vitest). For lib/stellar.ts, loadVerifiedTokens is not exported and uses a module-level cache — test it indirectly via getAllTokens/isVerifiedToken or use vi.resetModules() + dynamic import; mock global.fetch and @/lib/sentry. For formatTimeAgo, pin Date.now with fake timers for deterministic output. For the contract test, confirm the exact paused error variant name in lib.rs (require_not_paused) before asserting; the try_* client returns Result<Result<T, StreamError>, _> so the assertion is Err(Ok(StreamError::...)). No production code changes are expected; if a bug is found, note it in the PR.

Changes

  • Add Vitest tests for the verified-token list helpers in lib/stellar.ts. Extend the existing test file with a new describe block covering: (1) loadVerifiedTokens — mock global.fetch to return a Response-like object with ok:true and json() resolving to { tokens: [...] } (use the shape from lib/tokens.json) and assert the returned list; note the module-level cache means you should use vi.resetModules()/dynamic import per test to avoid cross-test cache leakage. (2) load failure — mock fetch to reject or return ok:false and assert the function resolves to [] without throwing (and that captureError is invoked, e.g. by mocking @/lib/sentry). (3) isVerifiedToken — assert true for a known built-in address and false for an unknown one. (4) getAllTokens — assert it returns the network's knownTokens plus custom tokens from localStorage (mock localStorage via jsdom), and that overlapping addresses are not duplicated / precedence is as implemented. Run npm test. (tests/lib/stellar.test.ts)
  • Add Vitest tests for formatTimeAgo in lib/stream-utils.ts. Extend the existing test file with a describe block that uses vi.useFakeTimers()/vi.setSystemTime() (or vi.spyOn(Date, 'now')) to pin the current time, then assert: 'just now' for <60s, 'Xm ago' for minutes, 'Xh ago' for hours, 'Xd ago' for days, a locale date string for timestamps older than 7 days, and future timestamps (diff negative → 'just now'). Cover boundary values exactly at 59s (just now), 60s ('1m ago'), 3_600_000ms ('1h ago'), 86_400_000ms ('1d ago'), and 7*86_400_000ms (falls through to locale date). Restore real timers in afterEach. Run npm test. (tests/lib/stream-utils.test.ts)
  • Create a new Testing Library test file for the Tabs UI component (components/ui/tabs.tsx). Render a Tabs/TabsList/TabsTrigger/TabsContent tree with two or three tabs and assert: (1) all triggers and the active panel render (inactive panels hidden); (2) clicking a trigger with userEvent switches the visible panel; (3) keyboard ArrowRight/ArrowLeft moves focus/selection between triggers and updates the active panel. Use @testing-library/react and @testing-library/user-event following the conventions in sibling tests like tests/components/ui/dropdown-menu.test.tsx. Run npm test. (tests/components/ui/tabs.test.tsx)
  • Add a Soroban contract test in contracts/streaming/src/test.rs asserting remove_delegate is rejected while paused. Using the existing TestEnv fixture: set up the env, create a stream with a delegate (call set_delegate as recipient), call client.pause() as admin, then assert client.try_remove_delegate(&stream_id, &recipient) returns Err(Ok(StreamError::ContractPaused)) — matching the exact variant returned by require_not_paused. Also assert the delegate is unchanged after the failed call. Run cargo test, cargo clippy --all-targets -- -D warnings, and cargo fmt --check from contracts/. (contracts/streaming/src/test.rs)

Co-authored-by: Simple Agent <agent@simple.dev>
@drips-wave

drips-wave Bot commented Oct 17, 2026

Copy link
Copy Markdown

@topsonDev Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits.

You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀

Learn more about application limits

@Austinaminu2
Austinaminu2 merged commit b73ece5 into FlowwStar:main Oct 18, 2026
@grantfox-oss grantfox-oss Bot mentioned this pull request Oct 18, 2026
3 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Contract: test remove_delegate is rejected while paused Add tests for the Tabs UI component Test formatTimeAgo Test verified token list helpers

2 participants