Skip to content

Commit dfbc31c

Browse files
authored
improve playwright tests (#934)
1 parent 2212cd7 commit dfbc31c

File tree

2 files changed

+7
-16
lines changed

2 files changed

+7
-16
lines changed

tests/e2e/onboarding.test.ts

Lines changed: 5 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -60,9 +60,6 @@ test('onboarding with link', async ({ page, getOnboardingData }) => {
6060
await emailTextbox.fill(onboardingData.email)
6161

6262
await page.getByRole('button', { name: /submit/i }).click()
63-
await expect(
64-
page.getByRole('button', { name: /submit/i, disabled: true }),
65-
).toBeVisible()
6663
await expect(page.getByText(/check your email/i)).toBeVisible()
6764

6865
const email = await readEmail(onboardingData.email)
@@ -92,6 +89,8 @@ test('onboarding with link', async ({ page, getOnboardingData }) => {
9289

9390
await page.getByLabel(/^confirm password/i).fill(onboardingData.password)
9491

92+
await page.waitForLoadState('networkidle') // ensure js is fully loaded.
93+
9594
await page.getByLabel(/terms/i).check()
9695

9796
await page.getByLabel(/remember me/i).check()
@@ -120,9 +119,6 @@ test('onboarding with a short code', async ({ page, getOnboardingData }) => {
120119
await emailTextbox.fill(onboardingData.email)
121120

122121
await page.getByRole('button', { name: /submit/i }).click()
123-
await expect(
124-
page.getByRole('button', { name: /submit/i, disabled: true }),
125-
).toBeVisible()
126122
await expect(page.getByText(/check your email/i)).toBeVisible()
127123

128124
const email = await readEmail(onboardingData.email)
@@ -173,6 +169,7 @@ test('completes onboarding after GitHub OAuth given valid user details', async (
173169
name: /create an account/i,
174170
})
175171

172+
await page.waitForLoadState('networkidle') // ensure js is fully loaded.
176173
await page
177174
.getByLabel(/do you agree to our terms of service and privacy policy/i)
178175
.check()
@@ -313,6 +310,8 @@ test('shows help texts on entering invalid details on onboarding page after GitH
313310
await expect(page).toHaveURL(/\/onboarding\/github/)
314311

315312
// we are all set up and ...
313+
314+
await page.waitForLoadState('networkidle') // ensure js is fully loaded.
316315
await page
317316
.getByLabel(/do you agree to our terms of service and privacy policy/i)
318317
.check()
@@ -350,9 +349,6 @@ test('reset password with a link', async ({ page, insertNewUser }) => {
350349
).toBeVisible()
351350
await page.getByRole('textbox', { name: /username/i }).fill(user.username)
352351
await page.getByRole('button', { name: /recover password/i }).click()
353-
await expect(
354-
page.getByRole('button', { name: /recover password/i, disabled: true }),
355-
).toBeVisible()
356352
await expect(page.getByText(/check your email/i)).toBeVisible()
357353

358354
const email = await readEmail(user.email)
@@ -377,9 +373,6 @@ test('reset password with a link', async ({ page, insertNewUser }) => {
377373
await page.getByLabel(/^confirm password$/i).fill(newPassword)
378374

379375
await page.getByRole('button', { name: /reset password/i }).click()
380-
await expect(
381-
page.getByRole('button', { name: /reset password/i, disabled: true }),
382-
).toBeVisible()
383376

384377
await expect(page).toHaveURL('/login')
385378
await page.getByRole('textbox', { name: /username/i }).fill(user.username)
@@ -408,9 +401,6 @@ test('reset password with a short code', async ({ page, insertNewUser }) => {
408401
).toBeVisible()
409402
await page.getByRole('textbox', { name: /username/i }).fill(user.username)
410403
await page.getByRole('button', { name: /recover password/i }).click()
411-
await expect(
412-
page.getByRole('button', { name: /recover password/i, disabled: true }),
413-
).toBeVisible()
414404
await expect(page.getByText(/check your email/i)).toBeVisible()
415405

416406
const email = await readEmail(user.email)

tests/mocks/github.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import { fileURLToPath } from 'node:url'
33
import { faker } from '@faker-js/faker'
44
import fsExtra from 'fs-extra'
55
import { HttpResponse, passthrough, http, type HttpHandler } from 'msw'
6+
import { USERNAME_MAX_LENGTH } from '#app/utils/user-validation.ts'
67

78
const { json } = HttpResponse
89

@@ -54,7 +55,7 @@ function createGitHubUser(code?: string | null) {
5455
code,
5556
accessToken: `${code}_mock_access_token`,
5657
profile: {
57-
login: faker.internet.username(),
58+
login: faker.internet.username().slice(0, USERNAME_MAX_LENGTH),
5859
id: faker.number.int(),
5960
name: faker.person.fullName(),
6061
avatar_url: 'https://github.com/ghost.png',

0 commit comments

Comments
 (0)