优化历史会话排序逻辑,按首条消息时间排序
This commit is contained in:
@@ -33,8 +33,37 @@ describe("AgentHistoryPanel", () => {
|
||||
fireEvent.change(screen.getByPlaceholderText("请输入会话标题"), {
|
||||
target: { value: "新的会话标题" },
|
||||
});
|
||||
fireEvent.click(screen.getByLabelText("确认修改历史会话标题"));
|
||||
fireEvent.click(screen.getByLabelText("确认"));
|
||||
|
||||
expect(onRenameSession).toHaveBeenCalledWith("session-1", "新的会话标题");
|
||||
});
|
||||
|
||||
it("orders history by the first message time instead of the latest update time", () => {
|
||||
renderWithTheme(
|
||||
<AgentHistoryPanel
|
||||
sessions={[
|
||||
{
|
||||
id: "session-newer-update",
|
||||
title: "较新的更新",
|
||||
createdAt: new Date("2026-05-18T09:00:00+08:00").getTime(),
|
||||
updatedAt: new Date("2026-05-19T12:00:00+08:00").getTime(),
|
||||
},
|
||||
{
|
||||
id: "session-newer-first-message",
|
||||
title: "较新的首条消息",
|
||||
createdAt: new Date("2026-05-19T08:00:00+08:00").getTime(),
|
||||
updatedAt: new Date("2026-05-19T08:30:00+08:00").getTime(),
|
||||
},
|
||||
]}
|
||||
onNewSession={jest.fn()}
|
||||
onRenameSession={jest.fn()}
|
||||
onSelectSession={jest.fn()}
|
||||
onDeleteSession={jest.fn()}
|
||||
/>,
|
||||
);
|
||||
|
||||
const sessionTitles = screen.getAllByText(/较新的/).map((element) => element.textContent);
|
||||
|
||||
expect(sessionTitles).toEqual(["较新的首条消息", "较新的更新"]);
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user