fix(webui): simplify existing copy across all locales (#6116)

* fix(webui): clarify Chinese copy and channel field guidance

* fix(webui): complete concise copy across all locales

* fix(webui): limit copy rewrite to existing strings
This commit is contained in:
chengyongru authored and GitHub committed 2026-10-09 17:47:21 +08:00
1 parent de56e5de6b
commit bbe7648868
210 files changed
+4658 -4658

No files matched your search

@@ -793,7 +793,7 @@ describe("AgentActivityCluster", () => {
const toggle = screen.getByTestId("file-edit-diff-toggle");
expect(toggle).toHaveAttribute("aria-expanded", "false");
expect(toggle).toHaveTextContent("View large diff");
expect(toggle).toHaveTextContent("Expand changes");
expect(toggle).toHaveTextContent("165 lines");
expect(screen.queryByTestId("file-edit-diff")).not.toBeInTheDocument();
expect(screen.queryByText("line-1")).not.toBeInTheDocument();
@@ -882,7 +882,7 @@ describe("AgentActivityCluster", () => {
const toggle = screen.getByTestId("file-edit-diff-toggle");
expect(toggle).toHaveAttribute("aria-expanded", "false");
expect(toggle).toHaveTextContent("View diff");
expect(toggle).toHaveTextContent("View changes");
expect(toggle).toHaveTextContent("3 lines");
expect(screen.queryByTestId("file-edit-diff")).not.toBeInTheDocument();
expect(screen.queryByText("return <New />;")).not.toBeInTheDocument();
@@ -940,7 +940,7 @@ describe("AgentActivityCluster", () => {
const toggle = screen.getByTestId("file-edit-diff-toggle");
expect(toggle).toHaveAttribute("aria-expanded", "false");
expect(toggle).toHaveTextContent("View large diff");
expect(toggle).toHaveTextContent("Expand changes");
expect(screen.queryByTestId("file-edit-diff-truncated")).not.toBeInTheDocument();
fireEvent.click(toggle);
+24 -24
View File
@@ -655,15 +655,15 @@ describe("App layout", () => {
render(<App />);
await waitFor(() => expect(connectSpy).toHaveBeenCalled());
await user.click(await screen.findByRole("button", { name: "Choose your AI" }));
await user.click(await screen.findByRole("button", { name: "Choose model" }));
expect(
await screen.findByRole("navigation", { name: "Settings sections" }),
).toBeInTheDocument();
expect(screen.getByText("Model providers")).toBeInTheDocument();
expect(screen.getByText("Providers")).toBeInTheDocument();
expect(screen.getByRole("button", { name: "Add provider" }))
.toBeInTheDocument();
expect(screen.queryByRole("dialog", { name: "Choose your AI" })).not.toBeInTheDocument();
expect(screen.queryByRole("dialog", { name: "Choose model" })).not.toBeInTheDocument();
});
it("places Automations after Skills in the main sidebar", async () => {
@@ -719,16 +719,16 @@ describe("App layout", () => {
const originalTitle = document.title;
expect(within(sidebar).queryByRole("button", { name: "Remote connections" })).not.toBeInTheDocument();
fireEvent.pointerDown(await within(sidebar).findByRole("button", { name: "Switch host" }), { button: 0, ctrlKey: false });
fireEvent.click(await screen.findByRole("menuitem", { name: "Manage connections…" }));
fireEvent.click(await screen.findByRole("menuitem", { name: "Manage connections" }));
expect(await screen.findByRole("heading", { name: "Remote connections" })).toBeVisible();
expect(screen.getByRole("main")).toContainElement(screen.getByRole("region", { name: "Remote connections" }));
expect(screen.queryByRole("dialog")).not.toBeInTheDocument();
expect(sidebar).toBeVisible();
fireEvent.click(await screen.findByRole("button", { name: "Connect to remote nanobot" }));
fireEvent.pointerDown(screen.getByRole("button", { name: "Other ways" }), { button: 0, ctrlKey: false });
fireEvent.click(screen.getByRole("menuitem", { name: "Use existing SSH settings" }));
fireEvent.click(screen.getByRole("menuitem", { name: "SSH connection" }));
const host = await screen.findByRole("textbox", { name: "SSH address" });
expect(screen.getByRole("dialog", { name: "Connect to a server" })).toContainElement(host);
expect(screen.getByRole("dialog", { name: "Add connection" })).toContainElement(host);
expect(window.location.hash).toBe(originalHash);
expect(document.title).toBe(originalTitle);
fireEvent.click(screen.getByRole("button", { name: "Cancel" }));
@@ -753,7 +753,7 @@ describe("App layout", () => {
render(<App />);
const sidebar = await screen.findByRole("navigation", { name: "Sidebar navigation" });
fireEvent.pointerDown(await within(sidebar).findByRole("button", { name: "Switch host" }), { button: 0, ctrlKey: false });
fireEvent.click(await screen.findByRole("menuitem", { name: "Manage connections…" }));
fireEvent.click(await screen.findByRole("menuitem", { name: "Manage connections" }));
expect(await screen.findByRole("region", { name: "Remote connections" })).toBeVisible();
fireEvent.click(within(sidebar).getByRole("button", { name: "Apps" }));
expect(await screen.findByRole("heading", { name: "Apps" })).toBeVisible();
@@ -778,7 +778,7 @@ describe("App layout", () => {
await user.click(await screen.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…" }));
fireEvent.click(await screen.findByRole("menuitem", { name: "Manage connections" }));
await waitFor(() => expect(sheet).not.toBeInTheDocument());
expect(screen.getByRole("main")).toContainElement(screen.getByRole("region", { name: "Remote connections" }));
expect(screen.queryByRole("dialog")).not.toBeInTheDocument();
@@ -976,7 +976,7 @@ describe("App layout", () => {
expect(temporaryTooltip).toHaveTextContent("Temporary chat");
expect(temporaryTooltip).toHaveTextContent("Not saved to history or memory");
expect(within(temporaryTooltip).getByText(
"Reloading, closing, or losing the connection ends these chats.",
"Ends on reload, close, or disconnection.",
)).toHaveClass("font-medium");
await user.unhover(heroTemporaryToggle);
@@ -1014,7 +1014,7 @@ describe("App layout", () => {
await waitFor(() => expect(window.location.hash).toMatch(/^#\/temporary\/[0-9a-f-]+$/));
expect(screen.queryByText("Not saved")).not.toBeInTheDocument();
expect(screen.queryByRole("button", { name: "Clear temporary chat" })).not.toBeInTheDocument();
expect(screen.queryByRole("button", { name: "Clear chat" })).not.toBeInTheDocument();
expect(screen.queryByRole("button", { name: "Temporary chat" })).not.toBeInTheDocument();
});
@@ -1088,7 +1088,7 @@ describe("App layout", () => {
expect(window.location.hash).toBe("#/new");
// Let queued browser navigation events settle before sending the first message.
await act(async () => { await new Promise((resolve) => setTimeout(resolve, 50)); });
expect(await screen.findByRole("button", { name: "Switch working directory" })).toHaveTextContent("selected-project");
expect(await screen.findByRole("button", { name: "Switch directory" })).toHaveTextContent("selected-project");
fireEvent.change(screen.getByLabelText("Message input"), {
target: { value: "project topic" },
});
@@ -1113,7 +1113,7 @@ describe("App layout", () => {
render(<App />);
await waitFor(() => expect(connectSpy).toHaveBeenCalled());
expect(await screen.findByRole("button", { name: "Switch working directory" })).toBeInTheDocument();
expect(await screen.findByRole("button", { name: "Switch directory" })).toBeInTheDocument();
act(() => {
sessionUpdateHandlers.forEach((handler) => handler("selected-chat", "metadata", {
project_path: "/tmp/selected-project",
@@ -1124,7 +1124,7 @@ describe("App layout", () => {
});
fireEvent.click(screen.getByRole("button", { name: "Temporary chat" }));
expect(screen.queryByRole("button", { name: "Switch working directory" })).not.toBeInTheDocument();
expect(screen.queryByRole("button", { name: "Switch directory" })).not.toBeInTheDocument();
expect(screen.queryByText("Full Access")).not.toBeInTheDocument();
fireEvent.change(screen.getByLabelText("Message input"), {
target: { value: "temporary project check" },
@@ -1172,7 +1172,7 @@ describe("App layout", () => {
render(<App />);
await waitFor(() => expect(connectSpy).toHaveBeenCalled());
fireEvent.click(await screen.findByRole("button", { name: "Switch working directory" }));
fireEvent.click(await screen.findByRole("button", { name: "Switch directory" }));
fireEvent.click(screen.getByRole("button", { name: /^Edit path:/ }));
fireEvent.change(await screen.findByRole("combobox"), {
target: { value: projectPath },
@@ -1187,7 +1187,7 @@ describe("App layout", () => {
await waitFor(() => expect(createChatSpy).toHaveBeenCalledTimes(1));
expect(message).toHaveValue("keep this first message");
const projectButton = screen.getByRole("button", { name: "Switch working directory" });
const projectButton = screen.getByRole("button", { name: "Switch directory" });
await waitFor(() => expect(projectButton).toHaveFocus());
expect(screen.getByRole("alert")).toHaveTextContent(
"The gateway rejected this project or access mode. Choose an existing project or a different access mode, then try again.",
@@ -1627,7 +1627,7 @@ describe("App layout", () => {
expect(discoverTab.querySelector("svg")).toBeNull();
fireEvent.click(discoverTab);
expect(
await screen.findByRole("heading", { name: "Trending by marketplace" }),
await screen.findByRole("heading", { name: "Popular skills" }),
).toBeInTheDocument();
expect(
screen.queryByText("Each marketplace keeps its own ranking and install metrics."),
@@ -1930,7 +1930,7 @@ describe("App layout", () => {
fireEvent.click(screen.getByRole("button", { name: "Tasks", exact: true }));
fireEvent.click(screen.getByRole("button", { name: /Past one-shot/ }));
fireEvent.click(screen.getByRole("button", { name: "Edit" }));
await screen.findByRole("dialog", { name: "Edit automation" });
await screen.findByRole("dialog", { name: "Edit task" });
expect(screen.queryByText("Run time must be in the future.")).not.toBeInTheDocument();
expect(
screen.queryByText("Update the prompt and schedule. The linked chat stays unchanged."),
@@ -2429,10 +2429,10 @@ 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."),
screen.queryByText("Deleting this topic also deletes its linked automations."),
).not.toBeInTheDocument();
fireEvent.click(screen.getByRole("button", { name: "删除" }));
@@ -2949,7 +2949,7 @@ describe("App layout", () => {
expect(
requestMutationSpy.mock.calls.some(([action]) => action === "settings.agent.update"),
).toBe(false);
expect(screen.queryByRole("heading", { name: "Regional" })).not.toBeInTheDocument();
expect(screen.queryByRole("heading", { name: "Region and timezone" })).not.toBeInTheDocument();
expect(
screen.queryByText("Used for schedules and time-aware replies."),
).not.toBeInTheDocument();
@@ -3442,7 +3442,7 @@ describe("App layout", () => {
await waitFor(() => expect(Array.from(grid.children).map(
(pane) => pane.getAttribute("aria-label"),
)).toEqual(["Alpha child"]));
expect(screen.queryByRole("button", { name: "Pane layout" })).not.toBeInTheDocument();
expect(screen.queryByRole("button", { name: "Layout" })).not.toBeInTheDocument();
expect(screen.queryByRole("button", { name: "Add pane" })).not.toBeInTheDocument();
const sidebar = screen.getByRole("navigation", { name: "Sidebar navigation" });
@@ -3625,7 +3625,7 @@ describe("App layout", () => {
const grid = await screen.findByTestId("pane-grid");
expect(Array.from(grid.children).map((pane) => pane.getAttribute("aria-label")))
.toEqual(["Alpha"]);
expect(screen.queryByRole("button", { name: "Pane layout" }))
expect(screen.queryByRole("button", { name: "Layout" }))
.not.toBeInTheDocument();
fireEvent.click(screen.getByRole("button", { name: "Add pane" }));
@@ -3633,7 +3633,7 @@ describe("App layout", () => {
await waitFor(() => expect(createChatSpy).toHaveBeenCalledTimes(1));
await waitFor(() => expect(grid.children).toHaveLength(2));
expect(screen.getByRole("button", { name: "Pane layout" })).toBeInTheDocument();
expect(screen.getByRole("button", { name: "Layout" })).toBeInTheDocument();
expect(window.location.hash).toBe("#/chat/websocket%3Achat-pane");
expect(Array.from(grid.children).map((pane) => pane.getAttribute("aria-label")))
.toEqual(["Alpha", "New topic"]);
@@ -3648,7 +3648,7 @@ describe("App layout", () => {
await waitFor(() => expect(sendMessageSpy).toHaveBeenCalled());
expect(sendMessageSpy.mock.calls.at(-1)?.[0]).toBe("chat-pane");
fireEvent.pointerDown(screen.getByRole("button", { name: "Pane layout" }), {
fireEvent.pointerDown(screen.getByRole("button", { name: "Layout" }), {
button: 0,
ctrlKey: false,
});
@@ -21,7 +21,7 @@ beforeEach(() => { vi.mocked(fetchAutomationChats).mockResolvedValue(choices); }
afterEach(() => { cleanup(); vi.clearAllMocks(); });
async function choose() {
const control = await screen.findByRole("combobox", { name: "Run and reply in" });
const control = await screen.findByRole("combobox", { name: "Run in chat" });
await waitFor(() => expect(control).toBeEnabled());
fireEvent.keyDown(control, { key: "ArrowDown" });
fireEvent.click(await screen.findByRole("option", { name: /Product team/ }));
@@ -53,17 +53,17 @@ it("keeps the original route until acknowledgement and saves the reviewed prompt
finish();
});
expect(await screen.findByRole("status")).toHaveTextContent("Applies from the next run");
expect(screen.getByRole("combobox", { name: "Run and reply in" })).toHaveTextContent("Product team");
expect(screen.getByRole("combobox", { name: "Run and reply in" })).toBeDisabled();
expect(screen.getByRole("combobox", { name: "Run in chat" })).toHaveTextContent("Product team");
expect(screen.getByRole("combobox", { name: "Run in chat" })).toBeDisabled();
await act(async () => refresh({ ...choices, current: target, revision: "rev-2" }));
expect(screen.getByRole("combobox", { name: "Run and reply in" })).toHaveFocus();
expect(screen.getByRole("combobox", { name: "Run in chat" })).toHaveFocus();
expect(props.onAction).not.toHaveBeenCalled();
await user.click(screen.getByRole("button", { name: "Change back to “My planning”" }));
expect(save).toHaveBeenCalledTimes(1);
expect(screen.getByRole("group", { name: "Now" })).toHaveTextContent("Product team");
expect(screen.getByRole("combobox", { name: "Change to" })).toHaveTextContent("My planning");
await user.click(screen.getByRole("button", { name: "Cancel" }));
expect(screen.getByRole("combobox", { name: "Run and reply in" })).toHaveTextContent("Product team");
expect(screen.getByRole("combobox", { name: "Run in chat" })).toHaveTextContent("Product team");
await user.click(screen.getByRole("button", { name: "Change back to “My planning”" }));
await user.click(screen.getByRole("button", { name: "Confirm change" }));
expect(save.mock.calls[1]).toEqual([
@@ -82,7 +82,7 @@ it("uses Chinese for the task menu and the change/cancel path", async () => {
expect(screen.getByRole("menuitem", { name: "停用" })).toBeInTheDocument();
expect(screen.getByRole("menuitem", { name: "删除" })).toBeInTheDocument();
await user.keyboard("{Escape}");
const picker = screen.getByRole("combobox", { name: "运行与回复" });
const picker = screen.getByRole("combobox", { name: "运行对话" });
await waitFor(() => expect(picker).toBeEnabled());
fireEvent.keyDown(picker, { key: "ArrowDown" });
await user.click(await screen.findByRole("option", { name: /Product team/ }));
@@ -95,7 +95,7 @@ it("uses Chinese for the task menu and the change/cancel path", async () => {
expect(screen.getByRole("button", { name: "保存并更换" })).toBeInTheDocument();
await user.click(screen.getByRole("button", { name: "取消" }));
expect(screen.getByRole("heading", { name: "Daily report" })).toBeInTheDocument();
expect(screen.getByRole("combobox", { name: "运行与回复" })).toHaveFocus();
expect(screen.getByRole("combobox", { name: "运行对话" })).toHaveFocus();
expect(save).not.toHaveBeenCalled();
});
@@ -109,10 +109,10 @@ it("keeps change-back available when another proposed change is cancelled", asyn
rerender(<AutomationDetailDialog {...props} job={{ ...job, chat_binding_revision: "rev-2" }} onChangeChat={save} />);
const changeBack = await screen.findByRole("button", { name: "Change back to “My planning”" });
await waitFor(() => expect(changeBack).toBeEnabled());
fireEvent.keyDown(screen.getByRole("combobox", { name: "Run and reply in" }), { key: "ArrowDown" });
fireEvent.keyDown(screen.getByRole("combobox", { name: "Run in chat" }), { key: "ArrowDown" });
await user.click(await screen.findByRole("option", { name: /My planning/ }));
await user.click(screen.getByRole("button", { name: "Cancel" }));
expect(screen.getByRole("combobox", { name: "Run and reply in" })).toHaveTextContent("Product team");
expect(screen.getByRole("combobox", { name: "Run in chat" })).toHaveTextContent("Product team");
expect(screen.getByRole("button", { name: "Change back to “My planning”" })).toBeEnabled();
expect(save).toHaveBeenCalledTimes(1);
});
@@ -129,8 +129,8 @@ it("removes an obsolete save confirmation after another client changes the chat"
vi.mocked(fetchAutomationChats).mockResolvedValue({ ...choices, revision: "rev-3" });
rerender(<AutomationDetailDialog {...props} job={{ ...job, chat_binding_revision: "rev-3" }} onChangeChat={save} />);
await waitFor(() => expect(screen.getByRole("combobox", { name: "Run and reply in" })).toBeEnabled());
expect(screen.getByRole("combobox", { name: "Run and reply in" })).toHaveTextContent("My planning");
await waitFor(() => expect(screen.getByRole("combobox", { name: "Run in chat" })).toBeEnabled());
expect(screen.getByRole("combobox", { name: "Run in chat" })).toHaveTextContent("My planning");
expect(screen.queryByRole("status")).not.toBeInTheDocument();
expect(screen.queryByRole("button", { name: /Change back/ })).not.toBeInTheDocument();
expect(save).toHaveBeenCalledTimes(1);
@@ -146,8 +146,8 @@ it("cancels a chat change without saving the edited instructions", async () => {
await user.type(screen.getByRole("textbox", { name: "Task instructions" }), "Discard this draft");
await user.click(screen.getByRole("button", { name: "Cancel" }));
expect(save).not.toHaveBeenCalled();
expect(screen.getByRole("combobox", { name: "Run and reply in" })).toHaveTextContent("My planning");
expect(screen.getByRole("combobox", { name: "Run and reply in" })).toHaveFocus();
expect(screen.getByRole("combobox", { name: "Run in chat" })).toHaveTextContent("My planning");
expect(screen.getByRole("combobox", { name: "Run in chat" })).toHaveFocus();
await choose();
expect(screen.queryByRole("textbox", { name: "Task instructions" })).not.toBeInTheDocument();
await user.click(screen.getByRole("button", { name: "Edit instructions" }));
@@ -167,7 +167,7 @@ it("keeps a rejected draft and its original revision across polling", async () =
expect(await screen.findByRole("alert")).toHaveTextContent("draft is kept");
expect(screen.getByRole("textbox", { name: "Task instructions" })).toHaveValue("Summarize the work. Reviewed");
await user.click(screen.getByRole("button", { name: "Cancel" }));
expect(screen.getByRole("combobox", { name: "Run and reply in" })).toHaveTextContent("My planning");
expect(screen.getByRole("combobox", { name: "Run in chat" })).toHaveTextContent("My planning");
});
it("does not send the new request to an old host and locks a pending task", async () => {
@@ -176,7 +176,7 @@ it("does not send the new request to an old host and locks a pending task", asyn
expect(fetchAutomationChats).not.toHaveBeenCalled();
expect(screen.queryByRole("combobox")).not.toBeInTheDocument();
rerender(<AutomationDetailDialog {...props} job={{ ...job, state: { pending: true } }} onChangeChat={save} />);
expect(await screen.findByRole("combobox", { name: "Run and reply in" })).toBeDisabled();
expect(await screen.findByRole("combobox", { name: "Run in chat" })).toBeDisabled();
expect(save).not.toHaveBeenCalled();
});
@@ -198,7 +198,7 @@ it("keeps the reviewed chat identity when refreshed choices no longer contain it
expect(screen.getByRole("button", { name: "Save and change" })).toBeDisabled();
expect(save).not.toHaveBeenCalled();
await user.click(screen.getByRole("button", { name: "Cancel" }));
expect(screen.getByRole("combobox", { name: "Run and reply in" })).toHaveTextContent("Renamed planning");
expect(screen.getByRole("combobox", { name: "Run in chat" })).toHaveTextContent("Renamed planning");
});
it("keeps the current chat visible when discovery fails and permits a retry", async () => {
@@ -206,7 +206,7 @@ it("keeps the current chat visible when discovery fails and permits a retry", as
vi.mocked(fetchAutomationChats).mockRejectedValueOnce(new Error("offline"));
render(<AutomationDetailDialog {...props} job={job} onChangeChat={vi.fn()} />);
await user.click(await screen.findByRole("button", { name: "Retry loading chats" }));
await waitFor(() => expect(screen.getByRole("combobox", { name: "Run and reply in" })).toBeEnabled());
await waitFor(() => expect(screen.getByRole("combobox", { name: "Run in chat" })).toBeEnabled());
expect(fetchAutomationChats).toHaveBeenCalledTimes(2);
});
@@ -235,10 +235,10 @@ it("uses live sidebar names through loading, review, save and change-back withou
vi.mocked(fetchAutomationChats).mockImplementationOnce(() => new Promise(done => { resolve = done; }));
const titles = { "websocket:source": "推特大战场", "websocket:target": "产品讨论" };
const { rerender } = render(<NamedChats titles={titles} onSave={save} />);
expect(await screen.findByRole("combobox", { name: "Run and reply in" })).toHaveTextContent("推特大战场");
expect(screen.getByRole("combobox", { name: "Run and reply in" })).toHaveAttribute("aria-busy", "true");
expect(await screen.findByRole("combobox", { name: "Run in chat" })).toHaveTextContent("推特大战场");
expect(screen.getByRole("combobox", { name: "Run in chat" })).toHaveAttribute("aria-busy", "true");
await act(async () => resolve({ ...choices, chats: [source, webTarget] }));
const control = screen.getByRole("combobox", { name: "Run and reply in" });
const control = screen.getByRole("combobox", { name: "Run in chat" });
expect(control).toHaveTextContent("推特大战场");
expect(control).toHaveAttribute("aria-busy", "false");
fireEvent.keyDown(control, { key: "ArrowDown" });
@@ -271,7 +271,7 @@ it("distinguishes identical renamed chats by handle and uses the original title
const save = vi.fn();
vi.mocked(fetchAutomationChats).mockResolvedValue({ ...choices, chats: [source, webTarget] });
const { rerender } = render(<NamedChats titles={{ "websocket:source": "日报", "websocket:target": "日报" }} onSave={save} />);
const control = await screen.findByRole("combobox", { name: "Run and reply in" });
const control = await screen.findByRole("combobox", { name: "Run in chat" });
await waitFor(() => expect(control).toBeEnabled());
expect(control).toHaveTextContent("日报 · @nime");
fireEvent.keyDown(control, { key: "ArrowDown" });
@@ -280,6 +280,6 @@ it("distinguishes identical renamed chats by handle and uses the original title
expect(screen.getByRole("combobox", { name: "Change to" })).toHaveTextContent("日报 · @jeno");
await user.click(screen.getByRole("button", { name: "Cancel" }));
rerender(<NamedChats titles={{}} onSave={save} />);
expect(screen.getByRole("combobox", { name: "Run and reply in" })).toHaveTextContent("My planning");
expect(screen.getByRole("combobox", { name: "Run in chat" })).toHaveTextContent("My planning");
expect(save).not.toHaveBeenCalled();
});
@@ -91,7 +91,7 @@ describe("Automation run time picker", () => {
render(<AutomationEditDialog job={job} saving={false} onSave={save} onOpenChange={onOpenChange} />);
await user.click(screen.getByRole("button", { name: "Choose date" }));
await user.keyboard("{Escape}");
expect(screen.getByRole("dialog", { name: "Edit automation" })).toBeVisible();
expect(screen.getByRole("dialog", { name: "Edit task" })).toBeVisible();
expect(onOpenChange).not.toHaveBeenCalled();
await user.click(screen.getByRole("button", { name: "Choose date" }));
await user.click(screen.getByRole("button", { name: dayName("2099-09-17") }));
+10 -10
View File
@@ -87,7 +87,7 @@ afterEach(() => {
describe("Automation task list and detail sheet", () => {
it("keeps view selection and filters in one persistent panel toolbar", () => {
render(<Harness />);
const views = screen.getByRole("group", { name: "Automation view" });
const views = screen.getByRole("group", { name: "Task view" });
const filters = screen.getByRole("button", { name: /^Filter/ });
const toolbar = views.closest(".automation-panel-toolbar");
expect(toolbar).not.toBeNull();
@@ -115,7 +115,7 @@ describe("Automation task list and detail sheet", () => {
expect(screen.queryByRole("button", { name: /Review on request/ })).not.toBeInTheDocument();
await user.click(screen.getByRole("button", { name: "Tasks", exact: true }));
const row = screen.getByRole("button", { name: /Review on request/ });
expect(within(row).getByText("Triggered by command")).toBeVisible();
expect(within(row).getByText("Command trigger")).toBeVisible();
expect(within(row).queryByText("Waiting for trigger")).not.toBeInTheDocument();
expect(within(row).queryByText(/nanobot trigger/)).not.toBeInTheDocument();
await user.click(row);
@@ -261,7 +261,7 @@ describe("Automation task list and detail sheet", () => {
await user.click(row);
const dialog = screen.getByRole("dialog", { name: "PR watch" });
expect(dialog).not.toHaveAttribute("aria-describedby");
expect(within(dialog).queryByText("Instructions")).not.toBeInTheDocument();
expect(within(dialog).queryByText("Task instructions")).not.toBeInTheDocument();
expect(taskMenuItem("Open a chat")).toHaveAttribute(
"href", "#/chat/websocket%3Ademo",
);
@@ -495,7 +495,7 @@ describe("Automation task list and detail sheet", () => {
await user.click(screen.getByRole("button", { name: "Today" }));
await waitFor(() => expect(surface).toHaveAttribute("data-compact", "true"));
await user.click(screen.getByRole("button", { name: "fast" }));
expect(screen.getByRole("dialog", { name: "Switch model for this chat" })).toBeVisible();
expect(screen.getByRole("dialog", { name: "Switch model" })).toBeVisible();
expect(surface).toHaveAttribute("data-compact", "true");
});
@@ -528,7 +528,7 @@ describe("Automation task list and detail sheet", () => {
render(<Harness payload={{ jobs: [] }} onStartChat={onStartChat} settingsSnapshot={modelSettings} />);
await user.click(screen.getByRole("button", { name: "fast" }));
const picker = screen.getByRole("dialog", { name: "Switch model for this chat" });
const picker = screen.getByRole("dialog", { name: "Switch model" });
await user.click(within(picker).getByRole("option", { name: "deep" }));
expect(screen.getByRole("button", { name: "deep" })).toBeVisible();
@@ -561,7 +561,7 @@ describe("Automation task list and detail sheet", () => {
render(<Harness payload={{ jobs: [] }} onStartChat={() => {}} settingsSnapshot={modelSettings} />);
expect(screen.getByRole("textbox", { name: "Describe an automation" })).toHaveAttribute(
"placeholder",
"What would you like nanobot to automate?",
"What should nanobot automate?",
);
});
@@ -569,7 +569,7 @@ describe("Automation task list and detail sheet", () => {
await act(() => i18n.changeLanguage("zh-CN"));
render(<Harness payload={{ jobs: [] }} onStartChat={() => {}} settingsSnapshot={modelSettings} />);
expect(screen.getByRole("textbox", { name: "描述一个自动任务" })).toHaveAttribute(
"placeholder", "想让 nanobot 自动帮你做什么?",
"placeholder", "想让 nanobot 自动做什么?",
);
});
@@ -601,7 +601,7 @@ describe("Automation task list and detail sheet", () => {
expect(dialog).toHaveClass("max-w-[440px]");
expect(dialog).not.toHaveAttribute("aria-describedby");
expect(dialog.querySelector("p")).toBeNull();
expect(within(dialog).queryByText("Instructions")).not.toBeInTheDocument();
expect(within(dialog).queryByText("Task instructions")).not.toBeInTheDocument();
expect(within(dialog).queryByText("System-managed automation")).not.toBeInTheDocument();
expect(within(dialog).queryByText("Schedule")).not.toBeInTheDocument();
expect(within(dialog).getAllByRole("button")).toHaveLength(2);
@@ -992,7 +992,7 @@ describe("Automation task list and detail sheet", () => {
for (const operation of ["Cancel", "Close"]) {
if (!screen.queryByRole("dialog", { name: "PR watch" })) await user.click(row);
await user.click(screen.getByRole("button", { name: "Edit", exact: true }));
const editor = await screen.findByRole("dialog", { name: "Edit automation" });
const editor = await screen.findByRole("dialog", { name: "Edit task" });
expect(screen.getAllByRole("dialog")).toHaveLength(1);
await user.click(within(editor).getByRole("button", { name: operation, exact: true }));
await waitFor(() => expect(screen.getByRole("dialog", { name: "PR watch" })).toBeVisible());
@@ -1114,7 +1114,7 @@ describe("Automation task list and detail sheet", () => {
render(<Harness payload={{ jobs: [{ ...task, payload: { message } }] }} />);
fireEvent.click(screen.getByRole("button", { name: /PR watch/ }));
const dialog = screen.getByRole("dialog", { name: "PR watch" });
expect(within(dialog).queryByText("Instructions")).not.toBeInTheDocument();
expect(within(dialog).queryByText("Task instructions")).not.toBeInTheDocument();
expect(within(dialog).queryByText("System-managed automation")).not.toBeInTheDocument();
expect(within(dialog).queryByText("Last run")).not.toBeInTheDocument();
expect(within(dialog).getByRole("button", { name: "Edit" })).toBeEnabled();
@@ -123,7 +123,7 @@ describe("CredentialForm", () => {
const password = screen.getByLabelText("Password");
expect(password).toHaveAttribute("aria-invalid", "true");
expect(password).toHaveAccessibleDescription("Required to complete setup.");
fireEvent.click(screen.getByRole("button", { name: "Remove saved credential" }));
fireEvent.click(screen.getByRole("button", { name: "Remove credentials" }));
expect(onClearSecret).toHaveBeenCalledWith("channels.matrix.password", true);
});
+2 -2
View File
@@ -132,7 +132,7 @@ describe("channelSetup", () => {
expect(setup.fields).toEqual([
expect.objectContaining({
key: "channels.discord.groupPolicy",
label: "Group behavior",
label: "Group rules",
defaultValue: "open",
options: [{ value: "open", label: "All messages" }],
}),
@@ -150,7 +150,7 @@ describe("channelSetup", () => {
expect(setup.officialLabel).toBe("打开钉钉开发者后台");
expect(setup.fields).toContainEqual(expect.objectContaining({
key: "channels.dingtalk.allowFrom",
label: "允许的用户",
label: "允许用户",
}));
});
@@ -45,7 +45,7 @@ describe("Copilot device sign-in", () => {
return jsonResponse(payload);
}));
renderSettingsView({ initialSection: "models" });
fireEvent.click(await screen.findByRole("button", { name: "New model preset" }));
fireEvent.click(await screen.findByRole("button", { name: "New preset" }));
fireEvent.change(screen.getByRole("textbox", { name: "Preset name" }), { target: { value: "Draft" } });
await openPopover(screen.getByRole("button", { name: "Select model" }));
fireEvent.click(await screen.findByRole("button", { name: "Sign in again" }));
+1 -1
View File
@@ -111,7 +111,7 @@ describe("host switcher", () => {
const group = screen.getByRole("group", { name: "Switch host" });
expect(within(group).getAllByRole("menuitem")).toHaveLength(count + 1);
expect(group).toHaveClass("overflow-y-auto", "min-h-0");
expect(group).not.toContainElement(screen.getByRole("menuitem", { name: "Manage connections…" }));
expect(group).not.toContainElement(screen.getByRole("menuitem", { name: "Manage connections" }));
await userEvent.type(input, "HOST-6.TEST");
expect(within(group).getAllByRole("menuitem")).toHaveLength(1);
expect(within(group).getByText("Server 6")).toBeVisible();
+5 -5
View File
@@ -543,7 +543,7 @@ describe("webui i18n", () => {
expect(screen.getByRole("listbox", { name: "斜杠命令" })).toBeInTheDocument();
expect(screen.getByText("压缩上下文")).toBeInTheDocument();
expect(screen.getByText("压缩当前对话的上下文并继续对话。")).toBeInTheDocument();
expect(screen.getByText("压缩上下文后继续对话")).toBeInTheDocument();
expect(screen.getByText("/compact")).toBeInTheDocument();
});
@@ -661,13 +661,13 @@ describe("webui i18n", () => {
expect(settings.sections.webSearch).toBe("网络搜索");
expect(settings.byok.tabs.webSearch).toBe("网络搜索");
expect(settings.overview.webSearch).toBe("网络搜索");
expect(settings.overview.workspace).toBe("工作区");
expect(settings.overview.workspace).toBe("工作目录");
expect(settings.skills.installedTab).toBe("已安装");
expect(settings.skills.discoverTab).toBe("发现");
expect(settings.skills.marketplaceProviderFilter).toBe("技能来源");
expect(settings.skills.marketplaceProviderAll).toBe("全部");
expect(settings.skills.marketplaceSearchPlaceholder).toBe("搜索技能");
expect(settings.skills.marketplaceTrendingTitle).toBe("各市场热门技能");
expect(settings.skills.marketplaceTrendingTitle).toBe("热门技能");
});
it("keeps the Simplified Chinese group workflow localized", () => {
@@ -675,7 +675,7 @@ describe("webui i18n", () => {
expect(workbench.tabAria).toBe("分组:{{title}}");
expect(workbench.createGroup).toBe("创建分组");
expect(workbench.renameGroupTitle).toBe("重命名分组");
expect(workbench.renameGroupTitle).toBe("分组改名");
expect(workbench.renameGroupDescription).toBe("为这个分组命名。");
expect(workbench.renameGroupPlaceholder).toBe("分组名称");
expect(workbench.moveTo).toBe("移动到");
@@ -705,6 +705,6 @@ describe("webui i18n", () => {
expect(settings.sections.webSearch).toBe("Busca na web");
expect(settings.byok.tabs.webSearch).toBe("Busca na web");
expect(settings.overview.webSearch).toBe("Busca na web");
expect(settings.overview.workspace).toBe("Espaço de trabalho");
expect(settings.overview.workspace).toBe("Diretório de trabalho");
});
});
@@ -95,7 +95,7 @@ describe("McpManagementDialog", () => {
await waitFor(() => expect(onAction).toHaveBeenCalledWith("test", "docs"));
expect(within(dialog).queryByText("Not inspected")).not.toBeInTheDocument();
expect(within(dialog).getByText("No tools available")).toBeInTheDocument();
fireEvent.click(within(dialog).getByRole("button", { name: "Reload tools" }));
fireEvent.click(within(dialog).getByRole("button", { name: "Refresh tools" }));
expect(onAction).toHaveBeenCalledTimes(2);
});
@@ -145,7 +145,7 @@ describe("McpManagementDialog", () => {
expect(within(dialog).queryByRole("status", { name: "Loading tools…" })).not.toBeInTheDocument();
expect(within(dialog).getByText(message)).toBeInTheDocument();
if (error) expect(within(dialog).getByRole("alert")).toHaveTextContent(error);
fireEvent.click(within(dialog).getByRole("button", { name: "Reload tools" }));
fireEvent.click(within(dialog).getByRole("button", { name: "Refresh tools" }));
expect(onAction).toHaveBeenLastCalledWith("test", "docs");
});
});
+2 -2
View File
@@ -540,7 +540,7 @@ describe("MessageBubble", () => {
);
menuActions(container);
fireEvent.click(screen.getByRole("button", { name: "Fork" }));
fireEvent.click(screen.getByRole("button", { name: "New chat from here" }));
expect(onForkFromHere).toHaveBeenCalledTimes(1);
});
@@ -575,7 +575,7 @@ describe("MessageBubble", () => {
/>);
const actions = menuActions(container);
const copy = screen.getByRole("button", { name: "Copy" });
const fork = screen.getByRole("button", { name: "Fork" });
const fork = screen.getByRole("button", { name: "New chat from here" });
const metadata = actions.querySelector("[data-message-block-metadata]")!;
expect(actions.querySelector("[data-message-block-toolbar]")).toContainElement(copy);
expect(actions.querySelector("[data-message-block-toolbar]")).toContainElement(fork);
+2 -2
View File
@@ -111,8 +111,8 @@ describe("message link actions", () => {
expect(container.querySelectorAll("[data-message-mobile-actions]")).toHaveLength(2);
fireEvent.click(screen.getAllByRole("button", { name: "Message actions" })[1]);
const menu = screen.getByRole("dialog");
expect(within(menu).getByRole("button", { name: "Fork" })).toHaveTextContent("Fork");
fireEvent.click(within(menu).getByRole("button", { name: "Fork" }));
expect(within(menu).getByRole("button", { name: "New chat from here" })).toHaveTextContent("New chat from here");
fireEvent.click(within(menu).getByRole("button", { name: "New chat from here" }));
expect(fork).toHaveBeenCalledWith(1);
await waitFor(() => expect(screen.queryByRole("dialog")).not.toBeInTheDocument());
});
+3 -3
View File
@@ -90,7 +90,7 @@ describe("ModelPresetBadge selected preset tooltip", () => {
expect(onPresetChange).not.toHaveBeenCalled();
await user.click(trigger);
await user.tab();
expect(screen.getByRole("button", { name: "Manage models" })).toHaveFocus();
expect(screen.getByRole("button", { name: "Manage presets" })).toHaveFocus();
await user.keyboard("{Enter}");
expect(onManageModels).toHaveBeenCalledTimes(1);
expect(screen.queryByRole("dialog")).not.toBeInTheDocument();
@@ -106,7 +106,7 @@ describe("ModelPresetBadge selected preset tooltip", () => {
expect(screen.queryByTestId("composer-model-pill-viewport")).not.toBeInTheDocument();
fireEvent.pointerUp(trigger, { pointerId: 1, pointerType: "touch", clientY: 100 });
fireEvent.click(trigger);
expect(screen.getByRole("button", { name: "Manage models" })).toBeInTheDocument();
expect(screen.getByRole("button", { name: "Manage presets" })).toBeInTheDocument();
} finally {
vi.useRealTimers();
}
@@ -122,7 +122,7 @@ describe("ModelPresetBadge selected preset tooltip", () => {
fireEvent.click(current);
expect(onPresetChange).not.toHaveBeenCalled();
fireEvent.click(screen.getByRole("button", { name: "deepseek-chat" }));
fireEvent.click(screen.getByRole("button", { name: "Manage models" }));
fireEvent.click(screen.getByRole("button", { name: "Manage presets" }));
expect(onManageModels).toHaveBeenCalledTimes(1);
});
+2 -2
View File
@@ -20,14 +20,14 @@ describe("paired network route", () => {
it("does not mislabel a saved custom route as a direct connection", () => {
mocks.config = "/private/paired/ssh_route";
render(<PairRouteSettings id="paired" />);
expect(screen.getByRole("combobox")).toHaveTextContent("Saved network route");
expect(screen.getByRole("combobox")).toHaveTextContent("Saved route");
expect(screen.getByRole("button", { name: "Save changes" })).toBeDisabled();
expect(mocks.action).not.toHaveBeenCalled();
});
it("shows direct only when no saved route is configured", () => {
render(<PairRouteSettings id="paired" />);
expect(screen.getByRole("combobox")).toHaveTextContent("Direct connection");
expect(screen.getByText(i18n.t("remote.pair.routeHint"))).toBeVisible();
expect(screen.getByText(i18n.t("remote.pair.routeHint").replace(/\s+/g, " ").trim())).toBeVisible();
expect(screen.getByRole("button", { name: "Save changes" })).toBeDisabled();
});
it("shows saving, then confirms the saved route without connecting", async () => {
+4 -4
View File
@@ -308,8 +308,8 @@ describe("PaneWorkbench", () => {
render(<WorkbenchHarness />);
const header = screen.getByTestId("workbench-header-host");
expect(within(header).getAllByRole("button", { name: "Pane layout" })).toHaveLength(1);
fireEvent.pointerDown(within(header).getByRole("button", { name: "Pane layout" }), {
expect(within(header).getAllByRole("button", { name: "Layout" })).toHaveLength(1);
fireEvent.pointerDown(within(header).getByRole("button", { name: "Layout" }), {
button: 0,
ctrlKey: false,
});
@@ -317,7 +317,7 @@ describe("PaneWorkbench", () => {
expect(screen.getByTestId("pane-grid")).toHaveAttribute("data-layout", "rows");
await waitFor(() => expect(animate).toHaveBeenCalledTimes(2));
fireEvent.pointerDown(within(header).getByRole("button", { name: "Pane layout" }), {
fireEvent.pointerDown(within(header).getByRole("button", { name: "Layout" }), {
button: 0,
ctrlKey: false,
});
@@ -403,7 +403,7 @@ describe("PaneWorkbench", () => {
expect(screen.getByTestId("pane-grid").children).toHaveLength(1);
expect(screen.getByTestId("workbench-pane-gamma")).toBeInTheDocument();
expect(screen.queryByRole("button", { name: "Pane layout" })).not.toBeInTheDocument();
expect(screen.queryByRole("button", { name: "Layout" })).not.toBeInTheDocument();
expect(screen.queryByRole("button", { name: "Add pane" })).not.toBeInTheDocument();
expect(screen.queryByRole("separator")).not.toBeInTheDocument();
+4 -4
View File
@@ -21,16 +21,16 @@ it("lets users type into prompt search immediately after opening it", async () =
]} onJumpToPrompt={onJumpToPrompt} />);
await user.tab();
expect(screen.getByRole("button", { name: "Open prompt navigator" })).toHaveFocus();
expect(screen.getByRole("button", { name: "Message navigation" })).toHaveFocus();
await user.keyboard("{Enter}");
const search = await screen.findByRole("textbox", { name: "Search prompts" });
const search = await screen.findByRole("textbox", { name: "Search messages" });
await waitFor(() => expect(search).toHaveFocus());
await user.keyboard("beta");
expect(search).toHaveValue("beta");
expect(screen.queryByRole("button", { name: "Jump to prompt: alpha" })).not.toBeInTheDocument();
expect(screen.queryByRole("button", { name: "Jump to message: alpha" })).not.toBeInTheDocument();
await user.tab();
expect(screen.getByRole("button", { name: "Jump to prompt: beta" })).toHaveFocus();
expect(screen.getByRole("button", { name: "Jump to message: beta" })).toHaveFocus();
await user.keyboard("{Enter}");
expect(onJumpToPrompt).toHaveBeenCalledWith("two");
await waitFor(() => expect(screen.queryByRole("dialog")).not.toBeInTheDocument());
+10 -10
View File
@@ -58,7 +58,7 @@ function returnedView() {
async function reviewed() {
await screen.findByRole("button", { name: "Copy command" });
chooseOtherWay("Use a connection code instead");
chooseOtherWay("Connection code");
fireEvent.change(await screen.findByRole("textbox", { name: "Connection code" }), { target: { value: "nbpc1.encrypted" } });
fireEvent.click(screen.getByRole("button", { name: "Review connection" }));
await screen.findByRole("heading", { name: "Open this nanobot?" });
@@ -98,7 +98,7 @@ describe("quick pairing", () => {
});
view();
await waitFor(() => expect(screen.getByRole("button", { name: "Copy command" })).toBeEnabled());
chooseOtherWay("Use a connection code instead");
chooseOtherWay("Connection code");
fireEvent.change(screen.getByRole("textbox", { name: "Connection code" }), { target: { value: "nbpc1.expired" } });
fireEvent.click(screen.getByRole("button", { name: "Review connection" }));
const restart = await screen.findByRole("button", { name: "Get a new command" });
@@ -138,7 +138,7 @@ describe("quick pairing", () => {
it("uses the same copyable revocation code block in pairing details", async () => {
returnedView();
await screen.findByRole("heading", { name: "Open this nanobot?" });
fireEvent.click(screen.getByRole("button", { name: "Connection details & revocation" }));
fireEvent.click(screen.getByRole("button", { name: "Manage access" }));
expect(screen.getByText(preview.revoke_command).closest("pre")).not.toBeNull();
fireEvent.click(screen.getByRole("button", { name: "Copy code" }));
expect(await screen.findByRole("button", { name: "Copied" })).toBeVisible();
@@ -181,7 +181,7 @@ describe("quick pairing", () => {
it("keeps the illustration out of code entry and authorization review", async () => {
view();
await waitFor(() => expect(screen.getByRole("button", { name: "Copy command" })).toBeEnabled());
chooseOtherWay("Use a connection code instead");
chooseOtherWay("Connection code");
const dialog = screen.getByRole("dialog");
expect(dialog.querySelector('image[href="/brand/nanobot_mark.svg"]')).toBeNull();
fireEvent.change(screen.getByRole("textbox", { name: "Connection code" }), { target: { value: "nbpc1.encrypted" } });
@@ -332,7 +332,7 @@ describe("quick pairing", () => {
const ssh = vi.fn();
view(ssh);
await waitFor(() => expect(screen.getByRole("button", { name: "Copy command" })).toBeEnabled());
chooseOtherWay("Use a connection code instead");
chooseOtherWay("Connection code");
fireEvent.change(screen.getByRole("textbox", { name: "Connection code" }), { target: { value: "nbpc1.unfinished" } });
mocks.action.mockImplementation(() => new Promise(() => {}));
vi.useFakeTimers();
@@ -340,7 +340,7 @@ describe("quick pairing", () => {
act(() => { vi.advanceTimersByTime(200); });
expect(screen.getByRole("textbox", { name: "Connection code" })).toHaveValue("nbpc1.unfinished");
expect(screen.getByRole("button", { name: "Checking the connection link…" })).toBeDisabled();
chooseOtherWay("Use existing SSH settings");
chooseOtherWay("SSH connection");
expect(ssh).toHaveBeenCalledOnce();
});
it("advances only after copying succeeds and never implies a server connection", async () => {
@@ -372,12 +372,12 @@ describe("quick pairing", () => {
it("keeps a manual code when returning to the simpler command screen", async () => {
view();
await waitFor(() => expect(screen.getByRole("button", { name: "Copy command" })).toBeEnabled());
chooseOtherWay("Use a connection code instead");
chooseOtherWay("Connection code");
await waitFor(() => expect(screen.getByRole("textbox", { name: "Connection code" })).toHaveFocus());
fireEvent.change(screen.getByRole("textbox", { name: "Connection code" }), { target: { value: "nbpc1.unfinished" } });
fireEvent.click(screen.getByRole("button", { name: "Back" }));
expect(screen.queryByRole("textbox")).toBeNull();
chooseOtherWay("Use a connection code instead");
chooseOtherWay("Connection code");
expect(screen.getByRole("textbox", { name: "Connection code" })).toHaveValue("nbpc1.unfinished");
});
it("replaces copied guidance with recovery when the invitation expires", async () => {
@@ -410,7 +410,7 @@ describe("quick pairing", () => {
expect(mocks.action.mock.calls.filter(([action]) => action === "remote.pair_start")).toHaveLength(1);
expect(screen.queryByRole("textbox", { name: /Private key/ })).toBeNull();
expect(screen.queryByRole("textbox", { name: "Connection code" })).toBeNull();
chooseOtherWay("Use existing SSH settings");
chooseOtherWay("SSH connection");
expect(ssh).toHaveBeenCalledOnce();
});
it("reviews public details before storing and opening the connection", async () => {
@@ -437,7 +437,7 @@ describe("quick pairing", () => {
return {};
});
view(); await waitFor(() => expect(screen.getByRole("button", { name: "Copy command" })).toBeEnabled());
chooseOtherWay("Use a connection code instead");
chooseOtherWay("Connection code");
fireEvent.change(await screen.findByRole("textbox", { name: "Connection code" }), { target: { value: "bad-code" } });
fireEvent.click(screen.getByRole("button", { name: "Review connection" }));
expect(await screen.findByRole("alert")).toHaveTextContent(/invalid/);
+39 -39
View File
@@ -105,7 +105,7 @@ describe("remote instance UX", () => {
view();
await screen.findByRole("region", { name: i18n.t(`remote.compatibility.${status}`) });
expect(screen.queryByRole("region", { name: "Server connection lost" })).not.toBeInTheDocument();
fireEvent.click(screen.getByRole("button", { name: "Version & compatibility" }));
fireEvent.click(screen.getByRole("button", { name: "Version check" }));
expect(within(await screen.findByRole("dialog")).getByRole("status")).toHaveTextContent(i18n.t(`remote.compatibility.${status}`));
expect(screen.queryByRole("textbox", { name: "SSH address" })).not.toBeInTheDocument();
expect(readSelectedRemote()?.id).toBe(profile.id);
@@ -116,7 +116,7 @@ describe("remote instance UX", () => {
compatibility: { status, client_version: "1.0.0", host_version: "2.0.0" } }] });
view(); await openDirectory();
fireEvent.pointerDown(screen.getByRole("button", { name: "Manage Team server" }), { button: 0, ctrlKey: false });
fireEvent.click(screen.getByRole("menuitem", { name: "Version & compatibility" }));
fireEvent.click(screen.getByRole("menuitem", { name: "Version check" }));
const dialog = await screen.findByRole("dialog");
expect(within(dialog).getByText("1.0.0")).toBeVisible();
expect(within(dialog).getByText("2.0.0")).toBeVisible();
@@ -129,7 +129,7 @@ describe("remote instance UX", () => {
it("keeps an unchecked host distinct from an incompatible host", async () => {
view(); await openDirectory();
fireEvent.pointerDown(screen.getByRole("button", { name: "Manage Team server" }), { button: 0, ctrlKey: false });
fireEvent.click(screen.getByRole("menuitem", { name: "Version & compatibility" }));
fireEvent.click(screen.getByRole("menuitem", { name: "Version check" }));
const dialog = await screen.findByRole("dialog");
expect(within(dialog).getByRole("status")).toHaveTextContent("Not checked yet");
expect(within(dialog).queryByRole("link")).not.toBeInTheDocument();
@@ -196,8 +196,8 @@ describe("remote instance UX", () => {
fireEvent.pointerDown(screen.getByRole("button", { name: "Manage Team server" }), { button: 0, ctrlKey: false });
fireEvent.click(screen.getByRole("menuitem", { name: i18n.t("remote.pair.route") }));
const dialog = await screen.findByRole("dialog", { name: i18n.t("remote.pair.route") });
expect(within(dialog).getAllByText(i18n.t("remote.pair.routeHint"))).toHaveLength(1);
expect(dialog).toHaveAccessibleDescription(i18n.t("remote.pair.routeHint"));
expect(within(dialog).getAllByText(i18n.t("remote.pair.routeHint").replace(/\s+/g, " ").trim())).toHaveLength(1);
expect(dialog).toHaveAccessibleDescription(i18n.t("remote.pair.routeHint").replace(/\s+/g, " ").trim());
expect(within(dialog).queryByText(i18n.t("remote.pair.routeDescription"))).not.toBeInTheDocument();
expect(within(dialog).getByRole("combobox", { name: i18n.t("remote.pair.route") })).toBeEnabled();
expect(mocks.request).not.toHaveBeenCalled();
@@ -243,7 +243,7 @@ describe("remote instance UX", () => {
mocks.read.mockResolvedValue({ available: true, profiles: [{ ...profile, paired: true, revoke_command: command }] });
view(); await openDirectory();
fireEvent.pointerDown(screen.getByRole("button", { name: "Manage Team server" }), { button: 0, ctrlKey: false });
fireEvent.click(screen.getByRole("menuitem", { name: "Forget server" }));
fireEvent.click(screen.getByRole("menuitem", { name: "Remove connection" }));
const dialog = await screen.findByRole("dialog", { name: "Forget Team server?" });
const code = within(dialog).getByText(command);
expect(code.closest("pre")).not.toBeNull();
@@ -271,7 +271,7 @@ describe("remote instance UX", () => {
expect(await screen.findByRole("dialog", { name: "Forget this connection?" })).toHaveTextContent(i18n.t("remote.sameInstance.forgetHint"));
expect(screen.getByRole("button", { name: "Forget", exact: true })).toBeVisible();
expect(screen.getByRole("button", { name: "Forget", exact: true }).firstElementChild).not.toHaveClass("truncate");
expect(screen.queryByRole("button", { name: "Forget server", exact: true })).not.toBeInTheDocument();
expect(screen.queryByRole("button", { name: "Remove connection", exact: true })).not.toBeInTheDocument();
fireEvent.click(screen.getByRole("button", { name: "Cancel", exact: true }));
expect(mocks.request).not.toHaveBeenCalled();
fireEvent.click(screen.getByRole("button", { name: "Back", exact: true }));
@@ -427,7 +427,7 @@ describe("remote instance UX", () => {
fireEvent.click(screen.getByRole("button", { name: "Other server ubuntu@example.test" }));
expect(await screen.findByRole("alert")).toHaveTextContent(i18n.t("remote.errors.ssh_unreachable"));
expect(readSelectedRemote()?.id).toBe(profile.id);
fireEvent.click(within(screen.getByRole("dialog", { name: "Connect to a server" })).getByRole("button", { name: "Cancel" }));
fireEvent.click(within(screen.getByRole("dialog", { name: "Add connection" })).getByRole("button", { name: "Cancel" }));
expect(within(screen.getByRole("button", { name: "Other server ubuntu@example.test" })).getByRole("status")).toHaveTextContent("Connection error");
expect(screen.getByRole("region", { name: "Remote connections" })).toBeVisible();
});
@@ -469,7 +469,7 @@ describe("remote instance UX", () => {
mocks.read.mockResolvedValue({ available: true, machine_name: "Xubin-Mac", profiles: [{ ...profile, connected: true }] });
view(false, true);
fireEvent.pointerDown(await screen.findByRole("button", { name: "Manage Team server" }), { button: 0, ctrlKey: false });
fireEvent.click(await screen.findByRole("menuitem", { name: "Forget server" }));
fireEvent.click(await screen.findByRole("menuitem", { name: "Remove connection" }));
const dialog = await screen.findByRole("dialog", { name: "Forget Team server?" });
expect(within(dialog).getByRole("note")).toHaveTextContent("Unsaved work may be lost");
expect(within(dialog).getByRole("note")).toHaveTextContent("tabs using this connection");
@@ -516,8 +516,8 @@ describe("remote instance UX", () => {
chooseExistingSSH();
fireEvent.change(screen.getByRole("textbox", { name: "SSH address" }), { target: { value: "ubuntu@203.0.113.1" } });
fireEvent.click(screen.getByRole("button", { name: "Connection options" }));
fireEvent.click(screen.getByRole("button", { name: "Choose file: SSH config file (optional)" }));
await waitFor(() => expect(screen.getByRole("textbox", { name: "SSH config file (optional)" })).toHaveValue("/local/team/ssh_config"));
fireEvent.click(screen.getByRole("button", { name: "Choose file: SSH config" }));
await waitFor(() => expect(screen.getByRole("textbox", { name: "SSH config" })).toHaveValue("/local/team/ssh_config"));
expect(mocks.request).toHaveBeenCalledWith("remote.pick_file", {}, 310_000);
expect(await screen.findByRole("button", { name: "Use cloud-team" })).toBeVisible();
expect(screen.getByRole("textbox", { name: "SSH address" })).toHaveValue("ubuntu@203.0.113.1");
@@ -531,10 +531,10 @@ describe("remote instance UX", () => {
fireEvent.click(screen.getByRole("button", { name: "Connect to remote nanobot" }));
chooseExistingSSH();
fireEvent.click(screen.getByRole("button", { name: "Connection options" }));
fireEvent.change(screen.getByRole("textbox", { name: "Private key path (optional)" }), { target: { value: "/local/ssh-key" } });
fireEvent.click(screen.getByRole("button", { name: "Choose file: Private key path (optional)" }));
await waitFor(() => expect(screen.getByRole("button", { name: "Choose file: Private key path (optional)" })).toBeEnabled());
expect(screen.getByRole("textbox", { name: "Private key path (optional)" })).toHaveValue("/local/ssh-key");
fireEvent.change(screen.getByRole("textbox", { name: "Private key path" }), { target: { value: "/local/ssh-key" } });
fireEvent.click(screen.getByRole("button", { name: "Choose file: Private key path" }));
await waitFor(() => expect(screen.getByRole("button", { name: "Choose file: Private key path" })).toBeEnabled());
expect(screen.getByRole("textbox", { name: "Private key path" })).toHaveValue("/local/ssh-key");
});
it("does not apply a late file choice to a new editor", async () => {
@@ -544,7 +544,7 @@ describe("remote instance UX", () => {
fireEvent.click(screen.getByRole("button", { name: "Connect to remote nanobot" }));
chooseExistingSSH();
fireEvent.click(screen.getByRole("button", { name: "Connection options" }));
fireEvent.click(screen.getByRole("button", { name: "Choose file: Private key path (optional)" }));
fireEvent.click(screen.getByRole("button", { name: "Choose file: Private key path" }));
expect(screen.getByRole("button", { name: "Connect" })).toBeDisabled();
expect(screen.getByText("Choose a file in the system dialog…")).toBeVisible();
fireEvent.click(screen.getByRole("button", { name: "Cancel" }));
@@ -552,7 +552,7 @@ describe("remote instance UX", () => {
chooseExistingSSH();
fireEvent.click(screen.getByRole("button", { name: "Connection options" }));
await act(async () => finish({ path: "/old/choice" }));
expect(screen.getByRole("textbox", { name: "Private key path (optional)" })).toHaveValue("");
expect(screen.getByRole("textbox", { name: "Private key path" })).toHaveValue("");
});
async function addAndInspect() {
@@ -635,7 +635,7 @@ describe("remote instance UX", () => {
await addAndInspect();
expect(await screen.findByText("No nanobot configuration found")).toBeVisible();
expect(screen.getByText("SSH connected")).toBeVisible();
fireEvent.change(screen.getByRole("textbox", { name: "Server's nanobot config path" }), { target: { value: "/srv/bot/config.json" } });
fireEvent.change(screen.getByRole("textbox", { name: "Config path" }), { target: { value: "/srv/bot/config.json" } });
fireEvent.click(screen.getByRole("button", { name: "Open nanobot" }));
await readyRemote();
expect(mocks.inspect).toHaveBeenCalledTimes(1);
@@ -647,8 +647,8 @@ describe("remote instance UX", () => {
expect(await screen.findByRole("alert")).toHaveTextContent("does not confirm a key problem");
expect(screen.queryByText("SSH connected")).not.toBeInTheDocument();
fireEvent.click(screen.getByRole("button", { name: "SSH login settings" }));
expect(screen.getByRole("textbox", { name: "Private key path (optional)" })).toBeVisible();
expect(screen.queryByRole("textbox", { name: "Server's nanobot config path" })).not.toBeInTheDocument();
expect(screen.getByRole("textbox", { name: "Private key path" })).toBeVisible();
expect(screen.queryByRole("textbox", { name: "Config path" })).not.toBeInTheDocument();
expect(screen.getByRole("textbox", { name: "SSH address" })).toHaveValue(profile.host);
});
@@ -659,7 +659,7 @@ describe("remote instance UX", () => {
await waitFor(() => expect(mocks.inspect).toHaveBeenCalledTimes(1));
fireEvent.click(screen.getByRole("button", { name: "Cancel" }));
await act(async () => resolve({ hostname: "server", candidates: [{ config_path: "/srv/bot/config.json", runtime_user: "", service: "" }], incomplete: false }));
expect(screen.queryByRole("dialog", { name: "Connect to a server" })).not.toBeInTheDocument();
expect(screen.queryByRole("dialog", { name: "Add connection" })).not.toBeInTheDocument();
expect(mocks.request.mock.calls.some(([action]) => action === "remote.connect")).toBe(false);
expect(mocks.request.mock.calls.filter(([action]) => action === "remote.save")).toHaveLength(1);
});
@@ -756,7 +756,7 @@ describe("remote instance UX", () => {
message({ type: "surface", theme: "dark", rect: { left: 272, top: 0, width: 900, height: 800 } });
expect(document.documentElement).not.toHaveClass("dark");
message({ type: "open", anchor: { left: 40, top: 500, width: 150, height: 32 } });
fireEvent.click(await screen.findByRole("menuitem", { name: "Manage connections…" }));
fireEvent.click(await screen.findByRole("menuitem", { name: "Manage connections" }));
const panel = screen.getByTestId("remote-management-surface");
expect(panel).toHaveStyle({ left: "272px" });
expect(document.documentElement).toHaveClass("dark");
@@ -786,8 +786,8 @@ describe("remote instance UX", () => {
expect(screen.getByText("本地 nanobot")).toBeInTheDocument();
fireEvent.click(screen.getByRole("button", { name: "连接远程 nanobot" }));
chooseExistingSSH();
expect(screen.getByRole("heading", { name: "连接服务器" })).toBeInTheDocument();
expect(screen.getByRole("dialog", { name: "连接服务器" })).toBeVisible();
expect(screen.getByRole("heading", { name: "添加连接" })).toBeInTheDocument();
expect(screen.getByRole("dialog", { name: "添加连接" })).toBeVisible();
fireEvent.click(screen.getByRole("button", { name: "取消" }));
expect(screen.getByRole("heading", { name: "远程连接" })).toBeInTheDocument();
expect(screen.queryByRole("textbox", { name: "SSH 地址" })).not.toBeInTheDocument();
@@ -867,13 +867,13 @@ describe("remote instance UX", () => {
const frame = await readyRemote();
await openDirectory();
fireEvent.pointerDown(screen.getByRole("button", { name: "Manage Team server" }), { button: 0, ctrlKey: false });
fireEvent.click(await screen.findByRole("menuitem", { name: "Forget server" }));
fireEvent.click(await screen.findByRole("menuitem", { name: "Remove connection" }));
const dialog = await screen.findByRole("dialog", { name: "Forget Team server?" });
mocks.request.mockImplementation(async (action: string) => {
if (action === "remote.remove") throw new Error("local_io_error");
return {};
});
fireEvent.click(within(dialog).getByRole("button", { name: "Forget server" }));
fireEvent.click(within(dialog).getByRole("button", { name: "Remove connection" }));
await within(dialog).findByRole("alert");
expect(readSelectedRemote()?.id).toBe(profile.id);
expect(frame).toBeInTheDocument();
@@ -881,7 +881,7 @@ describe("remote instance UX", () => {
mocks.request.mockResolvedValue({ available: true, profiles: [] });
mocks.read.mockRejectedValue(new Error("directory_unavailable"));
fireEvent.click(within(dialog).getByRole("button", { name: "Forget server" }));
fireEvent.click(within(dialog).getByRole("button", { name: "Remove connection" }));
await waitFor(() => expect(frame).not.toBeInTheDocument());
expect(readSelectedRemote()).toBeNull();
expect(screen.queryByRole("button", { name: "Manage Team server" })).not.toBeInTheDocument();
@@ -903,7 +903,7 @@ describe("remote instance UX", () => {
await screen.findByRole("region", { name: "Server connection lost" });
expect(screen.queryByText("Local conversations")).not.toBeVisible();
expect(screen.getByRole("button", { name: "Reconnect" })).toBeInTheDocument();
fireEvent.click(screen.getByRole("button", { name: "Back to local nanobot" }));
fireEvent.click(screen.getByRole("button", { name: "Back to local" }));
await screen.findByText("Local conversations");
});
@@ -928,7 +928,7 @@ describe("remote instance UX", () => {
mocks.request.mockRejectedValue(new Error("ssh_unreachable"));
view();
await screen.findByRole("region", { name: "Server connection lost" });
fireEvent.click(screen.getByRole("button", { name: "Back to local nanobot" }));
fireEvent.click(screen.getByRole("button", { name: "Back to local" }));
await screen.findByText("Local conversations");
mocks.request.mockResolvedValue(connection);
await openDirectory();
@@ -1002,7 +1002,7 @@ describe("remote instance UX", () => {
expect(mocks.request).not.toHaveBeenCalled();
fireEvent.click(screen.getByRole("button", { name: "Connection options" }));
expect(screen.getByRole("spinbutton", { name: "SSH port" })).toHaveValue(2222);
expect(screen.getByRole("textbox", { name: "Private key path (optional)" })).toHaveValue("~/.ssh/team key");
expect(screen.getByRole("textbox", { name: "Private key path" })).toHaveValue("~/.ssh/team key");
fireEvent.click(screen.getByRole("button", { name: "Connect" }));
await readyRemote();
expect(mocks.request).toHaveBeenCalledWith("remote.save", {
@@ -1066,7 +1066,7 @@ describe("remote instance UX", () => {
await waitFor(() => expect(finish).toBeDefined());
fireEvent.click(screen.getByRole("button", { name: "Cancel" }));
await act(async () => { finish?.(connection); });
expect(screen.queryByRole("dialog", { name: "Connect to a server" })).not.toBeInTheDocument();
expect(screen.queryByRole("dialog", { name: "Add connection" })).not.toBeInTheDocument();
expect(screen.queryByTitle("nanobot on Team server")).not.toBeInTheDocument();
expect(screen.queryByRole("alert")).not.toBeInTheDocument();
expect(readSelectedRemote()).toBeNull();
@@ -1108,7 +1108,7 @@ describe("remote instance UX", () => {
await waitFor(() => expect(finish).toBeDefined());
fireEvent.click(screen.getByRole("button", { name: "Cancel" }));
await act(async () => { finish?.({ fingerprint: "SHA256:example", challenge: "one-use" }); });
expect(screen.queryByRole("dialog", { name: "Connect to a server" })).not.toBeInTheDocument();
expect(screen.queryByRole("dialog", { name: "Add connection" })).not.toBeInTheDocument();
expect(screen.queryByText("SHA256:example")).not.toBeInTheDocument();
});
@@ -1135,14 +1135,14 @@ describe("remote instance UX", () => {
fireEvent.click(screen.getByRole("button", { name: "Connect to remote nanobot" }));
chooseExistingSSH();
const host = screen.getByRole("textbox", { name: "SSH address" });
const dialog = screen.getByRole("dialog", { name: "Connect to a server" });
const dialog = screen.getByRole("dialog", { name: "Add connection" });
expect(dialog).toContainElement(host);
expect(host).toHaveFocus();
expect(within(dialog).getAllByRole("textbox")).toHaveLength(1);
expect(screen.getByRole("button", { name: "Connect to remote nanobot", hidden: true })).toBeInTheDocument();
expect(screen.getByRole("button", { name: "Connect" })).toBeDisabled();
fireEvent.click(screen.getByRole("button", { name: "Cancel" }));
await waitFor(() => expect(screen.queryByRole("dialog", { name: "Connect to a server" })).not.toBeInTheDocument());
await waitFor(() => expect(screen.queryByRole("dialog", { name: "Add connection" })).not.toBeInTheDocument());
expect(screen.getByRole("button", { name: "Connect to remote nanobot" })).toHaveFocus();
expect(screen.getByRole("heading", { name: "Remote connections" })).toBeVisible();
});
@@ -1205,7 +1205,7 @@ describe("remote instance UX", () => {
expect(document.querySelector("header")).toBeNull();
fireEvent.pointerDown(identity, { button: 0, ctrlKey: false });
expect(await screen.findByRole("menuitem", { name: "Local nanobot Xubin-Mac" })).toBeVisible();
expect(screen.getByRole("menuitem", { name: "Manage connections…" })).toBeVisible();
expect(screen.getByRole("menuitem", { name: "Manage connections" })).toBeVisible();
});
it("discovers and filters SSH aliases without connecting, then inherits the selected config", async () => {
@@ -1241,9 +1241,9 @@ describe("remote instance UX", () => {
chooseExistingSSH();
fireEvent.click(screen.getByRole("button", { name: "Connection options" }));
mocks.discover.mockResolvedValue({ hosts: [{ host: "team", source: "/team/ssh_config", ssh_config: "/team/ssh_config" }], files: ["/team/ssh_config"], incomplete: false });
fireEvent.change(screen.getByRole("textbox", { name: "SSH config file (optional)" }), { target: { value: "/team/ssh_config" } });
fireEvent.change(screen.getByRole("textbox", { name: "SSH config" }), { target: { value: "/team/ssh_config" } });
fireEvent.click(await screen.findByRole("button", { name: "Use team" }));
expect(screen.getByRole("textbox", { name: "SSH config file (optional)" })).toHaveValue("/team/ssh_config");
expect(screen.getByRole("textbox", { name: "SSH config" })).toHaveValue("/team/ssh_config");
expect(screen.getByRole("spinbutton", { name: "SSH port" })).toHaveValue(null);
expect(mocks.discover).toHaveBeenCalledWith({ ssh_config: "/team/ssh_config" });
expect(screen.queryByRole("button", { name: "Read hosts" })).not.toBeInTheDocument();
@@ -1272,7 +1272,7 @@ describe("remote instance UX", () => {
chooseExistingSSH();
await waitFor(() => expect(finishOld).toBeDefined());
fireEvent.click(screen.getByRole("button", { name: "Connection options" }));
fireEvent.change(screen.getByRole("textbox", { name: "SSH config file (optional)" }), { target: { value: "/team/config" } });
fireEvent.change(screen.getByRole("textbox", { name: "SSH config" }), { target: { value: "/team/config" } });
await screen.findByRole("button", { name: "Use custom-team" });
await act(async () => { finishOld?.({ hosts: [{ host: "stale-host", source: "/default", ssh_config: "" }], files: ["/default"], incomplete: false }); });
expect(screen.queryByRole("button", { name: "Use stale-host" })).not.toBeInTheDocument();
@@ -1382,7 +1382,7 @@ describe("remote instance UX", () => {
await act(async () => { window.dispatchEvent(new Event("pageshow")); });
expect(screen.getByText(i18n.t(`remote.errors.${code}`))).toBeVisible();
expect(screen.queryByRole("button", { name: "Reconnect" })).not.toBeInTheDocument();
fireEvent.click(screen.getByRole("button", { name: "Manage connections…" }));
fireEvent.click(screen.getByRole("button", { name: "Manage connections" }));
expect(readSelectedRemote()?.id).toBe(profile.id);
expect(screen.getByRole("region", { name: "Remote connections" })).toBeVisible();
expect(mocks.request.mock.calls.filter(([action]) => action === "remote.disconnect")).toHaveLength(0);
@@ -79,7 +79,7 @@ describe("SessionInfoPopover", () => {
await user.click(row);
const detail = screen.getByRole("dialog", { name: "Morning check" });
expect(detail).toHaveClass("max-w-[520px]", "rounded-modal");
expect(within(detail).queryByText("Instructions")).not.toBeInTheDocument();
expect(within(detail).queryByText("Task instructions")).not.toBeInTheDocument();
expect(within(detail).getByText("Check the project status")).toBeInTheDocument();
await user.click(within(detail).getByRole("button", { name: "Close" }));
await waitFor(() => expect(screen.queryByRole("dialog", { name: "Morning check" })).not.toBeInTheDocument());
@@ -143,7 +143,7 @@ describe("SessionInfoPopover", () => {
await user.click(screen.getByRole("button", { name: "Session details" }));
await user.click(await screen.findByRole("button", { name: /Morning check/ }));
await user.click(screen.getByRole("button", { name: "Edit", exact: true }));
const editor = await screen.findByRole("dialog", { name: "Edit automation" });
const editor = await screen.findByRole("dialog", { name: "Edit task" });
expect(screen.getAllByRole("dialog")).toHaveLength(1);
await user.click(within(editor).getByRole("button", { name: "Cancel", exact: true }));
+3 -3
View File
@@ -186,7 +186,7 @@ describe("SettingsView Apps catalog", () => {
fireEvent.click(manage);
const dialog = screen.getByRole("dialog", { name: "Xmind" });
expect(within(dialog).getByRole("tab", { name: "连接" })).toHaveAttribute("aria-selected", "true");
expect(within(dialog).getByText("创建、读取和编辑 Xmind 云端思维导图。")).toHaveClass("sr-only");
expect(within(dialog).getByText("创建、读取和编辑云端思维导图")).toHaveClass("sr-only");
expect(within(dialog).getByText("连接失败", { exact: true })).toBeInTheDocument();
expect(within(dialog).getByRole("button", { name: "移除连接" })).toBeInTheDocument();
const reconnect = within(dialog).getByRole("button", { name: "重新连接" });
@@ -400,7 +400,7 @@ describe("SettingsView Apps catalog", () => {
fireEvent.change(screen.getByLabelText("Headers (JSON)"), {
target: { value: '{"Authorization":"Bearer stale"}' },
});
expect(screen.getByText("Add the request headers used by this server.")).toBeInTheDocument();
expect(screen.getByText("Enter the headers required by the service.")).toBeInTheDocument();
fireEvent.click(oauth);
expect(oauth).toHaveAttribute("aria-pressed", "true");
@@ -507,7 +507,7 @@ describe("SettingsView Apps catalog", () => {
fireEvent.click(await screen.findByRole("button", { name: "MCP" }));
fireEvent.click(await screen.findByRole("button", { name: "Connect Xmind" }));
const callbackInput = await screen.findByRole("textbox", { name: "Full callback URL" });
const callbackInput = await screen.findByRole("textbox", { name: "Callback URL" });
expect(screen.getByText(/localhost page will not load/i)).toBeInTheDocument();
expect(screen.getByRole("status")).toHaveTextContent(
"Finish signing in, then paste the callback URL into nanobot.",
+9 -9
View File
@@ -1036,7 +1036,7 @@ describe("Settings channels", () => {
expect(supportAdvanced).toHaveAttribute("aria-expanded", "true");
expect(support.getByLabelText("App ID")).toBeVisible();
expect(support.getByLabelText("App ID")).toHaveValue("cli_default");
expect(support.getByRole("group", { name: "Topic isolation" })).toBeVisible();
expect(support.getByRole("group", { name: "Topic sessions" })).toBeVisible();
fireEvent.click(productAdvanced);
expect(supportAdvanced).toHaveAttribute("aria-expanded", "false");
@@ -1363,9 +1363,9 @@ describe("Settings channels", () => {
advanced.focus();
await userEvent.setup().keyboard("[Enter]");
expect(advanced).toHaveAttribute("aria-expanded", "true");
const behavior = screen.getByRole("group", { name: "Group behavior" });
const behavior = screen.getByRole("group", { name: "Group rules" });
expect(behavior).toBeVisible();
expect(within(behavior).getByRole("radio", { name: "Mention only" })).toBeChecked();
expect(within(behavior).getByRole("radio", { name: "Mentions only" })).toBeChecked();
expect(within(behavior).getByRole("radio", { name: "All messages" })).toBeInTheDocument();
fireEvent.click(within(behavior).getByRole("radio", { name: "All messages" }));
@@ -1523,7 +1523,7 @@ describe("Settings channels", () => {
fireEvent.change(screen.getByLabelText("Allowed channels"), {
target: { value: "123, 456" },
});
fireEvent.click(within(screen.getByRole("group", { name: "Group behavior" })).getByRole(
fireEvent.click(within(screen.getByRole("group", { name: "Group rules" })).getByRole(
"radio",
{ name: "All messages" },
));
@@ -1639,7 +1639,7 @@ describe("Settings channels", () => {
fireEvent.change(screen.getByLabelText("SMTP username"), { target: { value: "bot@example.com" } });
fireEvent.change(screen.getByLabelText("SMTP password"), { target: { value: "smtp-secret" } });
const consentGroup = screen.getByRole("group", { name: "Allow nanobot to read and send email" });
const consentGroup = screen.getByRole("group", { name: "Email access" });
const notGranted = within(consentGroup).getByRole("radio", { name: "Not granted" });
const granted = within(consentGroup).getByRole("radio", { name: "Granted" });
expect(notGranted).toBeChecked();
@@ -1847,7 +1847,7 @@ describe("Settings channels", () => {
fireEvent.click(screen.getByRole("button", { name: "Advanced" }));
expect(screen.getByLabelText("Allowed channels")).toHaveValue("123, 456");
expect(within(screen.getByRole("group", { name: "Group behavior" })).getByRole(
expect(within(screen.getByRole("group", { name: "Group rules" })).getByRole(
"radio",
{ name: "All messages" },
)).toBeChecked();
@@ -1995,7 +1995,7 @@ describe("Settings channels", () => {
renderSettingsView({ initialSection: "channels" });
fireEvent.click(await screen.findByRole("button", { name: "View Email settings" }));
const consent = screen.getByRole("group", { name: "Allow nanobot to read and send email" });
const consent = screen.getByRole("group", { name: "Email access" });
expect(within(consent).getByRole("radio", { name: "Not granted" })).toBeChecked();
expect(within(consent).getByRole("radio", { name: "Granted" })).toBeInTheDocument();
@@ -2008,9 +2008,9 @@ describe("Settings channels", () => {
fireEvent.click(screen.getByRole("button", { name: "Close", exact: true }));
fireEvent.click(screen.getByRole("button", { name: "View Matrix settings" }));
expect(screen.getByText("Choose one credential method")).toBeInTheDocument();
expect(screen.getByText("Credential method")).toBeInTheDocument();
fireEvent.click(screen.getByRole("button", { name: "Advanced" }));
const matrixBehavior = screen.getByRole("group", { name: "Group behavior" });
const matrixBehavior = screen.getByRole("group", { name: "Group rules" });
expect(within(matrixBehavior).getByRole("radio", { name: "All messages" })).toBeChecked();
expect(within(matrixBehavior).getByRole("radio", { name: "Allowlist" })).toBeInTheDocument();
+15 -15
View File
@@ -124,14 +124,14 @@ describe("Settings models", () => {
return jsonResponse(payload);
}));
renderSettingsView({ initialSection: "models" });
fireEvent.click(await screen.findByRole("button", { name: "New model preset" }));
fireEvent.click(await screen.findByRole("button", { name: "New preset" }));
fireEvent.change(screen.getByRole("textbox", { name: "Preset name" }), {
target: { value: "My unsaved preset" },
});
await openPopover(screen.getByRole("button", { name: "Select model" }));
fireEvent.click(await screen.findByRole("button", { name: "Sign in again" }));
if (mode === "manual") {
fireEvent.change(await screen.findByRole("textbox", { name: "Full callback URL" }), {
fireEvent.change(await screen.findByRole("textbox", { name: "Callback URL" }), {
target: { value: "http://localhost:1455/auth/callback?code=fixture&state=test" },
});
fireEvent.click(screen.getByRole("button", { name: "Finish sign-in" }));
@@ -662,15 +662,15 @@ describe("Settings models", () => {
}),
),
);
fireEvent.click(screen.getByRole("button", { name: "New model preset" }));
expect(screen.getByRole("dialog", { name: "New model preset" })).toBeInTheDocument();
fireEvent.click(screen.getByRole("button", { name: "New preset" }));
expect(screen.getByRole("dialog", { name: "New preset" })).toBeInTheDocument();
expect(screen.getByRole("button", { name: "Save" })).toBeDisabled();
fireEvent.change(screen.getByRole("textbox", { name: "Preset name" }), {
target: { value: "Writer" },
});
await openPopover(screen.getByRole("button", { name: "Select model" }));
const modelSearch = await screen.findByRole("combobox", {
name: "Search or type model ID",
name: "Choose model",
});
fireEvent.change(modelSearch, {
target: { value: "openai/gpt-4o-mini" },
@@ -702,12 +702,12 @@ describe("Settings models", () => {
renderSettingsView({ initialSection: "models", initialSettings: payload });
fireEvent.click(screen.getByRole("button", { name: "New model preset" }));
fireEvent.click(screen.getByRole("button", { name: "New preset" }));
const nameInput = screen.getByRole("textbox", { name: "Preset name" });
fireEvent.change(nameInput, { target: { value: "PRIMARY" } });
await openPopover(screen.getByRole("button", { name: "Select model" }));
const modelSearch = await screen.findByRole("combobox", {
name: "Search or type model ID",
name: "Choose model",
});
fireEvent.change(modelSearch, { target: { value: "openai/gpt-4o-mini" } });
fireEvent.keyDown(modelSearch, { key: "Enter" });
@@ -809,7 +809,7 @@ describe("Settings models", () => {
renderSettingsView({ initialSection: "models", initialSettings: freshPayload });
expect(
await screen.findByRole("button", { name: "New model preset" }),
await screen.findByRole("button", { name: "New preset" }),
).toBeInTheDocument();
});
@@ -1197,7 +1197,7 @@ describe("Settings models", () => {
await togglePresetEditor();
const modelButtons = await screen.findAllByRole("button", { name: /open-codex\/gpt-5\.5/i });
await openPopover(modelButtons[modelButtons.length - 1]);
const input = (await screen.findByPlaceholderText("Search or type model ID")) as HTMLInputElement;
const input = (await screen.findByPlaceholderText("Choose model")) as HTMLInputElement;
expect(input.value).toBe("open-codex/gpt-5.5");
fireEvent.change(input, { target: { value: "openai-codex/gpt-5.5" } });
@@ -1280,7 +1280,7 @@ describe("Settings models", () => {
),
).toBe(false);
fireEvent.change(screen.getByPlaceholderText("Search or type model ID"), {
fireEvent.change(screen.getByPlaceholderText("Choose model"), {
target: { value: "cl" },
});
@@ -1474,12 +1474,12 @@ describe("Settings models", () => {
renderSettingsView({ initialSection: "models" });
const createButton = await screen.findByRole("button", { name: "New model preset" });
const createButton = await screen.findByRole("button", { name: "New preset" });
const previousPointerEvents = document.body.style.pointerEvents;
expect(createButton).toHaveClass("w-full");
fireEvent.click(createButton);
expect(screen.getByRole("dialog", { name: "New model preset" })).toBeInTheDocument();
expect(screen.getByRole("dialog", { name: "New preset" })).toBeInTheDocument();
expect(screen.getByRole("dialog")).toContainElement(screen.getByTestId("model-preset-editor"));
expect(screen.getByRole("textbox", { name: "Preset name" })).toHaveValue("");
fireEvent.click(screen.getByRole("button", { name: /Advanced options/ }));
@@ -1488,14 +1488,14 @@ describe("Settings models", () => {
await waitFor(() => expect(document.body.style.pointerEvents).toBe(previousPointerEvents));
fireEvent.click(screen.getByRole("button", { name: "New model preset" }));
fireEvent.click(screen.getByRole("button", { name: "New preset" }));
const nameInput = await screen.findByRole("textbox", { name: "Preset name" });
expect(nameInput).toHaveValue("");
expect(nameInput).toHaveAttribute("placeholder", "e.g. Fast writing");
await openPopover(screen.getByRole("button", { name: "Select model" }));
const modelSearch = await screen.findByRole("combobox", {
name: "Search or type model ID",
name: "Choose model",
});
fireEvent.change(modelSearch, { target: { value: "openai/gpt-4o-mini" } });
fireEvent.keyDown(modelSearch, { key: "Enter" });
@@ -1506,7 +1506,7 @@ describe("Settings models", () => {
fireEvent.change(nameInput, { target: { value: "Writer" } });
await openPopover(screen.getByRole("button", { name: /openai\/gpt-4o-mini/ }));
const nextModelSearch = await screen.findByRole("combobox", {
name: "Search or type model ID",
name: "Choose model",
});
fireEvent.change(nextModelSearch, { target: { value: "openai/gpt-4.1-mini" } });
fireEvent.keyDown(nextModelSearch, { key: "Enter" });
+2 -2
View File
@@ -81,7 +81,7 @@ describe("Settings overview and appearance", () => {
showSidebar: true,
});
expect(screen.getByText("File edit display")).toBeInTheDocument();
expect(screen.getByText("Edit preview")).toBeInTheDocument();
fireEvent.click(screen.getByRole("button", { name: "Diff" }));
await waitFor(() => {
@@ -150,7 +150,7 @@ describe("Settings overview and appearance", () => {
expect(await screen.findByText("No apps available.")).toBeInTheDocument();
fireEvent.click(screen.getByRole("button", { name: "Browse MCP tools" }));
expect(await screen.findByText("Add MCP server")).toBeInTheDocument();
expect(await screen.findByText("Add MCP")).toBeInTheDocument();
});
it("shows token activity on the overview", async () => {
+12 -12
View File
@@ -52,13 +52,13 @@ describe("Settings providers", () => {
await user.click(screen.getByRole("button", { name: "Add provider" }));
await user.type(screen.getByRole("combobox"), "does-not-exist");
expect(screen.getByRole("status")).toHaveTextContent("No providers match this search.");
await user.click(screen.getByRole("button", { name: "Custom provider", exact: true }));
await user.click(screen.getByRole("button", { name: "Custom", exact: true }));
expect(screen.getAllByRole("dialog")).toHaveLength(1);
await user.type(screen.getByPlaceholderText("My model provider"), "Unsaved gateway");
await user.click(screen.getByRole("button", { name: "Cancel" }));
await user.click(screen.getByRole("button", { name: "Add provider" }));
expect(screen.getByRole("combobox")).toHaveValue("");
await user.click(screen.getByRole("button", { name: "Custom provider", exact: true }));
await user.click(screen.getByRole("button", { name: "Custom", exact: true }));
expect(screen.getByPlaceholderText("My model provider")).toHaveValue("");
expect(requestMutationMock).not.toHaveBeenCalled();
});
@@ -73,8 +73,8 @@ describe("Settings providers", () => {
const dialog = screen.getByRole("dialog", { name: "Add provider" });
expect(dialog).toHaveClass("rounded-t-3xl", "bottom-0");
expect(screen.getByRole("combobox")).not.toHaveFocus();
fireEvent.click(screen.getByRole("button", { name: "Custom provider", exact: true }));
expect(screen.getByRole("dialog", { name: "Custom provider" })).toBe(dialog);
fireEvent.click(screen.getByRole("button", { name: "Custom", exact: true }));
expect(screen.getByRole("dialog", { name: "Custom" })).toBe(dialog);
});
it("adds a built-in provider only after saving and returns focus to Add", async () => {
@@ -105,7 +105,7 @@ describe("Settings providers", () => {
renderSettingsView({ initialSection: "models", initialSettings: payload });
await user.click(screen.getByRole("button", { name: "Add provider" }));
await user.click(custom
? screen.getByRole("button", { name: "Custom provider", exact: true })
? screen.getByRole("button", { name: "Custom", exact: true })
: screen.getByRole("option", { name: "Moonshot" }));
const dialog = screen.getByRole("dialog");
if (custom) {
@@ -121,7 +121,7 @@ describe("Settings providers", () => {
await user.click(within(dialog).getByRole("button", { name: "Back to providers" }));
expect(screen.getByRole("dialog", { name: "Add provider" })).toBe(dialog);
await user.click(custom
? screen.getByRole("button", { name: "Custom provider", exact: true })
? screen.getByRole("button", { name: "Custom", exact: true })
: screen.getByRole("option", { name: "Moonshot" }));
expect(screen.getByPlaceholderText("Enter API key")).toHaveValue("");
await user.click(screen.getByRole("button", { name: "Cancel" }));
@@ -501,7 +501,7 @@ describe("Settings providers", () => {
).toBeInTheDocument();
expect(within(dialog).getByText("Paste the callback URL to continue.")).toBeInTheDocument();
const callbackInput = within(dialog).getByRole("textbox", {
name: "Full callback URL",
name: "Callback URL",
});
expect(callbackInput).toHaveAttribute(
"placeholder",
@@ -923,7 +923,7 @@ describe("Settings providers", () => {
fireEvent.click(
screen.getByRole("button", { name: "Add provider" }),
);
const customOption = await screen.findByRole("button", { name: "Custom provider" });
const customOption = await screen.findByRole("button", { name: "Custom" });
const openRouterOption = screen.getByRole("option", { name: "OpenRouter" });
expect(customOption.querySelector("svg, img")).not.toBeNull();
expect(openRouterOption.querySelector("svg, img")).not.toBeNull();
@@ -941,9 +941,9 @@ describe("Settings providers", () => {
fireEvent.click(screen.getByRole("button", { name: "Advanced options" }));
for (const [title, value] of [
["Extra headers", '{"X-Tenant":"engineering"}'],
["Additional body parameters", '{"service_tier":"priority"}'],
["Additional query parameters", '{"api-version":"2026-01-01"}'],
["Headers", '{"X-Tenant":"engineering"}'],
["Body parameters", '{"service_tier":"priority"}'],
["Query parameters", '{"api-version":"2026-01-01"}'],
]) {
fireEvent.click(screen.getByRole("button", { name: title }));
const editor = screen.getByRole("dialog", { name: title });
@@ -954,7 +954,7 @@ describe("Settings providers", () => {
fireEvent.change(screen.getByLabelText("Network proxy"), {
target: { value: "http://127.0.0.1:7890" },
});
fireEvent.pointerDown(screen.getByRole("button", { name: "Reasoning parameter format" }));
fireEvent.pointerDown(screen.getByRole("button", { name: "Reasoning format" }));
fireEvent.click(await screen.findByRole("menuitem", { name: "enable_thinking" }));
fireEvent.click(screen.getByRole("button", { name: "Save provider" }));
@@ -86,10 +86,10 @@ describe("Runtime configuration settings", () => {
it("edits lists in a dialog, cancels drafts, and retains failed saves for retry", async () => {
const payload = runtimeSettings();
renderSettingsView({ initialSection: "advanced", initialSettings: payload });
const trigger = screen.getByRole("button", { name: "Allowed environment variables", expanded: false });
expect(screen.queryByRole("textbox", { name: "Allowed environment variables" })).not.toBeInTheDocument();
const trigger = screen.getByRole("button", { name: "Environment variables", expanded: false });
expect(screen.queryByRole("textbox", { name: "Environment variables" })).not.toBeInTheDocument();
fireEvent.click(trigger);
let dialog = screen.getByRole("dialog", { name: "Allowed environment variables" });
let dialog = screen.getByRole("dialog", { name: "Environment variables" });
let editor = within(dialog).getByRole("textbox");
expect(editor).toHaveValue("TERM");
await waitFor(() => expect(editor).toHaveFocus());
@@ -99,7 +99,7 @@ describe("Runtime configuration settings", () => {
expect(requestMutationMock).not.toHaveBeenCalled();
fireEvent.click(trigger);
dialog = screen.getByRole("dialog", { name: "Allowed environment variables" });
dialog = screen.getByRole("dialog", { name: "Environment variables" });
editor = within(dialog).getByRole("textbox");
expect(editor).toHaveValue("TERM");
fireEvent.change(editor, { target: { value: " TERM \n\n COLORTERM " } });
@@ -142,7 +142,7 @@ describe("Runtime configuration settings", () => {
requestMutationMock.mockResolvedValue({ ...payload, requires_restart: true,
runtime_config: { ...payload.runtime_config, "tools.exec.timeout": 90 } });
renderSettingsView({ initialSection: "advanced", initialSettings: payload });
fireEvent.change(screen.getByRole("spinbutton", { name: "Command timeout (seconds)" }), { target: { value: "90" } });
fireEvent.change(screen.getByRole("spinbutton", { name: "Command timeout" }), { target: { value: "90" } });
await waitFor(() => expect(requestMutationMock).toHaveBeenCalledWith(
"settings.runtime_config.update", { values: { "tools.exec.timeout": 90 } }, 20_000,
));
@@ -152,7 +152,7 @@ describe("Runtime configuration settings", () => {
it("validates numbers and keeps a failed draft editable", async () => {
requestMutationMock.mockRejectedValue(new Error("Could not save settings"));
renderSettingsView({ initialSection: "advanced", initialSettings: runtimeSettings() });
const field = screen.getByRole("spinbutton", { name: "Command timeout (seconds)" });
const field = screen.getByRole("spinbutton", { name: "Command timeout" });
fireEvent.change(field, { target: { value: "-1" } });
await waitFor(() => expect(field).toHaveFocus());
expect(field).toHaveAttribute("aria-invalid", "true");
@@ -194,7 +194,7 @@ describe("Runtime configuration settings", () => {
jsonResponse(String(input) === "/api/settings" ? payload : {})));
requestMutationMock.mockResolvedValue(payload);
renderSettingsView({ initialSection: "runtime", initialSettings: payload });
fireEvent.click(screen.getByRole("switch", { name: "Use system timezone" }));
fireEvent.click(screen.getByRole("switch", { name: "System timezone" }));
const field = screen.getByRole("button", { name: "Timezone", expanded: false });
expect(field).toBeEnabled();
fireEvent.click(field);
+1 -1
View File
@@ -308,7 +308,7 @@ describe("Settings system domains", () => {
const input = screen.getByRole("textbox", { name: "Describe an automation" });
expect(input).toHaveAttribute(
"placeholder",
"What would you like nanobot to automate?",
"What should nanobot automate?",
);
fireEvent.change(input, { target: { value: "Summarize updates every weekday at 9" } });
fireEvent.click(screen.getByRole("button", { name: "Send message" }));
+20 -20
View File
@@ -84,7 +84,7 @@ describe("session-owned task UI", () => {
: response([task({ state: "done", completed_at: 102 })])));
const user = userEvent.setup();
const view = render(layout({ historyEnabled: true }));
const work = await screen.findByRole("button", { name: /Delegated work/ });
const work = await screen.findByRole("button", { name: /Subtasks/ });
expect(work).toHaveAttribute("aria-expanded", "false");
act(() => { writeLocalPreferences({ ...DEFAULT_LOCAL_PREFS, activityMode: "expanded" }); });
@@ -134,7 +134,7 @@ describe("session-owned task UI", () => {
fetcher.mockImplementation(async (url) => url.endsWith("/webui-thread") ? childThread("## Findings\n\nVerified the full session", false)
: response([task({ revision: 2, state: "done", completed_at: 102 })]));
render(layout({ historyEnabled: true }));
await user.click(await screen.findByRole("button", { name: /Delegated work/ }));
await user.click(await screen.findByRole("button", { name: /Subtasks/ }));
await user.click(screen.getByRole("button", { name: /Config check Completed/ }));
expect(await within(screen.getByRole("dialog")).findByRole("heading", { name: "Findings" })).toBeVisible();
});
@@ -195,7 +195,7 @@ describe("session-owned task UI", () => {
const view = render(layout());
const runningRow = await screen.findByRole("button", { name: /Config check Running/ });
const work = runningRow.closest("section");
const header = within(work!).getByRole("button", { name: /Delegated work/ });
const header = within(work!).getByRole("button", { name: /Subtasks/ });
expect(screen.getByTestId("messages")).toContainElement(runningRow);
expect(header).toHaveAttribute("aria-expanded", "true");
vi.mocked(fetch).mockImplementation(async () => response([task({ revision: 2, state: "done", result: "Verified", completed_at: 102 })]));
@@ -206,10 +206,10 @@ describe("session-owned task UI", () => {
expect(row).toBe(runningRow);
expect(row.closest("section")).toBe(work);
expect(within(screen.getByTestId("composer")).queryByText("Config check")).not.toBeInTheDocument();
expect(work).toHaveAccessibleName("Delegated work");
expect(work).toHaveAccessibleName("Subtasks");
view.unmount();
render(layout());
fireEvent.click(await screen.findByRole("button", { name: /Delegated work Finished: 1/ }));
fireEvent.click(await screen.findByRole("button", { name: /Subtasks Finished: 1/ }));
expect(screen.getByRole("button", { name: /Config check Completed/ })).toBeVisible();
expect(requestMutation).not.toHaveBeenCalled();
});
@@ -221,7 +221,7 @@ describe("session-owned task UI", () => {
})]));
const user = userEvent.setup();
render(layout());
await user.click(await screen.findByRole("button", { name: /Delegated work/ }));
await user.click(await screen.findByRole("button", { name: /Subtasks/ }));
const row = await screen.findByRole("button", { name: /Config check Interrupted/ });
await user.click(row);
const detail = screen.getByRole("dialog", { name: "Config check" });
@@ -229,7 +229,7 @@ describe("session-owned task UI", () => {
expect(detail).toHaveFocus();
expect(within(detail).getByText("Interrupted")).toBeVisible();
expect(within(detail).getByText("Found a conflicting setting")).toBeVisible();
await user.click(within(detail).getByText("Message delivery"));
await user.click(within(detail).getByText("Message status"));
expect(within(detail).getByText("Delivered: 1")).toBeVisible();
expect(screen.queryByRole("button", { name: "Stop Config check" })).not.toBeInTheDocument();
await user.keyboard("{Escape}");
@@ -249,7 +249,7 @@ describe("session-owned task UI", () => {
fireEvent(window, new Event("focus"));
await waitFor(() => expect(fetch).toHaveBeenCalledTimes(2));
await act(async () => { resolveStop(task({ revision: 3, state: "cancelled", completed_at: 102 })); });
await user.click(screen.getByRole("button", { name: /Delegated work Finished: 1/ }));
await user.click(screen.getByRole("button", { name: /Subtasks Finished: 1/ }));
await screen.findByRole("button", { name: /Config check Cancelled/ });
await act(async () => { resolveRefresh(response([task()])); });
expect(screen.queryByRole("button", { name: "Stop Config check" })).not.toBeInTheDocument();
@@ -329,7 +329,7 @@ describe("session-owned task UI", () => {
expect(within(detail).getByRole("link", { name: /Evidence/ })).toHaveAttribute("href", "https://example.com/review");
expect(detail).toBeVisible();
await user.keyboard("{Escape}");
await waitFor(() => expect(screen.getByRole("button", { name: /Delegated work/ })).toHaveFocus());
await waitFor(() => expect(screen.getByRole("button", { name: /Subtasks/ })).toHaveFocus());
expect(requestMutation).not.toHaveBeenCalled();
});
@@ -343,7 +343,7 @@ describe("session-owned task UI", () => {
]));
render(layout({ threadMessages: replay }));
await screen.findByRole("button", { name: /Config check Running/ });
expect(screen.getAllByRole("region", { name: "Delegated work" })).toHaveLength(1);
expect(screen.getAllByRole("region", { name: "Subtasks" })).toHaveLength(1);
const rows = screen.getAllByRole("button", { name: /check Running/ });
expect(rows.map((row) => row.dataset.subagentId)).toEqual(["task-1", "second"]);
vi.mocked(fetch).mockImplementation(async () => response([
@@ -361,7 +361,7 @@ describe("session-owned task UI", () => {
vi.mocked(fetch).mockImplementation(async () => response([task({ origin_message_id: "followup" })]));
render(layout({ threadMessages: [...messages, { id: "followup", role: "user", content: "Check more", turnId: "turn-a" }] }));
await screen.findByRole("button", { name: /Config check Running/ });
const group = screen.getByRole("region", { name: "Delegated work" });
const group = screen.getByRole("region", { name: "Subtasks" });
expect(screen.getByText("Check more").compareDocumentPosition(group) & Node.DOCUMENT_POSITION_FOLLOWING).toBeTruthy();
});
@@ -374,11 +374,11 @@ describe("session-owned task UI", () => {
const user = userEvent.setup();
const view = render(layout());
await screen.findByRole("button", { name: /Config check Running/ });
const otherWork = screen.getByRole("region", { name: "Other delegated work" });
const header = within(otherWork).getByRole("button", { name: /Other delegated work/ });
const otherWork = screen.getByRole("region", { name: "Other tasks" });
const header = within(otherWork).getByRole("button", { name: /Other tasks/ });
expect(header).toHaveAttribute("aria-expanded", "false");
expect(otherWork.compareDocumentPosition(screen.getByText("Inspect config")) & Node.DOCUMENT_POSITION_FOLLOWING).toBeTruthy();
expect(within(screen.getByRole("region", { name: "Delegated work" })).queryByText("Nanjing weather")).not.toBeInTheDocument();
expect(within(screen.getByRole("region", { name: "Subtasks" })).queryByText("Nanjing weather")).not.toBeInTheDocument();
await user.click(header);
expect(within(otherWork).getByText("These tasks have no matching request in the displayed messages.")).toBeVisible();
await user.click(within(otherWork).getByRole("button", { name: /Nanjing weather Completed/ }));
@@ -388,8 +388,8 @@ describe("session-owned task UI", () => {
await user.keyboard("{Escape}");
view.unmount();
render(layout());
const restored = await screen.findByRole("region", { name: "Other delegated work" });
expect(within(restored).getByRole("button", { name: /Other delegated work/ })).toHaveAttribute("aria-expanded", "false");
const restored = await screen.findByRole("region", { name: "Other tasks" });
expect(within(restored).getByRole("button", { name: /Other tasks/ })).toHaveAttribute("aria-expanded", "false");
expect(restored.compareDocumentPosition(screen.getByText("Inspect config")) & Node.DOCUMENT_POSITION_FOLLOWING).toBeTruthy();
expect(requestMutation).not.toHaveBeenCalled();
});
@@ -401,7 +401,7 @@ describe("session-owned task UI", () => {
]));
const user = userEvent.setup();
const view = render(layout());
const otherWork = await screen.findByRole("region", { name: "Other delegated work" });
const otherWork = await screen.findByRole("region", { name: "Other tasks" });
await user.click(within(otherWork).getByRole("button", { name: /Earlier check Running/ }));
const detail = screen.getByRole("dialog", { name: "Earlier check" });
view.rerender(layout({ threadMessages: [
@@ -410,7 +410,7 @@ describe("session-owned task UI", () => {
] }));
expect(detail).toBeVisible();
await user.keyboard("{Escape}");
expect(screen.queryByRole("region", { name: "Other delegated work" })).not.toBeInTheDocument();
expect(screen.queryByRole("region", { name: "Other tasks" })).not.toBeInTheDocument();
const row = screen.getByRole("button", { name: /Earlier check Running/ });
expect(screen.getAllByRole("button", { name: /Earlier check Running/ })).toHaveLength(1);
expect(screen.getByText("Inspect earlier work").compareDocumentPosition(row) & Node.DOCUMENT_POSITION_FOLLOWING).toBeTruthy();
@@ -427,7 +427,7 @@ describe("session-owned task UI", () => {
await screen.findByRole("button", { name: /Sibling check Running/ });
await act(async () => { resolveRead(response([task()])); });
expect(screen.getByRole("button", { name: /Config check Completed/ })).toBeVisible();
expect(screen.getAllByRole("region", { name: "Delegated work" })).toHaveLength(1);
expect(screen.getAllByRole("region", { name: "Subtasks" })).toHaveLength(1);
vi.useFakeTimers();
await act(async () => { vi.advanceTimersByTime(10_000); });
expect(fetch).toHaveBeenCalledTimes(1);
@@ -475,7 +475,7 @@ describe("session-owned task UI", () => {
expect(screen.getByRole("button", { name: /Config check Running/ })).toBeVisible();
vi.mocked(fetch).mockImplementation(async () => response([task({ revision: undefined, state: "done", completed_at: 102 })]));
await act(async () => { await vi.advanceTimersByTimeAsync(3000); });
expect(screen.getByRole("button", { name: /Delegated work Finished: 1/ })).toBeVisible();
expect(screen.getByRole("button", { name: /Subtasks Finished: 1/ })).toBeVisible();
expect(client.onChat).not.toHaveBeenCalled();
view.rerender(layout({ liveEvents: false, visible: false }));
const reads = vi.mocked(fetch).mock.calls.length;
+27 -27
View File
@@ -561,7 +561,7 @@ describe("ThreadComposer", () => {
const input = screen.getByLabelText("Message input");
fireEvent.change(input, { target: { value: "keep this draft" } });
fireEvent.click(screen.getByRole("button", { name: "Remove quoted context" }));
fireEvent.click(screen.getByRole("button", { name: "Remove quote" }));
expect(onQuotedContextChange).toHaveBeenCalledWith(null);
expect(input).toHaveValue("keep this draft");
@@ -579,7 +579,7 @@ describe("ThreadComposer", () => {
expect(screen.getByText("claude-opus-4-5")).toBeInTheDocument();
expect(screen.queryByRole("button", { name: "Search" })).not.toBeInTheDocument();
expect(screen.queryByRole("button", { name: "Reason" })).not.toBeInTheDocument();
expect(screen.queryByRole("button", { name: "Thinking" })).not.toBeInTheDocument();
expect(screen.queryByRole("button", { name: "Deep research" })).not.toBeInTheDocument();
expect(screen.queryByRole("button", { name: "Voice input" })).not.toBeInTheDocument();
const input = screen.getByPlaceholderText("Ask anything...");
@@ -832,7 +832,7 @@ describe("ThreadComposer", () => {
expect(badge).toHaveClass("h-9");
expect(badge).toHaveClass("w-fit");
fireEvent.click(badge);
const picker = screen.getByRole("dialog", { name: "Switch model for this chat" });
const picker = screen.getByRole("dialog", { name: "Switch model" });
expect(picker).toHaveClass("w-[min(18rem,calc(100vw-2rem))]");
expect(badge).toHaveClass("w-fit");
expect(badge.querySelector(".composer-model-pill")).not.toHaveClass("w-full");
@@ -856,8 +856,8 @@ describe("ThreadComposer", () => {
const { badge } = renderPresetComposer("thread", onManageModels);
fireEvent.click(badge);
const picker = screen.getByRole("dialog", { name: "Switch model for this chat" });
fireEvent.click(within(picker).getByRole("button", { name: "Manage models" }));
const picker = screen.getByRole("dialog", { name: "Switch model" });
fireEvent.click(within(picker).getByRole("button", { name: "Manage presets" }));
expect(onManageModels).toHaveBeenCalledTimes(1);
await waitFor(() => expect(screen.queryByRole("dialog")).not.toBeInTheDocument());
@@ -1396,8 +1396,8 @@ describe("ThreadComposer", () => {
});
it.each([
["restricted", "Default Permission", "File access and command execution are restricted to the current working directory."],
["full", "Full Access", "Allows file access and command execution outside the current working directory."],
["restricted", "Default Permission", "Read files, edit files, and run commands only inside the working directory."],
["full", "Full Access", "Allow file access and commands outside the working directory."],
] as const)("explains %s workspace access on hover", async (mode, label, explanation) => {
const user = userEvent.setup();
render(<ThreadComposer onSend={vi.fn()} workspaceScope={{ project_path: "/tmp/project", project_name: "project", access_mode: mode, restrict_to_workspace: mode === "restricted" }} onWorkspaceScopeChange={vi.fn()} />);
@@ -1495,7 +1495,7 @@ describe("ThreadComposer", () => {
/>,
);
await user.click(screen.getByRole("button", { name: "Switch working directory" }));
await user.click(screen.getByRole("button", { name: "Switch directory" }));
expect(await screen.findByRole("button", { name: "/Users/test/.nanobot/workspace" })).toBeInTheDocument();
expect(screen.getByRole("dialog")).toBeInTheDocument();
@@ -1517,7 +1517,7 @@ describe("ThreadComposer", () => {
restrict_to_workspace: false,
}));
await user.click(screen.getByRole("button", { name: "Switch working directory" }));
await user.click(screen.getByRole("button", { name: "Switch directory" }));
await user.click(screen.getByRole("button", { name: /^Edit path:/ }));
const reopenedInput = await screen.findByRole("combobox");
fireEvent.change(reopenedInput, { target: { value: "~/Pictures/Photos" } });
@@ -1560,7 +1560,7 @@ describe("ThreadComposer", () => {
/>,
);
await user.click(screen.getByRole("button", { name: "Switch working directory" }));
await user.click(screen.getByRole("button", { name: "Switch directory" }));
fireEvent.change(await screen.findByRole("combobox"), { target: { value: selectedPath } });
await waitFor(() => expect(screen.getByRole("button", { name: "Confirm" })).toBeEnabled());
@@ -1589,16 +1589,16 @@ describe("ThreadComposer", () => {
/>
);
const { container, rerender } = render(composer(false));
const trigger = screen.getByRole("button", { name: "Switch working directory" });
const trigger = screen.getByRole("button", { name: "Switch directory" });
expect(trigger).toHaveTextContent("workspace");
expect(trigger.closest(".thread-composer-footer-primary")).not.toBeNull();
expect(trigger.closest(".thread-composer-workspace-group")).toContainElement(screen.getByRole("button", { name: "Workspace access mode: Full Access" }));
expect(container.querySelector("[data-composer-workspace-drawer]")).not.toBeInTheDocument();
rerender(composer(true));
expect(screen.queryByRole("button", { name: "Switch working directory" })).not.toBeInTheDocument();
expect(screen.queryByRole("button", { name: "Switch directory" })).not.toBeInTheDocument();
expect(screen.queryByRole("button", { name: "Workspace access mode: Full Access" })).not.toBeInTheDocument();
rerender(composer(false));
expect(screen.getByRole("button", { name: "Switch working directory" })).toBeEnabled();
expect(screen.getByRole("button", { name: "Switch directory" })).toBeEnabled();
});
it("places the directory left and access right on narrow composers, moving them into the toolbar on desktop", () => {
@@ -1610,7 +1610,7 @@ describe("ThreadComposer", () => {
{...workspacePickerProps(defaultScope)} workspaceControls={{ can_change_project: true }} onWorkspaceScopeChange={vi.fn()} />);
const input = screen.getByRole("textbox");
const row = container.querySelector(".thread-composer-workspace-row")!;
const trigger = screen.getByRole("button", { name: "Switch working directory" });
const trigger = screen.getByRole("button", { name: "Switch directory" });
expect(row).toContainElement(trigger);
expect(trigger.closest(".ml-auto")).toBeNull();
const access = screen.getByRole("button", { name: "Workspace access mode: Full Access" });
@@ -1618,10 +1618,10 @@ describe("ThreadComposer", () => {
expect(access.closest(".ml-auto")).not.toBeNull();
width = 800;
fireEvent(window, new Event("resize"));
expect(screen.getByRole("button", { name: "Switch working directory" }).closest(".thread-composer-footer-primary")).not.toBeNull();
expect(screen.getByRole("button", { name: "Switch directory" }).closest(".thread-composer-footer-primary")).not.toBeNull();
expect(container.querySelector("[data-composer-workspace-drawer]")).not.toBeInTheDocument();
expect(screen.getByRole("textbox")).toBe(input);
expect(screen.getAllByRole("button", { name: "Switch working directory" })).toHaveLength(1);
expect(screen.getAllByRole("button", { name: "Switch directory" })).toHaveLength(1);
});
it("browses and selects the connected host's project in one dialog on a native client", async () => {
@@ -1673,13 +1673,13 @@ describe("ThreadComposer", () => {
/>,
);
await user.click(screen.getByRole("button", { name: "Switch working directory" }));
expect(screen.getByRole("dialog", { name: "Choose a working folder" })).toBeInTheDocument();
await user.click(screen.getByRole("button", { name: "Switch directory" }));
expect(screen.getByRole("dialog", { name: "Choose directory" })).toBeInTheDocument();
await user.click(await screen.findByRole("option", { name: project.path }));
await waitFor(() => expect(screen.getByRole("button", { name: "Confirm" })).toBeEnabled());
expect(onWorkspaceScopeChange).not.toHaveBeenCalled();
await user.click(screen.getByRole("button", { name: "Confirm" }));
await waitFor(() => expect(screen.queryByRole("dialog", { name: "Choose a working folder" })).not.toBeInTheDocument());
await waitFor(() => expect(screen.queryByRole("dialog", { name: "Choose directory" })).not.toBeInTheDocument());
expect(onResolveWorkspaceProject).toHaveBeenCalledWith(project.path);
expect(onWorkspaceScopeChange).toHaveBeenCalledWith(expect.objectContaining({
project_path: project.path,
@@ -1714,7 +1714,7 @@ describe("ThreadComposer", () => {
/>,
);
await user.click(screen.getByRole("button", { name: "Switch working directory" }));
await user.click(screen.getByRole("button", { name: "Switch directory" }));
expect(await screen.findByRole("combobox")).toBeInTheDocument();
@@ -1889,7 +1889,7 @@ describe("ThreadComposer", () => {
const input = screen.getByLabelText("Message input");
fireEvent.change(input, { target: { value: "/" } });
expect(screen.getByRole("option", { name: /Stop current task/i })).toHaveAttribute(
expect(screen.getByRole("option", { name: /Stop task/i })).toHaveAttribute(
"aria-selected",
"true",
);
@@ -2886,7 +2886,7 @@ describe("ThreadComposer", () => {
/>,
);
expect(screen.queryByRole("button", { name: "Toggle image generation mode" })).not.toBeInTheDocument();
expect(screen.queryByRole("button", { name: "Image mode" })).not.toBeInTheDocument();
expect(screen.queryByRole("button", { name: "Image aspect ratio" })).not.toBeInTheDocument();
const input = screen.getByLabelText("Message input");
@@ -3440,7 +3440,7 @@ describe("ThreadComposer", () => {
expect(queue.parentElement?.className).toContain("group/composer");
expect(within(queue).getByText("first follow-up")).toBeInTheDocument();
expect(within(queue).getByText("second follow-up")).toBeInTheDocument();
expect(within(queue).getAllByRole("button", { name: "Edit guidance" })).toHaveLength(2);
expect(within(queue).getAllByRole("button", { name: "Edit message" })).toHaveLength(2);
expect(within(queue).getAllByRole("button", { name: "Send now" })).toHaveLength(2);
rerender(
@@ -3498,7 +3498,7 @@ describe("ThreadComposer", () => {
fireEvent.change(input, { target: { value: "rough follow-up" } });
fireEvent.keyDown(input, { key: "Enter" });
const editButton = screen.getByRole("button", { name: "Edit guidance" });
const editButton = screen.getByRole("button", { name: "Edit message" });
const textarea = input as HTMLTextAreaElement;
const setSelection = textarea.setSelectionRange.bind(textarea);
const focusedSelections: boolean[] = [];
@@ -3548,7 +3548,7 @@ describe("ThreadComposer", () => {
fireEvent.change(input, { target: { value: "second follow-up" } });
fireEvent.keyDown(input, { key: "Enter" });
fireEvent.click(screen.getAllByRole("button", { name: "Edit guidance" })[0]);
fireEvent.click(screen.getAllByRole("button", { name: "Edit message" })[0]);
await waitFor(() => {
expect(input).toHaveValue("first follow-up");
});
@@ -3619,7 +3619,7 @@ describe("ThreadComposer", () => {
expect(screen.getByText("look at this")).toBeInTheDocument();
expect(screen.queryByTestId("composer-chip")).not.toBeInTheDocument();
fireEvent.click(screen.getByRole("button", { name: "Edit guidance" }));
fireEvent.click(screen.getByRole("button", { name: "Edit message" }));
expect(input).toHaveValue("look at this");
expect(screen.getByTestId("composer-chip")).toHaveTextContent("draft.png");
expect(screen.queryByRole("group", { name: "Waiting to send" })).not.toBeInTheDocument();
@@ -3789,7 +3789,7 @@ describe("ThreadComposer", () => {
const input = screen.getByLabelText("Message input");
fireEvent.change(input, { target: { value: "remember this follow-up" } });
fireEvent.keyDown(input, { key: "Enter" });
fireEvent.click(screen.getByRole("button", { name: "Edit guidance" }));
fireEvent.click(screen.getByRole("button", { name: "Edit message" }));
fireEvent.change(input, { target: { value: "remember this edited follow-up" } });
fireEvent.keyDown(input, { key: "Enter" });
expect(screen.getByText("remember this edited follow-up")).toBeInTheDocument();
+2 -2
View File
@@ -29,7 +29,7 @@ function assistantActionCounts(root: ParentNode = document) {
if (!row.querySelector("[data-message-block-menu-trigger]")) continue;
const { menu } = openMessageBlockMenu(row);
counts.copy += within(menu).queryAllByRole("button", { name: "Copy", exact: true }).length;
counts.fork += within(menu).queryAllByRole("button", { name: "Fork", exact: true }).length;
counts.fork += within(menu).queryAllByRole("button", { name: "New chat from here", exact: true }).length;
fireEvent.keyDown(menu, { key: "Escape" });
}
return counts;
@@ -681,7 +681,7 @@ describe("ThreadMessages", () => {
} as unknown as Selection);
document.dispatchEvent(new Event("selectionchange"));
const action = await screen.findByRole("button", { name: "Ask about this" });
const action = await screen.findByRole("button", { name: "Ask about selection" });
fireEvent.click(action);
await waitFor(() => expect(onQuoteSelection).toHaveBeenCalledWith("selected answer"));
+15 -15
View File
@@ -512,7 +512,7 @@ describe("ThreadShell", () => {
onToggleSidebar={() => {}} />, null, "tok", ["webui.core.v1", "webui.subagents.v1"]);
const view = render(shell());
await screen.findByText("Delegate inspection");
fireEvent.click(await screen.findByRole("button", { name: /Delegated work Finished: 1/ }));
fireEvent.click(await screen.findByRole("button", { name: /Subtasks Finished: 1/ }));
const task = await screen.findByRole("button", { name: /Inspect settings Completed/ });
await screen.findByText("Delegate inspection");
expect(screen.getAllByRole("button", { name: /Inspect settings/ })).toHaveLength(1);
@@ -521,7 +521,7 @@ describe("ThreadShell", () => {
view.unmount();
render(shell());
await screen.findByText("Delegate inspection");
fireEvent.click(await screen.findByRole("button", { name: /Delegated work Finished: 1/ }));
fireEvent.click(await screen.findByRole("button", { name: /Subtasks Finished: 1/ }));
await screen.findByRole("button", { name: /Inspect settings Completed/ });
expect(client.sendMessage).not.toHaveBeenCalled();
});
@@ -611,7 +611,7 @@ describe("ThreadShell", () => {
const view = render(shell("draft-a"));
expect(screen.getByRole("textbox")).toHaveValue("draft A");
expect(screen.getByLabelText("Quoted context")).toHaveTextContent("quote A");
fireEvent.click(screen.getByRole("button", { name: "Remove quoted context" }));
fireEvent.click(screen.getByRole("button", { name: "Remove quote" }));
view.rerender(shell("draft-b"));
expect(screen.getByRole("textbox")).toHaveValue("draft B");
expect(screen.getByLabelText("Quoted context")).toHaveTextContent("quote B");
@@ -1201,7 +1201,7 @@ describe("ThreadShell", () => {
fireEvent.focus(await screen.findByLabelText("fast"));
expect(await screen.findByRole("tooltip")).toHaveTextContent("fast gpt-5.5 OpenAI Codex");
fireEvent.blur(screen.getByLabelText("fast"));
expect(screen.queryByRole("button", { name: "Choose your AI" })).not.toBeInTheDocument();
expect(screen.queryByRole("button", { name: "Choose model" })).not.toBeInTheDocument();
});
it("switches through every named preset while preserving call-order priority", async () => {
@@ -1285,7 +1285,7 @@ describe("ThreadShell", () => {
fireEvent.focus(await screen.findByLabelText("fast"));
expect(await screen.findByRole("tooltip")).toHaveTextContent("fast gpt-4 Company Proxy");
fireEvent.blur(screen.getByLabelText("fast"));
expect(screen.queryByRole("button", { name: "Choose your AI" })).not.toBeInTheDocument();
expect(screen.queryByRole("button", { name: "Choose model" })).not.toBeInTheDocument();
});
it("keeps the selected composer preset and attributes only the reply to its actual source", async () => {
@@ -1477,7 +1477,7 @@ describe("ThreadShell", () => {
));
await screen.findByText(hasHistory ? "Previous message" : HERO_GREETING_PATTERN);
const badge = screen.getByRole("button", { name: "Choose your AI" });
const badge = screen.getByRole("button", { name: "Choose model" });
fireEvent.focus(badge);
expect(screen.queryByRole("tooltip")).not.toBeInTheDocument();
fireEvent.click(badge);
@@ -1524,12 +1524,12 @@ describe("ThreadShell", () => {
),
);
const badge = await screen.findByRole("button", { name: "Choose your AI" });
const badge = await screen.findByRole("button", { name: "Choose model" });
expect(screen.queryByTestId("composer-model-setup-icon")).not.toBeInTheDocument();
expect(badge.querySelector('[data-needs-setup="true"]')).toHaveClass(
"composer-model-pill-setup",
);
expect(screen.getByTestId("composer-model-setup-label")).toHaveTextContent("Choose your AI");
expect(screen.getByTestId("composer-model-setup-label")).toHaveTextContent("Choose model");
expect(badge).not.toHaveClass("border-amber-500/35");
expect(screen.queryByTestId("composer-model-logo-openai_codex")).not.toBeInTheDocument();
@@ -1539,7 +1539,7 @@ describe("ThreadShell", () => {
});
fireEvent.click(badge);
expect(screen.queryByRole("dialog", { name: "Choose your AI" })).not.toBeInTheDocument();
expect(screen.queryByRole("dialog", { name: "Choose model" })).not.toBeInTheDocument();
expect(onOpenModelSettings).toHaveBeenCalledTimes(1);
expect(input).toHaveValue("hello");
expect(client.sendMessage).not.toHaveBeenCalled();
@@ -1585,7 +1585,7 @@ describe("ThreadShell", () => {
);
await screen.findByLabelText("Message input");
expect(screen.queryByRole("button", { name: "Toggle image generation mode" })).not.toBeInTheDocument();
expect(screen.queryByRole("button", { name: "Image mode" })).not.toBeInTheDocument();
await act(async () => {
rerender(
@@ -1602,7 +1602,7 @@ describe("ThreadShell", () => {
);
});
expect(screen.queryByRole("button", { name: "Toggle image generation mode" })).not.toBeInTheDocument();
expect(screen.queryByRole("button", { name: "Image mode" })).not.toBeInTheDocument();
});
it("restores in-memory messages when switching away and back to a session", async () => {
@@ -2133,7 +2133,7 @@ describe("ThreadShell", () => {
expect(greeting).toHaveClass("select-none", "whitespace-nowrap");
expect(screen.getByRole("textbox")).toBeInTheDocument();
expect(screen.queryByRole("button", { name: "Write code" })).not.toBeInTheDocument();
expect(screen.queryByRole("button", { name: "Create a project plan" })).not.toBeInTheDocument();
expect(screen.queryByRole("button", { name: "Make a plan" })).not.toBeInTheDocument();
});
it("does not leak the previous thread when opening a brand-new chat", async () => {
@@ -2242,7 +2242,7 @@ describe("ThreadShell", () => {
);
const menu = await openMessageActions("answer 100");
fireEvent.click(within(menu).getByRole("button", { name: "Fork" }));
fireEvent.click(within(menu).getByRole("button", { name: "New chat from here" }));
await waitFor(() =>
expect(onForkChat).toHaveBeenCalledWith("long-chat", 101),
@@ -4397,10 +4397,10 @@ describe("ThreadShell", () => {
);
await act(async () => {});
expect(screen.queryByText("Design an app icon")).not.toBeInTheDocument();
expect(screen.queryByText("Design an icon")).not.toBeInTheDocument();
expect(screen.queryByText("Write code")).not.toBeInTheDocument();
expect(screen.queryByText("Design an app icon")).not.toBeInTheDocument();
expect(screen.queryByText("Design an icon")).not.toBeInTheDocument();
expect(screen.queryByText("Write code")).not.toBeInTheDocument();
});
+15 -15
View File
@@ -1842,8 +1842,8 @@ describe("ThreadViewport", () => {
expect(promptEls).toHaveLength(5);
expect(screen.getByLabelText("User prompt navigation")).toBeInTheDocument();
const promptMarkers = screen.getAllByRole("button", { name: /Jump to prompt:/ });
expect(screen.getByLabelText("My message navigation")).toBeInTheDocument();
const promptMarkers = screen.getAllByRole("button", { name: /Jump to message:/ });
const markerTops = promptMarkers.map((marker) => Number.parseFloat(marker.style.top));
expect(markerTops[2]).toBeCloseTo(50);
expect(markerTops[1] - markerTops[0]).toBeCloseTo(16 / 3);
@@ -1865,7 +1865,7 @@ describe("ThreadViewport", () => {
fireEvent.pointerLeave(promptMarkers[2]);
expect(railMarkers.every((marker) => marker.style.width === "9px")).toBe(true);
const targetPrompt = screen.getByRole("button", { name: "Jump to prompt: message 3" });
const targetPrompt = screen.getByRole("button", { name: "Jump to message: message 3" });
fireEvent.pointerEnter(targetPrompt);
const preview = screen.getByTestId("prompt-rail-preview");
expect(within(preview).getByText("message 3")).toBeInTheDocument();
@@ -1884,7 +1884,7 @@ describe("ThreadViewport", () => {
await renderPromptRailViewport({ messages: promptMessages });
const targetPrompt = screen.getByRole("button", { name: "Jump to prompt: message 3" });
const targetPrompt = screen.getByRole("button", { name: "Jump to message: message 3" });
fireEvent.pointerEnter(targetPrompt);
const preview = screen.getByTestId("prompt-rail-preview");
@@ -1901,7 +1901,7 @@ describe("ThreadViewport", () => {
.mockReturnValue("started");
const cancel = vi.spyOn(ThreadCameraController.prototype, "cancel");
const { scroller } = await renderPromptRailViewport();
const targetPrompt = screen.getByRole("button", { name: "Jump to prompt: message 3" });
const targetPrompt = screen.getByRole("button", { name: "Jump to message: message 3" });
const restartNavigation = () => {
fireEvent.click(targetPrompt);
cancel.mockClear();
@@ -1960,17 +1960,17 @@ describe("ThreadViewport", () => {
});
});
fireEvent.click(screen.getByRole("button", { name: "Open prompt navigator" }));
fireEvent.click(screen.getByRole("button", { name: "Message navigation" }));
const dialog = screen.getByRole("dialog");
expect(within(dialog).getByText("Prompts")).toBeInTheDocument();
expect(within(dialog).getByText("My messages")).toBeInTheDocument();
expect(within(dialog).getByText("message 4")).toBeInTheDocument();
fireEvent.change(within(dialog).getByRole("textbox", { name: "Search prompts" }), {
fireEvent.change(within(dialog).getByRole("textbox", { name: "Search messages" }), {
target: { value: "message 4" },
});
expect(within(dialog).queryByText("message 1")).not.toBeInTheDocument();
fireEvent.click(within(dialog).getByRole("button", { name: "Jump to prompt: message 4" }));
fireEvent.click(within(dialog).getByRole("button", { name: "Jump to message: message 4" }));
expect(navigateTo).toHaveBeenCalledWith(1200);
});
@@ -1981,9 +1981,9 @@ describe("ThreadViewport", () => {
expect(screen.queryByText("message 20")).not.toBeInTheDocument();
fireEvent.click(screen.getByRole("button", { name: "Open prompt navigator" }));
fireEvent.click(screen.getByRole("button", { name: "Message navigation" }));
const dialog = screen.getByRole("dialog");
fireEvent.click(within(dialog).getByRole("button", { name: "Jump to prompt: message 20" }));
fireEvent.click(within(dialog).getByRole("button", { name: "Jump to message: message 20" }));
await waitFor(() => expect(screen.getByText("message 20")).toBeInTheDocument());
});
@@ -2021,7 +2021,7 @@ describe("ThreadViewport", () => {
await new Promise<void>((resolve) => window.requestAnimationFrame(() => resolve()));
});
expect(screen.getByLabelText("User prompt navigation")).toBeInTheDocument();
expect(screen.getByLabelText("My message navigation")).toBeInTheDocument();
});
it.each([2, 3, 100])("keeps %i prompts navigable before a very long answer", async (count) => {
@@ -2042,7 +2042,7 @@ describe("ThreadViewport", () => {
await new Promise<void>((resolve) => window.requestAnimationFrame(() => resolve()));
});
const markers = screen.getAllByRole("button", { name: /Jump to prompt:/ });
const markers = screen.getAllByRole("button", { name: /Jump to message:/ });
if (count < 30) {
expect(markers).toHaveLength(count);
markers.forEach((marker, index) => {
@@ -2061,7 +2061,7 @@ describe("ThreadViewport", () => {
const navigateTo = vi.spyOn(ThreadCameraController.prototype, "navigateTo")
.mockReturnValue("started");
const { scroller } = await renderPromptRailViewport();
const marker = screen.getByRole("button", { name: "Jump to prompt: message 1" });
const marker = screen.getByRole("button", { name: "Jump to message: message 1" });
scroller.style.paddingTop = "16px";
fireEvent.click(marker);
@@ -2109,7 +2109,7 @@ describe("ThreadViewport", () => {
await new Promise<void>((resolve) => window.requestAnimationFrame(() => resolve()));
});
const promptMarkers = screen.getAllByRole("button", { name: /Jump to prompt:/ });
const promptMarkers = screen.getAllByRole("button", { name: /Jump to message:/ });
expect(promptMarkers.length).toBeGreaterThan(3);
expect(promptMarkers.length).toBeLessThan(100);
expect(
+4 -4
View File
@@ -28,7 +28,7 @@ describe("Token usage card", () => {
{ date: days[1].date, provider: "openai", model: "a", total_tokens: 1 },
]} />);
const plot = container.querySelector("[data-model-usage-plot]")!;
const bars = within(screen.getByRole("group", { name: "Model usage over time" })).getAllByRole("img");
const bars = within(screen.getByRole("group", { name: "Model trends" })).getAllByRole("img");
expect(plot).toContainElement(bars[0]);
const baseline = container.querySelector('[data-model-usage-gridline="2"]')!;
expect(plot).toContainElement(baseline);
@@ -52,18 +52,18 @@ describe("Token usage card", () => {
day("2026-08-10", 9000), day("2026-08-11", 100), today, day("2026-09-10", 9000),
])} />);
expect(screen.getByLabelText("400 tokens")).toBeInTheDocument();
const bars = within(screen.getByRole("group", { name: "Daily token usage" })).getAllByRole("img");
const bars = within(screen.getByRole("group", { name: "Daily tokens" })).getAllByRole("img");
expect(bars).toHaveLength(30);
expect(bars.filter((bar) => bar.tabIndex === 0)).toEqual([bars[0], bars[29]]);
expect(bars[0]).toHaveAccessibleName(/2026-08-11: 100 tokens, 1 requests/);
expect(bars[29]).toHaveAccessibleName(/Cached input: 120, Cache miss: 60, Cache status unknown: 60, Output: 60/);
expect(bars[29]).toHaveAccessibleName(/Cached input: 120, Cache miss: 60, Unknown status: 60, Output: 60/);
const segments = bars[29].firstElementChild?.children;
expect(segments).toHaveLength(4);
expect(segments?.[0]).toHaveStyle({ height: "40%" });
expect(segments?.[1]).toHaveStyle({ height: "20%" });
expect(segments?.[2]).toHaveStyle({ height: "20%" });
expect(segments?.[3]).toHaveStyle({ height: "20%" });
expect(bars[0]).toHaveAccessibleName(/Cache miss: 0, Cache status unknown: 100/);
expect(bars[0]).toHaveAccessibleName(/Cache miss: 0, Unknown status: 100/);
expect(screen.getAllByText("50%")).toHaveLength(2);
expect(screen.getByText("Unclassified")).toBeInTheDocument();
});
+40 -40
View File
@@ -25,7 +25,7 @@ describe("Workspace project picker", () => {
const user = userEvent.setup();
const onChange = vi.fn();
render(<WorkspaceProjectPicker isHero scope={scope} defaultScope={scope} controls={catalog.controls} onBrowseDirectories={vi.fn().mockResolvedValue(directory)} onChange={onChange} />);
const trigger = screen.getByRole("button", { name: "Switch working directory" });
const trigger = screen.getByRole("button", { name: "Switch directory" });
if (entry === "pointer") await user.click(trigger);
else {
act(() => trigger.focus());
@@ -57,7 +57,7 @@ describe("Workspace project picker", () => {
return Promise.resolve({ ...directory, path, parent: path === "/" ? null : path.slice(0, path.lastIndexOf("/")) || "/", entries: [] });
});
render(<WorkspaceProjectPicker isHero scope={scope} defaultScope={scope} controls={catalog.controls} onLoadProjects={vi.fn().mockResolvedValue(catalog)} onBrowseDirectories={browse} onChange={onChange} />);
await user.click(screen.getByRole("button", { name: "Switch working directory" }));
await user.click(screen.getByRole("button", { name: "Switch directory" }));
await user.click(await screen.findByRole("button", { name: "/srv/beta" }));
await screen.findByRole("listbox", { name: "/srv/beta" });
await user.click(screen.getByRole("button", { name: "Back", exact: true }));
@@ -80,7 +80,7 @@ describe("Workspace project picker", () => {
const onChange = vi.fn();
const browse = vi.fn((raw: string) => Promise.resolve({ ...directory, path: raw.replace(/\/$/, ""), entries: [] }));
render(<WorkspaceProjectPicker isHero scope={scope} defaultScope={scope} controls={catalog.controls} onLoadProjects={vi.fn().mockResolvedValue(catalog)} onBrowseDirectories={browse} onChange={onChange} />);
await user.click(screen.getByRole("button", { name: "Switch working directory" }));
await user.click(screen.getByRole("button", { name: "Switch directory" }));
const lastVisited = screen.getByRole("button", { name: "Last visited folder" });
expect(lastVisited).toBeDisabled();
await user.click(await screen.findByRole("button", { name: "/srv/alpha" }));
@@ -96,7 +96,7 @@ describe("Workspace project picker", () => {
expect(screen.queryByRole("menu")).not.toBeInTheDocument();
expect(onChange).not.toHaveBeenCalled();
await user.click(screen.getByRole("button", { name: "Cancel", exact: true }));
await user.click(screen.getByRole("button", { name: "Switch working directory" }));
await user.click(screen.getByRole("button", { name: "Switch directory" }));
expect(screen.getByRole("button", { name: "Last visited folder" })).toBeDisabled();
});
@@ -110,7 +110,7 @@ describe("Workspace project picker", () => {
return Promise.resolve({ ...directory, path, entries: names.map(name => ({ name, path: `${path}/${name}` })) });
});
render(<WorkspaceProjectPicker isHero scope={scope} defaultScope={scope} controls={catalog.controls} onBrowseDirectories={browse} onChange={vi.fn()} />);
await user.click(screen.getByRole("button", { name: "Switch working directory" }));
await user.click(screen.getByRole("button", { name: "Switch directory" }));
await user.click(await screen.findByRole("option", { name: "/srv/workspace/memory" }));
await screen.findByRole("option", { name: "/srv/workspace/memory/reference" });
const parent = screen.getByRole("listbox", { name: scope.project_path });
@@ -150,7 +150,7 @@ describe("Workspace project picker", () => {
const onChange = vi.fn();
const browse = vi.fn((path: string) => Promise.resolve({ ...directory, path: path.replace(/\/$/, ""), entries: [] }));
render(<WorkspaceProjectPicker isHero scope={scope} defaultScope={scope} controls={catalog.controls} onBrowseDirectories={browse} onChange={onChange} />);
await user.click(screen.getByRole("button", { name: "Switch working directory" }));
await user.click(screen.getByRole("button", { name: "Switch directory" }));
await screen.findByText("No subfolders");
await user.click(screen.getByRole("button", { name: `Edit path: ${scope.project_path}` }));
const input = screen.getByRole("combobox") as HTMLInputElement;
@@ -183,13 +183,13 @@ describe("Workspace project picker", () => {
const browse = vi.fn().mockRejectedValueOnce(new Error("Permission denied"))
.mockResolvedValue({ ...directory, entries: [] });
render(<WorkspaceProjectPicker isHero scope={scope} defaultScope={scope} controls={catalog.controls} onBrowseDirectories={browse} onChange={vi.fn()} />);
await user.click(screen.getByRole("button", { name: "Switch working directory" }));
await user.click(screen.getByRole("button", { name: "Switch directory" }));
expect(await screen.findByRole("alert")).toHaveTextContent("Permission denied");
expect(screen.getByRole("button", { name: "Confirm" })).toBeDisabled();
await user.click(screen.getByRole("button", { name: "Try again" }));
await screen.findByText("No subfolders");
expect(screen.getByRole("button", { name: "Confirm" })).toBeEnabled();
await user.type(screen.getByRole("textbox", { name: "Filter this folder" }), "missing");
await user.type(screen.getByRole("textbox", { name: "Filter folders" }), "missing");
await screen.findByText("No matching folders.");
expect(screen.getByRole("button", { name: "Confirm" })).toBeEnabled();
});
@@ -204,7 +204,7 @@ describe("Workspace project picker", () => {
const resolve = vi.fn().mockResolvedValue(project);
const onChange = vi.fn();
render(<WorkspaceProjectPicker isHero scope={scope} defaultScope={scope} controls={{ ...catalog.controls, can_resolve_project: true }} onBrowseDirectories={browse} onResolveProject={resolve} onChange={onChange} />);
await user.click(screen.getByRole("button", { name: "Switch working directory" }));
await user.click(screen.getByRole("button", { name: "Switch directory" }));
await user.click(await screen.findByRole("option", { name: project.path }));
await waitFor(() => expect(screen.getByRole("listbox", { name: project.path })).toHaveAttribute("aria-busy", "true"));
expect(screen.getByRole("button", { name: "Confirm" })).toBeEnabled();
@@ -219,7 +219,7 @@ describe("Workspace project picker", () => {
const onChange = vi.fn();
const browse = vi.fn((path: string) => Promise.resolve({ ...directory, path: path.replace(/\/$/, ""), entries: [] }));
render(<WorkspaceProjectPicker isHero scope={scope} defaultScope={scope} controls={catalog.controls} onBrowseDirectories={browse} onChange={onChange} />);
await user.click(screen.getByRole("button", { name: "Switch working directory" }));
await user.click(screen.getByRole("button", { name: "Switch directory" }));
await screen.findByText("No subfolders");
await user.click(screen.getByRole("button", { name: /^Edit path:/ }));
await user.clear(screen.getByRole("combobox"));
@@ -239,7 +239,7 @@ describe("Workspace project picker", () => {
const user = userEvent.setup();
const browse = vi.fn((raw: string) => Promise.resolve(raw.replace(/\/$/, "") === scope.project_path ? directory : { ...directory, path: raw.replace(/\/$/, ""), entries: [] }));
render(<WorkspaceProjectPicker isHero scope={scope} defaultScope={scope} controls={catalog.controls} onLoadProjects={vi.fn().mockResolvedValue(catalog)} onBrowseDirectories={browse} onChange={vi.fn()} />);
await user.click(screen.getByRole("button", { name: "Switch working directory" }));
await user.click(screen.getByRole("button", { name: "Switch directory" }));
await user.click(await screen.findByRole("option", { name: "/srv/workspace/alpha" }));
expect(screen.getAllByRole("listbox")).toHaveLength(1);
await screen.findByText("No subfolders");
@@ -264,7 +264,7 @@ describe("Workspace project picker", () => {
{ name: "src", path: firstPath }, { name: "src", path: secondPath },
] });
render(<WorkspaceProjectPicker isHero scope={scope} defaultScope={scope} controls={catalog.controls} onLoadProjects={onLoadProjects} onBrowseDirectories={onBrowse} onChange={onChange} />);
await user.click(screen.getByRole("button", { name: "Switch working directory" }));
await user.click(screen.getByRole("button", { name: "Switch directory" }));
const first = await screen.findByRole("button", { name: firstPath });
const second = screen.getByRole("button", { name: secondPath });
expect(first).toHaveTextContent(/^src$/);
@@ -282,9 +282,9 @@ describe("Workspace project picker", () => {
const onChange = vi.fn();
const onBrowse = vi.fn().mockResolvedValue(directory);
render(<WorkspaceProjectPicker isHero scope={scope} defaultScope={scope} controls={catalog.controls} onLoadProjects={vi.fn().mockResolvedValue(catalog)} onBrowseDirectories={onBrowse} onChange={onChange} />);
await user.click(screen.getByRole("button", { name: "Switch working directory" }));
await user.click(screen.getByRole("button", { name: "Switch directory" }));
const shortcut = await screen.findByRole("button", { name: "/srv/beta" });
await user.type(screen.getByRole("textbox", { name: "Filter this folder" }), "al");
await user.type(screen.getByRole("textbox", { name: "Filter folders" }), "al");
await waitFor(() => expect(onBrowse).toHaveBeenLastCalledWith("/srv/workspace", "al", false, true));
expect(shortcut).toBeInTheDocument();
expect(screen.getAllByRole("listbox")).toHaveLength(1);
@@ -292,9 +292,9 @@ describe("Workspace project picker", () => {
await user.click(shortcut);
await waitFor(() => expect(screen.getByRole("button", { name: "Confirm" })).toBeEnabled());
expect(screen.getAllByRole("listbox")).toHaveLength(1);
expect(screen.getByRole("textbox", { name: "Filter this folder" })).toHaveValue("");
expect(screen.getByRole("textbox", { name: "Filter folders" })).toHaveValue("");
expect(onChange).not.toHaveBeenCalled();
await user.type(screen.getByRole("textbox", { name: "Filter this folder" }), "oth");
await user.type(screen.getByRole("textbox", { name: "Filter folders" }), "oth");
await waitFor(() => expect(onBrowse).toHaveBeenLastCalledWith("/srv/beta", "oth", false, true));
expect(shortcut).toBeInTheDocument();
await waitFor(() => expect(screen.getByRole("button", { name: "Confirm" })).toBeEnabled());
@@ -307,7 +307,7 @@ describe("Workspace project picker", () => {
const onBrowse = vi.fn((path: string) => Promise.resolve(path.replace(/\/$/, "") === scope.project_path
? directory : { ...directory, path: "/srv/workspace/alpha", entries: [] }));
render(<WorkspaceProjectPicker isHero scope={scope} defaultScope={scope} controls={catalog.controls} onBrowseDirectories={onBrowse} onChange={vi.fn()} />);
await user.click(screen.getByRole("button", { name: "Switch working directory" }));
await user.click(screen.getByRole("button", { name: "Switch directory" }));
await user.click(await screen.findByRole("option", { name: "/srv/workspace/alpha" }));
await screen.findByText("No subfolders");
expect(onBrowse).toHaveBeenCalledTimes(2);
@@ -316,7 +316,7 @@ describe("Workspace project picker", () => {
expect(screen.queryByRole("status")).not.toBeInTheDocument();
expect(onBrowse).toHaveBeenCalledTimes(2);
await user.keyboard("{Escape}");
await user.click(screen.getByRole("button", { name: "Switch working directory" }));
await user.click(screen.getByRole("button", { name: "Switch directory" }));
expect(screen.getByRole("option", { name: "/srv/workspace/alpha" })).toBeInTheDocument();
expect(screen.queryByRole("status")).not.toBeInTheDocument();
expect(onBrowse).toHaveBeenCalledTimes(2);
@@ -327,7 +327,7 @@ describe("Workspace project picker", () => {
const onBrowse = vi.fn((path: string) => Promise.resolve(path.replace(/\/$/, "") === scope.project_path
? directory : { ...directory, path: "/srv/workspace/alpha", entries: [] }));
render(<WorkspaceProjectPicker isHero scope={scope} defaultScope={scope} controls={catalog.controls} onBrowseDirectories={onBrowse} onChange={vi.fn()} />);
await user.click(screen.getByRole("button", { name: "Switch working directory" }));
await user.click(screen.getByRole("button", { name: "Switch directory" }));
await user.click(await screen.findByRole("option", { name: "/srv/workspace/alpha" }));
await screen.findByText("No subfolders");
const viewport = screen.getAllByRole("listbox")[0].closest("[data-workspace-columns]") as HTMLElement;
@@ -357,7 +357,7 @@ describe("Workspace project picker", () => {
return Promise.resolve({ ...directory, path, entries: path === scope.project_path ? entries : [{ name: "child", path: `${path}/child` }] });
});
render(<WorkspaceProjectPicker isHero scope={scope} defaultScope={scope} controls={catalog.controls} onBrowseDirectories={onBrowse} onChange={vi.fn()} />);
await user.click(screen.getByRole("button", { name: "Switch working directory" }));
await user.click(screen.getByRole("button", { name: "Switch directory" }));
const first = await screen.findByRole("option", { name: entries[0].path });
expect(first).toHaveAttribute("aria-setsize", "500");
expect(first).toHaveAttribute("aria-posinset", "1");
@@ -380,17 +380,17 @@ describe("Workspace project picker", () => {
const onChange = vi.fn();
const onBrowse = vi.fn().mockResolvedValue(directory);
render(<WorkspaceProjectPicker isHero scope={scope} defaultScope={scope} controls={catalog.controls} onBrowseDirectories={onBrowse} onChange={onChange} />);
await user.click(screen.getByRole("button", { name: "Switch working directory" }));
await user.click(screen.getByRole("button", { name: "Switch directory" }));
await screen.findByRole("option", { name: "/srv/workspace/alpha" });
expect(onBrowse).toHaveBeenLastCalledWith("/srv/workspace", "", false, true);
await user.click(screen.getByRole("switch", { name: "Show hidden folders" }));
await user.click(screen.getByRole("switch", { name: "Show hidden" }));
await waitFor(() => expect(onBrowse).toHaveBeenLastCalledWith("/srv/workspace", "", true, true));
onBrowse.mockResolvedValue({ ...directory, path: "/srv/workspace/alpha", entries: [] });
await user.click(screen.getByRole("option", { name: "/srv/workspace/alpha" }));
await waitFor(() => expect(screen.getByRole("button", { name: "Confirm" })).toBeEnabled());
await user.click(screen.getByRole("button", { name: "Confirm" }));
expect(onChange).toHaveBeenCalledWith(expect.objectContaining({ project_path: "/srv/workspace/alpha" }));
await waitFor(() => expect(screen.getByRole("button", { name: "Switch working directory" })).not.toHaveFocus());
await waitFor(() => expect(screen.getByRole("button", { name: "Switch directory" })).not.toHaveFocus());
});
it("keeps invalid paths editable and validates the project before closing", async () => {
@@ -399,7 +399,7 @@ describe("Workspace project picker", () => {
const onResolve = vi.fn().mockRejectedValueOnce(new Error("project_path must be an existing directory"))
.mockResolvedValueOnce({ name: "alpha", path: "/srv/alpha" });
render(<WorkspaceProjectPicker isHero scope={scope} defaultScope={scope} controls={{ ...catalog.controls, can_resolve_project: true }} onResolveProject={onResolve} onChange={onChange} />);
await user.click(screen.getByRole("button", { name: "Switch working directory" }));
await user.click(screen.getByRole("button", { name: "Switch directory" }));
await user.clear(screen.getByRole("combobox"));
await user.type(screen.getByRole("combobox"), "/srv/missing");
await user.keyboard("{Enter}");
@@ -420,7 +420,7 @@ describe("Workspace project picker", () => {
const onBrowse = vi.fn();
const onResolve = vi.fn();
render(<WorkspaceProjectPicker isHero scope={scope} defaultScope={scope} controls={{ can_change_project: true, can_use_full_access: false }} onBrowseDirectories={onBrowse} onResolveProject={onResolve} onChange={onChange} />);
await user.click(screen.getByRole("button", { name: "Switch working directory" }));
await user.click(screen.getByRole("button", { name: "Switch directory" }));
expect(screen.queryByRole("option", { name: "Browse folders…" })).not.toBeInTheDocument();
await user.type(screen.getByRole("combobox"), "relative-path");
expect(screen.getByRole("button", { name: "Confirm" })).toBeDisabled();
@@ -441,7 +441,7 @@ describe("Workspace project picker", () => {
let finish!: (value: WorkspaceDirectoriesPayload) => void;
const onBrowse = vi.fn(() => new Promise<WorkspaceDirectoriesPayload>((resolve) => { finish = resolve; }));
render(<WorkspaceProjectPicker isHero scope={scope} defaultScope={scope} controls={catalog.controls} onBrowseDirectories={onBrowse} onChange={onChange} />);
await user.click(screen.getByRole("button", { name: "Switch working directory" }));
await user.click(screen.getByRole("button", { name: "Switch directory" }));
await waitFor(() => expect(onBrowse).toHaveBeenCalled());
await user.keyboard("{Escape}");
finish(directory);
@@ -454,7 +454,7 @@ describe("Workspace project picker", () => {
const favorites = [{ name: "beta", path: "/srv/beta" }];
const onFavorite = vi.fn().mockResolvedValueOnce(favorites).mockRejectedValueOnce(new Error("disk full")).mockResolvedValueOnce([]);
render(<WorkspaceProjectPicker isHero scope={scope} defaultScope={scope} controls={catalog.controls} onLoadProjects={vi.fn().mockResolvedValue({ ...catalog, controls: { ...catalog.controls, can_manage_favorites: true } })} onFavoriteProject={onFavorite} onChange={onChange} />);
await user.click(screen.getByRole("button", { name: "Switch working directory" }));
await user.click(screen.getByRole("button", { name: "Switch directory" }));
await user.click(await screen.findByRole("button", { name: "Pin beta" }));
expect(onFavorite).toHaveBeenLastCalledWith("/srv/beta", true);
await screen.findByRole("button", { name: "Unpin beta" });
@@ -479,7 +479,7 @@ describe("Workspace project picker", () => {
render(<WorkspaceProjectPicker isHero scope={scope} defaultScope={scope} controls={catalog.controls}
onLoadProjects={vi.fn().mockResolvedValue({ ...catalog, controls: { ...catalog.controls, can_manage_favorites: true } })}
onBrowseDirectories={vi.fn().mockResolvedValue(directory)} onFavoriteProject={onFavorite} onChange={onChange} />);
await user.click(screen.getByRole("button", { name: "Switch working directory" }));
await user.click(screen.getByRole("button", { name: "Switch directory" }));
const option = await screen.findByRole("option", { name: "/srv/workspace/alpha" });
const star = await within(option.parentElement!).findByRole("button", { name: "Pin alpha" });
act(() => star.focus());
@@ -500,7 +500,7 @@ describe("Workspace project picker", () => {
const onChange = vi.fn();
const onBrowse = vi.fn((path: string) => Promise.resolve({ ...directory, path: completed, partial: path === draft, entries: path === draft ? [{ name: "alpha", path: completed }] : [] }));
render(<WorkspaceProjectPicker isHero scope={scope} defaultScope={scope} controls={catalog.controls} onBrowseDirectories={onBrowse} onChange={onChange} />);
await user.click(screen.getByRole("button", { name: "Switch working directory" }));
await user.click(screen.getByRole("button", { name: "Switch directory" }));
await user.click(screen.getByRole("button", { name: /^Edit path:/ }));
const input = screen.getByRole("combobox");
await user.clear(input);
@@ -521,7 +521,7 @@ describe("Workspace project picker", () => {
const user = userEvent.setup();
const onBrowse = vi.fn((path: string) => Promise.resolve({ ...directory, path: path === "/srv/al" ? "/srv" : path, parent: "/srv", partial: path === "/srv/al", entries: path === "/srv/al" ? [{ name: "alpha", path: "/srv/alpha" }, { name: "alpine", path: "/srv/alpine" }] : [] }));
render(<WorkspaceProjectPicker isHero scope={scope} defaultScope={scope} controls={catalog.controls} onBrowseDirectories={onBrowse} onChange={vi.fn()} />);
await user.click(screen.getByRole("button", { name: "Switch working directory" }));
await user.click(screen.getByRole("button", { name: "Switch directory" }));
await user.click(screen.getByRole("button", { name: /^Edit path:/ }));
const input = screen.getByRole("combobox");
await user.clear(input);
@@ -544,7 +544,7 @@ describe("Workspace project picker", () => {
return Promise.resolve({ ...directory, path, partial: false, entries: [{ name: "docs", path: `${path}/docs` }] });
});
render(<WorkspaceProjectPicker isHero scope={scope} defaultScope={scope} controls={catalog.controls} onBrowseDirectories={onBrowse} onChange={vi.fn()} />);
await user.click(screen.getByRole("button", { name: "Switch working directory" }));
await user.click(screen.getByRole("button", { name: "Switch directory" }));
await screen.findByRole("option", { name: "/srv/workspace/docs" });
await user.click(screen.getByRole("button", { name: /^Edit path:/ }));
const input = screen.getByRole("combobox");
@@ -565,7 +565,7 @@ describe("Workspace project picker", () => {
let finish!: (value: WorkspaceDirectoriesPayload) => void;
const onBrowse = vi.fn((path: string) => path === "/srv/al" ? new Promise<WorkspaceDirectoriesPayload>(resolve => { finish = resolve; }) : Promise.resolve({ ...directory, entries: [] }));
render(<WorkspaceProjectPicker isHero scope={scope} defaultScope={scope} controls={catalog.controls} onBrowseDirectories={onBrowse} onChange={vi.fn()} />);
await user.click(screen.getByRole("button", { name: "Switch working directory" }));
await user.click(screen.getByRole("button", { name: "Switch directory" }));
await user.click(screen.getByRole("button", { name: /^Edit path:/ }));
const input = screen.getByRole("combobox");
await user.clear(input);
@@ -584,7 +584,7 @@ describe("Workspace project picker", () => {
? new Promise<WorkspaceDirectoriesPayload>(resolve => { finish = resolve; })
: Promise.resolve({ ...directory, path, entries: [] }));
render(<WorkspaceProjectPicker isHero scope={scope} defaultScope={scope} controls={catalog.controls} onBrowseDirectories={onBrowse} onChange={vi.fn()} />);
await user.click(screen.getByRole("button", { name: "Switch working directory" }));
await user.click(screen.getByRole("button", { name: "Switch directory" }));
await user.click(screen.getByRole("button", { name: /^Edit path:/ }));
const input = screen.getByRole("combobox");
await user.clear(input);
@@ -603,7 +603,7 @@ describe("Workspace project picker", () => {
const onBrowse = vi.fn((path: string) => path === "/srv/old/" ? new Promise<WorkspaceDirectoriesPayload>(resolve => { finishOld = resolve; }) : Promise.resolve({ ...directory, path, entries: [{ name: path === "/srv/new/" ? "new-child" : "initial-child", path: `${path.replace(/\/$/, "")}/child` }] }));
const onChange = vi.fn();
render(<WorkspaceProjectPicker isHero scope={scope} defaultScope={scope} controls={catalog.controls} onBrowseDirectories={onBrowse} onChange={onChange} />);
await user.click(screen.getByRole("button", { name: "Switch working directory" }));
await user.click(screen.getByRole("button", { name: "Switch directory" }));
await screen.findByRole("option", { name: "/srv/workspace/child" });
await user.click(screen.getByRole("button", { name: /^Edit path:/ }));
const input = screen.getByRole("combobox");
@@ -632,9 +632,9 @@ describe("Workspace project picker", () => {
return Promise.resolve({ ...directory, path, entries: names.filter(name => name.includes(query)).map(name => ({ name, path: `${path}/${name}` })) });
});
render(<WorkspaceProjectPicker isHero scope={scope} defaultScope={scope} controls={catalog.controls} onBrowseDirectories={onBrowse} onChange={onChange} />);
await user.click(screen.getByRole("button", { name: "Switch working directory" }));
await user.click(screen.getByRole("button", { name: "Switch directory" }));
await screen.findByRole("option", { name: "/srv/workspace/alpha" });
const input = screen.getByRole("textbox", { name: "Filter this folder" });
const input = screen.getByRole("textbox", { name: "Filter folders" });
await user.type(input, "alp");
await waitFor(() => expect(onBrowse).toHaveBeenLastCalledWith("/srv/workspace", "alp", false, true));
expect(screen.queryByRole("combobox")).not.toBeInTheDocument();
@@ -661,7 +661,7 @@ describe("Workspace project picker", () => {
return Promise.resolve({ ...directory, path, entries: entries.filter(entry => entry.name.includes(query)) });
});
render(<WorkspaceProjectPicker isHero scope={scope} defaultScope={scope} controls={catalog.controls} onBrowseDirectories={browse} onChange={onChange} />);
const trigger = screen.getByRole("button", { name: "Switch working directory" });
const trigger = screen.getByRole("button", { name: "Switch directory" });
await user.click(trigger);
const alpha = await screen.findByRole("option", { name: "/srv/workspace/alpha" });
const column = screen.getByRole("listbox");
@@ -674,7 +674,7 @@ describe("Workspace project picker", () => {
expect(browse).toHaveBeenCalledTimes(requests);
expect(trigger).not.toHaveFocus();
expect(onChange).not.toHaveBeenCalled();
const filter = screen.getByRole("textbox", { name: "Filter this folder" });
const filter = screen.getByRole("textbox", { name: "Filter folders" });
await user.type(filter, "hjkl");
expect(filter).toHaveValue("hjkl");
expect(screen.getByRole("listbox", { name: "/srv/workspace", exact: true })).toBeInTheDocument();
@@ -697,7 +697,7 @@ describe("Workspace project picker", () => {
return Promise.resolve({ ...directory, path, entries: names.map(name => ({ name, path: `${path}/${name}` })) });
});
render(<WorkspaceProjectPicker isHero scope={scope} defaultScope={scope} controls={catalog.controls} onBrowseDirectories={onBrowse} onChange={onChange} />);
await user.click(screen.getByRole("button", { name: "Switch working directory" }));
await user.click(screen.getByRole("button", { name: "Switch directory" }));
await user.click(await screen.findByRole("option", { name: "/srv/workspace/alpha" }));
await user.click(await screen.findByRole("option", { name: "/srv/workspace/alpha/child" }));
expect(screen.getAllByRole("listbox")).toHaveLength(3);
@@ -716,7 +716,7 @@ describe("Workspace project picker", () => {
expect(screen.getByRole("option", { name: "/srv/workspace/alpha" })).toHaveAttribute("aria-selected", "true");
expect(onChange).not.toHaveBeenCalled();
expect(onBrowse.mock.calls.filter(call => call[0].replace(/\/$/, "") === scope.project_path)).toHaveLength(1);
await user.click(screen.getByRole("switch", { name: "Show hidden folders" }));
await user.click(screen.getByRole("switch", { name: "Show hidden" }));
await screen.findByRole("option", { name: "/srv/workspace/.hidden" });
await screen.findByRole("option", { name: "/srv/workspace/alpha/.hidden" });
await screen.findByRole("option", { name: "/srv/workspace/alpha/child/.hidden" });