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.
This commit is contained in:
Adam Shiervani
2026-03-31 11:04:16 +02:00
committed by GitHub
parent 238ab07d43
commit 0806c23f6b
+16 -4
View File
@@ -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<string> {
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<void> {
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;