- campaign name survives a reload (autosave debounce respected) - export/import round trip: Save downloads dashboard.json with the current state, Clear blanks it via the confirm modal, Load restores it - specs take BASE_URL env override (default stays localhost:3000) - both new tests and the three smoke tests pass on chromium
58 lines
2.1 KiB
TypeScript
58 lines
2.1 KiB
TypeScript
import { test, expect, type Page } from "@playwright/test";
|
||
|
||
// Override with BASE_URL (e.g. when the dev server runs on another port).
|
||
const BASE = process.env.BASE_URL ?? "http://localhost:3000";
|
||
|
||
// Collects browser console errors and page errors for the duration of a test.
|
||
function trackErrors(page: Page): string[] {
|
||
const errors: string[] = [];
|
||
page.on("console", (msg) => {
|
||
if (msg.type() === "error") {
|
||
errors.push(msg.text());
|
||
}
|
||
});
|
||
page.on("pageerror", (err) => {
|
||
errors.push(String(err));
|
||
});
|
||
return errors;
|
||
}
|
||
|
||
test("home page: campaign name, version, nav", async ({ page }) => {
|
||
const errors = trackErrors(page);
|
||
await page.goto(`${BASE}/`);
|
||
|
||
await expect(page.locator("#campaign-name")).toHaveValue("В Поисках Дмитрия Шардалина");
|
||
await expect(page.locator(".version")).toContainText("aex");
|
||
await expect(page.locator(".main-nav a")).toHaveCount(3);
|
||
await expect(page.locator(".main-nav")).toContainText("Персонаж");
|
||
await expect(page.locator(".main-nav")).toContainText("Инвентарь");
|
||
await expect(page.locator(".main-nav")).toContainText("Информация");
|
||
|
||
expect(errors).toEqual([]);
|
||
});
|
||
|
||
test("inventories page: personal and common sections", async ({ page }) => {
|
||
const errors = trackErrors(page);
|
||
await page.goto(`${BASE}/inv`);
|
||
|
||
await expect(page.locator(".inventory-personal")).toHaveCount(1);
|
||
await expect(page.locator(".inventory-common")).toHaveCount(1);
|
||
// each section has one balance block with five currency inputs
|
||
await expect(page.locator(".inventory-personal .balance .numput")).toHaveCount(5);
|
||
await expect(page.locator(".inventory-common .balance .numput")).toHaveCount(5);
|
||
// and at least one item row each
|
||
await expect(page.locator(".inventory-personal .item").first()).toBeVisible();
|
||
await expect(page.locator(".inventory-common .item").first()).toBeVisible();
|
||
|
||
expect(errors).toEqual([]);
|
||
});
|
||
|
||
test("wiki page: stub renders", async ({ page }) => {
|
||
const errors = trackErrors(page);
|
||
await page.goto(`${BASE}/wiki`);
|
||
|
||
await expect(page.locator("body")).toContainText("books");
|
||
|
||
expect(errors).toEqual([]);
|
||
});
|