test(NetworkBanner): fix undefined renderWithNetwork helper - #640
Open
uche001-dev wants to merge 1 commit into
Open
test(NetworkBanner): fix undefined renderWithNetwork helper#640uche001-dev wants to merge 1 commit into
uche001-dev wants to merge 1 commit into
Conversation
Related to Sorokit#523 While verifying Sorokit#523 (network switching) was already fixed on main, found that 3 of NetworkBanner.test.tsx's 11 tests were calling a renderWithNetwork helper that was never defined anywhere in the file, failing with ReferenceError: renderWithNetwork is not defined. Adds the missing helper: mocks useSorokit to return a synthetic network built from just a name (rpcUrl/passphrase/horizonUrl are irrelevant to NetworkBanner, which only ever reads network.name), then renders the given element (or a bare <NetworkBanner /> by default). Also fixes the third broken test, which asserted client.network.getNetwork had been called — NetworkBanner never touches a client at all, it only reads network from context directly, so that assertion could never have passed against the real component. Replaced with an assertion of what the component actually does (renders nothing when active="network", exercised here against an arbitrary/unknown network to keep it independent of the synchronous mainnet/testnet case already covered above), and renamed it to stop duplicating the title of the existing synchronous version of the same case. Verification: all 11 tests in this file pass; npx eslint clean (after --fix reordered imports per the project's import-sort rule); npx tsc --noEmit clean across the whole project.
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.
Related to #523 (not closing it — see the disclosure comment on that issue for why #523's actual behavior is already fixed on
main)Summary
While verifying #523 (network switching) was already resolved, found that 3 of
NetworkBanner.test.tsx's 11 tests were calling arenderWithNetworkhelper that was never defined anywhere in the file:This PR:
renderWithNetwork(name, element?)helper — mocksuseSorokitto return a synthetic network built from just aname(the otherNetworkInfofields are irrelevant toNetworkBanner, which only ever readsnetwork.name), then renders the given element (or a bare<NetworkBanner />by default).client.network.getNetworkhad been called —NetworkBannernever touches aclientat all, it only readsnetworkstraight from context, so that assertion could never have passed against the real component even with the helper defined. Replaced with an assertion of what the component actually does (renders nothing whenactive="network"), and renamed it since it was an exact duplicate of an existing test's title.Why this and not #523/#522/#519 themselves
Checked all three of my assigned issues in this repo before starting any work:
c4fcb4a("fix: mock-client.ts is dead code duplicated by inline adapter in main.tsx causing diverged mocks #536 unify mock client adapter and support pagination in getHistory"), which removed the duplicated adapter inmain.tsxthese issues were filed against. Posted a disclosure comment on Network switching in main.tsx adapter always returns current testnet config regardless of selection #523 with details; this PR is the one small loose end that surfaced while verifying it (the broken test helper above).QRCode.tsxuses the realqrcodelibrary (QRCodeLib.toCanvas) with proper loading/error states and accessibility, exceeding the issue's own acceptance criteria. Commit history shows80df1fb/590a4e7as the relevant fixes.I didn't want to open a no-op PR against any of the three original issues, but this test-infra gap was concrete, small, and directly tied to #523's own acceptance criteria ("active network badge shows the correct network"), so it seemed worth fixing rather than just disclosing.
Verification
npx vitest run src/components/NetworkBanner.test.tsx— 11/11 passing (was 8/11).npx eslint src/components/NetworkBanner.test.tsx— clean (ran--fixonce for import ordering per the project'ssimple-import-sortrule).npx tsc --noEmit— clean across the whole project.