fix playwright tests (#759)

This commit is contained in:
slothful-vassal
2026-02-01 21:02:36 +01:00
committed by GitHub
parent 029f1f134b
commit 6d5494935d
8 changed files with 90 additions and 42 deletions

View File

@@ -1,30 +1,39 @@
import { test as base, expect } from '@playwright/test';
import { ListsPage } from '../../pages/lists_page';
// Run tests serially to avoid race conditions with shared list data
base.describe.configure({ mode: 'serial' });
const test = base.extend<{ listsPage: ListsPage }>({
listsPage: async ({ page }, use) => {
const listsPage = new ListsPage(page);
await listsPage.goto();
await listsPage.create();
await use(listsPage);
await listsPage.removeAll();
},
});
test('shows a list card', async ({ listsPage }) => {
const testListName = `Test List ${Date.now()}`;
const listItemCount = await listsPage.listItems.count();
await listsPage.create();
expect(listsPage.listItems).toHaveCount(listItemCount + 1);
expect(listsPage.listItemsImage).toBeVisible();
await listsPage.create(testListName);
await expect(listsPage.listItems).toHaveCount(listItemCount + 1);
const createdListItem = listsPage.listItems.filter({ hasText: testListName });
await expect(createdListItem).toBeVisible();
await expect(createdListItem.getByRole('img', { name: 'list avatar' })).toBeVisible();
});
test('update a list card', async ({ listsPage }) => {
await listsPage.create("List to Update");
await listsPage.update();
expect(listsPage.listItems.first()).toContainText("Updated List");
expect(listsPage.listItems.first()).toContainText("New Description");
await expect(listsPage.listItems.first()).toContainText("Updated List");
await expect(listsPage.listItems.first()).toContainText("New Description");
});
test('delete a list card', async ({ listsPage }) => {
await listsPage.create("List to Delete");
const countBefore = await listsPage.listItems.count();
await listsPage.delete();
expect(listsPage.listItems).toHaveCount(0);
await expect(listsPage.listItems).toHaveCount(countBefore - 1);
});