Files
pleno-vue/tests/e2e/connectivityIssue.spec.ts
T
Jeppe Bundgaard 828e2fd312 Add test cases for internationalization, orders table rendering, and error handling:
- **Internationalization:** Added end-to-end test `i18n.smoke.spec.ts` to validate Danish locale translations. Ensured normalization and removed unexpected strings in the `da` locale file.
- **Orders Table:** Created unit test `orders-table.spec.js` to verify sparse data handling, invoice collection preloading, and rendering correctness.
- **Error Handling:** Enhanced connectivity issue UI (`ConnectivityIssue.vue`) with `data-testid` attributes for improved testability.
- **E2E Playwright Tests:** Updated and simplified e2e test utilities. Replaced `seedAuthenticatedState` with `primeMockSession` for session preparation. Added new tests for `/user/orders` and `/user/invoices` pages focusing on edge cases and maintaining structure consistency.
2026-04-13 12:44:06 +02:00

56 lines
2.3 KiB
TypeScript

import { test, expect } from "@playwright/test";
const PING_URL = /https:\/\/api\.truckwash\.io:4433\/ping(?:\?.*)?$/;
function installPingFailure(page, onPing) {
return page.route(PING_URL, async (route) => {
onPing();
await route.fulfill({
status: 500,
contentType: "application/json",
body: JSON.stringify({ message: "Connectivity check failed" }),
});
});
}
test.describe("Connectivity issue", () => {
test("renders the recovery state when ping fails", async ({ page }) => {
let pingCount = 0;
await installPingFailure(page, () => {
pingCount += 1;
});
await page.goto("/connectivity-issue");
await expect(page.getByTestId("connectivity-issue")).toBeVisible();
await expect(page.getByTestId("connectivity-icon")).toBeVisible();
await expect(page.getByTestId("connectivity-title")).toHaveText("Forbindelsesproblem");
await expect(page.getByTestId("connectivity-subtitle")).toContainText("internetforbindelse");
await expect(page.getByTestId("connectivity-subtitle")).toContainText("vores server");
await expect(page.getByTestId("connectivity-description")).toContainText("Vent venligst");
await expect(page.getByTestId("connectivity-description")).toContainText("serveren");
await expect(page.getByTestId("connectivity-retry-timer")).toContainText("Pr");
await expect(page.getByTestId("connectivity-retry-button")).toHaveText("Prøv igen");
await expect(page.getByTestId("connectivity-footer")).toContainText("kontakt venligst support");
await expect.poll(() => pingCount).toBeGreaterThan(0);
});
test("retry button triggers a fresh ping attempt and keeps the recovery screen visible", async ({ page }) => {
let pingCount = 0;
await installPingFailure(page, () => {
pingCount += 1;
});
await page.goto("/connectivity-issue");
await expect(page.getByTestId("connectivity-issue")).toBeVisible();
await expect.poll(() => pingCount).toBeGreaterThan(0);
const initialPingCount = pingCount;
await page.getByTestId("connectivity-retry-button").click();
await expect.poll(() => pingCount).toBeGreaterThan(initialPingCount);
await expect(page.getByTestId("connectivity-issue")).toBeVisible();
await expect(page.getByTestId("connectivity-title")).toHaveText("Forbindelsesproblem");
});
});