feat(FN-4739): complete Step 4 — add room clear API helper
Fusion-Task-Id: FN-4739 Fusion-Task-Lineage: fc120dfa-d1b2-4065-9595-d0bc6304d2af
This commit is contained in:
committed by
gsxdsm
parent
698e8c272a
commit
207b62a31d
@@ -3,6 +3,7 @@ import {
|
|||||||
addChatRoomMember,
|
addChatRoomMember,
|
||||||
createChatRoom,
|
createChatRoom,
|
||||||
deleteChatRoom,
|
deleteChatRoom,
|
||||||
|
clearChatRoomMessages,
|
||||||
deleteChatRoomMessage,
|
deleteChatRoomMessage,
|
||||||
fetchChatRoom,
|
fetchChatRoom,
|
||||||
fetchChatRoomMembers,
|
fetchChatRoomMembers,
|
||||||
@@ -76,6 +77,7 @@ describe("chat room legacy API client", () => {
|
|||||||
await fetchChatRoomMessages("room-1", { limit: 2, offset: 1, before: "2026-01-01", order: "desc" }, "proj-3");
|
await fetchChatRoomMessages("room-1", { limit: 2, offset: 1, before: "2026-01-01", order: "desc" }, "proj-3");
|
||||||
await postChatRoomMessage("room-1", { content: "hello", mentions: ["agent-x"] }, "proj-3");
|
await postChatRoomMessage("room-1", { content: "hello", mentions: ["agent-x"] }, "proj-3");
|
||||||
await deleteChatRoomMessage("room-1", "msg-1", "proj-3");
|
await deleteChatRoomMessage("room-1", "msg-1", "proj-3");
|
||||||
|
await clearChatRoomMessages("room-1", "proj-3");
|
||||||
|
|
||||||
const [listUrl] = fetchMock.mock.calls[0] as [string, RequestInit];
|
const [listUrl] = fetchMock.mock.calls[0] as [string, RequestInit];
|
||||||
expect(listUrl).toContain("/api/chat/rooms/room-1/messages?");
|
expect(listUrl).toContain("/api/chat/rooms/room-1/messages?");
|
||||||
@@ -91,6 +93,10 @@ describe("chat room legacy API client", () => {
|
|||||||
|
|
||||||
const [, delInit] = fetchMock.mock.calls[2] as [string, RequestInit];
|
const [, delInit] = fetchMock.mock.calls[2] as [string, RequestInit];
|
||||||
expect(delInit.method).toBe("DELETE");
|
expect(delInit.method).toBe("DELETE");
|
||||||
|
|
||||||
|
const [clearUrl, clearInit] = fetchMock.mock.calls[3] as [string, RequestInit];
|
||||||
|
expect(clearUrl).toContain("/api/chat/rooms/room-1/messages?projectId=proj-3");
|
||||||
|
expect(clearInit.method).toBe("DELETE");
|
||||||
});
|
});
|
||||||
|
|
||||||
it("omits order param when undefined", async () => {
|
it("omits order param when undefined", async () => {
|
||||||
|
|||||||
@@ -8525,6 +8525,16 @@ export function deleteChatRoomMessage(
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function clearChatRoomMessages(
|
||||||
|
id: string,
|
||||||
|
projectId?: string,
|
||||||
|
): Promise<{ success: boolean; deletedCount: number }> {
|
||||||
|
return api<{ success: boolean; deletedCount: number }>(
|
||||||
|
withProjectId(`/chat/rooms/${encodeURIComponent(id)}/messages`, projectId),
|
||||||
|
{ method: "DELETE" },
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Room POST /messages in FN-3808 is persist-only (201 JSON response).
|
* Room POST /messages in FN-3808 is persist-only (201 JSON response).
|
||||||
* Do not add streamChatRoomResponse until FN-3810 introduces AI invocation/streaming.
|
* Do not add streamChatRoomResponse until FN-3810 introduces AI invocation/streaming.
|
||||||
|
|||||||
Reference in New Issue
Block a user