-
Notifications
You must be signed in to change notification settings - Fork 42
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Keep universe in goBack in IcrcWalletPage (#4122)
# Motivation In `IcrcWalletPage` (and other wallets) when there is no or an incorrect account identifier, we navigate back to the accounts page. In `SnsWallet` it navigates to the accounts page of the same universe but in `IcrcWalletPage` it reverts to the ICP universe. Instead it should stay with the universe of the wallet we were on. In an earlier version of this PR, the test would end up in an infinite loop because navigating to a different URL would trigger the `selectedIcrcTokenUniverseIdStore` which would result in `IcrcWalletPage` trying again to load the data and again trying to go back to the accounts page etc. In reality this would not happen, because as soon as the app navigates away from the wallet page, the component would be unmounted and it wouldn't try to load data anymore. To make the test more realistic, I added a wrapper component that only renders the wallet if the page store shows that we are on the wallet route. # Changes 1. Include the universe in the URL when navigating from the `IcrcWalletPage` to the accounts page. 2. Render `IcrcWallet` inside a wrapper component `WalletTest.svelte` which only renders the component if we're on the wallet route, to make the test more realistic and avoid an infinite loop. 3. Change the test to use the new test wrapper. 4. Change the test to expect the universe in the URL. 5. Drive-by improvement: Expect error toast messages. # Tests Unit tests updated. Tested manually. # Todos - [x] Add entry to changelog (if necessary).
- Loading branch information
Showing
4 changed files
with
67 additions
and
9 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
<script lang="ts"> | ||
import { AppPath } from "$lib/constants/routes.constants"; | ||
import { pathForRouteId } from "$lib/utils/page.utils"; | ||
import { page } from "$app/stores"; | ||
import type { SvelteComponent } from "svelte"; | ||
export let testComponent: typeof SvelteComponent; | ||
export let accountIdentifier: string | undefined = undefined; | ||
let currentAppPath: string | undefined = undefined; | ||
$: currentAppPath = pathForRouteId($page.route.id); | ||
</script> | ||
|
||
{#if currentAppPath === AppPath.Wallet} | ||
<svelte:component this={testComponent} {accountIdentifier} /> | ||
{/if} |