test(e2e): run Playwright against an isolated Compose stand
This commit is contained in:
1 parent
7a5105acc7
commit
4cd7d060bd
23 files changed
+431
-41
No files matched your search
Vendored
+3
@@ -0,0 +1,3 @@
|
||||
// The Playwright config reads its settings from the environment. The project
|
||||
// does not depend on @types/node, so declare only the access the config uses.
|
||||
declare const process: { readonly env: Readonly<Record<string, string | undefined>> };
|
||||
@@ -0,0 +1,48 @@
|
||||
import { expect, test } from "@playwright/test";
|
||||
|
||||
// Technical smoke of the real stand: the built SPA behind Nginx, the Go API
|
||||
// behind the /api proxy, and the error routes of both. It needs no data and
|
||||
// checks no candidate or employer workflow.
|
||||
|
||||
test("start page renders the SPA in Russian", async ({ page }) => {
|
||||
await page.goto("/");
|
||||
|
||||
await expect(page.locator("html")).toHaveAttribute("lang", "ru");
|
||||
await expect(
|
||||
page.getByRole("heading", { level: 1, name: "Протокол подтвержденных навыков" }),
|
||||
).toBeVisible();
|
||||
});
|
||||
|
||||
test("status page shows a live API", async ({ page }) => {
|
||||
const healthz = page.waitForResponse(
|
||||
(response) => new URL(response.url()).pathname === "/api/v1/healthz",
|
||||
);
|
||||
await page.goto("/status");
|
||||
|
||||
await expect(page.getByRole("heading", { level: 1, name: "Технический статус" })).toBeVisible();
|
||||
expect((await healthz).status()).toBe(200);
|
||||
await expect(page.locator("dt", { hasText: "Статус" }).locator("+ dd")).toHaveText("ok");
|
||||
});
|
||||
|
||||
test("API healthz answers through the frontend proxy", async ({ request }) => {
|
||||
const response = await request.get("/api/v1/healthz");
|
||||
|
||||
expect(response.status()).toBe(200);
|
||||
expect(await response.json()).toEqual({ status: "ok" });
|
||||
});
|
||||
|
||||
test("unknown SPA route shows the not-found page", async ({ page }) => {
|
||||
await page.goto("/e2e-missing-page");
|
||||
|
||||
await expect(page.getByRole("heading", { level: 1, name: "Страница не найдена" })).toBeVisible();
|
||||
await expect(page.getByText("/e2e-missing-page")).toBeVisible();
|
||||
await expect(page.getByRole("link", { name: "На главную" })).toHaveAttribute("href", "/");
|
||||
});
|
||||
|
||||
test("unknown API route returns a not_found problem", async ({ request }) => {
|
||||
const response = await request.get("/api/v1/missing");
|
||||
|
||||
expect(response.status()).toBe(404);
|
||||
expect(response.headers()["content-type"]).toMatch(/^application\/problem\+json\b/);
|
||||
expect(await response.json()).toMatchObject({ status: 404, code: "not_found" });
|
||||
});
|
||||
@@ -0,0 +1,8 @@
|
||||
{
|
||||
"extends": "../tsconfig.json",
|
||||
"compilerOptions": {
|
||||
"lib": ["ES2022", "DOM"],
|
||||
"types": []
|
||||
},
|
||||
"include": ["./**/*.ts", "../playwright.config.ts"]
|
||||
}
|
||||
Reference in new issue
Block a user