Skip to content

Commit 27e05fb

Browse files
authored
refactor: remove URL expectations from tests for improved stability (#31)
* refactor: remove URL expectations from tests for improved stability * refactor: remove unused 'expect' import from list-test helper * test: add URL expectations for genre links in movie details page
1 parent 0dfb536 commit 27e05fb

File tree

7 files changed

+304
-111
lines changed

7 files changed

+304
-111
lines changed

playwright.config.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@ export default defineConfig({
2626
/* Reporter to use. See https://playwright.dev/docs/test-reporters */
2727
reporter: process.env.CI ? [['html'], ['dot']] : 'html',
2828
/* Shared settings for all the projects below. See https://playwright.dev/docs/api/class-testoptions. */
29-
updateSourceMethod: 'overwrite',
3029
use: {
3130
/* Base URL to use in actions like `await page.goto('/')`. */
3231
baseURL: 'http://localhost:3000/',

tests/helpers/list-test.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { test as baseTest, Page, expect } from '@playwright/test';
1+
import { test as baseTest, Page } from '@playwright/test';
22
import { createList, addMovie } from './list-utilities';
33

44
/**
@@ -30,7 +30,6 @@ export const listTest = baseTest.extend<{ listPage: Page }>({
3030

3131
await listTest.step('add image to list', async () => {
3232
await page.getByRole('link', { name: 'Choose Image' }).click();
33-
await expect(page).toHaveURL(/choose-image/);
3433
const movie = page
3534
.getByRole('listitem', { name: 'movie' })
3635
.filter({ hasText: /Garfield/ })

tests/helpers/list-utilities.ts

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,6 @@ export async function openLists(page: Page, name: string = 'My Lists') {
4242
await test.step('open list from menu', async () => {
4343
await page.getByRole('button', { name: 'User Profile' }).click();
4444
await page.getByRole('link', { name }).click();
45-
const formattedName = name.toLowerCase().replace(/\s+/g, '-');
46-
await expect(page).toHaveURL(new RegExp(`/${formattedName}`));
4745
});
4846
}
4947

@@ -85,7 +83,6 @@ export async function addImageToList(page: Page, movieName: string) {
8583
await test.step('add image to list', async () => {
8684
// Click on the "Choose Image" link
8785
await page.getByRole('link', { name: 'Choose Image' }).click();
88-
await expect(page).toHaveURL(/choose-image/);
8986

9087
// Find the movie list item and verify its heading contains the movie name
9188
const movie = page.getByRole('listitem', { name: 'movie' });

tests/logged-in/manage-lists-fixtures.spec.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ test('editing an existing list', async ({ listPage }) => {
1717
await expect(page.getByRole('textbox', { name: 'Name' })).toHaveValue('my action movies');
1818
await expect(page.getByRole('textbox', { name: 'Description' }))
1919
.toHaveValue('my favorite action movies');
20-
// TODO: replace regex with text when Playwright is rolled.
2120
await expect(page.locator('main')).toMatchAriaSnapshot(`
2221
- heading "my action movies" [level=1]
2322
- textbox "Name": my action movies
@@ -108,7 +107,6 @@ test('deleting a list', async ({ listPage }) => {
108107
});
109108

110109
// Verify that the list has been deleted
111-
await expect(page).toHaveURL(/my-lists/);
112110
await expect(page.getByRole('heading', { level: 3 }))
113111
.toHaveText(/no lists/);
114112
await expect(page.getByRole('listitem', { name: 'movie' })).toHaveCount(0);

0 commit comments

Comments
 (0)