fix(organize): 展示智能体处理状态并刷新恢复结果
This commit is contained in:
1 parent
86351f20f3
commit
b306d27d08
9 files changed
+172
-12
No files matched your search
@@ -0,0 +1,43 @@
|
||||
import { QueryClient } from "@tanstack/react-query";
|
||||
import { afterEach, describe, expect, it, vi } from "vitest";
|
||||
|
||||
const state = vi.hoisted(() => ({ client: null as QueryClient | null, onSuccess: null as (() => void) | null }));
|
||||
vi.mock("@tanstack/react-query", async (original) => ({
|
||||
...(await original<typeof import("@tanstack/react-query")>()),
|
||||
useQueryClient: () => state.client,
|
||||
useMutation: (options: { onSuccess: () => void }) => {
|
||||
state.onSuccess = options.onSuccess;
|
||||
return {};
|
||||
},
|
||||
}));
|
||||
|
||||
import { useResolveDecision } from "./decisions.ts";
|
||||
|
||||
afterEach(() => {
|
||||
state.client?.clear();
|
||||
state.client = null;
|
||||
state.onSuccess = null;
|
||||
});
|
||||
|
||||
describe("事项处理后的业务状态刷新", () => {
|
||||
it("指定作品或确认映射后,记录、统计、关注汇总和规则预览都会重新读取", () => {
|
||||
const client = new QueryClient();
|
||||
state.client = client;
|
||||
const keys = [
|
||||
["decisions", "list"],
|
||||
["identity", "entity"],
|
||||
["records", "one", "record"],
|
||||
["records", "list", { attention: true }],
|
||||
["records", "stats", {}],
|
||||
["attention"],
|
||||
["episode-mapping", "words", "entity"],
|
||||
["episode-mapping", "preview", "entity", {}],
|
||||
];
|
||||
for (const key of keys) client.setQueryData(key, { previous: true });
|
||||
client.setQueryData(["settings"], { unrelated: true });
|
||||
useResolveDecision();
|
||||
state.onSuccess!();
|
||||
for (const key of keys) expect(client.getQueryState(key)?.isInvalidated, JSON.stringify(key)).toBe(true);
|
||||
expect(client.getQueryState(["settings"])?.isInvalidated).toBe(false);
|
||||
});
|
||||
});
|
||||
Reference in new issue
Block a user