mirror of
https://github.com/blakeblackshear/frigate.git
synced 2026-11-26 23:37:07 +03:00
encode notice ids in notice action urls
Notice ids went into the URL raw, so a detector on a repeated device like openvino:GPU#2 had everything after the # dropped as a fragment. The acknowledge, mute, and unhide requests 404'd and the buttons did nothing. The hooks now encode the id.
This commit is contained in:
@@ -57,6 +57,14 @@ const EVENT_NOTICE = {
|
||||
muted_at: null,
|
||||
};
|
||||
|
||||
// a repeated device gets a '#2' suffix, which a raw URL would cut off as a fragment
|
||||
const SUFFIXED_NOTICE = {
|
||||
...EVENT_NOTICE,
|
||||
id: "detector_stuck:openvino:GPU#2",
|
||||
scope: "openvino:GPU#2",
|
||||
params: { detector: "openvino:GPU#2" },
|
||||
};
|
||||
|
||||
test.describe("System — Health tab @medium", () => {
|
||||
test("Health is the default tab and lists notices by severity", async ({
|
||||
frigateApp,
|
||||
@@ -95,19 +103,20 @@ test.describe("System — Health tab @medium", () => {
|
||||
|
||||
for (const action of ["acknowledge", "mute"] as const) {
|
||||
test(`${action} posts and removes the row`, async ({ frigateApp }) => {
|
||||
const path = `/api/notices/${encodeURIComponent(SUFFIXED_NOTICE.id)}/${action}`;
|
||||
await frigateApp.installDefaults({
|
||||
config: RESTREAMED,
|
||||
stats: QUIET_STATS,
|
||||
notices: [EVENT_NOTICE],
|
||||
notices: [SUFFIXED_NOTICE],
|
||||
});
|
||||
|
||||
// the list shrinks after the POST so the refetch shows the row gone
|
||||
let hidden = false;
|
||||
await frigateApp.page.route("**/api/notices", (route) =>
|
||||
route.fulfill({ json: hidden ? [] : [EVENT_NOTICE] }),
|
||||
route.fulfill({ json: hidden ? [] : [SUFFIXED_NOTICE] }),
|
||||
);
|
||||
await frigateApp.page.route(
|
||||
`**/api/notices/detector_stuck/${action}`,
|
||||
(url) => url.pathname.endsWith(path),
|
||||
(route) => {
|
||||
hidden = true;
|
||||
return route.fulfill({ json: { success: true } });
|
||||
@@ -117,11 +126,10 @@ test.describe("System — Health tab @medium", () => {
|
||||
await frigateApp.goto("/system#health");
|
||||
const request = frigateApp.page.waitForRequest(
|
||||
(req) =>
|
||||
req.url().includes(`/api/notices/detector_stuck/${action}`) &&
|
||||
req.method() === "POST",
|
||||
new URL(req.url()).pathname.endsWith(path) && req.method() === "POST",
|
||||
);
|
||||
await frigateApp.page
|
||||
.getByTestId("health-problem-notice:detector_stuck")
|
||||
.getByTestId(`health-problem-notice:${SUFFIXED_NOTICE.id}`)
|
||||
.getByRole("button", {
|
||||
name: action === "mute" ? "Mute" : "Acknowledge",
|
||||
exact: true,
|
||||
@@ -264,8 +272,9 @@ test.describe("System — Health tab @medium", () => {
|
||||
url.searchParams.get("include_hidden") === "true",
|
||||
(route) => route.fulfill({ json: [MUTED_NOTICE] }),
|
||||
);
|
||||
const path = `/api/notices/${encodeURIComponent(MUTED_NOTICE.id)}/hidden`;
|
||||
await frigateApp.page.route(
|
||||
"**/api/notices/model_download_failed:yolo/model.onnx/hidden",
|
||||
(url) => url.pathname.endsWith(path),
|
||||
(route) => route.fulfill({ json: { success: true } }),
|
||||
);
|
||||
await frigateApp.goto("/system#health");
|
||||
@@ -276,11 +285,7 @@ test.describe("System — Health tab @medium", () => {
|
||||
|
||||
const request = frigateApp.page.waitForRequest(
|
||||
(req) =>
|
||||
req
|
||||
.url()
|
||||
.endsWith(
|
||||
"/api/notices/model_download_failed:yolo/model.onnx/hidden",
|
||||
) && req.method() === "DELETE",
|
||||
new URL(req.url()).pathname.endsWith(path) && req.method() === "DELETE",
|
||||
);
|
||||
await frigateApp.page
|
||||
.getByTestId(
|
||||
@@ -1281,10 +1286,14 @@ test.describe("System — Health notices sources @medium", () => {
|
||||
|
||||
// the list gains the mute after the POST so the refetch hides the row
|
||||
let muted = false;
|
||||
await frigateApp.page.route(`**/api/notices/${id}/mute`, (route) => {
|
||||
muted = true;
|
||||
return route.fulfill({ json: { success: true } });
|
||||
});
|
||||
const path = `/api/notices/${encodeURIComponent(id)}/mute`;
|
||||
await frigateApp.page.route(
|
||||
(url) => url.pathname.endsWith(path),
|
||||
(route) => {
|
||||
muted = true;
|
||||
return route.fulfill({ json: { success: true } });
|
||||
},
|
||||
);
|
||||
await frigateApp.page.route("**/api/notices/muted_checks", (route) =>
|
||||
route.fulfill({ json: muted ? [{ id, muted_at: NOW }] : [] }),
|
||||
);
|
||||
@@ -1297,8 +1306,7 @@ test.describe("System — Health notices sources @medium", () => {
|
||||
);
|
||||
const request = frigateApp.page.waitForRequest(
|
||||
(req) =>
|
||||
req.url().includes(`/api/notices/${id}/mute`) &&
|
||||
req.method() === "POST",
|
||||
new URL(req.url()).pathname.endsWith(path) && req.method() === "POST",
|
||||
);
|
||||
await row.getByRole("button", { name: "Mute", exact: true }).click();
|
||||
await request;
|
||||
|
||||
@@ -58,7 +58,7 @@ export function useHealthProblems(
|
||||
|
||||
const muteCheck = useCallback(
|
||||
async (id: string) => {
|
||||
await axios.post(`notices/${id}/mute`);
|
||||
await axios.post(`notices/${encodeURIComponent(id)}/mute`);
|
||||
mutateMutedChecks();
|
||||
},
|
||||
[mutateMutedChecks],
|
||||
@@ -66,7 +66,7 @@ export function useHealthProblems(
|
||||
|
||||
const unmuteCheck = useCallback(
|
||||
async (id: string) => {
|
||||
await axios.delete(`notices/${id}/hidden`);
|
||||
await axios.delete(`notices/${encodeURIComponent(id)}/hidden`);
|
||||
mutateMutedChecks();
|
||||
},
|
||||
[mutateMutedChecks],
|
||||
|
||||
@@ -60,15 +60,17 @@ export function useNotices(showHidden: boolean) {
|
||||
);
|
||||
|
||||
const acknowledge = useCallback(
|
||||
(id: string) => act(axios.post(`notices/${id}/acknowledge`)),
|
||||
(id: string) =>
|
||||
act(axios.post(`notices/${encodeURIComponent(id)}/acknowledge`)),
|
||||
[act],
|
||||
);
|
||||
const mute = useCallback(
|
||||
(id: string) => act(axios.post(`notices/${id}/mute`)),
|
||||
(id: string) => act(axios.post(`notices/${encodeURIComponent(id)}/mute`)),
|
||||
[act],
|
||||
);
|
||||
const unhide = useCallback(
|
||||
(id: string) => act(axios.delete(`notices/${id}/hidden`)),
|
||||
(id: string) =>
|
||||
act(axios.delete(`notices/${encodeURIComponent(id)}/hidden`)),
|
||||
[act],
|
||||
);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user