feat(webui): present chats as topics

This commit is contained in:
chengyongru
2026-07-24 10:29:13 +08:00
committed by chengyongru
parent 8bcab8885e
commit 6a9157f477
18 changed files with 233 additions and 233 deletions
+20 -20
View File
@@ -858,13 +858,13 @@ describe("App layout", () => {
).toBeInTheDocument(),
);
fireEvent.pointerDown(screen.getByLabelText("Chat actions for First chat"), {
fireEvent.pointerDown(screen.getByLabelText("Topic actions for First chat"), {
button: 0,
});
fireEvent.click(await screen.findByRole("menuitem", { name: "Delete" }));
await waitFor(() =>
expect(screen.getByText("Delete this chat?")).toBeInTheDocument(),
expect(screen.getByText("Delete this topic?")).toBeInTheDocument(),
);
fireEvent.click(screen.getByRole("button", { name: "Delete" }));
@@ -876,7 +876,7 @@ describe("App layout", () => {
within(sidebar).getByRole("button", { name: /^Second chat$/ }),
).toBeInTheDocument(),
);
expect(screen.queryByText("Delete this chat?")).not.toBeInTheDocument();
expect(screen.queryByText("Delete this topic?")).not.toBeInTheDocument();
expect(document.body.style.pointerEvents).not.toBe("none");
}, 15_000);
@@ -921,7 +921,7 @@ describe("App layout", () => {
).toBeInTheDocument(),
);
fireEvent.pointerDown(screen.getByLabelText(/First chat.*话操作/), {
fireEvent.pointerDown(screen.getByLabelText(/First chat.*话操作/), {
button: 0,
});
fireEvent.click(await screen.findByRole("menuitem", { name: "删除" }));
@@ -931,7 +931,7 @@ describe("App layout", () => {
);
expect(getSessionAutomationsSpy).toHaveBeenCalledWith("websocket:chat-a");
expect(
screen.getByText("这个话有关联的自动任务。删除话也会删除这些自动任务。"),
screen.getByText("这个话有关联的自动任务。删除话也会删除这些自动任务。"),
).toBeInTheDocument();
expect(
screen.queryByText("This chat has scheduled automations. Deleting it will also delete them."),
@@ -989,7 +989,7 @@ describe("App layout", () => {
);
fireEvent.pointerDown(
within(mobileSidebar).getByLabelText("Chat actions for Existing chat"),
within(mobileSidebar).getByLabelText("Topic actions for Existing chat"),
{ button: 0 },
);
@@ -1000,7 +1000,7 @@ describe("App layout", () => {
fireEvent.click(deleteItem);
await waitFor(() =>
expect(screen.getByText("Delete this chat?")).toBeInTheDocument(),
expect(screen.getByText("Delete this topic?")).toBeInTheDocument(),
);
}, 15_000);
@@ -1143,16 +1143,16 @@ describe("App layout", () => {
await waitFor(() => expect(connectSpy).toHaveBeenCalled());
const sidebar = screen.getByRole("navigation", { name: "Sidebar navigation" });
await waitFor(() =>
expect(within(sidebar).getByText("Chats")).toBeInTheDocument(),
expect(within(sidebar).getByText("Topics")).toBeInTheDocument(),
);
const group = within(sidebar).getByText("Chats").closest("section");
const group = within(sidebar).getByText("Topics").closest("section");
expect(group).toBeTruthy();
const labels = within(group as HTMLElement)
.getAllByRole("button")
.map((button) => button.textContent?.trim())
.filter(Boolean);
expect(labels).toEqual(["Alpha plan", "New chat", "Zulu work"]);
expect(labels).toEqual(["Alpha plan", "New topic", "Zulu work"]);
});
it("shows running and completed session indicators in the sidebar", async () => {
@@ -1969,7 +1969,7 @@ describe("App layout", () => {
await waitFor(() => expect(connectSpy).toHaveBeenCalled());
const sidebar = screen.getByRole("navigation", { name: "Sidebar navigation" });
fireEvent.click(within(sidebar).getByRole("button", { name: "New chat" }));
fireEvent.click(within(sidebar).getByRole("button", { name: "New topic" }));
await waitFor(() => expect(document.title).toBe("nanobot"));
fireEvent.click(within(sidebar).getByRole("button", { name: "Settings" }));
@@ -2009,7 +2009,7 @@ describe("App layout", () => {
const sidebar = screen.getByRole("navigation", { name: "Sidebar navigation" });
expect(within(sidebar).getByText("Q2 roadmap")).toBeInTheDocument();
expect(within(sidebar).getByText("Travel ideas")).toBeInTheDocument();
const newChatButton = within(sidebar).getByRole("button", { name: "New chat" });
const newChatButton = within(sidebar).getByRole("button", { name: "New topic" });
const searchButton = within(sidebar).getByRole("button", { name: "Search" });
expect(
newChatButton.compareDocumentPosition(searchButton) &
@@ -2139,10 +2139,10 @@ describe("App layout", () => {
await waitFor(() => expect(connectSpy).toHaveBeenCalled());
const sidebar = screen.getByRole("navigation", { name: "Sidebar navigation" });
const newChatButton = within(sidebar).getByRole("button", { name: "New chat" });
const newChatButton = within(sidebar).getByRole("button", { name: "New topic" });
expect(newChatButton).toHaveAttribute(
"title",
"New chat (Ctrl+Shift+O)",
"New topic (Ctrl+Shift+O)",
);
expect(newChatButton).toHaveAttribute(
"aria-keyshortcuts",
@@ -2157,9 +2157,9 @@ describe("App layout", () => {
await waitFor(() => expect(connectSpy).toHaveBeenCalled());
const sidebar = screen.getByRole("navigation", { name: "Sidebar navigation" });
expect(within(sidebar).getByRole("button", { name: "New chat" })).toHaveAttribute(
expect(within(sidebar).getByRole("button", { name: "New topic" })).toHaveAttribute(
"title",
"New chat (⌘⇧O)",
"New topic (⌘⇧O)",
);
});
@@ -2230,9 +2230,9 @@ describe("App layout", () => {
const sidebarAside = container.querySelector("aside.lg\\:block") as HTMLElement;
await waitFor(() => expect(sidebarAside.style.width).toBe("56px"));
expect(screen.queryByRole("button", { name: "Start a new chat" })).not.toBeInTheDocument();
expect(screen.queryByRole("button", { name: "Start a new topic" })).not.toBeInTheDocument();
const rail = screen.getByRole("navigation", { name: "Sidebar navigation" });
expect(within(rail).getByRole("button", { name: "New chat" })).toBeInTheDocument();
expect(within(rail).getByRole("button", { name: "New topic" })).toBeInTheDocument();
expect(within(rail).getByRole("button", { name: "Search" })).toBeInTheDocument();
expect(within(rail).queryByRole("button", { name: "View" })).not.toBeInTheDocument();
expect(within(rail).queryByText("Existing chat")).not.toBeInTheDocument();
@@ -2241,10 +2241,10 @@ describe("App layout", () => {
await waitFor(() => expect(sidebarAside.style.width).toBe("272px"));
const sidebar = screen.getByRole("navigation", { name: "Sidebar navigation" });
fireEvent.click(within(sidebar).getByRole("button", { name: "New chat" }));
fireEvent.click(within(sidebar).getByRole("button", { name: "New topic" }));
expect(createChatSpy).not.toHaveBeenCalled();
expect(screen.getByText(HERO_GREETING_PATTERN)).toBeInTheDocument();
expect(screen.queryByRole("button", { name: "Start a new chat" })).not.toBeInTheDocument();
expect(screen.queryByRole("button", { name: "Start a new topic" })).not.toBeInTheDocument();
expect(screen.getByRole("button", { name: "Toggle theme from header" })).toBeInTheDocument();
expect(within(sidebar).getByRole("button", { name: "Settings" })).toBeInTheDocument();