mirror of
https://github.com/jetkvm/kvm.git
synced 2026-05-21 05:20:35 +00:00
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:
@@ -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;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user