Skip to content

test/docs: sell-flow E2E, bigint formatXlm coverage, rejection logging, testing conventions - #649

Merged
Chucks1093 merged 4 commits into
accesslayerorg:devfrom
omarima-10:test/sell-flow-formatxlm-rejections-docs
Jul 27, 2026
Merged

test/docs: sell-flow E2E, bigint formatXlm coverage, rejection logging, testing conventions#649
Chucks1093 merged 4 commits into
accesslayerorg:devfrom
omarima-10:test/sell-flow-formatxlm-rejections-docs

Conversation

@omarima-10

Copy link
Copy Markdown
Contributor

Summary

Covers four issues: an end-to-end sell-flow integration test (plus the minimal sell-toast fix it needed to be assertable), bigint support and coverage in useFormatXlm, a structured logger for unhandled promise rejections, and a testing-conventions doc. 36 tests across the three touched suites, all passing; tsc -b and eslint clean.

closes #644
closes #645
closes #647
closes #648

Changes

  • Add integration test for the sell flow completing end-to-end from quantity input to success toast #644 — sell flow E2E (src/pages/__tests__/LandingPage.sellFlow.integration.test.tsx): full happy path with the real wallet layer (react-query QueryClientProvider + unmocked useWallet, demo wallet's default 3 held keys) — open the trade panel on the sell side, enter quantity 2, submit through the simulated on-chain confirmation, assert the success toast with creator name and quantity, assert holdings decremented 3 → 1, and assert no error surfaced at any stage. Two companion tests pin the pending-state loading message and singular "1 key" wording.
    • Required one small implementation fix: the sell branch's success toast said Holdings refreshed: -N keys. with no creator name, while acceptance (and the existing Add toast notification on successful key buy or sell transaction #540 toast test's expectation /^Sold 1 key from .+$/) call for creator name + quantity. The toast now reads Sold 2 keys from Alex Rivers, with the hardcoded dialog creator name extracted into a shared FEATURED_CREATOR_NAME constant. This also brings the sell half of the currently-failing LandingPage.tradeConfirmToast test in line with the implementation (that test has an unrelated pre-existing failure: it renders without a QueryClientProvider).
  • Add unit tests for the useFormatXlm hook handling bigint inputs without precision loss #645 — bigint formatXlm (src/hooks/useFormatXlm.ts + tests): the issue's premise is that the hook accepts bigint, but the signature was number-only — so this adds a number | bigint union with a precision-safe bigint path: integer arithmetic end to end (scaled half-up rounding mirroring Intl's halfExpand), Intl-formatted whole part (Intl accepts bigint natively, preserving locale grouping), and the locale's decimal separator for the fraction so output matches the number path in any locale. Nine new tests: safe-range bigint ≡ equivalent number (including decimals options), MAX_SAFE_INTEGER + 2 stroops keeping its final digit (the number path provably rounds it away), no scientific notation, every digit of a 20-digit bigint preserved, 0n → "0.00", negative bigint ≡ negative number, no -0.00 when a negative amount rounds to zero, and hook-interface parity.
  • Add structured log for unhandled promise rejections via window.onunhandledrejection #647 — unhandled rejection logging (src/utils/unhandledRejectionLogger.ts, registered in src/main.tsx): window.onunhandledrejection handler emitting a debug-level structured log with reason (Error name+message, string, or JSON), promise_origin (first stack frame of the rejection site, unknown otherwise), and rejected_at (ISO timestamp). Registration is module-scope at app init with a once-guard (re-renders can't re-register), the handler never calls preventDefault (default browser reporting preserved), and emission is suppressed when Vite's MODE === 'test' — injectable for the logger's own tests. It cannot duplicate error-boundary logs because boundaries catch render-time throws, which never surface as unhandled rejections (documented in the module). Eight tests cover registration-once, structured fields, stack-derived origin, non-Error reasons, preserved default behaviour, test-env suppression, and one-log-per-rejection.
  • Add docs for testing conventions covering unit test structure, mocking patterns, and integration test setup #648 — testing conventions doc (docs/testing-conventions.md): documents the __tests__/ co-location and <Page>.<feature>.integration.test.tsx naming, both React Query mock patterns (service-mock + real provider vs. hook-module mock, with code examples and the fresh-client/no-retries rules), the wallet mock seam with an example and when to prefer the real demo wallet, the six-step integration setup (providers, service mocks, toast sink, presentation mocks, browser-API stubs including the newer-Node localStorage pitfall, cleanup), and a table of the copyable utilities that exist today with a promotion rule for when they should graduate to src/test/. Cross-links the utils testing guide and the error-handling-in-hooks doc.

Test plan

  • npx vitest run on the three touched suites: 36 tests passing (3 sell-flow E2E, 25 formatXlm incl. 9 new bigint, 8 rejection-logger).
  • npx tsc -b: clean. npx eslint on all changed files: clean.
  • Note for local runs on Node ≥25: Node's global WebStorage shadows jsdom's localStorage and breaks several pre-existing page suites (window.localStorage.clear is not a function) — unrelated to this PR; the new E2E installs its own storage stub and is immune, and the conventions doc documents the pitfall for future suites.

@drips-wave

drips-wave Bot commented Jul 27, 2026

Copy link
Copy Markdown

@omarima-10 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

@Chucks1093
Chucks1093 merged commit cd3c5bb into accesslayerorg:dev Jul 27, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment