55 lines
2.2 KiB
TypeScript
55 lines
2.2 KiB
TypeScript
|
|
import { test, expect } from "@playwright/test";
|
||
|
|
|
||
|
|
test.describe("Equipment Detail Page", () => {
|
||
|
|
test("should show error for non-existent ID", async ({ page }) => {
|
||
|
|
await page.goto("/mietkatalog/999999");
|
||
|
|
await expect(page.getByText("nicht gefunden")).toBeVisible();
|
||
|
|
});
|
||
|
|
|
||
|
|
test("should have link back to mietkatalog on error", async ({ page }) => {
|
||
|
|
await page.goto("/mietkatalog/999999");
|
||
|
|
const link = page.getByText("Zurück zum Mietkatalog");
|
||
|
|
await expect(link).toBeVisible();
|
||
|
|
});
|
||
|
|
|
||
|
|
test("should display breadcrumb navigation", async ({ page }) => {
|
||
|
|
await page.goto("/mietkatalog/1");
|
||
|
|
await expect(page.getByText("Home")).toBeVisible();
|
||
|
|
await expect(page.getByText("Mietkatalog")).toBeVisible();
|
||
|
|
});
|
||
|
|
|
||
|
|
test("should show equipment name as heading", async ({ page }) => {
|
||
|
|
await page.goto("/mietkatalog/1");
|
||
|
|
const name = page.getByTestId("equipment-name");
|
||
|
|
const errorState = page.getByText("nicht gefunden");
|
||
|
|
const hasContent = await name.isVisible().catch(() => false) || await errorState.isVisible().catch(() => false);
|
||
|
|
expect(hasContent).toBeTruthy();
|
||
|
|
});
|
||
|
|
|
||
|
|
test("should show specs section if equipment found", async ({ page }) => {
|
||
|
|
await page.goto("/mietkatalog/1");
|
||
|
|
const specs = page.getByTestId("equipment-specs");
|
||
|
|
const errorState = page.getByText("nicht gefunden");
|
||
|
|
const hasContent = await specs.isVisible().catch(() => false) || await errorState.isVisible().catch(() => false);
|
||
|
|
expect(hasContent).toBeTruthy();
|
||
|
|
});
|
||
|
|
|
||
|
|
test("should have Mietanfrage button", async ({ page }) => {
|
||
|
|
await page.goto("/mietkatalog/1");
|
||
|
|
const btn = page.getByTestId("add-to-cart-detail");
|
||
|
|
const errorState = page.getByText("nicht gefunden");
|
||
|
|
const hasContent = await btn.isVisible().catch(() => false) || await errorState.isVisible().catch(() => false);
|
||
|
|
expect(hasContent).toBeTruthy();
|
||
|
|
});
|
||
|
|
|
||
|
|
test("should navigate back to mietkatalog via breadcrumb", async ({ page }) => {
|
||
|
|
await page.goto("/mietkatalog/1");
|
||
|
|
const breadcrumbLink = page.locator('a[href="/mietkatalog"]').first();
|
||
|
|
if (await breadcrumbLink.isVisible()) {
|
||
|
|
await breadcrumbLink.click();
|
||
|
|
await page.waitForURL("/mietkatalog");
|
||
|
|
await expect(page).toHaveURL(/\/mietkatalog$/);
|
||
|
|
}
|
||
|
|
});
|
||
|
|
});
|