fix(workbench): keep active notices after reading
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
import { afterEach, describe, expect, it, vi } from "vitest";
|
||||
import {
|
||||
fetchOperationalTaskNotifications,
|
||||
parseOperationalTask,
|
||||
parseOperationalTaskNotification
|
||||
} from "./operational-task-client";
|
||||
@@ -105,4 +106,30 @@ describe("operational notification contract", () => {
|
||||
resolution_reason: "action_approved"
|
||||
}).lifecycle_status).toBe("resolved");
|
||||
});
|
||||
|
||||
it("requests the active inbox instead of hiding already read work", async () => {
|
||||
let request: Request | undefined;
|
||||
vi.stubGlobal("fetch", vi.fn(async (input, init) => {
|
||||
request = new Request(input, init);
|
||||
return new Response(JSON.stringify({
|
||||
items: [{
|
||||
...notification,
|
||||
lifecycle_status: "active",
|
||||
status: "read",
|
||||
version: 2,
|
||||
read_at: time,
|
||||
read_by: `principal:${id}`
|
||||
}],
|
||||
limit: 100,
|
||||
offset: 0,
|
||||
next_offset: null
|
||||
}), { status: 200 });
|
||||
}));
|
||||
|
||||
const items = await fetchOperationalTaskNotifications();
|
||||
|
||||
expect(items).toHaveLength(1);
|
||||
expect(items[0]?.status).toBe("read");
|
||||
expect(new URL(request!.url).searchParams.get("unread_only")).toBe("false");
|
||||
});
|
||||
});
|
||||
|
||||
@@ -397,18 +397,18 @@ export async function decideOperationalTaskAccess(taskId: string, accessRequestI
|
||||
|
||||
export async function fetchOperationalTaskNotifications(getAccessToken?: AccessTokenProvider, signal?: AbortSignal) {
|
||||
return notificationPageSchema.parse(await operationalTaskRequest(
|
||||
"/operational-task-notifications?unread_only=true&limit=100&offset=0",
|
||||
"/operational-task-notifications?unread_only=false&limit=100&offset=0",
|
||||
getAccessToken,
|
||||
{ signal }
|
||||
)).items;
|
||||
}
|
||||
|
||||
export async function acknowledgeOperationalTaskNotification(notificationId: string, version: number, requestId: string, getAccessToken?: AccessTokenProvider) {
|
||||
await operationalTaskRequest(
|
||||
return notificationSchema.parse(await operationalTaskRequest(
|
||||
`/operational-task-notifications/${encodeURIComponent(notificationId)}/acknowledge`,
|
||||
getAccessToken,
|
||||
{ method: "POST", body: JSON.stringify({ request_id: requestId, expected_version: version }) }
|
||||
);
|
||||
));
|
||||
}
|
||||
|
||||
export async function fetchOperationalTaskSchedules(getAccessToken?: AccessTokenProvider, signal?: AbortSignal) {
|
||||
|
||||
Reference in New Issue
Block a user