feat(webui): unify the Apps catalog (#6700)
* feat(webui): unify the Apps catalog * fix(webui): serve all channel branding locally * fix(webui): refine Apps navigation and sidebar
This commit is contained in:
1 parent
5997a714f2
commit
2b232c9133
89 files changed
+1576
-1024
No files matched your search
@@ -652,7 +652,11 @@ describe("App layout", () => {
|
||||
expect(main).not.toHaveAttribute("style");
|
||||
expect(screen.getByTestId("sidebar-brand-row")).toHaveClass("pt-3");
|
||||
expect(screen.getByTestId("sidebar-brand-mark")).not.toHaveClass("mt-5");
|
||||
expect(screen.getByRole("separator", { name: "Resize sidebar" })).toHaveAttribute("aria-valuenow", "272");
|
||||
const resizeHandle = screen.getByRole("separator", { name: "Resize sidebar" });
|
||||
expect(resizeHandle).toHaveAttribute("aria-valuenow", "56");
|
||||
fireEvent.keyDown(resizeHandle, { key: "Enter" });
|
||||
expect(resizeHandle).toHaveAttribute("aria-valuenow", "272");
|
||||
expect(main).not.toHaveAttribute("style");
|
||||
|
||||
const asideClassNames = Array.from(container.querySelectorAll("aside")).map(
|
||||
(el) => el.className,
|
||||
@@ -729,44 +733,67 @@ describe("App layout", () => {
|
||||
expect(screen.queryByRole("dialog", { name: "Choose model" })).not.toBeInTheDocument();
|
||||
});
|
||||
|
||||
it("places Automations after Skills in the main sidebar", async () => {
|
||||
it("opens the Apps catalog from the sidebar's bottom navigation", async () => {
|
||||
mockSessions = [{ key: "websocket:chat-a", channel: "websocket", chatId: "chat-a", createdAt: null, updatedAt: null, preview: "First chat" }];
|
||||
mockFetchRoutes({
|
||||
"/api/settings": baseSettingsPayload(),
|
||||
"/api/settings/cli-apps": { apps: [], installed_count: 0 },
|
||||
"/api/settings/mcp-presets": { presets: [], installed_count: 0 },
|
||||
"/api/remote-instances": { available: true, profiles: [] },
|
||||
});
|
||||
render(<App />);
|
||||
|
||||
await waitFor(() => expect(connectSpy).toHaveBeenCalled());
|
||||
const sidebar = screen.getByRole("navigation", { name: "Sidebar navigation" });
|
||||
const appsButton = within(sidebar).getByRole("button", { name: "Apps" });
|
||||
const skillsButton = within(sidebar).getByRole("button", { name: "Skills" });
|
||||
const automationsButton = within(sidebar).getByRole("button", { name: "Automations" });
|
||||
|
||||
expect(appsButton.compareDocumentPosition(skillsButton) & Node.DOCUMENT_POSITION_FOLLOWING)
|
||||
.toBeTruthy();
|
||||
expect(
|
||||
skillsButton.compareDocumentPosition(automationsButton) &
|
||||
Node.DOCUMENT_POSITION_FOLLOWING,
|
||||
).toBeTruthy();
|
||||
const footer = within(sidebar).getByTestId("sidebar-footer");
|
||||
await within(footer).findByRole("button", { name: "Switch host" });
|
||||
const buttons = within(footer).getAllByRole("button");
|
||||
expect(buttons.map((button) => button.getAttribute("aria-label")))
|
||||
.toEqual(["Apps", "Automations", "Settings", "Switch host"]);
|
||||
expect(buttons.slice(0, 3).map((button) => button.textContent)).toEqual(["Apps", "Automations", "Settings"]);
|
||||
fireEvent.click(within(footer).getByRole("button", { name: "Apps" }));
|
||||
await act(async () => { await import("@/components/settings/SettingsView"); });
|
||||
const sections = await screen.findByRole("group", { name: "Apps" });
|
||||
expect(within(sections).getAllByRole("button").map((button) => button.textContent)).toEqual(["Tools", "Skills", "Channels"]);
|
||||
expect(within(sections).getByRole("button", { name: "Tools" })).toHaveAttribute("aria-pressed", "true");
|
||||
});
|
||||
|
||||
it("opens Channels below Automations and supports its keyboard shortcut", async () => {
|
||||
it("keeps focus and independent searches when navigating among Apps sections", async () => {
|
||||
mockFetchRoutes({
|
||||
"/api/settings": baseSettingsPayload(),
|
||||
"/api/settings/cli-apps": { apps: [], installed_count: 0 },
|
||||
"/api/settings/mcp-presets": { presets: [], installed_count: 0 },
|
||||
"/api/settings/nanobot-features": { features: [], enabled_count: 0 },
|
||||
});
|
||||
render(<App />);
|
||||
await waitFor(() => expect(connectSpy).toHaveBeenCalled());
|
||||
const sidebar = screen.getByRole("navigation", { name: "Sidebar navigation" });
|
||||
const channels = within(sidebar).getByRole("button", { name: "Channels" });
|
||||
expect(within(sidebar).getByRole("button", { name: "Automations" })
|
||||
.compareDocumentPosition(channels) & Node.DOCUMENT_POSITION_FOLLOWING).toBeTruthy();
|
||||
fireEvent.click(channels);
|
||||
expect(await screen.findByRole("heading", { name: "Channels" })).toBeVisible();
|
||||
expect(window.location.hash).toBe("#/channels");
|
||||
expect(channels).toHaveAttribute("aria-current", "page");
|
||||
expect(document.title).toBe("Channels");
|
||||
fireEvent.click(within(sidebar).getByRole("button", { name: "New topic" }));
|
||||
await waitFor(() => expect(window.location.hash).toBe("#/new"));
|
||||
fireEvent.keyDown(window, { key: "$", code: "Digit4", ctrlKey: true, shiftKey: true });
|
||||
expect(await screen.findByRole("heading", { name: "Channels" })).toBeVisible();
|
||||
expect(window.location.hash).toBe("#/channels");
|
||||
const apps = within(sidebar).getByRole("button", { name: "Apps" });
|
||||
fireEvent.click(apps);
|
||||
await act(async () => { await import("@/components/settings/SettingsView"); });
|
||||
await screen.findByRole("button", { name: "Tools", pressed: true });
|
||||
const search = screen.getByLabelText("Search tools");
|
||||
fireEvent.change(search, { target: { value: "mcp" } });
|
||||
fireEvent.click(screen.getByRole("button", { name: "Channels" }));
|
||||
expect(await screen.findByRole("searchbox", { name: "Search channels" })).toBe(search);
|
||||
expect(search).toHaveValue("");
|
||||
expect(window.location.hash).toBe("#/apps?section=channels");
|
||||
expect(apps).toHaveAttribute("aria-current", "page");
|
||||
expect(document.title).toBe("Apps");
|
||||
fireEvent.change(search, { target: { value: "telegram" } });
|
||||
search.focus();
|
||||
|
||||
act(() => {
|
||||
window.history.replaceState(window.history.state, "", "#/apps?section=skills");
|
||||
window.dispatchEvent(new PopStateEvent("popstate"));
|
||||
});
|
||||
expect(await screen.findByLabelText("Search installed skills")).toBe(search);
|
||||
expect(search).toHaveFocus();
|
||||
expect(search).toHaveValue("");
|
||||
fireEvent.click(screen.getByRole("button", { name: "Channels" }));
|
||||
expect(await screen.findByRole("searchbox", { name: "Search channels" })).toHaveValue("telegram");
|
||||
fireEvent.click(screen.getByRole("button", { name: "Tools" }));
|
||||
expect(await screen.findByLabelText("Search tools")).toHaveValue("mcp");
|
||||
});
|
||||
|
||||
it("opens management in the main content area while keeping the standalone deep link", async () => {
|
||||
@@ -838,7 +865,7 @@ describe("App layout", () => {
|
||||
});
|
||||
render(<App />);
|
||||
await waitFor(() => expect(connectSpy).toHaveBeenCalled());
|
||||
await user.click(await screen.findByRole("button", { name: "Toggle sidebar" }));
|
||||
await user.click(await within(screen.getByRole("main")).findByRole("button", { name: "Toggle sidebar" }));
|
||||
const sheet = await screen.findByRole("dialog");
|
||||
fireEvent.pointerDown(await within(sheet).findByRole("button", { name: "Switch host" }), { button: 0, ctrlKey: false });
|
||||
fireEvent.click(await screen.findByRole("menuitem", { name: "Manage connections" }));
|
||||
@@ -869,7 +896,8 @@ describe("App layout", () => {
|
||||
"/api/remote-instances": { available: true, profiles: [profile] },
|
||||
});
|
||||
render(<App />);
|
||||
await user.click(await screen.findByRole("button", { name: "Toggle sidebar" }));
|
||||
await waitFor(() => expect(connectSpy).toHaveBeenCalled());
|
||||
await user.click(await within(screen.getByRole("main")).findByRole("button", { name: "Toggle sidebar" }));
|
||||
const sheet = await screen.findByRole("dialog");
|
||||
await user.click(await within(sheet).findByRole("button", { name: "Switch host" }));
|
||||
await user.click(await screen.findByRole("menuitem", { name: "Team server team" }));
|
||||
@@ -895,16 +923,26 @@ describe("App layout", () => {
|
||||
expect(window.location.hash).toBe("#/remote");
|
||||
});
|
||||
|
||||
it("highlights the blank new-topic destination immediately", async () => {
|
||||
it("keeps the compose action in place and hands off keyboard focus between sidebar toggles", async () => {
|
||||
const user = userEvent.setup();
|
||||
render(<App />);
|
||||
|
||||
await waitFor(() => expect(connectSpy).toHaveBeenCalled());
|
||||
const sidebar = screen.getByRole("navigation", { name: "Sidebar navigation" });
|
||||
const newTopicButton = within(sidebar).getByRole("button", { name: "New topic" });
|
||||
const sidebar = within(await screen.findByRole("navigation", { name: "Sidebar navigation" }));
|
||||
const compose = sidebar.getByRole("button", { name: "New topic" });
|
||||
expect(compose).not.toHaveAttribute("aria-current");
|
||||
expect(compose.querySelector("svg")).toHaveAttribute("data-product-icon", "compose");
|
||||
|
||||
expect(newTopicButton).toHaveAttribute("aria-current", "page");
|
||||
expect(newTopicButton).toHaveClass("transition-[width,padding,color,background-color]");
|
||||
expect(newTopicButton).toBeEnabled();
|
||||
const expand = sidebar.getByRole("button", { name: "Toggle sidebar", expanded: false });
|
||||
expand.focus();
|
||||
await user.keyboard("{Enter}");
|
||||
const collapse = sidebar.getByRole("button", { name: "Collapse sidebar", expanded: true });
|
||||
expect(collapse).toHaveFocus();
|
||||
expect(sidebar.getByRole("button", { name: "New topic" })).toBe(compose);
|
||||
expect(compose).toHaveTextContent("New topic");
|
||||
|
||||
await user.keyboard(" ");
|
||||
expect(expand).toHaveFocus();
|
||||
expect(expand).toHaveAttribute("aria-expanded", "false");
|
||||
});
|
||||
|
||||
it("keeps a just-created topic route while the session list catches up", async () => {
|
||||
@@ -1325,9 +1363,10 @@ describe("App layout", () => {
|
||||
|
||||
await waitFor(() => expect(connectSpy).toHaveBeenCalled());
|
||||
expect(
|
||||
await screen.findByRole("heading", { name: "Channels" }),
|
||||
await screen.findByRole("heading", { name: "Apps" }),
|
||||
).toBeInTheDocument();
|
||||
expect(within(screen.getByRole("navigation", { name: "Sidebar navigation" })).getByRole("button", { name: "Channels" })).toHaveAttribute("aria-current", "page");
|
||||
expect(screen.getByRole("button", { name: "Channels" })).toHaveAttribute("aria-pressed", "true");
|
||||
expect(within(screen.getByRole("navigation", { name: "Sidebar navigation" })).getByRole("button", { name: "Apps" })).toHaveAttribute("aria-current", "page");
|
||||
expect(window.location.hash).toBe("#/settings?section=channels");
|
||||
});
|
||||
|
||||
@@ -1497,11 +1536,10 @@ describe("App layout", () => {
|
||||
|
||||
await waitFor(() => expect(connectSpy).toHaveBeenCalled());
|
||||
const sidebar = screen.getByRole("navigation", { name: "Sidebar navigation" });
|
||||
const skillsButton = within(sidebar).getByRole("button", { name: "Skills" });
|
||||
fireEvent.click(within(sidebar).getByRole("button", { name: "Apps" }));
|
||||
fireEvent.click(await screen.findByRole("button", { name: "Skills" }));
|
||||
|
||||
fireEvent.click(skillsButton);
|
||||
|
||||
expect(await screen.findByRole("heading", { name: "Skills" })).toBeInTheDocument();
|
||||
expect(await screen.findByRole("button", { name: "Skills" })).toHaveAttribute("aria-pressed", "true");
|
||||
expect(screen.getByRole("textbox", { name: "Search installed skills" })).toBeInTheDocument();
|
||||
expect(screen.getByRole("heading", { name: "Custom" })).toBeInTheDocument();
|
||||
expect(screen.getByRole("heading", { name: "Built-in" })).toBeInTheDocument();
|
||||
@@ -1510,17 +1548,18 @@ describe("App layout", () => {
|
||||
expect(screen.getByText("Needs setup")).toBeInTheDocument();
|
||||
expect(screen.getByRole("navigation", { name: "Sidebar navigation" })).toBeInTheDocument();
|
||||
expect(screen.queryByRole("navigation", { name: "Settings sections" })).not.toBeInTheDocument();
|
||||
expect(within(sidebar).getByRole("button", { name: "Skills" })).toHaveAttribute(
|
||||
expect(within(sidebar).getByRole("button", { name: "Apps" })).toHaveAttribute(
|
||||
"aria-current",
|
||||
"page",
|
||||
);
|
||||
expect(document.title).toBe("Skills");
|
||||
expect(document.title).toBe("Apps");
|
||||
|
||||
fireEvent.click(screen.getByRole("button", { name: "Back to chat" }));
|
||||
expect(await screen.findByTestId("thread-welcome-mark")).toBeInTheDocument();
|
||||
|
||||
fireEvent.click(within(sidebar).getByRole("button", { name: "Skills" }));
|
||||
expect(await screen.findByRole("heading", { name: "Skills" })).toBeInTheDocument();
|
||||
fireEvent.click(within(sidebar).getByRole("button", { name: "Apps" }));
|
||||
fireEvent.click(await screen.findByRole("button", { name: "Skills" }));
|
||||
expect(await screen.findByRole("button", { name: "Skills" })).toHaveAttribute("aria-pressed", "true");
|
||||
|
||||
fireEvent.click(screen.getByRole("button", { name: "Open details for github" }));
|
||||
|
||||
@@ -1592,7 +1631,8 @@ describe("App layout", () => {
|
||||
|
||||
await waitFor(() => expect(connectSpy).toHaveBeenCalled());
|
||||
const sidebar = screen.getByRole("navigation", { name: "Sidebar navigation" });
|
||||
fireEvent.click(within(sidebar).getByRole("button", { name: "Skills" }));
|
||||
fireEvent.click(within(sidebar).getByRole("button", { name: "Apps" }));
|
||||
fireEvent.click(await screen.findByRole("button", { name: "Skills" }));
|
||||
fireEvent.click(
|
||||
await screen.findByRole("button", { name: "Open details for custom-skill" }),
|
||||
);
|
||||
@@ -1724,10 +1764,13 @@ describe("App layout", () => {
|
||||
|
||||
await waitFor(() => expect(connectSpy).toHaveBeenCalled());
|
||||
const sidebar = screen.getByRole("navigation", { name: "Sidebar navigation" });
|
||||
fireEvent.click(within(sidebar).getByRole("button", { name: "Skills" }));
|
||||
const discoverTab = await screen.findByRole("tab", { name: "Discover" });
|
||||
expect(discoverTab.querySelector("svg")).toBeNull();
|
||||
fireEvent.click(discoverTab);
|
||||
fireEvent.click(within(sidebar).getByRole("button", { name: "Apps" }));
|
||||
fireEvent.click(await screen.findByRole("button", { name: "Skills" }));
|
||||
const selectView = async (view: string) => {
|
||||
const views = await screen.findByRole("radiogroup", { name: "Skills views" });
|
||||
await userEvent.click(within(views).getByRole("radio", { name: view }));
|
||||
};
|
||||
await selectView("Marketplace");
|
||||
expect(
|
||||
await screen.findByRole("heading", { name: "Popular skills" }),
|
||||
).toBeInTheDocument();
|
||||
@@ -1736,11 +1779,12 @@ describe("App layout", () => {
|
||||
expect(screen.getByRole("link", { name: "Open ima-skills on SkillHub" })).toHaveAttribute(
|
||||
"href", "https://skillhub.cn/skills/tencent-adm/ima-skills",
|
||||
);
|
||||
expect(screen.getAllByText("SkillHub")).toHaveLength(2);
|
||||
expect(screen.getAllByText("skills.sh")).toHaveLength(2);
|
||||
expect(screen.getByRole("link", { name: "Open SkillHub" })).toBeInTheDocument();
|
||||
expect(screen.getByRole("link", { name: "Open skills.sh" })).toBeInTheDocument();
|
||||
expect(screen.getByText(/14,481 installs \/ 24h/)).toBeInTheDocument();
|
||||
expect(screen.queryByText(/11,831 installs/)).not.toBeInTheDocument();
|
||||
fireEvent.click(screen.getByRole("tab", { name: "SkillHub" }));
|
||||
const sources = within(screen.getByRole("radiogroup", { name: "Skill source" }));
|
||||
fireEvent.click(sources.getByRole("radio", { name: "SkillHub" }));
|
||||
expect(screen.getByText("ima-skills")).toBeInTheDocument();
|
||||
expect(screen.queryByText("find-skills")).not.toBeInTheDocument();
|
||||
expect(
|
||||
@@ -1749,7 +1793,7 @@ describe("App layout", () => {
|
||||
String(input) === "/api/webui/skills/trending?provider=skillhub",
|
||||
),
|
||||
).toBe(false);
|
||||
fireEvent.click(screen.getByRole("tab", { name: "All" }));
|
||||
fireEvent.click(sources.getByRole("radio", { name: "All" }));
|
||||
expect(screen.getByText("find-skills")).toBeInTheDocument();
|
||||
expect(screen.getByText("ima-skills")).toBeInTheDocument();
|
||||
expect(
|
||||
@@ -1780,8 +1824,10 @@ describe("App layout", () => {
|
||||
150_000,
|
||||
);
|
||||
});
|
||||
fireEvent.click(screen.getByRole("tab", { name: "Installed" }));
|
||||
fireEvent.click(screen.getByRole("tab", { name: "Discover" }));
|
||||
await selectView("Installed");
|
||||
await selectView("Marketplace");
|
||||
expect(screen.getByRole("textbox", { name: "Search skills" })).toHaveValue("React");
|
||||
fireEvent.change(screen.getByRole("textbox", { name: "Search skills" }), { target: { value: "" } });
|
||||
expect(
|
||||
await screen.findByRole("button", { name: "Install find-skills" }),
|
||||
).toBeDisabled();
|
||||
@@ -1794,7 +1840,7 @@ describe("App layout", () => {
|
||||
await waitFor(() => {
|
||||
expect(screen.getByRole("button", { name: "Install find-skills" })).toBeEnabled();
|
||||
});
|
||||
fireEvent.click(screen.getByRole("tab", { name: "Installed" }));
|
||||
await selectView("Installed");
|
||||
expect(screen.getByText("react-testing")).toBeInTheDocument();
|
||||
});
|
||||
|
||||
@@ -2184,9 +2230,9 @@ describe("App layout", () => {
|
||||
|
||||
await waitFor(() => expect(connectSpy).toHaveBeenCalled());
|
||||
const sidebar = screen.getByRole("navigation", { name: "侧边栏导航" });
|
||||
fireEvent.click(within(sidebar).getByRole("button", { name: "自动任务" }));
|
||||
fireEvent.click(within(sidebar).getByRole("button", { name: "任务" }));
|
||||
|
||||
const heading = await screen.findByRole("heading", { name: "自动任务" });
|
||||
const heading = await screen.findByRole("heading", { name: "任务" });
|
||||
expect(heading).toBeInTheDocument();
|
||||
const automationsMain = heading.closest("main");
|
||||
expect(automationsMain).not.toBeNull();
|
||||
@@ -2204,10 +2250,29 @@ describe("App layout", () => {
|
||||
expect(screen.queryByText("近期无问题")).not.toBeInTheDocument();
|
||||
expect(screen.queryByText("Workspace automations")).not.toBeInTheDocument();
|
||||
expect(screen.queryByRole("button", { name: "刷新" })).not.toBeInTheDocument();
|
||||
expect(document.title).toBe("自动任务");
|
||||
expect(document.title).toBe("任务");
|
||||
});
|
||||
|
||||
it("collapses an empty sidebar, then restores the saved width when the first chat is created", async () => {
|
||||
localStorage.setItem("nanobot-webui.sidebar", "1");
|
||||
localStorage.setItem("nanobot-webui.sidebar.width", "320");
|
||||
render(<App />);
|
||||
|
||||
const sidebar = await screen.findByTestId("host-sidebar-flow");
|
||||
expect(sidebar).toHaveStyle({ width: "56px" });
|
||||
fireEvent.click(within(sidebar).getByRole("button", { name: "Toggle sidebar" }));
|
||||
expect(sidebar).toHaveStyle({ width: "320px" });
|
||||
fireEvent.keyDown(within(sidebar).getByRole("separator"), { key: "Enter" });
|
||||
expect(sidebar).toHaveStyle({ width: "56px" });
|
||||
|
||||
const composer = await screen.findByLabelText("Message input");
|
||||
fireEvent.change(composer, { target: { value: "First message" } });
|
||||
fireEvent.click(screen.getByRole("button", { name: "Send message" }));
|
||||
await waitFor(() => expect(sidebar).toHaveStyle({ width: "320px" }));
|
||||
});
|
||||
|
||||
it("resizes the sidebar, collapses at the drag threshold and restores its saved width", async () => {
|
||||
mockSessions = [{ key: "websocket:chat-a", channel: "websocket", chatId: "chat-a", createdAt: null, updatedAt: null, preview: "First chat" }];
|
||||
const view = render(<App />);
|
||||
await waitFor(() => expect(connectSpy).toHaveBeenCalled());
|
||||
const handle = screen.getByRole("separator", { name: "Resize sidebar" });
|
||||
@@ -2251,7 +2316,7 @@ describe("App layout", () => {
|
||||
const sidebar = screen.getByTestId("host-sidebar-flow");
|
||||
await within(sidebar).findByTestId("chats-selection-highlight");
|
||||
const handle = within(sidebar).getByRole("separator", { name: "Resize sidebar" });
|
||||
for (const label of ["Apps", "Skills", "Automations", "Channels"]) {
|
||||
for (const label of ["Apps", "Automations"]) {
|
||||
expect(within(sidebar).getByRole("button", { name: label })).toHaveClass(
|
||||
"group-data-[resizing=true]/sidebar:transition-none",
|
||||
);
|
||||
@@ -2269,7 +2334,7 @@ describe("App layout", () => {
|
||||
expect(sidebar).toHaveStyle({ width: "400px" });
|
||||
fireEvent[finish](handle, { pointerId: 1, clientX: 400 });
|
||||
expect(sidebar).not.toHaveAttribute("data-resizing");
|
||||
expect(sidebar).toHaveClass("transition-[width]");
|
||||
expect(sidebar).not.toHaveAttribute("data-collapsed");
|
||||
});
|
||||
|
||||
it("uses the shared sidebar controls and rail on the native host", async () => {
|
||||
@@ -2415,6 +2480,11 @@ describe("App layout", () => {
|
||||
);
|
||||
expect(screen.queryByText("Delete this topic?")).not.toBeInTheDocument();
|
||||
expect(document.body.style.pointerEvents).not.toBe("none");
|
||||
|
||||
fireEvent.pointerDown(screen.getByLabelText("Topic actions for Second chat"), { button: 0 });
|
||||
fireEvent.click(await screen.findByRole("menuitem", { name: "Delete" }));
|
||||
fireEvent.click(within(await screen.findByRole("alertdialog")).getByRole("button", { name: "Delete" }));
|
||||
await waitFor(() => expect(screen.getByTestId("host-sidebar-flow")).toHaveStyle({ width: "56px" }));
|
||||
}, 15_000);
|
||||
|
||||
it.each([false, true])("archives only persisted selected topics in one sidebar update (draft=%s)", async (includeDraft) => {
|
||||
@@ -3416,7 +3486,7 @@ describe("App layout", () => {
|
||||
await waitFor(() => expect(requestMutationSpy).toHaveBeenCalledWith(
|
||||
"settings.channel.configure", expect.objectContaining({ name: "email", values: { "channels.email.imapHost": "imap.changed.test" } }), 150_000,
|
||||
));
|
||||
expect(window.location.hash).toBe("#/channels");
|
||||
expect(window.location.hash).toBe("#/apps?section=channels");
|
||||
expect(host).toHaveValue("imap.changed.test");
|
||||
await act(async () => {
|
||||
if (saved) resolveSave({ name: "email", saved: true, saved_keys: ["channels.email.imapHost"] });
|
||||
@@ -3426,7 +3496,7 @@ describe("App layout", () => {
|
||||
await waitFor(() => expect(window.location.hash).toBe("#/new"));
|
||||
expect(screen.queryByRole("dialog")).not.toBeInTheDocument();
|
||||
} else {
|
||||
expect(window.location.hash).toBe("#/channels");
|
||||
expect(window.location.hash).toBe("#/apps?section=channels");
|
||||
expect(host).toHaveValue("imap.changed.test");
|
||||
expect(await screen.findByText("Save failed")).toBeVisible();
|
||||
}
|
||||
@@ -3533,7 +3603,7 @@ describe("App layout", () => {
|
||||
expect(settingsHighlight).toHaveAttribute("data-active-id", "capabilities");
|
||||
});
|
||||
|
||||
it("defaults to Ready again when returning to Apps from another sidebar page", async () => {
|
||||
it("defaults to Ready again when returning to Tools from another Apps tab", async () => {
|
||||
const app = {
|
||||
name: "example", display_name: "Example App", category: "productivity", description: "Example",
|
||||
requires: "", source: "catalog", entry_point: "example", install_supported: true,
|
||||
@@ -3551,16 +3621,18 @@ describe("App layout", () => {
|
||||
fireEvent.click(within(sidebar).getByRole("button", { name: "Apps" }));
|
||||
await act(async () => { await import("@/components/settings/SettingsView"); });
|
||||
expect(await screen.findByRole("heading", { name: "Example App" })).toBeInTheDocument();
|
||||
expect(screen.getByRole("button", { name: "Ready" })).toHaveAttribute("aria-pressed", "true");
|
||||
fireEvent.click(screen.getByRole("button", { name: "MCP" }));
|
||||
fireEvent.click(within(sidebar).getByRole("button", { name: "Skills" }));
|
||||
expect(await screen.findByRole("heading", { name: "Skills" })).toBeInTheDocument();
|
||||
fireEvent.click(within(sidebar).getByRole("button", { name: "Apps" }));
|
||||
expect(screen.getByRole("switch", { name: "Ready only" })).toBeChecked();
|
||||
const types = within(screen.getByRole("radiogroup", { name: "Tool type" }));
|
||||
await userEvent.click(types.getByRole("radio", { name: "MCP" }));
|
||||
expect(types.getByRole("radio", { name: "MCP" })).toBeChecked();
|
||||
fireEvent.click(screen.getByRole("button", { name: "Skills" }));
|
||||
expect(screen.getByRole("button", { name: "Skills" })).toHaveAttribute("aria-pressed", "true");
|
||||
fireEvent.click(screen.getByRole("button", { name: "Tools" }));
|
||||
expect(await screen.findByRole("heading", { name: "Example App" })).toBeInTheDocument();
|
||||
expect(screen.getByRole("button", { name: "Ready" })).toHaveAttribute("aria-pressed", "true");
|
||||
expect(screen.getByRole("switch", { name: "Ready only" })).toBeChecked();
|
||||
});
|
||||
|
||||
it("transitions between Apps and Skills without replacing the sidebar", async () => {
|
||||
it("switches Apps tabs without replacing their navigation or the sidebar", async () => {
|
||||
mockFetchRoutes({
|
||||
"/api/settings": baseSettingsPayload(),
|
||||
"/api/settings/cli-apps": { apps: [], installed_count: 0, catalog_updated_at: "2026-04-18" },
|
||||
@@ -3601,10 +3673,13 @@ describe("App layout", () => {
|
||||
"motion-reduce:animate-none",
|
||||
);
|
||||
expect(document.title).toBe("Apps");
|
||||
const sections = screen.getByRole("group", { name: "Apps" });
|
||||
fireEvent.click(within(sections).getByRole("button", { name: "Skills" }));
|
||||
|
||||
fireEvent.click(within(sidebar).getByRole("button", { name: "Skills" }));
|
||||
|
||||
expect(await screen.findByRole("heading", { name: "Skills" })).toBeInTheDocument();
|
||||
expect(screen.getByRole("group", { name: "Apps" })).toBe(sections);
|
||||
expect(within(sections).getByRole("button", { name: "Skills" })).toHaveAttribute("aria-pressed", "true");
|
||||
expect(window.location.hash).toBe("#/apps?section=skills");
|
||||
expect(screen.getByRole("textbox", { name: "Search installed skills" })).toBeVisible();
|
||||
await waitFor(() => {
|
||||
expect(screen.getByTestId("settings-section-transition")).toHaveAttribute(
|
||||
"data-settings-section",
|
||||
@@ -3612,15 +3687,15 @@ describe("App layout", () => {
|
||||
);
|
||||
});
|
||||
expect(screen.getByRole("navigation", { name: "Sidebar navigation" })).toBeInTheDocument();
|
||||
expect(within(sidebar).getByRole("button", { name: "Skills" })).toHaveAttribute(
|
||||
expect(within(sidebar).getByRole("button", { name: "Apps" })).toHaveAttribute(
|
||||
"aria-current",
|
||||
"page",
|
||||
);
|
||||
expect(within(sidebar).getByTestId("actions-selection-highlight")).toHaveAttribute(
|
||||
"data-active-id",
|
||||
"utility:skills",
|
||||
"utility:apps",
|
||||
);
|
||||
expect(document.title).toBe("Skills");
|
||||
expect(document.title).toBe("Apps");
|
||||
});
|
||||
|
||||
it("returns from settings to the blank start page when no session was active", async () => {
|
||||
@@ -3796,7 +3871,7 @@ describe("App layout", () => {
|
||||
const newChatButton = within(sidebar).getByRole("button", { name: "New topic" });
|
||||
const searchButton = within(sidebar).getByRole("button", { name: "Search" });
|
||||
expect(
|
||||
searchButton.compareDocumentPosition(newChatButton) &
|
||||
newChatButton.compareDocumentPosition(searchButton) &
|
||||
Node.DOCUMENT_POSITION_FOLLOWING,
|
||||
).toBeTruthy();
|
||||
|
||||
@@ -4404,16 +4479,17 @@ describe("App layout", () => {
|
||||
});
|
||||
|
||||
it.each([
|
||||
["apps", "1", "Digit1", true],
|
||||
["skills", "2", "Digit2", true],
|
||||
["automations", "3", "Digit3", true],
|
||||
["settings", ",", "Comma", false],
|
||||
])("opens %s using its sidebar shortcut", async (route, key, code, shiftKey) => {
|
||||
["Apps", "#/apps", "!", "Digit1", "Meta+Shift+1 Control+Shift+1"],
|
||||
["Automations", "#/automations", "@", "Digit2", "Meta+Shift+2 Control+Shift+2"],
|
||||
["Settings", "#/settings", ",", "Comma", "Meta+, Control+,"],
|
||||
])("opens %s using its sidebar shortcut", async (name, hash, key, code, ariaShortcut) => {
|
||||
mockFetchRoutes({ "/api/settings": baseSettingsPayload() });
|
||||
render(<App />);
|
||||
await waitFor(() => expect(connectSpy).toHaveBeenCalled());
|
||||
fireEvent.keyDown(window, { key, code, shiftKey, ctrlKey: true });
|
||||
await waitFor(() => expect(window.location.hash).toContain("#/" + route));
|
||||
const sidebar = screen.getByRole("navigation", { name: "Sidebar navigation" });
|
||||
expect(within(sidebar).getByRole("button", { name })).toHaveAttribute("aria-keyshortcuts", ariaShortcut);
|
||||
fireEvent.keyDown(window, { key, code, shiftKey: code !== "Comma", ctrlKey: true });
|
||||
await waitFor(() => expect(window.location.hash).toBe(hash));
|
||||
});
|
||||
|
||||
it.each([
|
||||
@@ -4472,7 +4548,6 @@ describe("App layout", () => {
|
||||
const sidebar = screen.getByRole("navigation", { name: "Sidebar navigation" });
|
||||
|
||||
const newChatButton = within(sidebar).getByRole("button", { name: "New topic" });
|
||||
expect(newChatButton).toHaveTextContent("");
|
||||
await userEvent.setup().hover(newChatButton);
|
||||
const tooltip = await screen.findByRole("tooltip");
|
||||
expect(tooltip).toHaveTextContent("New topic");
|
||||
@@ -4568,7 +4643,7 @@ describe("App layout", () => {
|
||||
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();
|
||||
expect(within(rail).queryByRole("button", { name: "Existing chat" })).not.toBeInTheDocument();
|
||||
|
||||
fireEvent.click(within(rail).getByRole("button", { name: "Toggle sidebar" }));
|
||||
await waitFor(() => expect(sidebarAside.style.width).toBe("272px"));
|
||||
|
||||
@@ -9,6 +9,8 @@ import {
|
||||
installSettingsViewTestHooks,
|
||||
jsonResponse,
|
||||
renderSettingsView,
|
||||
selectToolType,
|
||||
showOnlyReadyTools,
|
||||
settingsPayload,
|
||||
} from "@/tests/settings-test-utils";
|
||||
|
||||
@@ -57,9 +59,10 @@ describe("catalog loading", () => {
|
||||
cleanup();
|
||||
fetch.mockClear();
|
||||
renderSettingsView({ client, initialSettings: settingsPayload() });
|
||||
fireEvent.click(screen.getByRole("button", { name: "CLI Apps" }));
|
||||
await selectToolType("CLI Apps");
|
||||
expect(screen.getByRole("heading", { name: "AnyGen" })).toBeInTheDocument();
|
||||
fireEvent.click(screen.getByRole("button", { name: "Agent Plugins" }));
|
||||
await selectToolType("Agent Plugins");
|
||||
await showOnlyReadyTools(false);
|
||||
expect(screen.getByRole("heading", { name: "Computer Use" })).toBeInTheDocument();
|
||||
expect(screen.queryByRole("status", { name: "Loading apps…" })).not.toBeInTheDocument();
|
||||
expect(fetch.mock.calls.filter(([url]) => String(url).match(/cli-apps|mcp-presets/))).toHaveLength(0);
|
||||
@@ -68,9 +71,10 @@ describe("catalog loading", () => {
|
||||
const now = vi.spyOn(Date, "now").mockReturnValue(Date.now() + TOOLS_CATALOG_TTL_MS + 1);
|
||||
try {
|
||||
renderSettingsView({ client, initialSettings: settingsPayload() });
|
||||
fireEvent.click(screen.getByRole("button", { name: "CLI Apps" }));
|
||||
await selectToolType("CLI Apps");
|
||||
expect(screen.getByRole("heading", { name: "AnyGen" })).toBeInTheDocument();
|
||||
fireEvent.click(screen.getByRole("button", { name: "Agent Plugins" }));
|
||||
await selectToolType("Agent Plugins");
|
||||
await showOnlyReadyTools(false);
|
||||
expect(screen.getByRole("heading", { name: "Computer Use" })).toBeInTheDocument();
|
||||
expect(screen.queryByRole("status", { name: "Loading apps…" })).not.toBeInTheDocument();
|
||||
expect(fetch.mock.calls.filter(([url]) => String(url).match(/cli-apps|mcp-presets/))).toHaveLength(2);
|
||||
@@ -79,7 +83,7 @@ describe("catalog loading", () => {
|
||||
mcp.resolve(jsonResponse({ presets: [{ ...plugin, display_name: "Updated plugin" }], installed_count: 1 }));
|
||||
});
|
||||
expect(screen.getByRole("heading", { name: "Updated plugin" })).toBeInTheDocument();
|
||||
fireEvent.click(screen.getByRole("button", { name: "CLI Apps" }));
|
||||
await selectToolType("CLI Apps");
|
||||
expect(screen.getByRole("heading", { name: "Updated app" })).toBeInTheDocument();
|
||||
} finally {
|
||||
now.mockRestore();
|
||||
@@ -139,7 +143,7 @@ describe("catalog loading", () => {
|
||||
return Promise.resolve(jsonResponse(settingsPayload()));
|
||||
}));
|
||||
renderSettingsView({ initialSettings: settingsPayload() });
|
||||
fireEvent.click(screen.getByRole("button", { name: "CLI Apps" }));
|
||||
await selectToolType("CLI Apps");
|
||||
expect(screen.getByRole("status", { name: "Loading apps…" })).toHaveAttribute("aria-busy", "true");
|
||||
|
||||
await act(async () => { cli.resolve(jsonResponse({ apps: [app], installed_count: 1 })); });
|
||||
@@ -147,7 +151,8 @@ describe("catalog loading", () => {
|
||||
expect(screen.getByRole("status", { name: "Loading apps…" })).toBeInTheDocument();
|
||||
await act(async () => { mcp.resolve(jsonResponse({ presets: [plugin], installed_count: 1 })); });
|
||||
expect(screen.getByRole("heading", { name: "AnyGen" })).toBeInTheDocument();
|
||||
fireEvent.click(screen.getByRole("button", { name: "Agent Plugins" }));
|
||||
await selectToolType("Agent Plugins");
|
||||
await showOnlyReadyTools(false);
|
||||
expect(screen.getByRole("heading", { name: "Computer Use" })).toBeInTheDocument();
|
||||
expect(screen.queryByRole("status", { name: "Loading apps…" })).not.toBeInTheDocument();
|
||||
});
|
||||
@@ -165,17 +170,18 @@ describe("catalog loading", () => {
|
||||
renderSettingsView({ initialSettings: settingsPayload() });
|
||||
await act(async () => {});
|
||||
expect(screen.getByRole("status", { name: "Loading apps…" })).toBeInTheDocument();
|
||||
expect(screen.queryByText("No CLI Apps available.")).not.toBeInTheDocument();
|
||||
expect(screen.queryByText("No tools available")).not.toBeInTheDocument();
|
||||
|
||||
fireEvent.click(screen.getByRole("button", { name: "MCP" }));
|
||||
expect(screen.getByText("No MCP tools available.")).toBeInTheDocument();
|
||||
await selectToolType("MCP");
|
||||
await showOnlyReadyTools(false);
|
||||
expect(screen.getByText("No MCP tools available")).toBeInTheDocument();
|
||||
expect(screen.queryByRole("status", { name: "Loading apps…" })).not.toBeInTheDocument();
|
||||
fireEvent.change(screen.getByPlaceholderText("Search tools"), { target: { value: "AnyGen" } });
|
||||
expect(screen.getByText("No tools match your search.")).toBeInTheDocument();
|
||||
expect(screen.getByText("No tools match your search")).toBeInTheDocument();
|
||||
expect(screen.queryByRole("status", { name: "Loading apps…" })).not.toBeInTheDocument();
|
||||
fireEvent.click(screen.getByRole("button", { name: "CLI Apps" }));
|
||||
await selectToolType("CLI Apps");
|
||||
expect(screen.getByRole("status", { name: "Loading apps…" })).toBeInTheDocument();
|
||||
expect(screen.queryByText("No tools match your search.")).not.toBeInTheDocument();
|
||||
expect(screen.queryByText("No tools match your search")).not.toBeInTheDocument();
|
||||
await act(async () => { cli.resolve(jsonResponse({ apps: [app], installed_count: 1 })); });
|
||||
expect(screen.getByRole("heading", { name: "AnyGen" })).toBeInTheDocument();
|
||||
expect(screen.queryByRole("status", { name: "Loading apps…" })).not.toBeInTheDocument();
|
||||
@@ -191,7 +197,7 @@ describe("catalog loading", () => {
|
||||
renderSettingsView({ initialSection: section, initialSettings: settingsPayload() });
|
||||
expect(await screen.findByText("Catalog offline")).toBeInTheDocument();
|
||||
expect(screen.queryByRole("status", { name: /Loading (apps|channels)/ })).not.toBeInTheDocument();
|
||||
expect(screen.queryByText("No CLI Apps available.")).not.toBeInTheDocument();
|
||||
expect(screen.queryByText("No tools available")).not.toBeInTheDocument();
|
||||
expect(screen.queryByText("No channels match this filter.")).not.toBeInTheDocument();
|
||||
});
|
||||
|
||||
|
||||
@@ -4,7 +4,6 @@ import { afterEach, beforeEach, describe, expect, it } from "vitest";
|
||||
import { channelUiPresentation, registeredChannelUiContributions } from "@/channel-plugins/registry";
|
||||
import { ChannelLogo } from "@/components/settings/channels/ChannelIdentity";
|
||||
import { __clearLogoFallbackCacheForTests } from "@/hooks/useLogoFallback";
|
||||
import { logoFallbackUrls } from "@/lib/provider-brand";
|
||||
import type { NanobotFeatureInfo } from "@/lib/types";
|
||||
|
||||
function feature(name: string): NanobotFeatureInfo {
|
||||
@@ -31,11 +30,11 @@ describe("channel logos", () => {
|
||||
beforeEach(__clearLogoFallbackCacheForTests);
|
||||
afterEach(cleanup);
|
||||
|
||||
const remoteChannels = registeredChannelUiContributions()
|
||||
const channelsWithBrandMarks = registeredChannelUiContributions()
|
||||
.filter(({ contribution }) => contribution.presentation.logoUrl)
|
||||
.map(({ channel }) => channel);
|
||||
|
||||
it.each(remoteChannels)("keeps %s in one stable tile while loading", (channel) => {
|
||||
it.each(channelsWithBrandMarks)("loads the bundled %s mark in one stable tile", (channel) => {
|
||||
const { container } = render(<ChannelLogo feature={feature(channel)} showBrandLogos />);
|
||||
const icon = container.firstElementChild!;
|
||||
const image = icon.querySelector("img")!;
|
||||
@@ -45,6 +44,7 @@ describe("channel logos", () => {
|
||||
expectFootprint(icon);
|
||||
expect(icon).toHaveClass("bg-muted");
|
||||
expect(fallback).toHaveClass("opacity-100");
|
||||
expect(presentation.logoUrl).toMatch(/^\/brand\//);
|
||||
expect(image).toHaveAttribute("src", presentation.logoUrl);
|
||||
expect(image).toHaveAttribute("alt", "");
|
||||
expect(image).toHaveAttribute("referrerpolicy", "no-referrer");
|
||||
@@ -58,54 +58,47 @@ describe("channel logos", () => {
|
||||
for (const className of ["invert", "grayscale", "object-cover"]) {
|
||||
expect(image).not.toHaveClass(className);
|
||||
}
|
||||
expect(icon).toHaveClass(presentation.logoLayout === "tile" ? "bg-transparent" : "bg-white");
|
||||
expect(image).toHaveClass(...(presentation.logoLayout === "tile" ? ["h-8", "w-8"] : ["h-6", "w-6"]));
|
||||
expect(icon).toHaveClass("bg-white");
|
||||
expect(image).toHaveClass("h-6", "w-6");
|
||||
});
|
||||
|
||||
it.each(["linear", "feishu", "lark"])("insets unknown %s fallback assets instead of stretching them", (channel) => {
|
||||
const { container } = render(<ChannelLogo feature={feature(channel)} showBrandLogos />);
|
||||
it.each(["dingtalk", "feishu", "lark", "mochat", "msteams", "napcat", "slack", "wecom"])(
|
||||
"shows %s initials without an external image when there is no bundled mark",
|
||||
(channel) => {
|
||||
const { container } = render(<ChannelLogo feature={feature(channel)} showBrandLogos />);
|
||||
const icon = container.firstElementChild!;
|
||||
expectFootprint(icon);
|
||||
expect(icon).toHaveTextContent(channelUiPresentation(channel)!.initials!);
|
||||
expect(icon.querySelector("img")).toBeNull();
|
||||
},
|
||||
);
|
||||
|
||||
it("keeps QQ readable when its bundled SVG fails, without requesting another image", () => {
|
||||
const { container } = render(<ChannelLogo feature={feature("qq")} showBrandLogos />);
|
||||
const icon = container.firstElementChild!;
|
||||
const image = icon.querySelector("img")!;
|
||||
fireEvent.load(image);
|
||||
expect(icon).toHaveClass("bg-transparent");
|
||||
expect(image).toHaveClass("h-8", "w-8");
|
||||
|
||||
expect(image).toHaveAttribute("src", "/brand/channels/qq.svg");
|
||||
fireEvent.error(image);
|
||||
expect(icon).toHaveClass("bg-muted");
|
||||
expect(image).toHaveClass("h-6", "w-6", "opacity-0");
|
||||
fireEvent.load(image);
|
||||
expect(icon).toHaveClass("bg-white");
|
||||
expect(container.firstElementChild).toBe(icon);
|
||||
expectFootprint(icon);
|
||||
});
|
||||
|
||||
it("falls back to initials after all remote sources fail without changing size", () => {
|
||||
const { container } = render(<ChannelLogo feature={feature("slack")} showBrandLogos />);
|
||||
const icon = container.firstElementChild!;
|
||||
for (const url of logoFallbackUrls(channelUiPresentation("slack")!.logoUrl)) {
|
||||
const image = icon.querySelector("img")!;
|
||||
expect(image).toHaveAttribute("src", url);
|
||||
fireEvent.error(image);
|
||||
expect(container.firstElementChild).toBe(icon);
|
||||
expectFootprint(icon);
|
||||
expect(icon).toHaveClass("bg-muted");
|
||||
expect(icon.querySelector("span")).toHaveClass("opacity-100");
|
||||
}
|
||||
expect(icon).toHaveClass("bg-muted");
|
||||
expect(icon.querySelector("span")).toHaveClass("opacity-100");
|
||||
expect(icon).toHaveTextContent("QQ");
|
||||
expect(icon.querySelector("img")).toBeNull();
|
||||
expect(icon).toHaveTextContent(channelUiPresentation("slack")!.initials!);
|
||||
});
|
||||
|
||||
it("respects the brand logo preference even for cached images", () => {
|
||||
const { container, rerender } = render(<ChannelLogo feature={feature("slack")} showBrandLogos />);
|
||||
const { container, rerender } = render(<ChannelLogo feature={feature("linear")} showBrandLogos />);
|
||||
const icon = container.firstElementChild!;
|
||||
fireEvent.load(icon.querySelector("img")!);
|
||||
|
||||
rerender(<ChannelLogo feature={feature("slack")} showBrandLogos={false} />);
|
||||
rerender(<ChannelLogo feature={feature("linear")} showBrandLogos={false} />);
|
||||
expectFootprint(icon);
|
||||
expect(icon.querySelector("img")).toBeNull();
|
||||
expect(icon).toHaveClass("bg-muted");
|
||||
expect(icon.querySelector("span")).toHaveClass("opacity-100");
|
||||
|
||||
rerender(<ChannelLogo feature={feature("slack")} showBrandLogos />);
|
||||
rerender(<ChannelLogo feature={feature("linear")} showBrandLogos />);
|
||||
expect(icon.querySelector("img")).toHaveClass("opacity-100");
|
||||
expect(icon).toHaveClass("bg-white");
|
||||
});
|
||||
@@ -118,16 +111,6 @@ describe("channel logos", () => {
|
||||
expect(channelUiPresentation("email")?.logoUrl).toBeUndefined();
|
||||
});
|
||||
|
||||
it("falls back to QQ's official favicon rather than its CDN's identity", () => {
|
||||
const { container } = render(<ChannelLogo feature={feature("qq")} showBrandLogos />);
|
||||
const image = container.querySelector("img")!;
|
||||
expect(image).toHaveAttribute("src", channelUiPresentation("qq")!.logoUrl);
|
||||
fireEvent.error(image);
|
||||
expect(image).toHaveAttribute("src", "https://im.qq.com/favicon.ico");
|
||||
fireEvent.load(image);
|
||||
expect(container.firstElementChild).toHaveClass("bg-white");
|
||||
});
|
||||
|
||||
it("keeps the local nanobot mark and unknown channel initials readable", () => {
|
||||
const { container, rerender } = render(<ChannelLogo feature={feature("websocket")} showBrandLogos />);
|
||||
expectFootprint(container.firstElementChild!);
|
||||
|
||||
@@ -146,7 +146,8 @@ it("switches the chat list preview between ready, loading, empty and archived st
|
||||
await setMode("loading");
|
||||
expect(preview.getByText("Loading…")).toBeVisible();
|
||||
await setMode("empty");
|
||||
expect(preview.getByText("No sessions yet.")).toBeVisible();
|
||||
expect(preview.getByRole("combobox", { name: "Chat list state" })).toHaveTextContent("empty");
|
||||
expect(preview.queryByText("Loading…")).not.toBeInTheDocument();
|
||||
await setMode("archived");
|
||||
const archived = within(preview.getByRole("region", { name: "Archived" }));
|
||||
expect(archived.getByRole("button", { name: "@history 历史方案" })).toBeVisible();
|
||||
|
||||
@@ -126,7 +126,6 @@ const LOCALIZED_SETTINGS_COPY_KEYS = [
|
||||
"settings.skills.marketplaceSearchFailed",
|
||||
"settings.skills.marketplaceInstallFailed",
|
||||
"settings.skills.marketplaceSearchPlaceholder",
|
||||
"settings.skills.marketplaceSearchLabel",
|
||||
"settings.skills.marketplaceSearching",
|
||||
"settings.skills.marketplaceProviderFilter",
|
||||
"settings.skills.marketplaceProviderAll",
|
||||
@@ -248,7 +247,7 @@ const LOCALIZED_CHANNEL_SHELL_KEYS = [
|
||||
"settings.channels.configuredInstances",
|
||||
"settings.channels.connectPreview",
|
||||
"settings.channels.copyCommand",
|
||||
"settings.channels.filterAll",
|
||||
"settings.channels.enabledOnly",
|
||||
"settings.channels.filterOff",
|
||||
"settings.channels.filterOn",
|
||||
"settings.channels.helperCopied",
|
||||
@@ -696,7 +695,7 @@ describe("webui i18n", () => {
|
||||
expect(settings.overview.webSearch).toBe("网络搜索");
|
||||
expect(settings.overview.workspace).toBe("工作目录");
|
||||
expect(settings.skills.installedTab).toBe("已安装");
|
||||
expect(settings.skills.discoverTab).toBe("发现");
|
||||
expect(settings.skills.discoverTab).toBe("技能市场");
|
||||
expect(settings.skills.marketplaceProviderFilter).toBe("技能来源");
|
||||
expect(settings.skills.marketplaceProviderAll).toBe("全部");
|
||||
expect(settings.skills.marketplaceSearchPlaceholder).toBe("搜索技能");
|
||||
|
||||
@@ -16,6 +16,8 @@ import {
|
||||
installSettingsViewTestHooks,
|
||||
jsonResponse,
|
||||
renderSettingsView,
|
||||
selectToolType,
|
||||
showOnlyReadyTools,
|
||||
requestMutationMock,
|
||||
settingsPayload,
|
||||
} from "@/tests/settings-test-utils";
|
||||
@@ -272,7 +274,8 @@ describe("MCP connection draft lifecycle", () => {
|
||||
return { ok: false, status: 404, text: async () => "Not found" } as Response;
|
||||
}));
|
||||
renderSettingsView({ initialSection: "apps" });
|
||||
fireEvent.click(await screen.findByRole("button", { name: "MCP" }));
|
||||
await selectToolType("MCP");
|
||||
await showOnlyReadyTools(false);
|
||||
fireEvent.click(await screen.findByRole("button", { name: "Metabase" }));
|
||||
const dialog = await screen.findByRole("dialog", { name: "Metabase" });
|
||||
expect(within(dialog).getByRole("tab", { name: "Overview" })).toHaveAttribute("aria-selected", "true");
|
||||
@@ -349,7 +352,8 @@ describe("MCP connection draft lifecycle", () => {
|
||||
});
|
||||
|
||||
renderSettingsView({ initialSection: "apps" });
|
||||
fireEvent.click(await screen.findByRole("button", { name: "MCP" }));
|
||||
await selectToolType("MCP");
|
||||
await showOnlyReadyTools(false);
|
||||
fireEvent.click(await screen.findByRole("button", { name: "Connect Xmind" }));
|
||||
fireEvent.click(screen.getByRole("switch", { name: "Use proxy" }));
|
||||
fireEvent.click(screen.getByRole("button", { name: "Connect" }));
|
||||
|
||||
@@ -44,11 +44,11 @@ function LocalShell({ collapsed = false, initialRemote = false }) {
|
||||
return () => window.removeEventListener("hashchange", route);
|
||||
}, []);
|
||||
return <>
|
||||
<Sidebar collapsed={collapsed} sessions={[]} activeKey={null} loading={false} newChatActive={false}
|
||||
<Sidebar collapsed={collapsed} sessions={[]} activeKey={null} loading={false}
|
||||
onNewChat={() => { if (connections?.managing) connections.selectLocal(); window.location.hash = "/new"; setRemotePage(false); }} onSelect={noop} onRequestDelete={noop} onTogglePin={noop}
|
||||
onRequestRename={async () => {}} onToggleArchive={noop} onToggleGroup={noop}
|
||||
onRequestRenameProject={noop} onNewChatInProject={noop} onOpenSettings={noop}
|
||||
onOpenApps={noop} onOpenSkills={noop} onOpenAutomations={noop} onOpenChannels={noop}
|
||||
onOpenApps={noop} onOpenAutomations={noop}
|
||||
onOpenSearch={noop} onToggleArchived={noop} />
|
||||
<main><div hidden={connections?.managing} aria-hidden={connections?.managing || undefined}>
|
||||
{remotePage ? <RemoteConnectionsPage onBackToChat={() => setRemotePage(false)} /> : <><p>Local conversations</p><textarea aria-label="Local draft" /></>}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { act, cleanup, fireEvent, screen } from "@testing-library/react";
|
||||
import { act, cleanup, screen } from "@testing-library/react";
|
||||
import { describe, expect, it, vi } from "vitest";
|
||||
|
||||
import type { NanobotClient } from "@/lib/nanobot-client";
|
||||
@@ -6,6 +6,8 @@ import {
|
||||
installSettingsViewTestHooks,
|
||||
jsonResponse,
|
||||
renderSettingsView,
|
||||
selectToolType,
|
||||
showOnlyReadyTools,
|
||||
settingsPayload,
|
||||
} from "@/tests/settings-test-utils";
|
||||
|
||||
@@ -42,7 +44,10 @@ describe("Apps default filter", () => {
|
||||
renderSettingsView({ initialSettings: settingsPayload() });
|
||||
|
||||
expect(await screen.findByRole("heading", { name: "Example App" })).toBeInTheDocument();
|
||||
expect(screen.getByRole("button", { name: "CLI Apps" })).toHaveAttribute("aria-pressed", "true");
|
||||
expect(screen.getByRole("radio", { name: "All" })).toBeChecked();
|
||||
expect(screen.getByRole("switch", { name: "Ready only" })).not.toBeChecked();
|
||||
expect(screen.getByRole("heading", { name: "Docs MCP" })).toBeInTheDocument();
|
||||
expect(screen.getByRole("heading", { name: "Example Plugin" })).toBeInTheDocument();
|
||||
});
|
||||
|
||||
it("preserves a manual choice while MCP loads, then defaults to the cached Ready items on re-entry", async () => {
|
||||
@@ -56,14 +61,16 @@ describe("Apps default filter", () => {
|
||||
renderSettingsView({ client, initialSettings: settingsPayload() });
|
||||
await act(async () => {});
|
||||
expect(screen.queryByRole("heading", { name: "Example App" })).not.toBeInTheDocument();
|
||||
fireEvent.click(screen.getByRole("button", { name: "CLI Apps" }));
|
||||
await selectToolType("CLI Apps");
|
||||
await showOnlyReadyTools(false);
|
||||
await act(async () => { pending.resolve(jsonResponse({ presets: [mcp], installed_count: 1 })); });
|
||||
expect(screen.getByRole("button", { name: "CLI Apps" })).toHaveAttribute("aria-pressed", "true");
|
||||
expect(screen.getByRole("radio", { name: "CLI Apps" })).toBeChecked();
|
||||
expect(screen.getByRole("switch", { name: "Ready only" })).not.toBeChecked();
|
||||
expect(screen.getByRole("heading", { name: "Example App" })).toBeInTheDocument();
|
||||
|
||||
cleanup();
|
||||
renderSettingsView({ client, initialSettings: settingsPayload() });
|
||||
expect(screen.getByRole("button", { name: "Ready" })).toHaveAttribute("aria-pressed", "true");
|
||||
expect(screen.getByRole("switch", { name: "Ready only" })).toBeChecked();
|
||||
expect(screen.getByRole("heading", { name: "Docs MCP" })).toBeInTheDocument();
|
||||
});
|
||||
});
|
||||
@@ -6,6 +6,8 @@ import {
|
||||
installSettingsViewTestHooks,
|
||||
jsonResponse,
|
||||
renderSettingsView,
|
||||
selectToolType,
|
||||
showOnlyReadyTools,
|
||||
requestMutationMock,
|
||||
settingsPayload,
|
||||
} from "@/tests/settings-test-utils";
|
||||
@@ -43,7 +45,7 @@ async function connectXmind() {
|
||||
describe("SettingsView Apps catalog", () => {
|
||||
installSettingsViewTestHooks();
|
||||
|
||||
it("searches within the selected readiness or kind filter", async () => {
|
||||
it("combines independent type and readiness filters with search", async () => {
|
||||
const figmaLocal = { ...xmindMcpPreset, name: "figma-local", display_name: "Figma local" };
|
||||
const figmaConnected = {
|
||||
...xmindMcpPreset, name: "figma-connected", display_name: "Figma connected",
|
||||
@@ -72,18 +74,22 @@ describe("SettingsView Apps catalog", () => {
|
||||
}));
|
||||
|
||||
renderSettingsView({ initialSection: "apps" });
|
||||
fireEvent.click(await screen.findByRole("button", { name: "Ready" }));
|
||||
await showOnlyReadyTools(true);
|
||||
fireEvent.change(screen.getByPlaceholderText("Search tools"), { target: { value: "figma" } });
|
||||
expect(await screen.findByRole("heading", { name: "Figma connected" })).toBeInTheDocument();
|
||||
expect(screen.getByRole("heading", { name: "Figma CLI" })).toBeInTheDocument();
|
||||
expect(screen.queryByRole("heading", { name: "Figma local" })).not.toBeInTheDocument();
|
||||
expect(screen.queryByRole("heading", { name: "Figma pending" })).not.toBeInTheDocument();
|
||||
|
||||
fireEvent.click(screen.getByRole("button", { name: "MCP" }));
|
||||
await selectToolType("MCP");
|
||||
expect(screen.getByRole("switch", { name: "Ready only" })).toBeChecked();
|
||||
expect(screen.queryByRole("heading", { name: "Figma local" })).not.toBeInTheDocument();
|
||||
expect(screen.queryByRole("heading", { name: "Figma CLI" })).not.toBeInTheDocument();
|
||||
await showOnlyReadyTools(false);
|
||||
expect(screen.getByRole("heading", { name: "Figma local" })).toBeInTheDocument();
|
||||
expect(screen.getByRole("heading", { name: "Figma connected" })).toBeInTheDocument();
|
||||
expect(screen.queryByRole("heading", { name: "Figma CLI" })).not.toBeInTheDocument();
|
||||
fireEvent.click(screen.getByRole("button", { name: "CLI Apps" }));
|
||||
await selectToolType("CLI Apps");
|
||||
expect(screen.getByRole("heading", { name: "Figma pending" })).toBeInTheDocument();
|
||||
expect(screen.queryByRole("heading", { name: "Figma local" })).not.toBeInTheDocument();
|
||||
expect(screen.queryByRole("heading", { name: "Photoshop CLI" })).not.toBeInTheDocument();
|
||||
@@ -102,7 +108,8 @@ describe("SettingsView Apps catalog", () => {
|
||||
return { ok: false, status: 404, text: async () => "Not found" } as Response;
|
||||
}));
|
||||
renderSettingsView({ initialSection: "apps" });
|
||||
fireEvent.click(await screen.findByRole("button", { name: "MCP" }));
|
||||
await selectToolType("MCP");
|
||||
await showOnlyReadyTools(false);
|
||||
fireEvent.click(await screen.findByRole("button", { name: "Connect Xmind" }));
|
||||
const dialog = await screen.findByRole("dialog", { name: "Xmind" });
|
||||
const configure = within(dialog).queryByRole("button", { name: "Configure proxy" });
|
||||
@@ -158,7 +165,8 @@ describe("SettingsView Apps catalog", () => {
|
||||
});
|
||||
|
||||
renderSettingsView({ initialSection: "apps" });
|
||||
fireEvent.click(await screen.findByRole("button", { name: "MCP" }));
|
||||
await selectToolType("MCP");
|
||||
await showOnlyReadyTools(false);
|
||||
fireEvent.click(await screen.findByRole("button", { name: "Connect Metabase" }));
|
||||
|
||||
const dialog = await screen.findByRole("dialog", { name: "Metabase" });
|
||||
@@ -247,7 +255,8 @@ describe("SettingsView Apps catalog", () => {
|
||||
vi.stubGlobal("open", open);
|
||||
|
||||
renderSettingsView({ initialSection: "apps" });
|
||||
fireEvent.click(await screen.findByRole("button", { name: "MCP" }));
|
||||
await selectToolType("MCP");
|
||||
await showOnlyReadyTools(false);
|
||||
expect(screen.getByText("MCP tools")).toBeInTheDocument();
|
||||
const connectButton = await screen.findByRole("button", { name: "Connect Xmind" });
|
||||
expect(connectButton).toHaveTextContent("Connect");
|
||||
@@ -320,10 +329,11 @@ describe("SettingsView Apps catalog", () => {
|
||||
requestMutationMock.mockRejectedValueOnce(new Error("Stopped after request assertion"));
|
||||
|
||||
renderSettingsView({ initialSection: "apps" });
|
||||
fireEvent.click(await screen.findByRole("button", { name: "Ready" }));
|
||||
expect(await screen.findByText("No tools are ready yet.")).toBeInTheDocument();
|
||||
await showOnlyReadyTools(true);
|
||||
expect(await screen.findByText("No tools are ready yet")).toBeInTheDocument();
|
||||
|
||||
fireEvent.click(await screen.findByRole("button", { name: "MCP" }));
|
||||
await selectToolType("MCP");
|
||||
await showOnlyReadyTools(false);
|
||||
|
||||
const heading = await screen.findByRole("heading", { name: "Xmind" });
|
||||
const row = heading.closest("article");
|
||||
@@ -382,7 +392,8 @@ describe("SettingsView Apps catalog", () => {
|
||||
vi.stubGlobal("fetch", fetchMock);
|
||||
|
||||
renderSettingsView({ initialSection: "apps" });
|
||||
fireEvent.click(await screen.findByRole("button", { name: "MCP" }));
|
||||
await selectToolType("MCP");
|
||||
await showOnlyReadyTools(false);
|
||||
|
||||
const heading = await screen.findByRole("heading", { name: "Xmind" });
|
||||
const row = heading.closest("article");
|
||||
@@ -425,13 +436,14 @@ describe("SettingsView Apps catalog", () => {
|
||||
|
||||
const client = { requestMutation: requestMutationMock, status: "open", onStatus: () => () => {} } as never;
|
||||
renderSettingsView({ client, initialSection: "apps" });
|
||||
fireEvent.click(await screen.findByRole("button", { name: "MCP" }));
|
||||
await selectToolType("MCP");
|
||||
await showOnlyReadyTools(false);
|
||||
|
||||
expect(await screen.findByRole("button", { name: "Xmind" }))
|
||||
.toHaveAccessibleDescription("Connecting…");
|
||||
cleanup();
|
||||
renderSettingsView({ client, initialSection: "apps", initialSettings: settingsPayload() });
|
||||
fireEvent.click(screen.getByRole("button", { name: "MCP" }));
|
||||
await selectToolType("MCP");
|
||||
expect(screen.getByRole("button", { name: "Xmind" })).toHaveAccessibleDescription("Connecting…");
|
||||
expect(mcpPresetRequests).toBe(1);
|
||||
expect(await screen.findByRole(
|
||||
@@ -441,7 +453,7 @@ describe("SettingsView Apps catalog", () => {
|
||||
)).toHaveTextContent("Manage");
|
||||
expect(mcpPresetRequests).toBe(2);
|
||||
|
||||
fireEvent.click(screen.getByRole("button", { name: "Ready" }));
|
||||
await showOnlyReadyTools(true);
|
||||
expect(await screen.findByRole("heading", { name: "Xmind" })).toBeInTheDocument();
|
||||
});
|
||||
|
||||
@@ -486,7 +498,8 @@ describe("SettingsView Apps catalog", () => {
|
||||
});
|
||||
|
||||
renderSettingsView({ initialSection: "apps" });
|
||||
fireEvent.click(await screen.findByRole("button", { name: "MCP" }));
|
||||
await selectToolType("MCP");
|
||||
await showOnlyReadyTools(false);
|
||||
expect(await screen.findByText("Connection failed.")).toBeInTheDocument();
|
||||
|
||||
fireEvent.click(screen.getByRole("button", { name: "Manage team-docs" }));
|
||||
@@ -500,7 +513,8 @@ describe("SettingsView Apps catalog", () => {
|
||||
));
|
||||
const connected = await screen.findByRole("button", { name: "Manage team-docs" });
|
||||
expect(connected).toHaveTextContent("Manage");
|
||||
fireEvent.click(screen.getByRole("button", { name: "Ready" }));
|
||||
await selectToolType("All");
|
||||
await showOnlyReadyTools(true);
|
||||
const readyHeading = await screen.findByRole("heading", { name: "team-docs" });
|
||||
expect(within(readyHeading.closest("article") as HTMLElement).getByText("MCP"))
|
||||
.toBeInTheDocument();
|
||||
@@ -546,7 +560,8 @@ describe("SettingsView Apps catalog", () => {
|
||||
});
|
||||
|
||||
renderSettingsView({ initialSection: "apps" });
|
||||
fireEvent.click(await screen.findByRole("button", { name: "MCP" }));
|
||||
await selectToolType("MCP");
|
||||
await showOnlyReadyTools(false);
|
||||
fireEvent.click(await screen.findByRole("button", { name: "Custom" }));
|
||||
|
||||
fireEvent.change(screen.getByLabelText("Server name"), {
|
||||
@@ -673,7 +688,8 @@ describe("SettingsView Apps catalog", () => {
|
||||
vi.stubGlobal("open", vi.fn(() => popup));
|
||||
|
||||
renderSettingsView({ initialSection: "apps" });
|
||||
fireEvent.click(await screen.findByRole("button", { name: "MCP" }));
|
||||
await selectToolType("MCP");
|
||||
await showOnlyReadyTools(false);
|
||||
await connectXmind();
|
||||
|
||||
const callbackInput = await screen.findByRole("textbox", { name: "Callback URL" });
|
||||
@@ -740,7 +756,8 @@ describe("SettingsView Apps catalog", () => {
|
||||
vi.stubGlobal("open", vi.fn(() => popup));
|
||||
|
||||
renderSettingsView({ initialSection: "apps" });
|
||||
fireEvent.click(await screen.findByRole("button", { name: "MCP" }));
|
||||
await selectToolType("MCP");
|
||||
await showOnlyReadyTools(false);
|
||||
await connectXmind();
|
||||
|
||||
const cancelButton = await screen.findByRole("button", { name: "Cancel" });
|
||||
@@ -796,7 +813,8 @@ describe("SettingsView Apps catalog", () => {
|
||||
});
|
||||
|
||||
renderSettingsView({ initialSection: "apps" });
|
||||
fireEvent.click(await screen.findByRole("button", { name: "MCP" }));
|
||||
await selectToolType("MCP");
|
||||
await showOnlyReadyTools(false);
|
||||
fireEvent.click(await screen.findByRole("button", { name: "Manage Xmind" }));
|
||||
const dialog = screen.getByRole("dialog", { name: "Xmind" });
|
||||
fireEvent.click(within(dialog).getByRole("tab", { name: "Connection" }));
|
||||
@@ -846,7 +864,8 @@ describe("SettingsView Apps catalog", () => {
|
||||
vi.stubGlobal("open", open);
|
||||
|
||||
renderSettingsView({ initialSection: "apps" });
|
||||
fireEvent.click(await screen.findByRole("button", { name: "MCP" }));
|
||||
await selectToolType("MCP");
|
||||
await showOnlyReadyTools(false);
|
||||
await connectXmind();
|
||||
|
||||
const continueButton = await screen.findByRole("button", { name: "Continue sign-in" });
|
||||
@@ -916,7 +935,8 @@ describe("SettingsView Apps catalog", () => {
|
||||
vi.stubGlobal("open", vi.fn(() => popup));
|
||||
|
||||
renderSettingsView({ initialSection: "apps" });
|
||||
fireEvent.click(await screen.findByRole("button", { name: "MCP" }));
|
||||
await selectToolType("MCP");
|
||||
await showOnlyReadyTools(false);
|
||||
await connectXmind();
|
||||
|
||||
await waitFor(() => expect(statusCalls).toBe(1), { timeout: 2000 });
|
||||
|
||||
@@ -406,11 +406,12 @@ describe("Settings channels", () => {
|
||||
expect(await screen.findByRole("button", { name: "View Enabled channel settings" })).toBeInTheDocument();
|
||||
expect(screen.getByRole("button", { name: "View Enabled dependency channel settings" })).toBeInTheDocument();
|
||||
expect(screen.queryByRole("button", { name: "View Disabled channel settings" })).not.toBeInTheDocument();
|
||||
expect(screen.getByRole("button", { name: "Enabled" })).toHaveAttribute("aria-pressed", "true");
|
||||
expect(screen.getByRole("switch", { name: "Enabled only" })).toBeChecked();
|
||||
expect(screen.queryByText("No installation needed")).not.toBeInTheDocument();
|
||||
expect(screen.queryByText("Requires dependencies")).not.toBeInTheDocument();
|
||||
|
||||
fireEvent.click(screen.getByRole("button", { name: "All" }));
|
||||
await userEvent.click(screen.getByRole("switch", { name: "Enabled only" }));
|
||||
expect(screen.getByRole("switch", { name: "Enabled only" })).not.toBeChecked();
|
||||
expect(screen.getByRole("button", { name: "View Disabled channel settings" })).toBeInTheDocument();
|
||||
});
|
||||
|
||||
@@ -430,7 +431,7 @@ describe("Settings channels", () => {
|
||||
|
||||
expect(await screen.findByRole("button", { name: "View First channel settings" })).toBeInTheDocument();
|
||||
expect(screen.getByRole("button", { name: "View Second channel settings" })).toBeInTheDocument();
|
||||
expect(screen.getByRole("button", { name: "All" })).toHaveAttribute("aria-pressed", "true");
|
||||
expect(screen.getByRole("switch", { name: "Enabled only" })).not.toBeChecked();
|
||||
});
|
||||
|
||||
it("shows all channels by default when only the always-enabled WebUI is enabled", async () => {
|
||||
@@ -453,7 +454,7 @@ describe("Settings channels", () => {
|
||||
|
||||
expect(await screen.findByText("nanobot WebUI")).toBeInTheDocument();
|
||||
expect(screen.getByRole("button", { name: "View Disabled channel settings" })).toBeInTheDocument();
|
||||
expect(screen.getByRole("button", { name: "All" })).toHaveAttribute("aria-pressed", "true");
|
||||
expect(screen.getByRole("switch", { name: "Enabled only" })).not.toBeChecked();
|
||||
});
|
||||
|
||||
it("replaces the installed channel switch with an in-row restart action", async () => {
|
||||
|
||||
@@ -7,7 +7,7 @@ import { NanobotClient } from "@/lib/nanobot-client";
|
||||
import { ClientProvider } from "@/providers/ClientProvider";
|
||||
import type { SettingsPayload } from "@/lib/types";
|
||||
import { DEFAULT_LOCAL_PREFS, LOCAL_PREFS_STORAGE_KEY, readLocalPreferences, writeLocalPreferences } from "@/lib/local-preferences";
|
||||
import { jsonResponse, settingsPayload, renderSettingsView, installSettingsViewTestHooks } from "@/tests/settings-test-utils";
|
||||
import { jsonResponse, settingsPayload, renderSettingsView, installSettingsViewTestHooks, selectToolType } from "@/tests/settings-test-utils";
|
||||
|
||||
const thirdPartyBrandNotice =
|
||||
"Product names, logos, and brands are property of their respective owners. Use is for identification only and does not imply endorsement.";
|
||||
@@ -348,8 +348,8 @@ describe("Settings overview and appearance", () => {
|
||||
|
||||
renderSettingsView();
|
||||
|
||||
expect(await screen.findByText("No CLI Apps available.")).toBeInTheDocument();
|
||||
fireEvent.click(screen.getByRole("button", { name: "Browse MCP tools" }));
|
||||
expect(await screen.findByText("No tools available")).toBeInTheDocument();
|
||||
await selectToolType("MCP");
|
||||
expect(await screen.findByText("Add MCP")).toBeInTheDocument();
|
||||
});
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@ import { SkillsCatalogSettings } from "@/components/settings/SkillsCatalogSettin
|
||||
import { ClientProvider } from "@/providers/ClientProvider";
|
||||
import type { McpPresetInfo } from "@/lib/types";
|
||||
import { __clearLogoFallbackCacheForTests } from "@/hooks/useLogoFallback";
|
||||
import { requestMutationMock, jsonResponse, settingsPayload, renderSettingsView, installSettingsViewTestHooks } from "@/tests/settings-test-utils";
|
||||
import { requestMutationMock, jsonResponse, settingsPayload, renderSettingsView, selectToolType, showOnlyReadyTools, installSettingsViewTestHooks } from "@/tests/settings-test-utils";
|
||||
|
||||
|
||||
const installedAnyGen = {
|
||||
@@ -138,7 +138,8 @@ describe("Settings system domains", () => {
|
||||
|
||||
renderSettingsView();
|
||||
|
||||
fireEvent.click(await screen.findByRole("button", { name: "Agent Plugins" }));
|
||||
await selectToolType("Agent Plugins");
|
||||
await showOnlyReadyTools(false);
|
||||
expect(await screen.findByText("Computer Use")).toBeInTheDocument();
|
||||
expect(screen.getByText(/Control the desktop/)).toBeInTheDocument();
|
||||
fireEvent.click(screen.getByRole("button", { name: "Computer Use" }));
|
||||
@@ -180,12 +181,13 @@ describe("Settings system domains", () => {
|
||||
|
||||
expect(await screen.findByRole("heading", { name: "AnyGen" })).toBeVisible();
|
||||
expect(screen.queryByRole("heading", { name: "Managed plugin" })).not.toBeInTheDocument();
|
||||
fireEvent.click(screen.getByRole("button", { name: "Agent Plugins" }));
|
||||
await selectToolType("Agent Plugins");
|
||||
await showOnlyReadyTools(false);
|
||||
expect(screen.getByRole("heading", { name: "Separate plugin" })).toBeVisible();
|
||||
expect(screen.queryByRole("heading", { name: "Managed plugin" })).not.toBeInTheDocument();
|
||||
fireEvent.change(screen.getByPlaceholderText("Search tools"), { target: { value: "separate" } });
|
||||
expect(screen.getByRole("heading", { name: "Separate plugin" })).toBeVisible();
|
||||
fireEvent.click(screen.getByRole("button", { name: "CLI Apps" }));
|
||||
await selectToolType("CLI Apps");
|
||||
expect(screen.queryByRole("heading", { name: "AnyGen" })).not.toBeInTheDocument();
|
||||
fireEvent.change(screen.getByPlaceholderText("Search tools"), { target: { value: "" } });
|
||||
fireEvent.click(screen.getByRole("button", { name: "Agent Plugin disabled" }));
|
||||
@@ -206,7 +208,8 @@ describe("Settings system domains", () => {
|
||||
return jsonResponse(settingsPayload());
|
||||
}));
|
||||
renderSettingsView({ initialSection: "apps" });
|
||||
fireEvent.click(await screen.findByRole("button", { name: "Agent Plugins" }));
|
||||
await selectToolType("Agent Plugins");
|
||||
await showOnlyReadyTools(false);
|
||||
expect(await screen.findByRole("heading", { name: "Computer Use" })).toBeVisible();
|
||||
});
|
||||
|
||||
@@ -267,7 +270,8 @@ describe("Settings system domains", () => {
|
||||
it("does not hide a standalone heading when the navigation is collapsed or absent", () => {
|
||||
renderSettingsView({ initialSection: "skills", initialSettings: settingsPayload(), showSidebar: false, mainNavigationExpanded: false });
|
||||
expect(screen.getByTestId("settings-section-transition")).toHaveAttribute("data-main-navigation-expanded", "false");
|
||||
expect(screen.getByRole("heading", { name: "Skills", level: 1 })).toBeVisible();
|
||||
expect(screen.getByRole("heading", { name: "Apps", level: 1 })).toBeVisible();
|
||||
expect(screen.getByRole("button", { name: "Skills" })).toHaveAttribute("aria-pressed", "true");
|
||||
});
|
||||
|
||||
it("uses the inline section heading layout to align Apps titles and counts", async () => {
|
||||
@@ -288,10 +292,13 @@ describe("Settings system domains", () => {
|
||||
expect(title.nextElementSibling).not.toHaveClass(className);
|
||||
}
|
||||
|
||||
fireEvent.click(screen.getByRole("button", { name: "MCP" }));
|
||||
await selectToolType("MCP");
|
||||
const mcpTitle = screen.getByRole("heading", { name: "MCP tools" });
|
||||
expect(mcpTitle.parentElement).toHaveClass("settings-section-heading");
|
||||
expect(mcpTitle.nextElementSibling).toHaveTextContent("0");
|
||||
expect(screen.getByRole("switch", { name: "Ready only" })).toBeChecked();
|
||||
expect(screen.getByText("No MCP tools available")).toBeVisible();
|
||||
expect(screen.getByText("Add a custom MCP server below")).toBeVisible();
|
||||
});
|
||||
|
||||
it.each(["cli", "mcp"] as const)(
|
||||
@@ -320,7 +327,7 @@ describe("Settings system domains", () => {
|
||||
}));
|
||||
renderSettingsView({ initialSection: "apps", initialSettings: settingsPayload() });
|
||||
await screen.findByText("AnyGen");
|
||||
if (kind === "mcp") fireEvent.click(screen.getByRole("button", { name: "MCP" }));
|
||||
if (kind === "mcp") await selectToolType("MCP");
|
||||
const row = (await screen.findByText(name)).closest("article")!;
|
||||
const image = row.querySelector("img")!;
|
||||
expect(image).toHaveAttribute("src", logoUrl);
|
||||
@@ -660,10 +667,12 @@ describe("Settings system domains", () => {
|
||||
renderSettingsView({ initialSection: "apps" });
|
||||
|
||||
expect(await screen.findByText("AnyGen")).toBeInTheDocument();
|
||||
expect(screen.getByRole("button", { name: "Ready" })).toHaveAttribute("aria-pressed", "false");
|
||||
expect(screen.getByRole("button", { name: "CLI Apps" })).toHaveAttribute("aria-pressed", "true");
|
||||
expect(screen.getByRole("button", { name: "Agent Plugins" })).toBeInTheDocument();
|
||||
expect(screen.getByRole("button", { name: "MCP" })).toBeInTheDocument();
|
||||
expect(screen.getByRole("switch", { name: "Ready only" })).not.toBeChecked();
|
||||
const filters = within(screen.getByRole("radiogroup", { name: "Tool type" }));
|
||||
expect(filters.getByRole("radio", { name: "All" })).toBeChecked();
|
||||
for (const name of ["CLI Apps", "Agent Plugins", "MCP"]) {
|
||||
expect(filters.getByRole("radio", { name })).toBeInTheDocument();
|
||||
}
|
||||
});
|
||||
|
||||
it("installs optional channel support before enabling and disabling it", async () => {
|
||||
@@ -745,7 +754,6 @@ describe("Settings system domains", () => {
|
||||
renderSettingsView({ initialSection: "channels" });
|
||||
|
||||
const matrixRow = await screen.findByRole("button", { name: "View Matrix settings" });
|
||||
expect(matrixRow).toHaveAttribute("aria-haspopup", "dialog");
|
||||
fireEvent.click(matrixRow);
|
||||
expect(screen.queryByRole("dialog")).not.toBeInTheDocument();
|
||||
expect(screen.queryByRole("switch", { name: "Matrix channel" })).not.toBeInTheDocument();
|
||||
@@ -777,7 +785,9 @@ describe("Settings system domains", () => {
|
||||
);
|
||||
expect(screen.getAllByText("On").length).toBeGreaterThan(0);
|
||||
|
||||
fireEvent.click(screen.getByRole("button", { name: "View Matrix settings" }));
|
||||
const installedRow = screen.getByRole("button", { name: "View Matrix settings" });
|
||||
expect(installedRow).toHaveAttribute("aria-haspopup", "dialog");
|
||||
fireEvent.click(installedRow);
|
||||
expect(screen.getByLabelText("Homeserver")).toBeInTheDocument();
|
||||
expect(screen.getByLabelText("User ID")).toBeInTheDocument();
|
||||
expect(screen.getByLabelText("Device ID")).toBeInTheDocument();
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { cleanup, render } from "@testing-library/react";
|
||||
import { cleanup, render, screen, within } from "@testing-library/react";
|
||||
import userEvent from "@testing-library/user-event";
|
||||
import { afterEach, beforeEach, vi } from "vitest";
|
||||
import { SettingsView } from "@/components/settings/SettingsView";
|
||||
@@ -171,6 +171,16 @@ export async function openPopover(trigger: HTMLElement) {
|
||||
await userEvent.setup().click(trigger);
|
||||
}
|
||||
|
||||
export async function selectToolType(name: string) {
|
||||
const types = await screen.findByRole("radiogroup", { name: "Tool type" });
|
||||
await userEvent.click(within(types).getByRole("radio", { name }));
|
||||
}
|
||||
|
||||
export async function showOnlyReadyTools(ready: boolean) {
|
||||
const toggle = await screen.findByRole("switch", { name: "Ready only" });
|
||||
if ((toggle.getAttribute("aria-checked") === "true") !== ready) await userEvent.click(toggle);
|
||||
}
|
||||
|
||||
export function installSettingsViewTestHooks() {
|
||||
beforeEach(() => {
|
||||
requestMutationMock.mockReset().mockResolvedValue(settingsPayload());
|
||||
|
||||
@@ -3,7 +3,7 @@ import userEvent from "@testing-library/user-event";
|
||||
import { describe, expect, it, vi } from "vitest";
|
||||
|
||||
import type { McpPresetInfo } from "@/lib/types";
|
||||
import { installSettingsViewTestHooks, jsonResponse, renderSettingsView, requestMutationMock, settingsPayload } from "@/tests/settings-test-utils";
|
||||
import { installSettingsViewTestHooks, jsonResponse, renderSettingsView, selectToolType, requestMutationMock, settingsPayload } from "@/tests/settings-test-utils";
|
||||
|
||||
const preset: McpPresetInfo = {
|
||||
name: "docs", display_name: "Docs MCP", category: "productivity", description: "Docs",
|
||||
@@ -26,7 +26,7 @@ function installProxySettings() {
|
||||
}
|
||||
|
||||
async function openMcpSetup() {
|
||||
fireEvent.click(await screen.findByRole("button", { name: "MCP" }));
|
||||
await selectToolType("MCP");
|
||||
fireEvent.click(await screen.findByRole("button", { name: "Manage Docs MCP" }));
|
||||
const parent = await screen.findByRole("dialog", { name: "Docs MCP" });
|
||||
fireEvent.click(within(parent).getByRole("tab", { name: "Connection" }));
|
||||
@@ -103,7 +103,7 @@ describe("Inline shared proxy setup", () => {
|
||||
it("retains MCP tool selections when setup is cancelled", async () => {
|
||||
const { settings } = installProxySettings();
|
||||
renderSettingsView({ initialSection: "apps", initialSettings: settings });
|
||||
fireEvent.click(await screen.findByRole("button", { name: "MCP" }));
|
||||
await selectToolType("MCP");
|
||||
fireEvent.click(await screen.findByRole("button", { name: "Manage Docs MCP" }));
|
||||
const parent = await screen.findByRole("dialog", { name: "Docs MCP" });
|
||||
fireEvent.click(within(parent).getByRole("tab", { name: "Tools" }));
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import { useState, type ComponentProps } from "react";
|
||||
import { act, fireEvent, render, renderHook, screen } from "@testing-library/react";
|
||||
import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
|
||||
|
||||
@@ -32,10 +33,18 @@ vi.mock("@/lib/api", async (importOriginal) => {
|
||||
|
||||
const client = {} as NanobotClient;
|
||||
|
||||
function MarketplaceTestView(props: Omit<ComponentProps<typeof SkillsMarketplace>, "query" | "provider">) {
|
||||
const [query, setQuery] = useState("");
|
||||
return <>
|
||||
<input aria-label="Search skills" value={query} onChange={(event) => setQuery(event.target.value)} />
|
||||
<SkillsMarketplace {...props} query={query} provider="all" />
|
||||
</>;
|
||||
}
|
||||
|
||||
function marketplace(token: string) {
|
||||
return (
|
||||
<ClientProvider client={client} token={token}>
|
||||
<SkillsMarketplace
|
||||
<MarketplaceTestView
|
||||
installedSkills={[]}
|
||||
installing=""
|
||||
onInstallingChange={() => {}}
|
||||
@@ -73,7 +82,7 @@ describe("useSkills", () => {
|
||||
expect(screen.queryByRole("alert")).not.toBeInTheDocument();
|
||||
await act(async () => { resolveRetry({ skills: [] }); });
|
||||
expect(screen.getByText("No skills are available.")).toBeInTheDocument();
|
||||
expect(screen.getByRole("button", { name: "All 0" })).toBeInTheDocument();
|
||||
expect(screen.getByRole("radio", { name: "All 0" })).toBeChecked();
|
||||
|
||||
act(() => { requestSkillsRefresh(); });
|
||||
expect(screen.getByText("No skills are available.")).toBeInTheDocument();
|
||||
@@ -88,6 +97,10 @@ describe("useSkills", () => {
|
||||
target: { value: "" },
|
||||
});
|
||||
expect(screen.getByRole("button", { name: "Open details for weather" })).toBeInTheDocument();
|
||||
fireEvent.click(screen.getByRole("radio", { name: "Disabled 0" }));
|
||||
expect(screen.getByText("No matching skills.")).toBeInTheDocument();
|
||||
fireEvent.click(screen.getByRole("radio", { name: "Enabled 1" }));
|
||||
expect(screen.getByRole("button", { name: "Open details for weather" })).toBeInTheDocument();
|
||||
expect(fetchSkills).toHaveBeenCalledTimes(3);
|
||||
});
|
||||
|
||||
@@ -289,7 +302,7 @@ describe("SkillsMarketplace", () => {
|
||||
originSkill("new/source", "available"),
|
||||
],
|
||||
});
|
||||
render(<ClientProvider client={client} token="tok"><SkillsMarketplace
|
||||
render(<ClientProvider client={client} token="tok"><MarketplaceTestView
|
||||
installedSkills={[{ name: "agent-browser", source: "workspace", description: "Local", available: true }]}
|
||||
installing="" onInstallingChange={vi.fn()}
|
||||
/></ClientProvider>);
|
||||
|
||||
@@ -154,14 +154,20 @@ describe("temporary chat navigation", () => {
|
||||
vi.unstubAllGlobals();
|
||||
});
|
||||
|
||||
it.each(["settings", "apps", "automations", "skills", "channels"])(
|
||||
it.each([
|
||||
["settings", "#/settings"],
|
||||
["apps", "#/apps"],
|
||||
["automations", "#/automations"],
|
||||
["skills", "#/apps?section=skills"],
|
||||
["channels", "#/apps?section=channels"],
|
||||
])(
|
||||
"opens %s directly without mounting chat or retaining a chat query",
|
||||
async (view) => {
|
||||
async (view, canonicalHash) => {
|
||||
window.history.replaceState(null, "", `/#/${view}?chat=websocket%3Aregular`);
|
||||
render(<App />);
|
||||
await screen.findByRole("button", { name: "Back to chat" });
|
||||
act(() => TestSocket.current.open());
|
||||
await waitFor(() => expect(window.location.hash).toBe(`#/${view}`));
|
||||
await waitFor(() => expect(window.location.hash).toBe(canonicalHash));
|
||||
expect(window.history.state.nanobotReturnChat.key).toBe("websocket:regular");
|
||||
expect(screen.queryByTestId("thread-message-region")).not.toBeInTheDocument();
|
||||
const requests = vi.mocked(fetch).mock.calls.map(([url]) => String(url));
|
||||
|
||||
@@ -185,10 +185,10 @@ describe("Sidebar update entry", () => {
|
||||
|
||||
it("renders the same entry in expanded and collapsed navigation", () => {
|
||||
const noop = vi.fn();
|
||||
const props = { sessions: [], activeKey: null, loading: false, newChatActive: false,
|
||||
const props = { sessions: [], activeKey: null, loading: false,
|
||||
onNewChat: noop, onSelect: noop, onRequestDelete: noop, onTogglePin: noop, onRequestRename: noop,
|
||||
onToggleArchive: noop, onToggleGroup: noop, onRequestRenameProject: noop, onNewChatInProject: noop,
|
||||
onOpenSettings: noop, onOpenApps: noop, onOpenSkills: noop, onOpenAutomations: noop, onOpenChannels: noop,
|
||||
onOpenSettings: noop, onOpenApps: noop, onOpenAutomations: noop,
|
||||
onOpenSearch: noop, onToggleArchived: noop, onOpenUpdates: noop,
|
||||
availableUpdate: { version: "0.3.6", onDismiss: noop } };
|
||||
const { rerender } = render(<ClientProvider client={client} token="test"><Sidebar {...props} /></ClientProvider>);
|
||||
|
||||
Reference in new issue
Block a user