e2e: add medium-priority Playwright coverage (#44)
All checks were successful
Build and Push Image / docker-build-and-push (push) Successful in 2m29s
All checks were successful
Build and Push Image / docker-build-and-push (push) Successful in 2m29s
Co-authored-by: Shaun Campbell <shaun@campbellwireless.net> Reviewed-on: #44 Co-authored-by: AI Agent <ai-agent@campbellwireless.net> Co-committed-by: AI Agent <ai-agent@campbellwireless.net>
This commit was merged in pull request #44.
This commit is contained in:
44
e2e/checklist-experience-persistence.test.ts
Normal file
44
e2e/checklist-experience-persistence.test.ts
Normal file
@@ -0,0 +1,44 @@
|
||||
import { test, expect } from '@playwright/test';
|
||||
import { TEST_USERS } from './setup/test-users.js';
|
||||
import { loginAsLocalUser } from './helpers/auth.js';
|
||||
import { addActivity, addPackingList, createTrip, uniqueSuffix } from './helpers/trip.js';
|
||||
|
||||
test.beforeEach(async ({ context }) => {
|
||||
await context.clearCookies();
|
||||
});
|
||||
|
||||
test('checklists and experiences persist after reload', async ({ page }) => {
|
||||
const suffix = uniqueSuffix();
|
||||
const tripName = `E2E Checklist ${suffix}`;
|
||||
const listName = `Packing ${suffix}`;
|
||||
const itemOne = `Passport ${suffix}`;
|
||||
const itemTwo = `Sunscreen ${suffix}`;
|
||||
const activityName = `Museum Visit ${suffix}`;
|
||||
|
||||
await loginAsLocalUser(page, TEST_USERS.regular.username, TEST_USERS.regular.password);
|
||||
await createTrip(page, { name: tripName, description: 'Checklist persistence coverage' });
|
||||
|
||||
await addPackingList(page, { name: listName, items: [itemOne, itemTwo] });
|
||||
await addActivity(page, { name: activityName });
|
||||
|
||||
const toggleRequest = page.waitForResponse(
|
||||
(response) =>
|
||||
response.request().method() === 'POST' && response.url().includes('/toggleChecklistItem')
|
||||
);
|
||||
await page.getByRole('checkbox', { name: itemOne }).check();
|
||||
await toggleRequest;
|
||||
await expect(page.getByRole('checkbox', { name: itemOne })).toBeChecked();
|
||||
|
||||
await page.reload();
|
||||
|
||||
await expect(page.getByText(activityName, { exact: true })).toBeVisible();
|
||||
await expect(page.getByRole('checkbox', { name: itemOne })).toBeChecked();
|
||||
await expect(page.getByRole('checkbox', { name: itemTwo })).not.toBeChecked();
|
||||
|
||||
const listCard = page
|
||||
.getByText(listName, { exact: true })
|
||||
.locator('xpath=ancestor::div[contains(@class,"rounded-xl")]');
|
||||
const items = listCard.locator('label');
|
||||
await expect(items.nth(0)).toContainText(itemOne);
|
||||
await expect(items.nth(1)).toContainText(itemTwo);
|
||||
});
|
||||
Reference in New Issue
Block a user