mirror of
https://github.com/blakeblackshear/frigate.git
synced 2026-11-19 20:13:01 +03:00
Implement banner for stopping debug replay (#25022)
* Implement banner for stopping debug replay * Tweaks for review issue * Fix failures
This commit is contained in:
@@ -7,6 +7,10 @@
|
||||
*/
|
||||
|
||||
import { test, expect, type FrigateApp } from "../fixtures/frigate-test";
|
||||
import {
|
||||
activeSessionStatus,
|
||||
noSessionStatus,
|
||||
} from "../fixtures/mock-data/debug-replay";
|
||||
|
||||
// the selection is seeded around the playback position, so land near the
|
||||
// live edge
|
||||
@@ -183,6 +187,114 @@ test.describe("Debug Replay from History @high", () => {
|
||||
});
|
||||
});
|
||||
|
||||
// both layouts render the same form, so these run on desktop and mobile
|
||||
test.describe("Debug Replay form with an active session @high", () => {
|
||||
test("shows a banner that stops the running session", async ({
|
||||
frigateApp,
|
||||
}) => {
|
||||
let active = true;
|
||||
let stopCalled = false;
|
||||
|
||||
await frigateApp.installDefaults();
|
||||
await frigateApp.page.route("**/api/debug_replay/status", (route) =>
|
||||
route.fulfill({
|
||||
json: active
|
||||
? activeSessionStatus({ sourceCamera: "front_door" })
|
||||
: noSessionStatus(),
|
||||
}),
|
||||
);
|
||||
await frigateApp.page.route("**/api/debug_replay/stop", (route) => {
|
||||
if (route.request().method() === "POST") {
|
||||
stopCalled = true;
|
||||
active = false;
|
||||
}
|
||||
return route.fulfill({ json: { success: true } });
|
||||
});
|
||||
await openRecordingView(frigateApp);
|
||||
|
||||
const form = await openDebugReplayForm(frigateApp);
|
||||
const banner = form.getByRole("alert");
|
||||
const startButton = form.getByRole("button", { name: "Start Replay" });
|
||||
|
||||
await expect(banner).toContainText(
|
||||
"A debug replay session is already running for Front Door",
|
||||
{ timeout: 5_000 },
|
||||
);
|
||||
await expect(startButton).toBeDisabled();
|
||||
|
||||
await banner.getByRole("button", { name: "Stop Replay" }).click();
|
||||
|
||||
await expect.poll(() => stopCalled, { timeout: 5_000 }).toBe(true);
|
||||
await expect(banner).toBeHidden({ timeout: 5_000 });
|
||||
await expect(startButton).toBeEnabled();
|
||||
});
|
||||
|
||||
test.describe("after the session already ended", () => {
|
||||
// the stop endpoint answers 400 when no session is active, which
|
||||
// Chromium echoes to the console; the text carries no URL, so match the
|
||||
// 400 echo itself
|
||||
test.use({
|
||||
expectedErrors: [
|
||||
/^Failed to load resource: the server responded with a status of 400\b/,
|
||||
],
|
||||
});
|
||||
|
||||
test("stopping clears the banner", async ({ frigateApp }) => {
|
||||
let active = true;
|
||||
|
||||
await frigateApp.installDefaults();
|
||||
await frigateApp.page.route("**/api/debug_replay/status", (route) =>
|
||||
route.fulfill({
|
||||
json: active ? activeSessionStatus() : noSessionStatus(),
|
||||
}),
|
||||
);
|
||||
// the server tore the session down after the form loaded its status,
|
||||
// e.g. because startup failed
|
||||
await frigateApp.page.route("**/api/debug_replay/stop", (route) => {
|
||||
active = false;
|
||||
return route.fulfill({
|
||||
status: 400,
|
||||
json: { success: false, message: "No active replay session" },
|
||||
});
|
||||
});
|
||||
await openRecordingView(frigateApp);
|
||||
|
||||
const form = await openDebugReplayForm(frigateApp);
|
||||
const banner = form.getByRole("alert");
|
||||
|
||||
await expect(banner).toBeVisible({ timeout: 5_000 });
|
||||
await banner.getByRole("button", { name: "Stop Replay" }).click();
|
||||
|
||||
await expect(banner).toBeHidden({ timeout: 5_000 });
|
||||
await expect(
|
||||
form.getByRole("button", { name: "Start Replay" }),
|
||||
).toBeEnabled();
|
||||
await expect(
|
||||
frigateApp.page.getByText(/Failed to stop debug replay/),
|
||||
).toHaveCount(0);
|
||||
});
|
||||
});
|
||||
|
||||
test("shows no banner when nothing is running", async ({ frigateApp }) => {
|
||||
await frigateApp.installDefaults();
|
||||
await frigateApp.page.route("**/api/debug_replay/status", (route) =>
|
||||
route.fulfill({ json: noSessionStatus() }),
|
||||
);
|
||||
await openRecordingView(frigateApp);
|
||||
|
||||
const statusLoaded = frigateApp.page.waitForResponse(
|
||||
"**/api/debug_replay/status",
|
||||
);
|
||||
const form = await openDebugReplayForm(frigateApp);
|
||||
await statusLoaded;
|
||||
|
||||
await expect(
|
||||
form.getByRole("button", { name: "Start Replay" }),
|
||||
).toBeEnabled();
|
||||
await expect(form.getByRole("alert")).toHaveCount(0);
|
||||
});
|
||||
});
|
||||
|
||||
test.describe("Debug Replay from History — mobile @high @mobile", () => {
|
||||
test("a reselected range lands once and stays put", async ({
|
||||
frigateApp,
|
||||
|
||||
Reference in New Issue
Block a user