-
Notifications
You must be signed in to change notification settings - Fork 585
/
Copy pathhappy-path.spec.ts
156 lines (110 loc) · 4.27 KB
/
happy-path.spec.ts
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
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
import {faker} from '@faker-js/faker'
import {expect, test} from '@playwright/test'
import {resetUmbreldAndStart} from './misc'
const TEST_USER = faker.person.firstName()
const TEST_PASSWORD = 'sdfsdf'
let stopUmbreld: (() => void) | null = null
test.beforeAll(async () => {
// TODO: first check if we can reach umbreld. If so, we wanna reset it and restart it.
// TODO: also check if ui is running. If not, start it.
stopUmbreld = await resetUmbreldAndStart()
})
test.afterAll(async () => {
stopUmbreld?.()
})
test('happy path', async ({page, context}) => {
// Can reach backend at localhost:3001
const response = await page.goto('localhost:3001/trpc/debug.sayHi')
expect(response?.status()).toBe(200)
await page.goto('localhost:3000')
// Expect redirect to /onboarding
await expect(page).toHaveURL(/\/onboarding/)
// Expect to have button saying "Start"
await expect(page.getByText('Start')).toBeVisible()
// Click the button
await page.click('text=Start')
// Expect to go to `/create-account`
await expect(page).toHaveURL(/\/create-account/)
// Expect focus at `name`
await expect(page.getByPlaceholder('Name')).toBeFocused()
// Type name
await page.getByPlaceholder('Name').fill(TEST_USER)
// Type password
// Exact because there's also a "Confirm password" field
await page.getByPlaceholder('Password', {exact: true}).fill(TEST_PASSWORD)
// Type password confirmation
await page.getByPlaceholder('Confirm password').fill(TEST_PASSWORD)
// await page.screenshot({path: 'test-results/onboarding.png'})
// Submit
await page.keyboard.press('Enter')
// Click button
// For some reason, this doesn't work
// await page.click('text=Create')
// Wait for redirect
await page.waitForURL(/\/account-created/)
await page.waitForLoadState()
// Wait for text
await page.waitForSelector('text=You’re all set')
// await page.screenshot({path: 'test-results/onboarding-done.png'})
// Expect link with text "Launch"
await expect(page.getByTestId('to-desktop')).toBeVisible()
// Click link
await page.getByTestId('to-desktop').click()
// TODO: also test that pressing Enter works
// await page.keyboard.press('Enter')
await page.waitForURL(/\//)
await page.waitForLoadState()
// Expect to be at `/` and the content to be 'install first app'
await expect(page).toHaveURL(/\//)
// Wait for page load
await page.getByText('Install your first app')
// Expect `Bitcoin Node` to be visible
await expect(page.getByText('Bitcoin Node')).toBeVisible()
// await page.screenshot({path: 'test-results/install-first-app.png'})
// ----
// Click Bitcoin Node
await page.click('text=Bitcoin Node')
// Expect to be at '/app-store`
await expect(page).toHaveURL(/\/app-store/)
const top = page.getByTestId('app-top')
// Click install
await top.getByRole('button', {name: 'Install'}).click()
await expect(top.getByRole('button', {name: 'Installing'})).toBeVisible()
await expect(top.getByRole('button', {name: 'Open'})).toBeVisible({timeout: 20000})
// Click open
await top.getByRole('button', {name: 'Open'}).click()
// Expect credentials dialog
const pagePromise = context.waitForEvent('page')
await expect(page).toHaveURL(/\?dialog=default-credentials/)
await page.getByRole('button', {name: 'Launch app'}).click()
const newPage = await pagePromise
// console.log(await newPage.title())
// console.log(await newPage.url())
// TODO: this doesn't work
// await expect(newPage).toHaveURL(/localhost:2100/)
// Expect `chrome-error://chromewebdata/`
await expect(newPage).toHaveURL(/chrome-error:\/\/chromewebdata\//)
await newPage.close()
// Close the credentials dialog
await page.keyboard.press('Escape')
// Item in dock
// Click on link href that has `/settings`
await page.click('a[href*="/settings"]')
// Expect to be at `/settings`
await expect(page).toHaveURL(/\/settings/)
// Scroll to Factory reset
await page.click('text=Factory reset')
// Await redirect
await page.waitForURL(/\/factory-reset/)
// Press continue
// await page.keyboard.press('Enter')
await page.click('text=Continue')
// Await redirect
await page.waitForURL(/\/factory-reset\/confirm/)
// Enter password
await page.getByLabel('Enter password').fill(TEST_PASSWORD)
// Enter
await page.keyboard.press('Enter')
// Await redirect
await page.waitForURL(/\/factory-reset\/resetting/)
})