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 }); await page.getByRole('checkbox', { name: itemOne }).check(); 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); });