138 lines
4.7 KiB
TypeScript
138 lines
4.7 KiB
TypeScript
import { test, expect } from "@playwright/test";
|
|
|
|
test.describe("Error Boundaries", () => {
|
|
test.describe("404 - Page Not Found", () => {
|
|
test("should show 404 display for non-existent route", async ({ page }) => {
|
|
await page.goto("/this-route-does-not-exist-12345");
|
|
|
|
// Should show the NotFoundDisplay with muted styling
|
|
await expect(page.getByText("Page Not Found")).toBeVisible();
|
|
await expect(
|
|
page.getByText("The page you're looking for doesn't exist"),
|
|
).toBeVisible();
|
|
|
|
// Sidebar should still be visible and functional
|
|
await expect(page.getByText("Overview")).toBeVisible();
|
|
await expect(page.getByText("Inferences")).toBeVisible();
|
|
});
|
|
|
|
test("should allow navigation away from 404 via sidebar", async ({
|
|
page,
|
|
}) => {
|
|
await page.goto("/non-existent-page");
|
|
|
|
// Verify we're on the error page
|
|
await expect(page.getByText("Page Not Found")).toBeVisible();
|
|
|
|
// Click on Overview in sidebar
|
|
await page.getByRole("link", { name: "Overview" }).click();
|
|
|
|
// Should navigate to home page successfully
|
|
await expect(page.getByText("Ask a question")).toBeVisible();
|
|
await expect(page.getByText("Page Not Found")).not.toBeVisible();
|
|
});
|
|
});
|
|
|
|
test.describe("Resource Not Found (Layout Boundaries)", () => {
|
|
test("should show error for non-existent inference", async ({ page }) => {
|
|
// Navigate to an inference ID that doesn't exist
|
|
await page.goto(
|
|
"/observability/inferences/00000000-0000-0000-0000-000000000000",
|
|
);
|
|
|
|
// Should show an error (caught by layout boundary)
|
|
// PageErrorContent shows "Error {status}" format for resource 404s
|
|
await expect(
|
|
page.getByRole("heading", { name: "Error 404" }),
|
|
).toBeVisible();
|
|
|
|
// Sidebar should remain functional
|
|
await expect(
|
|
page.getByRole("link", { name: "Inferences" }).first(),
|
|
).toBeVisible();
|
|
});
|
|
|
|
test("should show error for non-existent episode", async ({ page }) => {
|
|
await page.goto(
|
|
"/observability/episodes/00000000-0000-0000-0000-000000000000",
|
|
);
|
|
|
|
// Should show an error (caught by layout boundary)
|
|
// PageErrorContent shows "Error {status}" format for resource 404s
|
|
await expect(
|
|
page.getByRole("heading", { name: "Error 404" }),
|
|
).toBeVisible();
|
|
|
|
// Sidebar should remain functional
|
|
await expect(
|
|
page.getByRole("link", { name: "Episodes" }).first(),
|
|
).toBeVisible();
|
|
});
|
|
|
|
test("should show error for non-existent dataset", async ({ page }) => {
|
|
await page.goto("/datasets/this-dataset-does-not-exist-xyz");
|
|
|
|
// Should show an error (caught by layout boundary)
|
|
await expect(page.getByRole("heading", { name: "Error" })).toBeVisible();
|
|
|
|
// Sidebar should remain functional
|
|
await expect(
|
|
page.getByRole("link", { name: "Datasets" }).first(),
|
|
).toBeVisible();
|
|
});
|
|
|
|
test("should show error for non-existent function", async ({ page }) => {
|
|
await page.goto("/observability/functions/this_function_does_not_exist");
|
|
|
|
// Should show an error (caught by layout boundary)
|
|
await expect(
|
|
page.getByRole("heading", { name: "Error 404" }),
|
|
).toBeVisible();
|
|
|
|
// Sidebar should remain functional
|
|
await expect(
|
|
page.getByRole("link", { name: "Functions" }).first(),
|
|
).toBeVisible();
|
|
});
|
|
});
|
|
|
|
test.describe("Navigation Recovery", () => {
|
|
test("should recover from error state when navigating to valid page", async ({
|
|
page,
|
|
}) => {
|
|
// Start on a valid page
|
|
await page.goto("/");
|
|
await expect(page.getByText("Ask a question")).toBeVisible();
|
|
|
|
// Navigate to error page
|
|
await page.goto("/invalid-route");
|
|
await expect(page.getByText("Page Not Found")).toBeVisible();
|
|
|
|
// Navigate back using browser back button
|
|
await page.goBack();
|
|
|
|
// Should be back on valid page without errors
|
|
await expect(page.getByText("Ask a question")).toBeVisible();
|
|
await expect(page.getByText("Page Not Found")).not.toBeVisible();
|
|
});
|
|
|
|
test("should handle multiple error navigations gracefully", async ({
|
|
page,
|
|
}) => {
|
|
// Navigate to multiple non-existent routes
|
|
await page.goto("/invalid-1");
|
|
await expect(page.getByText("Page Not Found")).toBeVisible();
|
|
|
|
await page.goto("/invalid-2");
|
|
await expect(page.getByText("Page Not Found")).toBeVisible();
|
|
|
|
await page.goto("/invalid-3");
|
|
await expect(page.getByText("Page Not Found")).toBeVisible();
|
|
|
|
// Should still be able to navigate to valid page
|
|
await page.goto("/");
|
|
await expect(page.getByText("Ask a question")).toBeVisible();
|
|
});
|
|
});
|
|
});
|