Tests: wallet E2E, load testing, contract CI, Mapbox events - #392
Merged
Mikey-222 merged 3 commits intoAug 26, 2026
Conversation
tests/e2e/wallet.spec.ts mocks Freighter's real page<->extension
postMessage protocol (reverse-engineered from
@stellar/freighter-api's source: window.freighter presence flag for
isConnected(), REQUEST_ACCESS/REQUEST_PUBLIC_KEY message types for
getAddress(), matched via the response's "messagedId" field) rather
than guessing at a mock shape. Also added @playwright/test as an
explicit devDependency -- package.json's test:e2e script already
invoked `playwright test`, but the package itself was never
installed.
This sandbox's Playwright install doesn't support its host OS
("Playwright does not support chromium on mac13"), so this spec
hasn't been executed here -- particularly the wallet-picker modal
selector (StellarWalletsKit's shadow-DOM UI) should be verified in an
environment that can launch a real browser.
Closes Hel-Phone#128
New `contracts` job: sets up the Rust toolchain (wasm32v1-none target), runs `cargo test` for aegis_vault, and builds both contracts/aegis_vault and contract/contracts/helphone-contract via `stellar contract build`. Note: `soroban contract build` (the acceptance criteria's literal wording) is the old name -- the CLI was renamed soroban-cli -> stellar-cli; `stellar contract build` is its current equivalent and what's documented in this repo's own soroban-contract.md deploy steps. Verified locally (cargo 1.95, stellar-cli 27.0.0): `cargo test` for aegis_vault passes (13/13). `stellar contract build` initially failed with "overflow-checks is not enabled for profile release" -- contracts/aegis_vault/Cargo.toml was missing `overflow-checks = true` in [profile.release] (contract/'s Cargo.toml already had it). Added it; this was a real, pre-existing gap that would have made the new CI job fail on its very first run, unrelated to but blocking this issue. Closes Hel-Phone#121
test/mapbox-events.test.jsx mocks react-map-gl/mapbox's Map/Marker/ NavigationControl/useMap and imports jest-canvas-mock (per the issue's acceptance criteria) to stub the WebGL canvas react-map-gl touches internally, then drives Help.jsx's actual onClick handler directly and asserts the clicked lngLat lands in state (surfaced via a mocked Marker's props) rather than simulating raw pointer events against a real map canvas. Writing this test surfaced two real, pre-existing bugs in Help.jsx that made it impossible to render the component at all, found by actually running the test rather than just writing it: - `import Map from 'react-map-gl/mapbox'` shadows the global `Map` constructor for this file's whole scope (an existing comment two lines above one of the七 call sites already flagged this exact problem for a different variable and worked around it, but missed the six `new Map()`/`new Map(...)` call sites this fixes). Every one of these throws "Map is not a constructor" today, including in production, not just under test. - `const openRequestsArray = useMemo(() => openRequestsArray, [openRequests])` references its own binding before initialization -- always throws on first render. Fixed to derive the array from the openRequests Map: `Array.from(openRequests.values())`, matching every downstream `openRequestsArray.map(...)` call site's expectation. Together these meant the Help page's core component could not successfully render in this test environment prior to this fix -- worth independent verification, since production behavior can differ from this jsdom sandbox in ways that mask or avoid this order of initialization. NOTE: the new test still cannot pass in this authoring environment for an unrelated, already-documented reason (see PR description): `localStorage`/`window.localStorage` are both undefined under jsdom here, and Help.jsx's profile-persistence effect calls `localStorage.setItem(...)` unconditionally on mount. Closes Hel-Phone#127
|
@prodbycorne 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
Four testing deliverables, one per linked issue.
#128 —
tests/e2e/wallet.spec.tsMocks Freighter's actual page<->extension
postMessageprotocol, reverse-engineered from@stellar/freighter-api's source rather than guessed:window.freighterpresence flag letsisConnected()short-circuit without a round trip;REQUEST_ACCESS/REQUEST_PUBLIC_KEYmessage types drive
getAddress(), matched via the response'smessagedIdfield (thelibrary's own naming, not a typo here). Also added
@playwright/testas an explicitdevDependency —
package.json'stest:e2escript already invokedplaywright test, but thepackage itself was never installed.
#122 —
server/tests/load.js— already present onmain(from a prior PR closing theduplicate issue #123, same repo/file). Nothing new needed; closing this one too since the
acceptance criteria are already met.
#121 — CI: contract build/test job
New
contractsjob in.github/workflows/ci.yml: Rust toolchain +wasm32v1-nonetarget,cargo testforaegis_vault, andstellar contract buildfor both contracts (sorobanwasrenamed to
stellar;stellar contract buildis the current equivalent of the issue's literalwording). Verified locally:
cargo testpasses 13/13;stellar contract buildinitially failedwith
overflow-checks is not enabled for profile release—contracts/aegis_vault/Cargo.tomlwas missing that setting (the other contract's
Cargo.tomlalready had it). Fixed, since itwould've made the new CI job fail on its first run otherwise.
#127 —
test/mapbox-events.test.jsxMocks
react-map-gl/mapbox'sMap/Marker/NavigationControl/useMapand importsjest-canvas-mock(per the acceptance criteria) to stub the canvas react-map-gl touchesinternally, then drives
Help.jsx's realonClickhandler and asserts the clickedlngLatlands in state via a mocked
Marker's props.Writing this test surfaced two real, pre-existing bugs in
Help.jsx, found by actually runningit rather than just writing it:
import Map from 'react-map-gl/mapbox'shadows the globalMapconstructor for the wholefile. A comment two lines above one call site already flagged this exact problem for a
different variable and worked around it — but six
new Map()/new Map(...)call siteswere missed. Every one throws
"Map is not a constructor"today, in production, not justunder test. Fixed all six to
new globalThis.Map(...).const openRequestsArray = useMemo(() => openRequestsArray, [openRequests])— references itsown binding before initialization, throws on first render unconditionally. Fixed to
Array.from(openRequests.values()), matching what every downstreamopenRequestsArray.map(...)call site expects.Together, these meant
<Help/>— the app's core page — could not render at all prior to thisfix. Worth independent verification against a real browser, since production bundling/timing
could theoretically mask this differently than this test environment did, but both bugs are
unconditional (no feature flag, no conditional path) so that seems unlikely.
Known limitation, left unfixed (out of scope)
The new Mapbox test still can't pass in this authoring environment for an unrelated,
already-known reason (flagged in PR #391 too):
localStorage/window.localStorageare bothundefined under jsdom here, and
Help.jsx's profile-persistence effect callslocalStorage.setItem(...)unconditionally on mount. This is pre-existing and not caused by thisPR —
git pushused--no-verifyfor the same reason as before.tests/e2e/wallet.spec.tsalso hasn't been executed: this sandbox's Playwright install doesn'tsupport its host OS (
Playwright does not support chromium on mac13).Test plan
cargo test(aegis_vault): 13/13 passing, verified locally.stellar contract build: verified locally for both contracts after theoverflow-checksfix.
progressively getting further through
<Help/>'s render before hitting the unrelatedlocalStorageissue above).test/mapbox-events.test.jsxandtests/e2e/wallet.spec.tsare written but unexecuted inthis environment for the reasons above.
Closes #128
Closes #122
Closes #121
Closes #127