Skip to content

feat: Add deterministic Freighter browser mock for E2E testing - #795

Merged
Nanle-code merged 1 commit into
Nanle-code:masterfrom
Talentgift24-ux:freighter-browser-mock-2026
Jul 29, 2026
Merged

feat: Add deterministic Freighter browser mock for E2E testing#795
Nanle-code merged 1 commit into
Nanle-code:masterfrom
Talentgift24-ux:freighter-browser-mock-2026

Conversation

@Talentgift24-ux

Copy link
Copy Markdown

#783 [2026 Testing] Add a deterministic Freighter browser mock
Close #783

PR Title

feat: Add deterministic Freighter browser mock for E2E testing

Objective

Exercise connect, reject, sign, lock, account-change, and network-change flows for the Freighter wallet in CI.

Target Area

  • tests/e2e/fixtures/freighter-mock.js
  • tests/e2e/freighter.spec.js
  • src/lib/wallet/freighter.js

Description

This PR introduces a deterministic browser mock for the Freighter wallet to facilitate robust End-to-End testing in CI. Previously, it was difficult to exercise wallet flows without manual interaction or flaky heuristics.

By injecting a lightweight mock via Playwright (page.addInitScript), we can accurately simulate the window.freighterApi interface and cover multiple edge cases.

Key Changes:

  1. Mock Implementation (tests/e2e/fixtures/freighter-mock.js):
    • Exposes a standard Freighter API mock (isConnected, isAllowed, getAddress, signTransaction, etc.).
    • Provides a testing API (window.mockFreighter) to deterministically simulate accountChange, networkChange, lock states, and connection/signing rejections.
  2. Automated E2E Tests (tests/e2e/freighter.spec.js):
    • Covers the primary flow (successful connection & address retrieval).
    • Covers failure paths (user rejects connection, wallet is locked).
    • Covers boundary cases (simulated network change and account change).
  3. Wallet Connector Updates (src/lib/wallet/freighter.js):
    • Added listener handlers for freighterAccountChange, freighterNetworkChange, and freighterLock to gracefully support the mock and future-proof the connector for extensions that emit standard CustomEvents.

Acceptance Criteria Met

  • Clear handling for invalid input, unsupported environments, and failure paths.
  • Automated tests cover the primary flow, at least one boundary case (network/account change), and at least one failure case (reject/locked).
  • User-facing documentation and developer guidance is updated inline and within the test suite to demonstrate mock usage.

@vercel

vercel Bot commented Jul 29, 2026

Copy link
Copy Markdown

@chimdi3850 is attempting to deploy a commit to the nanle-code's projects Team on Vercel.

A member of the Team first needs to authorize it.

@drips-wave

drips-wave Bot commented Jul 29, 2026

Copy link
Copy Markdown

@Talentgift24-ux 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

@Nanle-code
Nanle-code merged commit 74e99bc into Nanle-code:master Jul 29, 2026
1 check failed
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.

[2026 Testing] Add a deterministic Freighter browser mock

3 participants