From 0806c23f6bf82ea1fc6ba792cf9b855fb87c972e Mon Sep 17 00:00:00 2001 From: Adam Shiervani Date: Tue, 31 Mar 2026 11:04:16 +0200 Subject: [PATCH] fix(test): add wakeDisplay and waitForVideoStream to video codec tests (#1385) Ensure display is active and video stream is flowing before asserting codec stats, preventing flaky failures on idle/sleeping displays. --- ui/e2e/video-codec.spec.ts | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/ui/e2e/video-codec.spec.ts b/ui/e2e/video-codec.spec.ts index ce9ff3eb..caad9edc 100644 --- a/ui/e2e/video-codec.spec.ts +++ b/ui/e2e/video-codec.spec.ts @@ -1,6 +1,12 @@ import { test, expect, type Page } from "@playwright/test"; -import { ensureLocalAuthMode, waitForWebRTCReady, callJsonRpc } from "./helpers"; +import { + ensureLocalAuthMode, + waitForWebRTCReady, + waitForVideoStream, + wakeDisplay, + callJsonRpc, +} from "./helpers"; /** * Wait for inbound video stats to report a non-empty codec mimeType. @@ -10,9 +16,7 @@ async function getActiveCodec(page: Page, timeout = 15000): Promise { await expect .poll( async () => { - const stats = await page.evaluate(() => - window.__kvmTestHooks?.getInboundVideoStats(), - ); + const stats = await page.evaluate(() => window.__kvmTestHooks?.getInboundVideoStats()); if (stats?.codecMimeType) codec = stats.codecMimeType; return codec; }, @@ -49,6 +53,8 @@ async function reconnect(page: Page): Promise { await page.waitForLoadState("networkidle"); await ensureLocalAuthMode(page, { mode: "noPassword" }); await waitForWebRTCReady(page); + await wakeDisplay(page); + await waitForVideoStream(page); } test.describe("Video codec negotiation", () => { @@ -59,6 +65,8 @@ test.describe("Video codec negotiation", () => { await page.waitForLoadState("networkidle"); await ensureLocalAuthMode(page, { mode: "noPassword" }); await waitForWebRTCReady(page); + await wakeDisplay(page); + await waitForVideoStream(page); const originalCodec = (await callJsonRpc(page, "getVideoCodecPreference")) as string; @@ -88,6 +96,8 @@ test.describe("Video codec negotiation", () => { await page.waitForLoadState("networkidle"); await ensureLocalAuthMode(page, { mode: "noPassword" }); await waitForWebRTCReady(page); + await wakeDisplay(page); + await waitForVideoStream(page); const originalCodec = (await callJsonRpc(page, "getVideoCodecPreference")) as string; @@ -118,6 +128,8 @@ test.describe("Video codec negotiation", () => { await page.waitForLoadState("networkidle"); await ensureLocalAuthMode(page, { mode: "noPassword" }); await waitForWebRTCReady(page); + await wakeDisplay(page); + await waitForVideoStream(page); const originalCodec = (await callJsonRpc(page, "getVideoCodecPreference")) as string;