-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathwallet-flows.e2e.ts
More file actions
107 lines (95 loc) · 3.38 KB
/
Copy pathwallet-flows.e2e.ts
File metadata and controls
107 lines (95 loc) · 3.38 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
import { expect, type Page, type TestInfo, test } from "@playwright/test"
const captureScreenshot = async (
page: Page,
testInfo: TestInfo,
name: string,
) => {
await page.evaluate(() => document.fonts.ready)
await page.screenshot({
animations: "disabled",
caret: "hide",
path: testInfo.snapshotPath(name),
fullPage: true,
})
}
const preparePage = async (page: Page, showOnboarding: boolean) => {
await page.context().route("**/*", (route) => {
const { hostname, pathname } = new URL(route.request().url())
if (pathname === "/api/tokens") {
return route.fulfill({
contentType: "application/json",
body: JSON.stringify({ tokens: {} }),
})
}
if (hostname === "fonts.googleapis.com") {
return route.fulfill({
contentType: "text/css",
body: '@font-face { font-family: "Inter"; src: local("Arial"); }',
})
}
return hostname === "localhost" ? route.continue() : route.abort()
})
await page.addInitScript(
({ showOnboarding }) => {
localStorage.setItem("ShowWelcomeDialog", String(showOnboarding))
localStorage.setItem("defaultLoginMethod", JSON.stringify("testlogin"))
localStorage.setItem("Tracking_Sentry", "denied")
localStorage.setItem("Tracking_Amplitude", "denied")
sessionStorage.setItem("gd-claim-view-seen", "true")
sessionStorage.removeItem("deep_link_url")
},
{ showOnboarding },
)
}
const login = async (page: Page) => {
await page.goto("/en?login=master_seed")
await page.getByRole("button", { name: "Playwright test wallet" }).click()
await expect(page.getByText("Playwright test wallet")).toBeVisible()
}
test("captures the locale-aware onboarding and login entry", async ({
page,
}, testInfo) => {
await preparePage(page, true)
await page.goto("/da?login=master_seed")
await expect(
page.getByText("Velkommen til din nye og forbedrede GoodWallet!"),
).toBeVisible()
await captureScreenshot(page, testInfo, "login-onboarding-da.png")
await page.getByRole("button", { name: "Sign In" }).click()
await expect(
page.getByRole("button", { name: "Playwright test wallet" }),
).toBeVisible()
})
test("captures the authenticated home balance and responsive action grid", async ({
page,
}, testInfo) => {
await preparePage(page, false)
await login(page)
await expect(page.getByText("$124.68")).toBeVisible()
const walletActions = page.getByTestId("wallet-actions")
await expect(walletActions).toBeVisible()
if (testInfo.project.name === "mobile") {
const actionsToggle = page.getByTestId("wallet-actions-toggle")
await expect(actionsToggle).toBeVisible()
await actionsToggle.getByRole("button").click()
}
await captureScreenshot(page, testInfo, "home-balances-overflow-en.png")
})
test("captures the claim verification requirement", async ({
page,
}, testInfo) => {
await preparePage(page, false)
await login(page)
await expect(page.getByRole("link", { name: "GoodDollar" })).toHaveAttribute(
"href",
"/en/gooddollar",
)
await page.goto("/en/gooddollar")
await expect(
page.getByText(
"Before you can start to claim your GoodDollars you first need to pass face verification to whitelist your account.",
),
).toBeVisible()
await expect(page.getByRole("button", { name: "Verify" })).toBeVisible()
await captureScreenshot(page, testInfo, "claim-requires-verification-en.png")
})