diff --git a/web/e2e/specs/settings/hwaccel-args.spec.ts b/web/e2e/specs/settings/hwaccel-args.spec.ts index e9e7f43507..884a0dfeed 100644 --- a/web/e2e/specs/settings/hwaccel-args.spec.ts +++ b/web/e2e/specs/settings/hwaccel-args.spec.ts @@ -10,6 +10,7 @@ import { readFileSync } from "node:fs"; import { resolve, dirname } from "node:path"; import { fileURLToPath } from "node:url"; +import type { Locator } from "@playwright/test"; import { test, expect, type FrigateApp } from "../../fixtures/frigate-test"; import { configFactory, @@ -586,14 +587,40 @@ const DEFAULT_MODE = "default"; const DEFAULTED_FIELDS = ["root_input_args", "root_output_args_record"]; const RECORD_SUB = "root_output_args_record_sub"; -const showOutputArgs = (app: FrigateApp) => - app.page.getByText("Output arguments", { exact: true }).first().click(); +// Sections also open on their own when a field inside them has a pending +// change, so a blind click can close one again. Clicks inside a section +// wait for its open animation to finish. +const expand = async (trigger: Locator) => { + await expect(async () => { + if ((await trigger.getAttribute("aria-expanded")) !== "true") { + await trigger.click(); + } + await expect(trigger).toHaveAttribute("aria-expanded", "true", { + timeout: 1_000, + }); + }).toPass(); + await trigger.page().waitForFunction(() => + document + .getAnimations() + .filter((animation) => + (animation as CSSAnimation).animationName?.startsWith("collapsible"), + ) + .every((animation) => animation.playState === "finished"), + ); +}; +const showOutputArgs = (app: FrigateApp) => + expand( + app.page + .locator("[aria-expanded]") + .filter({ has: app.page.getByText("Output arguments", { exact: true }) }), + ); + +// A sidebar switch lands after a delay, so wait for the FFmpeg form before +// opening its sections. const showGlobalArgs = async (app: FrigateApp) => { - await app.page - .getByRole("button", { name: /Advanced/ }) - .first() - .click(); + await expect(radio(app, "root_hwaccel_args", "auto")).toBeVisible(); + await expand(app.page.getByRole("button", { name: /Advanced/ }).first()); await showOutputArgs(app); }; @@ -604,6 +631,14 @@ const switchSection = (app: FrigateApp, name: string) => }) .click(); +// The sidebar commits a switch after a delay, and a second click before +// then cancels the first, so wait for the FFmpeg form to unmount. +const leaveFfmpegAndReturn = async (app: FrigateApp) => { + await switchSection(app, "Recording"); + await expect(radio(app, "root_hwaccel_args", "auto")).toHaveCount(0); + await switchSection(app, "FFmpeg"); +}; + test.describe("ffmpeg default args @medium", () => { test("global defaults show Default", async ({ frigateApp }) => { await openSettings(frigateApp, "/settings?page=globalFfmpeg"); @@ -671,8 +706,7 @@ test.describe("ffmpeg default args @medium", () => { await manualInput(frigateApp, field).fill("-x 1"); await radio(frigateApp, field, DEFAULT_MODE).click(); } - await switchSection(frigateApp, "Recording"); - await switchSection(frigateApp, "FFmpeg"); + await leaveFfmpegAndReturn(frigateApp); await showGlobalArgs(frigateApp); for (const field of DEFAULTED_FIELDS) { @@ -693,8 +727,7 @@ test.describe("ffmpeg default args @medium", () => { for (const field of DEFAULTED_FIELDS) { await radio(frigateApp, field, DEFAULT_MODE).click(); } - await switchSection(frigateApp, "Recording"); - await switchSection(frigateApp, "FFmpeg"); + await leaveFfmpegAndReturn(frigateApp); await showGlobalArgs(frigateApp); for (const field of DEFAULTED_FIELDS) { await expect(radio(frigateApp, field, DEFAULT_MODE)).toBeChecked(); @@ -748,24 +781,34 @@ test.describe("ffmpeg default args @medium", () => { const capture = await openSettings( frigateApp, "/settings?page=cameraFfmpeg&camera=front_door", - { ffmpeg: recordSub, cameras: { front_door: { ffmpeg: recordSub } } }, + { + ffmpeg: recordSub, + cameras: { + front_door: { ffmpeg: recordSub }, + backyard: { ffmpeg: { input_args: "-backyard 1" } }, + }, + }, ); + // Only Backyard has manual input args, which shows which camera's form + // is on screen. + const inputArgs = (mode: string) => + radio(frigateApp, "root_input_args", mode); const sameAsRecord = radio(frigateApp, RECORD_SUB, "inherit"); + await expect(inputArgs("inherit")).toBeChecked(); await showOutputArgs(frigateApp); await sameAsRecord.click(); await frigateApp.page .getByRole("button", { name: "Select a camera" }) .click(); await frigateApp.page.getByRole("switch", { name: "Backyard" }).click(); + await expect(inputArgs("manual")).toBeChecked(); await frigateApp.page .getByRole("button", { name: "Select a camera" }) .click(); await frigateApp.page.getByRole("switch", { name: "Front Door" }).click(); - await expect(radio(frigateApp, "root_input_args", "inherit")).toBeVisible(); - if (!(await sameAsRecord.isVisible())) { - await showOutputArgs(frigateApp); - } + await expect(inputArgs("inherit")).toBeChecked(); + await showOutputArgs(frigateApp); await expect(sameAsRecord).toBeChecked(); await save(frigateApp).click();