84 lines
3.3 KiB
TypeScript
84 lines
3.3 KiB
TypeScript
import { expect } from "@playwright/test";
|
|
import { test } from "../fixtures";
|
|
import { registerAndLogin, createList, addItem } from "../helpers";
|
|
|
|
test("a user can archive a list and it moves to the archive page", async ({ page }) => {
|
|
await registerAndLogin(page, "alice@example.com");
|
|
await createList(page, "Weekly shop");
|
|
|
|
// Archive from the list page.
|
|
await page.click('button:has-text("Archive")');
|
|
|
|
// Lands back on the lists page; the list is no longer shown.
|
|
await expect(page).toHaveURL(/\/lists/);
|
|
await expect(page.locator(".list-card").filter({ hasText: "Weekly shop" })).toHaveCount(0);
|
|
|
|
// The archived list is reachable from the archive page.
|
|
await page.goto("/archive");
|
|
await expect(page.locator(".list-card").filter({ hasText: "Weekly shop" })).toBeVisible();
|
|
});
|
|
|
|
test("the lists frame links to the archive page", async ({ page }) => {
|
|
await registerAndLogin(page, "alice@example.com");
|
|
await createList(page, "Weekly shop");
|
|
await page.goto("/lists");
|
|
|
|
await page.click('a.archive-link');
|
|
await expect(page).toHaveURL(/\/archive/);
|
|
});
|
|
|
|
test("an archived list is read-only", async ({ page }) => {
|
|
await registerAndLogin(page, "alice@example.com");
|
|
await createList(page, "Weekly shop");
|
|
await addItem(page, "Apple");
|
|
await page.click('button:has-text("Archive")');
|
|
|
|
// Open the archived list directly.
|
|
await page.goto("/archive");
|
|
await page.locator(".list-card").filter({ hasText: "Weekly shop" }).click();
|
|
await expect(page).toHaveURL(/\/lists\/\d+/);
|
|
|
|
// The item is still visible.
|
|
await expect(page.locator(".item-row").filter({ hasText: "Apple" })).toBeVisible();
|
|
|
|
// No mutation UI is present.
|
|
await expect(page.locator("#add-item-form")).toHaveCount(0);
|
|
await expect(page.locator(".item-actions-button")).toHaveCount(0);
|
|
await expect(page.locator(".check-form")).toHaveCount(0);
|
|
await expect(page.locator('button:has-text("+ Add meal")')).toHaveCount(0);
|
|
});
|
|
|
|
test("a user can restore an archived list and edit it again", async ({ page }) => {
|
|
await registerAndLogin(page, "alice@example.com");
|
|
await createList(page, "Weekly shop");
|
|
await addItem(page, "Apple");
|
|
await page.click('button:has-text("Archive")');
|
|
|
|
// Open the archived list and restore it.
|
|
await page.goto("/archive");
|
|
await page.locator(".list-card").filter({ hasText: "Weekly shop" }).click();
|
|
await page.click('button:has-text("Restore")');
|
|
|
|
// Back on the lists page, the list is active again.
|
|
await expect(page).toHaveURL(/\/lists/);
|
|
await expect(page.locator(".list-card").filter({ hasText: "Weekly shop" })).toBeVisible();
|
|
|
|
// The list is editable again.
|
|
await page.locator(".list-card").filter({ hasText: "Weekly shop" }).click();
|
|
await expect(page.locator("#add-item-form")).toBeVisible();
|
|
await addItem(page, "Banana");
|
|
await expect(page.locator(".item-row").filter({ hasText: "Banana" })).toBeVisible();
|
|
});
|
|
|
|
test("the archive page shows the list name and created date", async ({ page }) => {
|
|
await registerAndLogin(page, "alice@example.com");
|
|
await createList(page, "Weekly shop");
|
|
await page.click('button:has-text("Archive")');
|
|
|
|
await page.goto("/archive");
|
|
const card = page.locator(".list-card").filter({ hasText: "Weekly shop" });
|
|
await expect(card).toBeVisible();
|
|
// The card shows a created date (e.g. "Created 7 Aug 2026").
|
|
await expect(card.locator("small")).toContainText("Created");
|
|
});
|