diff --git a/playwright/errors.spec.ts b/playwright/errors.spec.ts index e0821172..851e448d 100644 --- a/playwright/errors.spec.ts +++ b/playwright/errors.spec.ts @@ -78,16 +78,25 @@ test("Should show error screen if call creation is restricted", async ({ }) => { await page.goto("/"); - await page.getByTestId("home_callName").click(); - await page.getByTestId("home_callName").fill("HelloCall"); - await page.getByTestId("home_displayName").click(); - await page.getByTestId("home_displayName").fill("John Doe"); - await page.getByTestId("home_go").click(); + // We need the socket connection to fail, but this cannot be done by using the websocket route. + // Instead, we will trick the app by returning a bad URL for the SFU that will not be reachable an error out. + await page.route( + "**/matrix-rtc.m.localhost/livekit/jwt/sfu/get", + async (route) => + await route.fulfill({ + status: 200, + contentType: "application/json", + body: JSON.stringify({ + url: "wss://badurltotricktest/livekit/sfu", + jwt: "FAKE", + }), + }), + ); - // Simulate when the room was not created prior to the call. + // Then if the socket connection fails, livekit will try to validate the token! // Livekit will not auto_create anymore and will return a 404 error. await page.route( - "**/livekit/sfu/rtc/validate?*", + "**/badurltotricktest/livekit/sfu/rtc/validate?**", async (route) => await route.fulfill({ status: 404, @@ -96,9 +105,18 @@ test("Should show error screen if call creation is restricted", async ({ }), ); + await page.pause(); + + await page.getByTestId("home_callName").click(); + await page.getByTestId("home_callName").fill("HelloCall"); + await page.getByTestId("home_displayName").click(); + await page.getByTestId("home_displayName").fill("John Doe"); + await page.getByTestId("home_go").click(); + // Join the call await page.getByTestId("lobby_joinCall").click(); + await page.pause(); // Should fail await expect(page.getByText("Failed to create call")).toBeVisible(); await expect(