fix(chat): add history loading skeletons
This commit is contained in:
@@ -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();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user