fix(chat): add history loading skeletons
Build Push and Deploy / docker-image (push) Successful in 1m2s
Build Push and Deploy / deploy-fallback-log (push) Has been skipped

This commit is contained in:
2026-06-10 17:51:28 +08:00
parent ab9e2a0420
commit 9c0a7a2864
6 changed files with 254 additions and 57 deletions
@@ -8,6 +8,56 @@ const renderWithTheme = (ui: React.ReactElement) =>
render(<ThemeProvider theme={createTheme()}>{ui}</ThemeProvider>);
describe("AgentHistoryPanel", () => {
it("shows skeleton rows while history sessions are loading", () => {
renderWithTheme(
<AgentHistoryPanel
sessions={[]}
isLoadingSessions
onNewSession={jest.fn()}
onRenameSession={jest.fn()}
onSelectSession={jest.fn()}
onDeleteSession={jest.fn()}
/>,
);
expect(screen.getByLabelText("正在加载历史会话")).toBeInTheDocument();
expect(screen.queryByText("暂无历史会话")).not.toBeInTheDocument();
});
it("disables the loading history session item", () => {
const onSelectSession = jest.fn();
const onRenameSession = jest.fn();
const onDeleteSession = jest.fn();
renderWithTheme(
<AgentHistoryPanel
sessions={[
{
id: "session-loading",
title: "正在加载的会话",
createdAt: Date.now(),
updatedAt: Date.now(),
},
]}
loadingSessionId="session-loading"
onNewSession={jest.fn()}
onRenameSession={onRenameSession}
onSelectSession={onSelectSession}
onDeleteSession={onDeleteSession}
/>,
);
expect(screen.queryByText("正在加载的会话")).not.toBeInTheDocument();
expect(screen.queryByRole("button", { name: "修改会话标题" })).not.toBeInTheDocument();
expect(screen.queryByRole("button", { name: "删除会话" })).not.toBeInTheDocument();
fireEvent.click(screen.getByLabelText("正在加载会话 正在加载的会话"));
expect(onSelectSession).not.toHaveBeenCalled();
expect(onRenameSession).not.toHaveBeenCalled();
expect(onDeleteSession).not.toHaveBeenCalled();
});
it("renames a history session from the list", () => {
const onRenameSession = jest.fn();