Skip to content

Write React Testing Library assertions for wallet disconnect handler … - #364

Merged
godamongstmen897 merged 28 commits into
Goldii-locks:mainfrom
madisonsc52-del:Write-React-Testing-Library-assertions-for-wallet-disconnect-handler-#242-FIX
Aug 31, 2026
Merged

Write React Testing Library assertions for wallet disconnect handler …#364
godamongstmen897 merged 28 commits into
Goldii-locks:mainfrom
madisonsc52-del:Write-React-Testing-Library-assertions-for-wallet-disconnect-handler-#242-FIX

Conversation

@madisonsc52-del

Copy link
Copy Markdown
Contributor

Findings

The issue was insufficient test coverage for app/lib/wallet_disconnect_handler.ts, particularly around the core disconnectWalletWithCheck() function.

  • The module handles wallet detection, availability checks, setup instructions, install URLs, and safe wallet disconnection.

  • Existing tests provided good coverage for wallet detection and availability checks.

  • However, disconnectWalletWithCheck() had only 8 basic tests.

Missing coverage included:

  • Successful mocked wallet disconnects

  • Error and non-Error failures

  • Concurrent and sequential disconnects

  • Delayed async operations

  • Logging behavior

  • Result object validation

  • Edge cases such as empty IDs, long errors, and synchronous throws

  • Window global integration

Fix Features

A new component test suite was added:

__tests__/wallet_disconnect_handler.component.test.ts

It includes:

  • 55 new tests

  • 13 test suites

  • Extensive vi.fn() wallet action mocking

The tests cover:

  1. Successful disconnects for all supported wallets

  2. Error-based disconnect failures

  3. Non-Error throws, including strings, numbers, objects, null, and undefined

  4. Wallet-not-installed behavior

  5. Detector failures

  6. Sequential and parallel disconnect operations

  7. Delayed and asynchronous operations

  8. Logging behavior

  9. WalletDisconnectResult structure

  10. Edge cases and repeated calls

  11. Window global detection and override behavior

  12. Detailed availability and fallback scenarios

Wallet Coverage

The test suite covers all supported wallets:

  • Freighter

  • Albedo

  • xBull

  • Hana

Each wallet is tested across relevant success, failure, missing-installation, and detection scenarios.

Validation

Test results:

wallet_disconnect_handler.component.test.ts
55/55 tests passed

Combined test suites
89/89 tests passed

Final Result

Before After
34 existing tests 89 total tests
8 basic disconnect tests Comprehensive disconnect action coverage
No concurrency testing Sequential and parallel scenarios covered
No non-Error failure coverage Multiple invalid throw types covered
No logging verification Logging behavior tested
Limited edge-case testing Empty IDs, long errors, sync throws, and repeated calls covered
No component-level window integration Window globals and detector overrides tested

Bottom line: The production implementation was not changed. The fix addresses the testing gap by adding comprehensive mocked wallet-action coverage for disconnectWalletWithCheck() and related wallet detection behavior, with all 89 tests passing.

CLOSE #242

vicajohn and others added 5 commits August 27, 2026 06:26
- Replace hardcoded empty message with EmptyStateCard component
- Display briefcase icon for job-related context
- Show descriptive title and explanation text
- Include role badges (Client, Freelancer, Arbiter) showing available participation options
- Add comprehensive test coverage with 16 test cases
- Ensure proper accessibility with region landmarks and aria-labels
- Validates placeholder display under empty data states
@drips-wave

drips-wave Bot commented Aug 29, 2026

Copy link
Copy Markdown

@madisonsc52-del 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

@madisonsc52-del

Copy link
Copy Markdown
Contributor Author

@godamongstmen897
PLEASE REVIEW AND MERGE

@godamongstmen897

Copy link
Copy Markdown
Contributor

Fix failed CI check @madisonsc52-del

@madisonsc52-del

Copy link
Copy Markdown
Contributor Author

@godamongstmen897
PLEASE REVIEW

@godamongstmen897

Copy link
Copy Markdown
Contributor

Fix failed CI check

@madisonsc52-del

Copy link
Copy Markdown
Contributor Author

OKAY LET ME WORK ON IT

@madisonsc52-del

Copy link
Copy Markdown
Contributor Author

@godamongstmen897
PLEASE CHECK AND LET ME KNOW IF IT'S FAILING

@godamongstmen897

Copy link
Copy Markdown
Contributor

Fix failed CI check

…handled rejections

- vitest.config.mts: inline @stellar/freighter-api + @creit.tech/stellar-wallets-kit
  so Vite (not Node) does the CJS->ESM interop. Node's named-export detection on
  freighter-api's minified UMD bundle only yields {default, freighterApi}, so the
  kit's 'import { getAddress }' threw a SyntaxError that killed every suite
  importing app/context/WalletContext.tsx.
- freighter_multisig_hook.test.ts: replace base64('aaaa...') fixtures with real
  signed testnet envelopes built via TransactionBuilder.
- signature_timeout_alert_timeout.test.ts: attach rejection handlers before
  advancing fake timers so Node's unhandled-rejection sweep does not fire.
- signature_timeout_alert.test.tsx: await the loader overlay instead of querying
  synchronously after a React state update.
- SignatureTimeoutAlert.tsx: remove the dangling expression left behind by the
  useMemo refactor.
@madisonsc52-del

Copy link
Copy Markdown
Contributor Author

@godamongstmen897
PLEASE REVIEW SORRY FOR THE DELAY

The PR imported EmptyStateCard but never added the component, so the
dashboard would not build. Added it, satisfying this PR's contract
(dashboard-empty-state test id, region role with an aria-label, an SVG
briefcase icon and role badges) while also carrying the shared
empty-state/-title/-description ids the existing dashboard empty-state
test queries.

The description now carries both wordings so the existing assertion
(/create one to get started/i) and this PR's fuller copy both hold.
…y-state-ui

feat: implement descriptive empty state UI for dashboard jobs list
…torybook-318

Build Storybook interface mocks for dark_mode_switcher
The branch was pushed with a botched conflict resolution: the `>>>>>>>`
markers were stripped but the branch-name lines and both sides of each
conflict were left in place. That left four stray
`Write-React-Testing-Library-assertions-...-Goldii-locks#242-FIX` lines, a duplicate
`@stellar/stellar-sdk` import block, a second `parseMessage` useMemo in
SignatureTimeoutAlert, and a duplicate `server` key in vitest.config.mts.

Resolved by taking main for the five files the branch only touched
incidentally -- main already carries the equivalent, deduplicated work
(the same parseMessage useMemo derivation and the same freighter-api
inline config the branch was re-adding).

The branch's actual deliverable for Goldii-locks#242 is kept intact:
WALLET_DISCONNECT_HANDLER_TESTS.md and the 851-line
wallet_disconnect_handler.component.test.ts.

lint 0 errors / tsc 0 errors / 1776 tests passing / build OK
@godamongstmen897
godamongstmen897 merged commit 4ddb097 into Goldii-locks:main Aug 31, 2026
1 check passed
godamongstmen897 added a commit to udeachudivine-spec/escrow-frontend that referenced this pull request Aug 31, 2026
… suites

Navbar (4 conflicts): kept main's design tokens and the props its side
passes (isConnecting, providerName, networkMismatch) -- the branch's
side replaced that block with a status="connected" badge and dropped
those three -- while taking the branch's mobile fixes: relative z-10,
px-4 sm:px-6, py-3 sm:py-4, gap-2, flex-wrap, min-w-0 and shrink-0 on
the brand link and badge. That is the actual Goldii-locks#259 deliverable.

wallet_disconnect_handler (3 conflicts): the third was git aligning the
branch's disconnectWalletWithCheck body onto withWalletDisconnectLoader
again, as in Goldii-locks#357 and Goldii-locks#371. Kept main's loader body; the branch's
pendingTx warning runs before the loader is entered, and its success log
sits on the real success path. Both Goldii-locks#357's options and this branch's
pendingTx wanted the 4th parameter, so options stays 4th and pendingTx
is 5th; the one call site passing it now passes undefined for options.

The logging levels were a genuine three-way conflict. This branch (Goldii-locks#241)
moves failures to console.error carrying the Error so the stack
survives, and adds a success log. Goldii-locks#364's component suite, already on
main, asserted the old behaviour: warn on failure, and complete silence
on success.

Settled as:
  success                    console.info   (informational -- keeps
                                            Goldii-locks#364's "no warn, no error"
                                            assertion true)
  disconnect failure         console.error(tag, err)
  availability check failure console.error(tag, err)
  pending transaction        console.warn
  wallet not installed       console.warn

Updated the assertions that described the superseded levels: four
failure checks in wallet_disconnect_handler.component.test.ts moved from
warnSpy to errorSpy, and this branch's success/pending-tx counts now
account for console.info. No assertion changed what it verifies.

lint 0 errors / tsc 0 errors / 1996 tests passing / build OK
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.

Write React Testing Library assertions for wallet_disconnect_handler

4 participants