Skip to content

Commit e2d4852

Browse files
apphelper: send task notification clicks to /serving/tasks (ChurchAppsSupport#1159) (#63)
1 parent 1529a72 commit e2d4852

3 files changed

Lines changed: 41 additions & 1 deletion

File tree

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@churchapps/apphelper": patch
3+
---
4+
5+
Task notifications now open `/serving/tasks/{id}` in B1Admin instead of the removed `/tasks/{id}` route, which showed Page Not Found.

‎apphelper/src/components/wrapper/Notifications.tsx‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ export const Notifications: React.FC<Props> = (props) => {
9292
let app = "";
9393
let path = "";
9494
switch (notification.contentType) {
95-
case "task": app = "b1admin"; path = "/tasks/" + notification.contentId; break;
95+
case "task": app = "b1admin"; path = "/serving/tasks/" + notification.contentId; break;
9696
case "assignment": app = "b1"; path = "/mobile/plans/" + notification.contentId; break;
9797
}
9898

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
import { describe, expect, it, vi } from "vitest";
2+
import React, { act } from "react";
3+
import { createRoot } from "react-dom/client";
4+
5+
vi.mock("@churchapps/helpers", async (importOriginal) => {
6+
const actual: any = await importOriginal();
7+
const notifications = [{ id: "n1", churchId: "c1", contentType: "task", contentId: "TSK1", message: "New task", timeSent: new Date(), isNew: true }];
8+
return { ...actual, ApiHelper: { ...actual.ApiHelper, get: vi.fn().mockResolvedValue(notifications) } };
9+
});
10+
11+
import { Notifications } from "../Notifications";
12+
13+
(globalThis as any).IS_REACT_ACT_ENVIRONMENT = true;
14+
15+
describe("Notifications click", () => {
16+
it("sends a task notification to the B1Admin serving task page", async () => {
17+
const onNavigate = vi.fn();
18+
const container = document.createElement("div");
19+
document.body.appendChild(container);
20+
const root = createRoot(container);
21+
const context: any = { userChurch: { church: { id: "c1", subDomain: "grace" } } };
22+
23+
await act(async () => {
24+
root.render(<Notifications appName="B1Admin" context={context} onNavigate={onNavigate} onUpdate={() => {}} />);
25+
});
26+
27+
const item = container.querySelector("#notification-item-n1") as HTMLElement;
28+
expect(item).not.toBeNull();
29+
await act(async () => { item.click(); });
30+
31+
expect(onNavigate).toHaveBeenCalledWith("/serving/tasks/TSK1");
32+
act(() => root.unmount());
33+
container.remove();
34+
});
35+
});

0 commit comments

Comments
 (0)