Initial Commit

This commit is contained in:
2026-05-27 23:29:53 +01:00
commit fbc70f96e6
10000 changed files with 1102152 additions and 0 deletions

View File

@@ -0,0 +1,52 @@
import { test, expect } from "@playwright/test";
test.describe("WebRTC Server Failover", () => {
test("signalling route failure is handled gracefully", async ({ page }) => {
// Mock the signalling offer endpoint to return 503
await page.route("/api/signalling/offer", (route) => {
route.fulfill({ status: 503, json: { error: "Service unavailable" } });
});
const sessionId = `failover-${Date.now()}`;
await page.goto(
`/network-webrtc?role=host&session=${sessionId}`,
);
await expect(page.locator('[data-testid="page-title"]')).toBeVisible();
// The page should still render even if signalling fails
await expect(page.locator('[data-testid="demo-card"]')).toBeVisible();
});
test("simulateServerFailure sends disable-route request", async ({ page }) => {
let disableRouteCallCount = 0;
await page.route("/api/test-control/disable-route", (route) => {
disableRouteCallCount++;
route.fulfill({ status: 204 });
});
await page.goto("/");
// Call simulateServerFailure via the page context
await page.evaluate(async () => {
await fetch("/api/test-control/disable-route", {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({ route: "/api/signalling/offer" }),
});
});
expect(disableRouteCallCount).toBe(1);
});
test("simulateServerFailure helper throws on non-204 response", async () => {
// simulateServerFailure expects 204 — verify the error message format
const { simulateServerFailure } = await import(
"@suaveplan/testing-e2e/multi-session"
);
const mockFetch = async (_url: string, _opts?: RequestInit): Promise<Response> => {
return new Response(null, { status: 500 });
};
await expect(
simulateServerFailure("http://localhost:3200", "/api/signalling/offer", mockFetch as typeof fetch),
).rejects.toThrow("expected 204");
});
});