Skip to content

Commit 5c51684

Browse files
authored
Minor improvements to e2e tests (#258)
1 parent 835cc96 commit 5c51684

File tree

3 files changed

+7
-3
lines changed

3 files changed

+7
-3
lines changed

tests/e2e/2fa.test.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ test('Users can add 2FA to their account and use it when logging in', async ({
3838
await dialog.getByRole('link', { name: /close/i }).click()
3939
await page.getByRole('link', { name: user.name ?? user.username }).click()
4040
await page.getByRole('menuitem', { name: /logout/i }).click()
41+
await expect(page).toHaveURL(`/`)
4142

4243
await page.goto('/login')
4344
await expect(page).toHaveURL(`/login`)

tests/e2e/notes.test.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ test('Users can create notes', async ({ login, page }) => {
2020
await page.getByRole('textbox', { name: /content/i }).fill(newNote.content)
2121

2222
await page.getByRole('button', { name: /submit/i }).click()
23+
await expect(page.getByText('Note created', { exact: true })).toBeVisible()
2324
await expect(page).toHaveURL(new RegExp(`/users/${user.username}/notes/.*`))
2425
})
2526

@@ -37,13 +38,14 @@ test('Users can edit notes', async ({ login, page }) => {
3738
await expect(page).toHaveURL(new RegExp(`/users/${user.username}/notes/.*`))
3839

3940
// edit the note
40-
await page.getByRole('link', { name: 'Edit' }).click()
41+
await page.getByRole('link', { name: 'Edit', exact: true }).click()
4142
const updatedNote = createNewNote()
4243
await page.getByRole('textbox', { name: /title/i }).fill(updatedNote.title)
4344
await page
4445
.getByRole('textbox', { name: /content/i })
4546
.fill(updatedNote.content)
4647
await page.getByRole('button', { name: /submit/i }).click()
48+
await expect(page.getByText('Note updated', { exact: true })).toBeVisible()
4749

4850
await expect(page).toHaveURL(new RegExp(`/users/${user.username}/notes/.*`))
4951
await expect(
@@ -68,6 +70,7 @@ test('Users can delete notes', async ({ login, page }) => {
6870
// find links with href prefix
6971
let countBefore = await page.locator('ul>li>a').count()
7072
await page.getByRole('button', { name: /delete/i }).click()
73+
await expect(page.getByText('Note deleted', { exact: true })).toBeVisible()
7174
await expect(page).toHaveURL(`/users/${user.username}/notes`)
7275
let countAfter = await page.locator('ul>li>a').count()
7376
expect(countAfter).toEqual(countBefore - 1)

tests/e2e/settings-profile.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ test('Users can update their profile photo', async ({ login, page }) => {
5656
await page.goto('/settings/profile')
5757

5858
const beforeSrc = await page
59-
.getByAltText(user.name ?? user.username)
59+
.getByRole('img', { name: user.name ?? user.username })
6060
.getAttribute('src')
6161

6262
await page.getByRole('link', { name: /change profile photo/i }).click()
@@ -79,7 +79,7 @@ test('Users can update their profile photo', async ({ login, page }) => {
7979
).toHaveURL(`/settings/profile`)
8080

8181
const afterSrc = await page
82-
.getByAltText(user.name ?? user.username)
82+
.getByRole('img', { name: user.name ?? user.username })
8383
.getAttribute('src')
8484

8585
expect(beforeSrc).not.toEqual(afterSrc)

0 commit comments

Comments
 (0)