strona-czynna/tests/admin.test.ts

40 lines
1.7 KiB
TypeScript

import { test, expect } from "./backend-fixture.js";
import { setTimeout as sleep } from "node:timers/promises";
test.beforeEach(async ({ page, backend }) => {
await page.goto(backend.url);
await page.getByRole("link", { name: "Go to Admin" }).click();
await page.getByPlaceholder("text").click();
await page.getByPlaceholder("text").fill("admin");
await page.getByPlaceholder("text").press("Tab");
await page.getByPlaceholder("password").fill("adminadmin");
await page.getByRole("button", { name: "Wyślij" }).click();
while (JSON.stringify(await page.context().cookies()) == "[]") {
await sleep(200);
}
});
test("Basic flow of adding a navbar link", async ({ page }) => {
await page.getByRole("link", { name: "Edit Navbar" }).click();
await page.getByRole("link", { name: "Create" }).click();
await page.getByLabel("label").click();
await page.getByLabel("label").fill("Homepage");
await page.getByLabel("href").fill("/");
await page.getByRole("button", { name: "Wyślij" }).click();
await page.getByRole("link", { name: "Homepage" }).click();
await expect(page).toHaveScreenshot();
});
test("Basic flow of creating a page", async ({ page, backend }) => {
await page.getByRole("link", { name: "Edit Pages" }).click();
await page.getByRole("link", { name: "Create" }).click();
await page.getByLabel("url").click();
await page.getByLabel("url").fill("/my-page/");
await page.getByLabel("title").fill("My Page");
await page.getByLabel("heading").fill("My Heading");
await page.getByLabel("description").fill("My Description");
await page.getByRole("button", { name: "Wyślij" }).click();
await page.goto(`${backend.url}/my-page/`);
await expect(page).toHaveScreenshot();
});