Skip to content
This repository was archived by the owner on Apr 21, 2025. It is now read-only.

Commit bd38058

Browse files
committed
fix routes test
1 parent 5d6b813 commit bd38058

File tree

3 files changed

+58
-26
lines changed

3 files changed

+58
-26
lines changed

e2e/routes.spec.ts

Lines changed: 44 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@ import { expect, Page, test } from "@playwright/test";
22

33
const routes = [
44
"/",
5-
"/activity",
65
"/feedback",
76
"/gift",
87
"/receive",
98
"/scanner",
9+
"/search",
1010
"/send",
1111
"/swap",
1212
"/settings"
@@ -58,24 +58,29 @@ test.beforeEach(async ({ page }) => {
5858

5959
test("visit each route", async ({ page }) => {
6060
// Start on the home page
61-
// Expect a title "to contain" a substring.
6261
await expect(page).toHaveTitle(/Mutiny Wallet/);
63-
64-
// Wait for an element matching the selector to appear in DOM.
65-
await page.waitForSelector("text=0 SATS");
66-
67-
console.log("Page loaded.");
62+
await page.waitForSelector("text=Welcome to the Mutiny!");
6863

6964
// Wait for a while just to make sure we can load everything
7065
await page.waitForTimeout(1000);
7166

67+
console.log("Waiting for new wallet to be created...");
68+
69+
await page.locator(`button:has-text('New Wallet')`).click();
70+
71+
await page.locator("text=Create your profile").first();
72+
73+
await page.locator("button:has-text('Skip for now')").click();
74+
7275
checklist.set("/", true);
7376

74-
await checkRoute(page, "/activity", "Activity", checklist);
75-
await page.goBack();
77+
// Should have a balance up top now
78+
await page.locator(`text=0 sats`).first();
7679

77-
// Navigate to settings
78-
await checkRoute(page, "/settings", "Settings", checklist);
80+
// Find an image with an alt text of "mutiny" and click it
81+
await page.locator("img[alt='mutiny']").first().click();
82+
await expect(page.locator("h1").first()).toHaveText("Settings");
83+
checklist.set("/settings", true);
7984

8085
// Mutiny+
8186
await checkRoute(page, "/settings/plus", "Mutiny+", checklist);
@@ -146,22 +151,43 @@ test("visit each route", async ({ page }) => {
146151
await checkRoute(page, "/settings/admin", "Secret Debug Tools", checklist);
147152
await page.goBack();
148153

149-
// Go back home
150-
await page.goBack();
151-
152154
// Feedback
153155
await checkRoute(page, "/feedback", "Give us feedback!", checklist);
154156
await page.goBack();
155157

156-
// Receive is covered in another test
157-
checklist.set("/receive", true);
158+
// Go back home
159+
await page.goBack();
160+
161+
// Try the fab button
162+
await page.locator("#fab").click();
163+
await page.locator("text=Send").click();
164+
await expect(page.locator("input").first()).toBeFocused();
158165

159166
// Send is covered in another test
160167
checklist.set("/send", true);
161168

169+
await page.goBack();
170+
171+
// Try the fab button again
172+
await page.locator("#fab").click();
173+
// (There are actually two buttons with the "Receive text on first run)
174+
await page.locator("text=Receive").last().click();
175+
176+
await expect(page.locator("h1").first()).toHaveText("Receive Bitcoin");
177+
178+
// Actual receive is covered in another test
179+
checklist.set("/receive", true);
180+
181+
await page.goBack();
182+
183+
// Try the fab button again
184+
await page.locator("#fab").click();
185+
await page.locator("text=Scan").click();
186+
162187
// Scanner
163-
await page.locator(`a[href='/scanner']`).first().click();
164-
await expect(page.locator("button").first()).toHaveText("Paste Something");
188+
await expect(
189+
page.locator("button:has-text('Paste Something')")
190+
).toBeVisible();
165191
checklist.set("/scanner", true);
166192

167193
// Now we have to check routes that aren't linked to directly for whatever reason

src/components/Fab.tsx

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import { ArrowDownLeft, ArrowUpRight, Plus, Scan } from "lucide-solid";
33
import { createSignal, JSX, onCleanup, onMount, Show } from "solid-js";
44

55
import { Circle } from "~/components";
6+
import { useI18n } from "~/i18n/context";
67

78
function FabMenuItem(props: {
89
onClick: () => void;
@@ -60,6 +61,7 @@ export function FabMenu(props: {
6061
export function Fab(props: { onSearch: () => void; onScan: () => void }) {
6162
const [open, setOpen] = createSignal(false);
6263
const navigate = useNavigate();
64+
const i18n = useI18n();
6365

6466
return (
6567
<>
@@ -74,13 +76,13 @@ export function Fab(props: { onSearch: () => void; onScan: () => void }) {
7476
}}
7577
>
7678
<ArrowUpRight />
77-
Send
79+
{i18n.t("common.send")}
7880
</FabMenuItem>
7981
</li>
8082
<li>
8183
<FabMenuItem onClick={() => navigate("/receive")}>
8284
<ArrowDownLeft />
83-
Recieve
85+
{i18n.t("common.receive")}
8486
</FabMenuItem>
8587
</li>
8688

@@ -92,14 +94,14 @@ export function Fab(props: { onSearch: () => void; onScan: () => void }) {
9294
}}
9395
>
9496
<Scan />
95-
Scan
97+
{i18n.t("common.scan")}
9698
</FabMenuItem>
9799
</li>
98100
</ul>
99101
</FabMenu>
100102
</Show>
101103
<div class="fixed bottom-8 right-8 text-m-red">
102-
<button onClick={() => setOpen(!open())}>
104+
<button id="fab" onClick={() => setOpen(!open())}>
103105
<Circle size="large">
104106
<Plus class="h-8 w-8" />
105107
</Circle>
@@ -116,6 +118,8 @@ export function MiniFab(props: {
116118
sendDisabled?: boolean | undefined;
117119
}) {
118120
const [open, setOpen] = createSignal(false);
121+
const i18n = useI18n();
122+
119123
return (
120124
<>
121125
<Show when={open()}>
@@ -130,7 +134,7 @@ export function MiniFab(props: {
130134
}}
131135
>
132136
<ArrowUpRight />
133-
Send
137+
{i18n.t("common.send")}
134138
</FabMenuItem>
135139
</li>
136140
<li>
@@ -141,7 +145,7 @@ export function MiniFab(props: {
141145
}}
142146
>
143147
<ArrowDownLeft />
144-
Request
148+
{i18n.t("common.request")}
145149
</FabMenuItem>
146150
</li>
147151

@@ -153,13 +157,13 @@ export function MiniFab(props: {
153157
}}
154158
>
155159
<Scan />
156-
Scan
160+
{i18n.t("common.scan")}
157161
</FabMenuItem>
158162
</li>
159163
</ul>
160164
</FabMenu>
161165
</Show>
162-
<button onClick={() => setOpen(true)}>
166+
<button id="fab" onClick={() => setOpen(true)}>
163167
<Plus class="h-8 w-8 text-m-red" />
164168
</button>
165169
</>

src/i18n/en/translations.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,11 @@ export default {
88
e_sat: "eSAT",
99
sats: "SATS",
1010
sat: "SAT",
11+
scan: "Scan",
1112
fee: "Fee",
1213
send: "Send",
1314
receive: "Receive",
15+
request: "Request",
1416
dangit: "Dangit",
1517
back: "Back",
1618
coming_soon: "(coming soon)",

0 commit comments

Comments
 (0)