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

Commit 4928e9f

Browse files
committed
some of the tests work
1 parent 40a3e79 commit 4928e9f

File tree

6 files changed

+79
-119
lines changed

6 files changed

+79
-119
lines changed

e2e/encrypt.spec.ts

Lines changed: 9 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,14 @@
11
import { expect, test } from "@playwright/test";
22

3+
import { loadHome, visitSettings } from "./utils";
4+
35
test.beforeEach(async ({ page }) => {
46
await page.goto("http://localhost:3420/");
57
});
68

79
test("test local encrypt", async ({ page }) => {
8-
// Expect a title "to contain" a substring.
9-
await expect(page).toHaveTitle(/Mutiny Wallet/);
10-
11-
// Wait for an element matching the selector to appear in DOM.
12-
await page.waitForSelector("text=0 SATS");
13-
14-
console.log("Page loaded.");
15-
16-
// Wait for a while just to make sure we can load everything
17-
await page.waitForTimeout(1000);
18-
19-
// Navigate to settings
20-
const settingsLink = await page.getByRole("link", { name: "Settings" });
21-
22-
settingsLink.click();
23-
24-
// Wait for settings to load
25-
await page.waitForSelector("text=Settings");
10+
await loadHome(page);
11+
await visitSettings(page);
2612

2713
// Click the "Backup" link
2814
await page.click("text=Backup");
@@ -48,6 +34,10 @@ test("test local encrypt", async ({ page }) => {
4834
// Click the "I wrote down the words" button
4935
await wroteDownButton.click();
5036

37+
// Go back to settings / change password
38+
await visitSettings(page);
39+
await page.click("text=Change Password");
40+
5141
// The header should now say "Encrypt your seed words"
5242
await expect(page.locator("h1")).toContainText(["Encrypt your seed words"]);
5343

@@ -86,5 +76,5 @@ test("test local encrypt", async ({ page }) => {
8676
await page.click("text=Decrypt Wallet");
8777

8878
// Wait for an element matching the selector to appear in DOM.
89-
await page.waitForSelector("text=0 SATS");
79+
await page.locator(`text=0 sats`).first();
9080
});

e2e/fedimint.spec.ts

Lines changed: 21 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
import { expect, test } from "@playwright/test";
22

3+
import { loadHome, visitSettings } from "./utils";
4+
35
const SIGNET_INVITE_CODE =
46
"fed11qgqzc2nhwden5te0vejkg6tdd9h8gepwvejkg6tdd9h8garhduhx6at5d9h8jmn9wshxxmmd9uqqzgxg6s3evnr6m9zdxr6hxkdkukexpcs3mn7mj3g5pc5dfh63l4tj6g9zk4er";
57

@@ -8,24 +10,8 @@ test.beforeEach(async ({ page }) => {
810
});
911

1012
test("fedmint join, receive, send", async ({ page }) => {
11-
// Expect a title "to contain" a substring.
12-
await expect(page).toHaveTitle(/Mutiny Wallet/);
13-
14-
// Wait for an element matching the selector to appear in DOM.
15-
await page.waitForSelector("text=0 SATS");
16-
17-
console.log("Page loaded.");
18-
19-
// Wait for a while just to make sure we can load everything
20-
await page.waitForTimeout(1000);
21-
22-
// Navigate to settings
23-
const settingsLink = await page.getByRole("link", { name: "Settings" });
24-
25-
settingsLink.click();
26-
27-
// Wait for settings to load
28-
await page.waitForSelector("text=Settings");
13+
await loadHome(page);
14+
await visitSettings(page);
2915

3016
// Click "Manage Federations" link
3117
await page.click("text=Manage Federations");
@@ -45,21 +31,27 @@ test("fedmint join, receive, send", async ({ page }) => {
4531
await page.goBack();
4632
await page.goBack();
4733

48-
// Make sure there's a fedimint icon
49-
await expect(page.getByRole("img", { name: "community" })).toBeVisible();
34+
// Click the top left button (it's the profile button), a child of header
35+
// TODO: better ARIA stuff
36+
await page.locator(`header button`).first().click();
5037

51-
// Click the receive button
52-
await page.click("text=Receive");
38+
// Make sure there's text that says "fedimint"
39+
await page.locator("text=fedimint").first();
40+
41+
// Navigate back home
42+
await page.goBack();
43+
44+
// Click the fab button
45+
await page.locator("#fab").click();
46+
// Click the receive button in the fab
47+
await page.locator("text=Receive").last().click();
5348

5449
// Expect the url to conain receive
5550
await expect(page).toHaveURL(/.*receive/);
5651

5752
// At least one h1 should show "0 sats"
5853
await expect(page.locator("h1")).toContainText(["0 SATS"]);
5954

60-
// At least one h2 should show "0 USD"
61-
await expect(page.locator("h2")).toContainText(["$0 USD"]);
62-
6355
// Type 100 into the input
6456
await page.locator("#sats-input").pressSequentially("100");
6557

@@ -114,16 +106,12 @@ test("fedmint join, receive, send", async ({ page }) => {
114106
// Click the "Nice" button
115107
await page.click("text=Nice");
116108

117-
// Make sure we have 100 sats in the fedimint balance
118-
await expect(
119-
page
120-
.locator("div")
121-
.filter({ hasText: /^100 eSATS$/ })
122-
.nth(1)
123-
).toBeVisible();
109+
// Make sure we have 100 sats in the top balance
110+
await expect(page.locator("text=100 SATS").first()).toBeVisible();
124111

125112
// Now we send
126-
await page.click("text=Send");
113+
await page.locator("#fab").click();
114+
await page.locator("text=Send").last().click();
127115

128116
// type refund@lnurl-staging.mutinywallet.com
129117
const sendInput = await page.locator("input");

e2e/load.spec.ts

Lines changed: 4 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,11 @@
1-
import { expect, test } from "@playwright/test";
1+
import { test } from "@playwright/test";
2+
3+
import { loadHome } from "./utils";
24

35
test.beforeEach(async ({ page }) => {
46
await page.goto("http://localhost:3420/");
57
});
68

79
test("initial load", async ({ page }) => {
8-
// Expect a title "to contain" a substring.
9-
await expect(page).toHaveTitle(/Mutiny Wallet/);
10-
11-
await expect(page.locator("header")).toContainText(["Activity"], {
12-
timeout: 30000
13-
});
14-
15-
// Wait up to 30 seconds for an image element matching the selector to be visible
16-
await page.waitForSelector("img[alt='lightning']", { timeout: 30000 });
17-
18-
// Wait for an element matching the selector to appear in DOM.
19-
await page.waitForSelector("text=0 SATS");
20-
21-
console.log("Page loaded.");
10+
await loadHome(page);
2211
});

e2e/restore.spec.ts

Lines changed: 16 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
import { expect, test } from "@playwright/test";
22

3+
import { loadHome, visitSettings } from "./utils";
4+
35
test.beforeEach(async ({ page }) => {
46
await page.goto("http://localhost:3420/");
57
});
@@ -9,34 +11,18 @@ test("restore from seed @slow", async ({ page }) => {
911
const TEST_SEED_WORDS =
1012
"rival hood review write spoon tide orange ill opera enrich clip acoustic";
1113

12-
// Expect a title "to contain" a substring.
13-
await expect(page).toHaveTitle(/Mutiny Wallet/);
14-
15-
// Wait for an element matching the selector to appear in DOM.
16-
await page.waitForSelector("text=0 SATS");
17-
18-
console.log("Page loaded.");
19-
20-
// Wait for a while just to make sure we can load everything
21-
await page.waitForTimeout(1000);
22-
23-
// Navigate to settings
24-
const settingsLink = await page.getByRole("link", { name: "Settings" });
25-
26-
settingsLink.click();
27-
28-
// Wait for settings to load
29-
await page.waitForSelector("text=Settings");
14+
await loadHome(page);
15+
await visitSettings(page);
3016

3117
// Click the "Restore" link
32-
page.click("text=Restore");
18+
await page.click("text=Restore");
3319

3420
// There should be some warning text: "This will replace your existing wallet"
3521
await expect(page.locator("p")).toContainText([
3622
"This will replace your existing wallet"
3723
]);
3824

39-
let seedWords = TEST_SEED_WORDS.split(" ");
25+
const seedWords = TEST_SEED_WORDS.split(" ");
4026

4127
// Find the input field with the name "words.0"
4228
for (let i = 0; i < 12; i++) {
@@ -56,31 +42,28 @@ test("restore from seed @slow", async ({ page }) => {
5642
const confirmButton = await page.locator("button", { hasText: "Confirm" });
5743
confirmButton.click();
5844

59-
// Wait for the wallet to load
60-
await page.waitForSelector("img[alt='lightning']");
61-
6245
// Eventually we should have a balance of 100k sats
63-
await page.waitForSelector("text=100,000 SATS");
46+
await page.locator("text=100,000 SATS");
6447

6548
// Now we should clean up after ourselves and delete the wallet
66-
settingsLink.click();
67-
68-
// Wait for settings to load
69-
await page.waitForSelector("text=Settings");
49+
await visitSettings(page);
7050

7151
// Click the "Restore" link
72-
page.click("text=Admin Page");
52+
await page.click("text=Admin Page");
7353

7454
// Clicke the Delete Everything button
75-
page.click("text=Delete Everything");
55+
await page.click("text=Delete Everything");
7656

7757
// A modal should pop up, click the "Confirm" button
7858
const confirmDeleteButton = await page.locator("button", {
7959
hasText: "Confirm"
8060
});
81-
confirmDeleteButton.click();
61+
62+
// wait 5 seconds for no reason
63+
await page.waitForTimeout(5000);
64+
65+
await confirmDeleteButton.click();
8266

8367
// Wait for the wallet to load
84-
// Wait for the wallet to load
85-
await page.waitForSelector("img[alt='lightning']");
68+
await page.waitForSelector("text=Welcome to the Mutiny!");
8669
});

e2e/routes.spec.ts

Lines changed: 4 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
import { expect, Page, test } from "@playwright/test";
22

3+
import { loadHome, visitSettings } from "./utils";
4+
35
const routes = [
46
"/",
57
"/feedback",
@@ -57,29 +59,12 @@ test.beforeEach(async ({ page }) => {
5759
});
5860

5961
test("visit each route", async ({ page }) => {
60-
// Start on the home page
61-
await expect(page).toHaveTitle(/Mutiny Wallet/);
62-
await page.waitForSelector("text=Welcome to the Mutiny!");
63-
64-
// Wait for a while just to make sure we can load everything
65-
await page.waitForTimeout(1000);
66-
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();
62+
await loadHome(page);
7463

7564
checklist.set("/", true);
7665

77-
// Should have a balance up top now
78-
await page.locator(`text=0 sats`).first();
66+
await visitSettings(page);
7967

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");
8368
checklist.set("/settings", true);
8469

8570
// Mutiny+

e2e/utils.ts

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
import { expect, Page } from "@playwright/test";
2+
3+
export async function loadHome(page: Page) {
4+
// Start on the home page
5+
await expect(page).toHaveTitle(/Mutiny Wallet/);
6+
await page.waitForSelector("text=Welcome to the Mutiny!");
7+
8+
console.log("Waiting for new wallet to be created...");
9+
10+
await page.locator(`button:has-text('New Wallet')`).click();
11+
12+
await page.locator("text=Create your profile").first();
13+
14+
await page.locator("button:has-text('Skip for now')").click();
15+
16+
// Should have a balance up top now
17+
await page.locator(`text=0 sats`).first();
18+
}
19+
20+
export async function visitSettings(page: Page) {
21+
// Find an image with an alt text of "mutiny" and click it
22+
// TODO: probably should have better ARIA stuff for this
23+
await page.locator("img[alt='mutiny']").first().click();
24+
await expect(page.locator("h1").first()).toHaveText("Settings");
25+
}

0 commit comments

Comments
 (0)