20260718 重构 RPKI Explorer 查询界面
This commit is contained in:
@@ -1,83 +1,101 @@
|
||||
import { expect, test } from "@playwright/test";
|
||||
import { installMockApi } from "./mockApi";
|
||||
|
||||
const screenshotRoot = "../../../../specs/develop/20260623_2/m6_full_e2e";
|
||||
|
||||
function collectConsoleErrors(page: import("@playwright/test").Page) {
|
||||
const consoleErrors: string[] = [];
|
||||
page.on("console", (message) => {
|
||||
if (message.type() === "error") {
|
||||
const text = message.text();
|
||||
if (!text.includes("Failed to load resource")) {
|
||||
consoleErrors.push(text);
|
||||
}
|
||||
}
|
||||
});
|
||||
return consoleErrors;
|
||||
}
|
||||
|
||||
test("opens the RPKI Explorer overview", async ({ page }) => {
|
||||
const consoleErrors = collectConsoleErrors(page);
|
||||
|
||||
await page.goto("/");
|
||||
|
||||
await expect(page.getByRole("heading", { name: "RPKI Explorer" })).toBeVisible();
|
||||
await expect(page.getByRole("heading", { name: "Global RPKI validation health" })).toBeVisible();
|
||||
await expect(page.getByRole("button", { name: /Overview/i })).toBeVisible();
|
||||
await expect(page.getByLabel("Current run")).toContainText("latest indexed run");
|
||||
await expect(page.getByPlaceholder("Exact URI lookup planned in M2")).toBeDisabled();
|
||||
await expect(page.getByText("Top repositories by workload")).toBeVisible();
|
||||
await expect(page.getByText("Recent validation issues")).toBeVisible();
|
||||
await page.screenshot({ path: `${screenshotRoot}/rpki-explorer-overview.png`, fullPage: true });
|
||||
expect(consoleErrors).toEqual([]);
|
||||
test.beforeEach(async ({ page }) => {
|
||||
await installMockApi(page);
|
||||
});
|
||||
|
||||
test("collapses sidebar to icon-only navigation on desktop", async ({ page }) => {
|
||||
const consoleErrors = collectConsoleErrors(page);
|
||||
|
||||
test("shell renders navigation, brand and connection status", async ({ page }) => {
|
||||
await page.goto("/");
|
||||
await expect(page.getByRole("heading", { name: "RPKI Explorer" })).toBeVisible();
|
||||
await expect(page.getByText("RPKI Explorer")).toBeVisible();
|
||||
|
||||
await page.getByRole("button", { name: "Collapse navigation" }).click();
|
||||
await expect(page.locator(".app-shell")).toHaveClass(/sidebar-collapsed/);
|
||||
await expect(page.getByRole("button", { name: "Expand navigation" })).toBeVisible();
|
||||
await expect(page.locator(".brand-copy")).toHaveCSS("position", "absolute");
|
||||
await expect(page.locator(".nav-item").first().locator("span")).toHaveCSS("position", "absolute");
|
||||
await expect(page.getByRole("button", { name: "Repositories" })).toBeVisible();
|
||||
await page.screenshot({ path: `${screenshotRoot}/rpki-explorer-sidebar-collapsed.png`, fullPage: true });
|
||||
|
||||
await page.getByRole("button", { name: "Repositories" }).click();
|
||||
await expect(page.getByRole("heading", { name: "Repository / publication point / object browser" })).toBeVisible();
|
||||
|
||||
await page.getByRole("button", { name: "Expand navigation" }).click();
|
||||
await expect(page.locator(".app-shell")).not.toHaveClass(/sidebar-collapsed/);
|
||||
await expect(page.getByRole("heading", { name: "RPKI Explorer" })).toBeVisible();
|
||||
expect(consoleErrors).toEqual([]);
|
||||
});
|
||||
|
||||
test("opens truthful placeholders for unfinished navigation", async ({ page }) => {
|
||||
const consoleErrors = collectConsoleErrors(page);
|
||||
await page.goto("/");
|
||||
|
||||
for (const name of ["Publication Points", "Validation", "Exports", "Runs", "API"]) {
|
||||
await page.getByRole("button", { name }).click();
|
||||
await expect(page.locator("#coming-soon-heading")).toHaveText(name);
|
||||
await expect(page.getByText("Coming soon", { exact: true })).toBeVisible();
|
||||
await expect(page.getByRole("heading", { name: "Global RPKI validation health" })).toHaveCount(0);
|
||||
const nav = page.getByRole("navigation", { name: "Primary" });
|
||||
for (const label of [
|
||||
"Overview",
|
||||
"Repositories",
|
||||
"Publication Points",
|
||||
"Objects",
|
||||
"Validation",
|
||||
"Exports",
|
||||
"Runs",
|
||||
"API",
|
||||
]) {
|
||||
await expect(nav.getByRole("link", { name: label })).toBeVisible();
|
||||
}
|
||||
|
||||
await page.screenshot({ path: `${screenshotRoot}/rpki-explorer-coming-soon.png`, fullPage: true });
|
||||
expect(consoleErrors).toEqual([]);
|
||||
await expect(page.getByText("connected")).toBeVisible();
|
||||
});
|
||||
|
||||
test("objects page starts from explicit empty state", async ({ page }) => {
|
||||
const consoleErrors = collectConsoleErrors(page);
|
||||
test("every nav entry navigates to a real page (no dead controls)", async ({ page }) => {
|
||||
await page.goto("/");
|
||||
const nav = page.getByRole("navigation", { name: "Primary" });
|
||||
|
||||
const cases: { label: string; path: RegExp; heading: string | RegExp }[] = [
|
||||
{ label: "Repositories", path: /\/repositories$/, heading: "Repositories" },
|
||||
{ label: "Publication Points", path: /\/publication-points$/, heading: "Publication Points" },
|
||||
{ label: "Objects", path: /\/objects$/, heading: "Objects" },
|
||||
{ label: "Validation", path: /\/validation$/, heading: "Validation" },
|
||||
{ label: "Exports", path: /\/exports$/, heading: "Exports" },
|
||||
{ label: "Runs", path: /\/runs$/, heading: "Runs" },
|
||||
{ label: "API", path: /\/api$/, heading: "API" },
|
||||
];
|
||||
|
||||
for (const { label, path, heading } of cases) {
|
||||
await nav.getByRole("link", { name: label, exact: true }).click();
|
||||
await expect(page).toHaveURL(path);
|
||||
await expect(page.getByRole("heading", { name: heading }).first()).toBeVisible();
|
||||
}
|
||||
});
|
||||
|
||||
test("run selector pins the run via ?run= and pages use it", async ({ page }) => {
|
||||
const requests: string[] = [];
|
||||
page.on("request", (req) => {
|
||||
if (req.url().includes("/api/v1/runs/")) requests.push(req.url());
|
||||
});
|
||||
|
||||
await page.goto("/");
|
||||
await page.getByRole("button", { name: /Objects/i }).click();
|
||||
|
||||
await expect(page.getByRole("heading", { name: "Object object" })).toBeVisible();
|
||||
await expect(page.getByText("Search an exact URI or open an object from Repository Browser.")).toBeVisible();
|
||||
await expect(page.locator("body")).not.toContainText("sample PP");
|
||||
await page.screenshot({ path: `${screenshotRoot}/rpki-explorer-objects-empty.png`, fullPage: true });
|
||||
expect(consoleErrors).toEqual([]);
|
||||
const selector = page.getByLabel("Run");
|
||||
await expect(selector).toBeVisible();
|
||||
await selector.selectOption("run_0001");
|
||||
await expect(page).toHaveURL(/run=run_0001/);
|
||||
await expect.poll(() => requests.some((url) => url.includes("/runs/run_0001/"))).toBe(true);
|
||||
});
|
||||
|
||||
test("topbar search routes to the search page with the query", async ({ page }) => {
|
||||
await page.goto("/");
|
||||
const input = page.getByRole("searchbox", { name: "Global search" });
|
||||
await input.fill("repo-a.example");
|
||||
await input.press("Enter");
|
||||
await expect(page).toHaveURL(/\/search\?q=repo-a/);
|
||||
await expect(page.getByRole("heading", { name: "Search", exact: true })).toBeVisible();
|
||||
});
|
||||
|
||||
test("unknown routes render the 404 page", async ({ page }) => {
|
||||
await page.goto("/definitely-not-a-page");
|
||||
await expect(page.getByText("404")).toBeVisible();
|
||||
await page.getByRole("link", { name: "Back to Overview" }).click();
|
||||
await expect(page).toHaveURL(/\/$/);
|
||||
});
|
||||
|
||||
test("deep links restore page state after reload", async ({ page }) => {
|
||||
await page.goto("/objects?type=manifest");
|
||||
await expect(page).toHaveURL(/type=manifest/);
|
||||
await expect(page.getByLabel("Type")).toHaveValue("manifest");
|
||||
await page.reload();
|
||||
await expect(page.getByLabel("Type")).toHaveValue("manifest");
|
||||
});
|
||||
|
||||
test("runs page lists runs, pins a run and expands artifacts", async ({ page }) => {
|
||||
await page.goto("/runs");
|
||||
await expect(page.getByRole("cell", { name: "run_0002" })).toBeVisible();
|
||||
await expect(page.getByRole("cell", { name: "run_0001" })).toBeVisible();
|
||||
|
||||
// Expand artifacts for run_0001
|
||||
const row = page.getByRole("row", { name: /run_0001/ });
|
||||
await row.getByRole("button", { name: "Artifacts" }).click();
|
||||
await expect(page.getByText("/data/runs/run_0001/report.json")).toBeVisible();
|
||||
|
||||
// Pin run_0001 — navigates to overview with ?run=run_0001
|
||||
await row.getByRole("button", { name: "Use run" }).click();
|
||||
await expect(page).toHaveURL(/run=run_0001/);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user