Improve Playwright/E2E testing setup (#5056)

Co-authored-by: Frank Elsinga <frank@elsinga.de>
This commit is contained in:
Shaun 2024-08-28 17:18:04 -04:00 committed by GitHub
parent 01210ce88d
commit 3d9bbe1a62
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
6 changed files with 168 additions and 46 deletions

View file

@ -0,0 +1,56 @@
import { test } from "@playwright/test";
import { getSqliteDatabaseExists, login, screenshot, takeSqliteSnapshot } from "../util-test";
test.describe("Uptime Kuma Setup", () => {
test.skip(() => getSqliteDatabaseExists(), "Must only run once per session");
/*
* Setup
*/
test("setup sqlite", async ({ page }, testInfo) => {
await page.goto("./");
await page.getByText("SQLite").click();
await page.getByRole("button", { name: "Next" }).click();
await screenshot(testInfo, page);
await page.waitForURL("/setup"); // ensures the server is ready to continue to the next test
await screenshot(testInfo, page);
});
test("setup admin", async ({ page }, testInfo) => {
await page.goto("./");
await page.getByPlaceholder("Username").click();
await page.getByPlaceholder("Username").fill("admin");
await page.getByPlaceholder("Username").press("Tab");
await page.getByPlaceholder("Password", { exact: true }).fill("admin123");
await page.getByPlaceholder("Password", { exact: true }).press("Tab");
await page.getByPlaceholder("Repeat Password").fill("admin123");
await page.getByRole("button", { name: "Create" }).click();
await screenshot(testInfo, page);
});
/*
* All other tests should be run after setup
*/
test("login", async ({ page }, testInfo) => {
await page.goto("./dashboard");
await login(page);
await screenshot(testInfo, page);
});
test("logout", async ({ page }, testInfo) => {
await page.goto("./dashboard");
await login(page);
await page.getByText("A", { exact: true }).click();
await page.getByRole("button", { name: "Log out" }).click();
await screenshot(testInfo, page);
});
test("take sqlite snapshot", async ({ page }, testInfo) => {
await takeSqliteSnapshot(page);
await screenshot(testInfo, page);
});
});