test/docs: sell-flow E2E, bigint formatXlm coverage, rejection logging, testing conventions - #649
Merged
Chucks1093 merged 4 commits intoJul 27, 2026
Conversation
|
@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! 🚀 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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 -band eslint clean.closes #644
closes #645
closes #647
closes #648
Changes
src/pages/__tests__/LandingPage.sellFlow.integration.test.tsx): full happy path with the real wallet layer (react-queryQueryClientProvider+ unmockeduseWallet, 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.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 readsSold 2 keys from Alex Rivers, with the hardcoded dialog creator name extracted into a sharedFEATURED_CREATOR_NAMEconstant. This also brings the sell half of the currently-failingLandingPage.tradeConfirmToasttest in line with the implementation (that test has an unrelated pre-existing failure: it renders without aQueryClientProvider).formatXlm(src/hooks/useFormatXlm.ts+ tests): the issue's premise is that the hook accepts bigint, but the signature wasnumber-only — so this adds anumber | bigintunion 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 + 2stroops 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.00when a negative amount rounds to zero, and hook-interface parity.src/utils/unhandledRejectionLogger.ts, registered insrc/main.tsx):window.onunhandledrejectionhandler emitting a debug-level structured log withreason(Error name+message, string, or JSON),promise_origin(first stack frame of the rejection site,unknownotherwise), andrejected_at(ISO timestamp). Registration is module-scope at app init with a once-guard (re-renders can't re-register), the handler never callspreventDefault(default browser reporting preserved), and emission is suppressed when Vite'sMODE === '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.docs/testing-conventions.md): documents the__tests__/co-location and<Page>.<feature>.integration.test.tsxnaming, 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 tosrc/test/. Cross-links the utils testing guide and the error-handling-in-hooks doc.Test plan
npx vitest runon 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 eslinton all changed files: clean.localStorageand 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.