Add export case menu (#24997)
CI / AMD64 Build (push) Waiting to run
CI / AMD64 Smoke Test (push) Blocked by required conditions
CI / ARM Build (push) Waiting to run
CI / Jetson Jetpack 6 (push) Waiting to run
CI / AMD64 Extra Build (push) Blocked by required conditions
CI / ARM Extra Build (push) Blocked by required conditions
CI / Synaptics Build (push) Blocked by required conditions
CI / Assemble and push default build (push) Blocked by required conditions

* add kebab menu to export cases

* disable download while case exports are still encoding

* stop case menu clicks from opening the case

* check case download readiness against jobs on every camera
This commit is contained in:
Josh Hawkins
2026-11-17 08:57:33 -07:00
committed by GitHub
parent 640ae1058a
commit 97f2096534
5 changed files with 450 additions and 28 deletions
+286
View File
@@ -159,6 +159,292 @@ test.describe("Export Page - Overview @high", () => {
});
});
test.describe("Export Page - Case Card Menu @high", () => {
async function openCaseMenu(frigateApp: FrigateApp) {
await frigateApp.goto("/export");
await frigateApp.page
.getByRole("button", { name: "Case options" })
.first()
.click();
const menu = frigateApp.page.getByRole("menu");
await expect(menu).toBeVisible();
return menu;
}
test("menu offers share, download, edit, and delete", async ({
frigateApp,
}) => {
const menu = await openCaseMenu(frigateApp);
await expect(
menu.getByRole("menuitem", { name: "Share case" }),
).toBeVisible();
await expect(
menu.getByRole("menuitem", { name: "Download case" }),
).toHaveAttribute("href", /api\/cases\/case-001\/download$/);
await expect(
menu.getByRole("menuitem", { name: "Edit case" }),
).toBeVisible();
await expect(
menu.getByRole("menuitem", { name: "Delete case" }),
).toBeVisible();
});
test("edit opens a prefilled dialog without opening the case", async ({
frigateApp,
}) => {
const menu = await openCaseMenu(frigateApp);
await menu.getByRole("menuitem", { name: "Edit case" }).click();
const dialog = frigateApp.page
.getByRole("dialog")
.filter({ hasText: "Edit Case" });
await expect(dialog).toBeVisible();
await expect(dialog.locator("input")).toHaveValue(
"Package Theft Investigation",
);
await expect(
frigateApp.page.getByRole("heading", {
name: "Package Theft Investigation",
}),
).toBeHidden();
});
test("delete opens the confirmation dialog", async ({ frigateApp }) => {
const menu = await openCaseMenu(frigateApp);
await menu.getByRole("menuitem", { name: "Delete case" }).click();
const dialog = frigateApp.page
.getByRole("alertdialog")
.filter({ hasText: "Delete Case" });
await expect(dialog).toBeVisible();
await expect(dialog.getByText(/Package Theft Investigation/)).toBeVisible();
});
test("share sends a link that opens the case", async ({ frigateApp }) => {
await frigateApp.page.addInitScript(() => {
Object.defineProperty(navigator, "share", {
configurable: true,
value: (data: ShareData) => {
(window as unknown as { sharedUrl?: string }).sharedUrl = data.url;
return Promise.resolve();
},
});
});
const menu = await openCaseMenu(frigateApp);
await menu.getByRole("menuitem", { name: "Share case" }).click();
const sharedUrl = await frigateApp.page.evaluate(
() => (window as unknown as { sharedUrl?: string }).sharedUrl,
);
expect(sharedUrl).toMatch(/\/export\?caseId=case-001$/);
await frigateApp.goto("/export?caseId=case-001");
await expect(
frigateApp.page.getByRole("heading", {
name: "Package Theft Investigation",
}),
).toBeVisible();
});
test("deleting via the card menu leaves body interactive", async ({
frigateApp,
}) => {
const initialCases = [
{
id: "case-001",
name: "Package Theft Investigation",
description: "",
created_at: 1775407931.3863528,
updated_at: 1775483531.3863528,
},
];
let deleted = false;
await frigateApp.page.route(/\/api\/cases(?:$|\?|\/)/, async (route) => {
const method = route.request().method();
if (method === "DELETE") {
deleted = true;
return route.fulfill({ json: { success: true } });
}
if (method === "GET") {
return route.fulfill({ json: deleted ? [] : initialCases });
}
return route.fallback();
});
const menu = await openCaseMenu(frigateApp);
await menu.getByRole("menuitem", { name: "Delete case" }).click();
const dialog = frigateApp.page.getByRole("alertdialog");
await dialog.getByRole("button", { name: /^delete$/i }).click();
await expect(dialog).toBeHidden();
await expect(
frigateApp.page.getByText("Package Theft Investigation", { exact: true }),
).toBeHidden();
await waitForBodyInteractive(frigateApp.page, 5_000);
await expectBodyInteractive(frigateApp.page);
});
test("download is disabled while a case export is still encoding", async ({
frigateApp,
}) => {
await frigateApp.page.route("**/api/export**", (route) =>
route.fulfill({
json: [
{
id: "export-done",
camera: "front_door",
name: "Finished",
date: 1775490731,
video_path: "/exports/export-done.mp4",
thumb_path: "/exports/export-done-thumb.jpg",
in_progress: false,
export_case_id: "case-001",
},
{
id: "export-encoding",
camera: "backyard",
name: "Still Encoding",
date: 1775490732,
video_path: "/exports/export-encoding.mp4",
thumb_path: "",
in_progress: true,
export_case_id: "case-001",
},
],
}),
);
const menu = await openCaseMenu(frigateApp);
const download = menu.getByRole("menuitem", { name: "Download case" });
await expect(download).toHaveAttribute("data-disabled", "");
await expect(download).not.toHaveAttribute("href");
const box = await download.boundingBox();
expect(box).not.toBeNull();
await frigateApp.page.mouse.click(
box!.x + box!.width / 2,
box!.y + box!.height / 2,
);
await expect(
frigateApp.page.getByRole("heading", {
name: "Package Theft Investigation",
}),
).toBeHidden();
await frigateApp.page.keyboard.press("Escape");
await frigateApp.goto("/export?caseId=case-001");
await expect(
frigateApp.page.getByRole("button", { name: "Download" }),
).toBeDisabled();
});
test("download is disabled while a case export job is queued", async ({
frigateApp,
}) => {
await frigateApp.page.route("**/api/jobs/export", (route) =>
route.fulfill({
json: [
{
id: "job-queued",
job_type: "export",
status: "queued",
camera: "front_door",
name: "Queued Sample",
export_case_id: "case-001",
request_start_time: 1775407931,
request_end_time: 1775408531,
start_time: null,
end_time: null,
error_message: null,
results: null,
current_step: null,
progress_percent: 0,
},
],
}),
);
const menu = await openCaseMenu(frigateApp);
await expect(
menu.getByRole("menuitem", { name: "Download case" }),
).toHaveAttribute("data-disabled", "");
});
test("download stays disabled for a running job on a filtered-out camera", async ({
frigateApp,
}) => {
await frigateApp.page.route("**/api/export**", (route) =>
route.fulfill({
json: [
{
id: "export-front",
camera: "front_door",
name: "Front Finished",
date: 1775490731,
video_path: "/exports/export-front.mp4",
thumb_path: "",
in_progress: false,
export_case_id: "case-001",
},
],
}),
);
await frigateApp.page.route("**/api/jobs/export", (route) =>
route.fulfill({
json: [
{
id: "job-backyard",
job_type: "export",
status: "running",
camera: "backyard",
name: "Backyard Running",
export_case_id: "case-001",
request_start_time: 1775407931,
request_end_time: 1775408531,
start_time: 1775407932,
end_time: null,
error_message: null,
results: null,
current_step: "encoding",
progress_percent: 10,
},
],
}),
);
await frigateApp.goto("/export?cameras=front_door");
await frigateApp.page
.getByRole("button", { name: "Case options" })
.first()
.click();
await expect(
frigateApp.page.getByRole("menuitem", { name: "Download case" }),
).toHaveAttribute("data-disabled", "");
});
test("viewers only see share and download", async ({ frigateApp }) => {
await frigateApp.installDefaults({ profile: viewerProfile() });
const menu = await openCaseMenu(frigateApp);
await expect(
menu.getByRole("menuitem", { name: "Share case" }),
).toBeVisible();
await expect(menu.getByRole("menuitem", { name: "Edit case" })).toHaveCount(
0,
);
await expect(
menu.getByRole("menuitem", { name: "Delete case" }),
).toHaveCount(0);
});
});
test.describe("Export Page - Case Detail @high", () => {
test("opening a case shows its detail view and associated export", async ({
frigateApp,