feat(faq): refine category icons and project faq flows
This commit is contained in:
@@ -3,8 +3,10 @@ import { beforeEach, describe, expect, it, vi } from "vitest";
|
||||
const apiPost = vi.fn();
|
||||
const apiPatch = vi.fn();
|
||||
const apiDelete = vi.fn();
|
||||
const apiGet = vi.fn();
|
||||
|
||||
vi.mock("./axios", () => ({
|
||||
apiGet,
|
||||
apiPost,
|
||||
apiPatch,
|
||||
apiDelete,
|
||||
@@ -54,4 +56,34 @@ describe("faqs item api", () => {
|
||||
params: { study_id: "study-1" },
|
||||
});
|
||||
});
|
||||
|
||||
it("passes study_id as a query parameter for item detail permission checks", async () => {
|
||||
const { fetchFaqItem, fetchFaqReplies, createFaqReply, deleteFaqReply, setFaqBestReply, setFaqStatus } = await import("./faqs");
|
||||
|
||||
fetchFaqItem("item-1", "study-1");
|
||||
fetchFaqReplies("item-1", "study-1");
|
||||
createFaqReply("item-1", "study-1", { content: "建议复查。" });
|
||||
deleteFaqReply("item-1", "reply-1", "study-1");
|
||||
setFaqBestReply("item-1", "study-1", { best_reply_id: "reply-1" });
|
||||
setFaqStatus("item-1", "study-1", { status: "RESOLVED" });
|
||||
|
||||
expect(apiGet).toHaveBeenCalledWith("/api/v1/faqs/items/item-1", {
|
||||
params: { study_id: "study-1" },
|
||||
});
|
||||
expect(apiGet).toHaveBeenCalledWith("/api/v1/faqs/items/item-1/replies", {
|
||||
params: { study_id: "study-1" },
|
||||
});
|
||||
expect(apiPost).toHaveBeenCalledWith("/api/v1/faqs/items/item-1/replies", { content: "建议复查。" }, {
|
||||
params: { study_id: "study-1" },
|
||||
});
|
||||
expect(apiDelete).toHaveBeenCalledWith("/api/v1/faqs/items/item-1/replies/reply-1", {
|
||||
params: { study_id: "study-1" },
|
||||
});
|
||||
expect(apiPatch).toHaveBeenCalledWith("/api/v1/faqs/items/item-1/best-reply", { best_reply_id: "reply-1" }, {
|
||||
params: { study_id: "study-1" },
|
||||
});
|
||||
expect(apiPatch).toHaveBeenCalledWith("/api/v1/faqs/items/item-1/status", { status: "RESOLVED" }, {
|
||||
params: { study_id: "study-1" },
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user