mirror of
https://github.com/blakeblackshear/frigate.git
synced 2026-10-25 16:04:41 +03:00
add viewer export test and remove stale non-admin case text
This commit is contained in:
@@ -1,4 +1,5 @@
|
|||||||
import { test, expect, type FrigateApp } from "../fixtures/frigate-test";
|
import { test, expect, type FrigateApp } from "../fixtures/frigate-test";
|
||||||
|
import { viewerProfile } from "../fixtures/mock-data/profile";
|
||||||
import {
|
import {
|
||||||
expectBodyInteractive,
|
expectBodyInteractive,
|
||||||
waitForBodyInteractive,
|
waitForBodyInteractive,
|
||||||
@@ -1040,6 +1041,34 @@ test.describe("Multi-Camera Export from History @high", () => {
|
|||||||
await expect.poll(() => capturedPayload).not.toBeNull();
|
await expect.poll(() => capturedPayload).not.toBeNull();
|
||||||
expect(typeof capturedPayload!.items[0].end_time).toBe("number");
|
expect(typeof capturedPayload!.items[0].end_time).toBe("number");
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test("viewers can export without a case", async ({ frigateApp }) => {
|
||||||
|
await frigateApp.installDefaults({ profile: viewerProfile() });
|
||||||
|
|
||||||
|
let capturedPayload: Record<string, unknown> | null = null;
|
||||||
|
await frigateApp.page.route("**/api/exports/batch", async (route) => {
|
||||||
|
capturedPayload = route.request().postDataJSON();
|
||||||
|
await route.fulfill({
|
||||||
|
status: 202,
|
||||||
|
json: { export_case_id: null, export_ids: [], results: [] },
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
const form = await openMultiCameraTab(frigateApp);
|
||||||
|
|
||||||
|
const firstCamera = form.locator("button[aria-pressed]").first();
|
||||||
|
await expect(firstCamera).toBeVisible({ timeout: 5_000 });
|
||||||
|
if ((await firstCamera.getAttribute("aria-pressed")) === "false") {
|
||||||
|
await firstCamera.click();
|
||||||
|
}
|
||||||
|
|
||||||
|
await expect(form.getByPlaceholder(/new case name/i)).toBeHidden();
|
||||||
|
await form.getByRole("button", { name: /^export \d+ cameras?$/i }).click();
|
||||||
|
|
||||||
|
await expect.poll(() => capturedPayload).not.toBeNull();
|
||||||
|
expect(capturedPayload).not.toHaveProperty("new_case_name");
|
||||||
|
expect(capturedPayload).not.toHaveProperty("export_case_id");
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
test.describe("Export Page - Active Job Progress @medium", () => {
|
test.describe("Export Page - Active Job Progress @medium", () => {
|
||||||
|
|||||||
@@ -66,7 +66,6 @@
|
|||||||
"newCaseNamePlaceholder": "New case name",
|
"newCaseNamePlaceholder": "New case name",
|
||||||
"newCaseDescriptionPlaceholder": "Case description",
|
"newCaseDescriptionPlaceholder": "Case description",
|
||||||
"label": "Case",
|
"label": "Case",
|
||||||
"nonAdminHelp": "A new case will be created for these exports.",
|
|
||||||
"placeholder": "Select a case",
|
"placeholder": "Select a case",
|
||||||
"nameRequired": "Case name is required"
|
"nameRequired": "Case name is required"
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -68,9 +68,7 @@ export default function MultiExportDialog({
|
|||||||
const isAdmin = useIsAdmin();
|
const isAdmin = useIsAdmin();
|
||||||
|
|
||||||
const { data: config } = useSWR<FrigateConfig>("config");
|
const { data: config } = useSWR<FrigateConfig>("config");
|
||||||
// Only admins can attach exports to an existing case (enforced server-side
|
// Only admins can assign exports to a case, so non-admins skip the case list
|
||||||
// by POST /exports/batch). Skip fetching the case list entirely for
|
|
||||||
// non-admins — they can only ever use the "Create new case" branch.
|
|
||||||
const { data: cases } = useSWR<ExportCase[]>(isAdmin ? "cases" : null);
|
const { data: cases } = useSWR<ExportCase[]>(isAdmin ? "cases" : null);
|
||||||
|
|
||||||
const [open, setOpen] = useState(false);
|
const [open, setOpen] = useState(false);
|
||||||
@@ -284,9 +282,6 @@ export default function MultiExportDialog({
|
|||||||
t,
|
t,
|
||||||
]);
|
]);
|
||||||
|
|
||||||
// New-case inputs: rendered below the Select when caseSelection === "new",
|
|
||||||
// or rendered standalone for non-admins (who never see the Select since
|
|
||||||
// they cannot attach to an existing case).
|
|
||||||
const newCaseInputs = (
|
const newCaseInputs = (
|
||||||
<div className="space-y-2 pt-1">
|
<div className="space-y-2 pt-1">
|
||||||
<Input
|
<Input
|
||||||
|
|||||||
Reference in New Issue
Block a user