mirror of
https://github.com/multica-ai/multica.git
synced 2026-06-17 03:38:32 +02:00
cleanupDeletedIssueCaches now also calls a new useRecentIssuesStore.forgetIssue(wsId, issueId) action so the persisted Recent Issues bucket no longer keeps deleted ids around. Both the delete mutation and the WS delete event flow through the same cleanup, so this covers self-delete and cross-client delete. Without this, Cmd+K fires a detail query for every recent id on open and returns a steady stream of 404s for issues the user has deleted (#3413). MUL-2765 Co-authored-by: J <j@multica.ai> Co-authored-by: multica-agent <github@multica.ai>
51 lines
1.7 KiB
TypeScript
51 lines
1.7 KiB
TypeScript
import { QueryClient } from "@tanstack/react-query";
|
|
import { beforeEach, describe, expect, it } from "vitest";
|
|
|
|
import { cleanupDeletedIssueCaches } from "./delete-cache";
|
|
import { issueKeys } from "./queries";
|
|
import { useRecentIssuesStore } from "./stores/recent-issues-store";
|
|
|
|
const WS_ID = "ws-a";
|
|
|
|
beforeEach(() => {
|
|
useRecentIssuesStore.setState({ byWorkspace: {} });
|
|
});
|
|
|
|
describe("cleanupDeletedIssueCaches — recent issues store", () => {
|
|
it("removes the deleted issue from the recent issues bucket", () => {
|
|
const { recordVisit } = useRecentIssuesStore.getState();
|
|
recordVisit(WS_ID, "issue-1");
|
|
recordVisit(WS_ID, "issue-2");
|
|
|
|
const qc = new QueryClient();
|
|
cleanupDeletedIssueCaches(qc, WS_ID, "issue-1");
|
|
|
|
const ids = useRecentIssuesStore
|
|
.getState()
|
|
.byWorkspace[WS_ID]?.map((e) => e.id);
|
|
expect(ids).toEqual(["issue-2"]);
|
|
});
|
|
|
|
it("does not touch the recent bucket of an unrelated workspace", () => {
|
|
const { recordVisit } = useRecentIssuesStore.getState();
|
|
recordVisit(WS_ID, "issue-1");
|
|
recordVisit("ws-b", "issue-1");
|
|
|
|
const qc = new QueryClient();
|
|
cleanupDeletedIssueCaches(qc, WS_ID, "issue-1");
|
|
|
|
const state = useRecentIssuesStore.getState().byWorkspace;
|
|
expect(state[WS_ID]).toBeUndefined();
|
|
expect(state["ws-b"]?.map((e) => e.id)).toEqual(["issue-1"]);
|
|
});
|
|
|
|
it("still removes the cached detail query for the deleted issue", () => {
|
|
const qc = new QueryClient();
|
|
qc.setQueryData(issueKeys.detail(WS_ID, "issue-1"), { id: "issue-1" });
|
|
|
|
cleanupDeletedIssueCaches(qc, WS_ID, "issue-1");
|
|
|
|
expect(qc.getQueryData(issueKeys.detail(WS_ID, "issue-1"))).toBeUndefined();
|
|
});
|
|
});
|