test: remove unreachable cases and strengthen weak assertions

This commit is contained in:
chengyongru authored and chengyongru committed 2026-10-22 17:19:20 +08:00
1 parent 169062be11
commit abfe510ce1
25 files changed
+64 -302

No files matched your search

@@ -284,8 +284,6 @@ describe("AgentActivityCluster", () => {
expect(content).toHaveClass("ps-6");
expect(content).not.toHaveClass("max-h-[180px]");
expect(content).not.toHaveClass("overflow-y-auto");
expect(screen.queryByTestId("activity-scroll-fade-top")).not.toBeInTheDocument();
expect(screen.queryByTestId("activity-scroll-fade-bottom")).not.toBeInTheDocument();
view.rerender(<AgentActivityCluster {...props} messages={activityMessages(" updated", {
id: "next-tool", role: "tool", kind: "trace", content: "open_browser()", createdAt: 3,
@@ -472,7 +470,6 @@ describe("AgentActivityCluster", () => {
const fileRef = screen.getByTestId("activity-file-reference");
expect(fileRef).toHaveTextContent("src/app.tsx");
expect(fileRef).toHaveAttribute("aria-label", "/Users/renxubin/project/src/app.tsx");
expect(screen.queryByTestId("activity-header-file-reference")).not.toBeInTheDocument();
expect(screen.queryByTestId("file-edit-diff")).not.toBeInTheDocument();
for (const diffPair of screen.getAllByTestId("activity-diff-pair")) {
expect(diffPair).toHaveClass("items-baseline");
@@ -1050,7 +1047,6 @@ describe("AgentActivityCluster", () => {
expect(screen.queryByRole("button", { name: /edited app\.tsx/i })).not.toBeInTheDocument();
expect(screen.queryByTestId("agent-activity-content")).not.toBeInTheDocument();
expect(screen.getByRole("img", { name: "Edited" })).toBeInTheDocument();
expect(screen.queryByTestId("activity-header-file-reference")).not.toBeInTheDocument();
const marker = screen.getByRole("img", { name: "Edited" });
expect(marker.querySelector("svg")).toHaveClass("lucide-file-code2");
expect(marker.closest('[data-testid="activity-step"]')?.querySelectorAll("svg")).toHaveLength(1);
@@ -2105,7 +2101,6 @@ describe("AgentActivityCluster", () => {
expect(screen.queryByText("Web")).not.toBeInTheDocument();
const row = screen.getByText("example.com").closest('[data-testid="activity-step"]');
expect(row).toHaveTextContent("Read");
expect(screen.queryByTestId("activity-evidence-preview")).not.toBeInTheDocument();
expect(screen.queryByText(/Found image/i)).not.toBeInTheDocument();
expect(screen.queryByRole("img", { name: "Homepage screenshot" })).not.toBeInTheDocument();
});
@@ -2212,7 +2207,6 @@ describe("AgentActivityCluster", () => {
expect(screen.queryByText("Vision")).not.toBeInTheDocument();
expect(screen.getByText("Captured screenshot")).toBeInTheDocument();
expect(screen.queryByTestId("activity-evidence-preview")).not.toBeInTheDocument();
expect(screen.queryByText("missing.png")).not.toBeInTheDocument();
});
@@ -2259,7 +2253,6 @@ describe("AgentActivityCluster", () => {
expect(line).toHaveClass("overflow-hidden");
expect(line).toHaveClass("whitespace-nowrap");
expect(step.querySelector("br")).not.toBeInTheDocument();
expect(step.querySelector('[data-testid="activity-evidence-preview"]')).not.toBeInTheDocument();
}
expect(document.querySelector("details")).not.toBeInTheDocument();
expect(document.querySelector("ul, li, section")).not.toBeInTheDocument();
-13
View File
@@ -1442,9 +1442,6 @@ describe("App layout", () => {
expect(screen.getByText("cron")).toBeInTheDocument();
expect(screen.getByText("github")).toBeInTheDocument();
expect(screen.getByText("Needs setup")).toBeInTheDocument();
expect(
screen.queryByText("Review the instruction skills this agent can load during a conversation."),
).not.toBeInTheDocument();
expect(screen.getByRole("navigation", { name: "Sidebar navigation" })).toBeInTheDocument();
expect(screen.queryByRole("navigation", { name: "Settings sections" })).not.toBeInTheDocument();
expect(within(sidebar).getByRole("button", { name: "Skills" })).toHaveAttribute(
@@ -1470,14 +1467,7 @@ describe("App layout", () => {
"true",
);
expect(screen.getByText("Setup required")).toBeInTheDocument();
expect(
screen.queryByText(
"Allow the agent to load this skill when its requirements are ready.",
),
).not.toBeInTheDocument();
expect(screen.getByText("brew install gh")).toBeInTheDocument();
expect(screen.queryByText("Unavailable reason")).not.toBeInTheDocument();
expect(screen.queryByText("Missing CLI")).not.toBeInTheDocument();
expect(screen.getByRole("button", { name: "Check again" })).toBeInTheDocument();
fireEvent.click(screen.getByText("Skill instructions"));
expect(screen.getByText(/Use GitHub CLI/)).toBeInTheDocument();
@@ -1675,9 +1665,6 @@ describe("App layout", () => {
expect(
await screen.findByRole("heading", { name: "Popular skills" }),
).toBeInTheDocument();
expect(
screen.queryByText("Each marketplace keeps its own ranking and install metrics."),
).not.toBeInTheDocument();
expect(screen.getByText("find-skills")).toBeInTheDocument();
expect(screen.getByText("ima-skills")).toBeInTheDocument();
expect(screen.getByRole("link", { name: "Open ima-skills on SkillHub" })).toHaveAttribute(
+12 -52
View File
@@ -609,50 +609,12 @@ describe("Automation task list and detail sheet", () => {
expect(screen.queryByText("No next run")).not.toBeInTheDocument();
});
it.each(["heartbeat", "dream", "other-system-job"])("shows only actual task data for %s", (id) => {
renderDetail({ ...systemTask, id, name: id, state: { next_run_at_ms: now + 540_000 } });
const dialog = screen.getByRole("dialog", { name: id });
expect(dialog).toHaveClass("max-w-[440px]");
expect(dialog).not.toHaveAttribute("aria-describedby");
expect(dialog.querySelector("p")).toBeNull();
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);
expect(within(dialog).getByRole("button", { name: "Close" })).toHaveClass("rounded-full", "h-7", "w-7");
const toggle = within(dialog).getByRole("button", { name: "Task information" });
expect(screen.queryByRole("dialog", { name: "Task information" })).not.toBeInTheDocument();
fireEvent.click(toggle);
const metadata = screen.getByRole("dialog", { name: "Task information" });
for (const label of ["Schedule", "Next run", "Last run"]) {
expect(within(metadata).getByText(label).closest("dt")).not.toBeNull();
}
expect(within(metadata).getByText("Every 30 minutes")).toBeVisible();
expect(within(metadata).getByText("Not run yet")).toBeVisible();
expect(within(metadata).getByText("ID")).toBeVisible();
fireEvent.click(toggle);
expect(screen.queryByRole("dialog", { name: "Task information" })).not.toBeInTheDocument();
});
it("keeps the shared protected detail read-only and does not infer purpose from a task name", () => {
renderDetail({ ...systemTask, id: "other-system-job", name: "heartbeat",
state: { last_run_at_ms: now - 60_000, last_status: "error", last_error: "Background check failed", next_run_at_ms: null },
});
const dialog = screen.getByRole("dialog", { name: "heartbeat" });
expect(within(dialog).queryByText("System-managed automation")).not.toBeInTheDocument();
expect(within(dialog).getByRole("alert")).toHaveTextContent("Background check failed");
fireEvent.click(within(dialog).getByRole("button", { name: "Task information" }));
expect(within(dialog).getByText("Failed")).toBeVisible();
expect(within(dialog).getByText("No next run")).toBeVisible();
expect(dialog).not.toHaveAttribute("aria-describedby");
});
it.each([task, systemTask])("uses shared dialog styling and quiet detail rows for $name", (job) => {
renderDetail(job);
const dialog = screen.getByRole("dialog", { name: job.name });
it("uses shared dialog styling and quiet detail rows", () => {
renderDetail(task);
const dialog = screen.getByRole("dialog", { name: task.name });
expect(dialog).toHaveClass("rounded-modal");
expect(dialog).not.toHaveClass("rounded-[20px]");
const title = within(dialog).getByRole("heading", { name: job.name });
const title = within(dialog).getByRole("heading", { name: task.name });
expect(title).toHaveClass("text-lg", "font-medium", "leading-snug");
expect(dialog).toHaveClass("text-sm", "font-normal");
expect(title).not.toHaveClass("text-[22px]");
@@ -662,16 +624,14 @@ describe("Automation task list and detail sheet", () => {
const details = within(dialog).getByRole("button", { name: "Task information" });
expect(details.parentElement).not.toHaveClass("border-t");
expect(details).toHaveAttribute("aria-expanded", "false");
if (!job.protected) {
expect(within(dialog).queryByRole("switch")).not.toBeInTheDocument();
const taskActions = within(dialog).getByRole("button", { name: "Run now" }).parentElement;
const edit = within(dialog).getByRole("button", { name: "Edit" });
expect(edit.parentElement).toBe(taskActions);
expect(edit.parentElement).toHaveClass("ml-auto");
expect(taskMenuItem("Disable")).toBeVisible();
expect(taskMenuItem("Delete")).toBeVisible();
expect(taskMenuItem("Open a chat")).toHaveAttribute("href", "#/chat/websocket%3Ademo");
}
expect(within(dialog).queryByRole("switch")).not.toBeInTheDocument();
const taskActions = within(dialog).getByRole("button", { name: "Run now" }).parentElement;
const edit = within(dialog).getByRole("button", { name: "Edit" });
expect(edit.parentElement).toBe(taskActions);
expect(edit.parentElement).toHaveClass("ml-auto");
expect(taskMenuItem("Disable")).toBeVisible();
expect(taskMenuItem("Delete")).toBeVisible();
expect(taskMenuItem("Open a chat")).toHaveAttribute("href", "#/chat/websocket%3Ademo");
});
it("keeps schedule and run metadata in task information", async () => {
@@ -163,7 +163,6 @@ describe("FilePreviewPanel", () => {
expect(codeBlock).toHaveTextContent("print('ok')");
expect(codeBlock).toHaveAttribute("data-language", "python");
expect(codeBlock).toHaveAttribute("data-highlight", "true");
expect(screen.queryByTestId("file-preview-breadcrumb")).not.toBeInTheDocument();
expect(screen.queryByText("quicksort.py")).not.toBeInTheDocument();
});
@@ -87,8 +87,6 @@ describe("McpManagementDialog", () => {
expect(within(dialog).getByText("Streamable HTTP")).toBeInTheDocument();
expect(within(dialog).getByRole("link", { name: "Open docs" })).toBeInTheDocument();
expect(within(dialog).getByRole("button", { name: "Remove connection" })).toBeInTheDocument();
expect(within(dialog).queryByText("Last checked")).not.toBeInTheDocument();
expect(within(dialog).queryByText("Connection actions apply immediately.")).not.toBeInTheDocument();
fireEvent.click(within(dialog).getByRole("button", { name: "Reconnect" }));
expect(onAction).toHaveBeenCalledWith("reconnect", "docs", {});
});
@@ -138,7 +136,7 @@ describe("McpManagementDialog", () => {
expect(screen.queryByRole("switch", { name: "Use proxy" })).not.toBeInTheDocument();
});
it("loads tools on entry and replaces passive inspection copy with recovery", async () => {
it("loads tools on entry and supports refreshing the empty inventory", async () => {
const onAction = vi.fn();
renderDialog({
initialTab: "tools",
@@ -148,7 +146,6 @@ describe("McpManagementDialog", () => {
const dialog = screen.getByRole("dialog", { name: "Docs MCP" });
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: "Refresh tools" }));
expect(onAction).toHaveBeenCalledTimes(2);
@@ -44,7 +44,7 @@ describe("Runtime configuration settings", () => {
expect([...paths, visibilityOnly].sort()).toEqual([...runtimeConfigKeys].sort());
});
it("keeps local service controls available when tool families are disabled", () => {
it("keeps chat permissions and local services available when tool families are disabled", () => {
const payload = runtimeSettings();
renderSettingsView({ initialSection: "advanced", initialSettings: {
...payload, runtime_config: {
@@ -53,11 +53,9 @@ describe("Runtime configuration settings", () => {
},
} });
expect(screen.getByRole("switch", { name: "Local services" })).toBeVisible();
});
it("keeps chat permission settings discoverable within the advanced page", () => {
renderSettingsView({ initialSection: "advanced", initialSettings: runtimeSettings() });
expect(screen.getByRole("switch", { name: "Local services" })).toBeInTheDocument();
expect(screen.getByText("Default access")).toBeVisible();
expect(screen.getByRole("button", { name: "Default Permission" })).toBeVisible();
expect(screen.getByRole("button", { name: "Full Access" })).toBeVisible();
});
it("places common settings in their feature pages and reserves advanced for low-frequency controls", () => {
@@ -18,7 +18,7 @@ function renderShell(expanded: boolean) {
}
describe("ThinkingReasoningShell", () => {
it.each([false, true])("shows activity without clipping or edge fades (active: %s)", (active) => {
it.each([false, true])("renders the full activity list (active: %s)", (active) => {
render(
<ThinkingReasoningShell
active={active}
@@ -32,8 +32,6 @@ describe("ThinkingReasoningShell", () => {
const content = screen.getByTestId("agent-activity-content");
expect(content).not.toHaveClass("max-h-[180px]");
expect(content).not.toHaveClass("overflow-y-auto");
expect(screen.queryByTestId("activity-scroll-fade-top")).not.toBeInTheDocument();
expect(screen.queryByTestId("activity-scroll-fade-bottom")).not.toBeInTheDocument();
expect(screen.getByText("Activity 1")).toBeVisible();
expect(screen.getByText("Activity 16")).toBeVisible();
});
+3 -10
View File
@@ -4078,6 +4078,7 @@ describe("ThreadComposer", () => {
});
it("keeps temporary chat guidance in memory only", async () => {
const setItem = vi.spyOn(window.localStorage, "setItem");
const onSend = vi.fn();
const view = render(
<ThreadComposer
@@ -4094,11 +4095,7 @@ describe("ThreadComposer", () => {
fireEvent.keyDown(input, { key: "Enter" });
expect(await screen.findByText("do not persist this")).toBeInTheDocument();
expect(
window.localStorage.getItem(
"nanobot.webui.composerQueuedGuidance.v1:temporary-private",
),
).toBeNull();
expect(setItem).not.toHaveBeenCalled();
view.unmount();
render(
@@ -4114,11 +4111,7 @@ describe("ThreadComposer", () => {
await waitFor(() => {
expect(screen.queryByText("do not persist this")).not.toBeInTheDocument();
});
expect(
window.localStorage.getItem(
"nanobot.webui.composerQueuedGuidance.v1:temporary-private",
),
).toBeNull();
expect(setItem).not.toHaveBeenCalled();
});
});
-31
View File
@@ -5221,37 +5221,6 @@ describe("ThreadShell", () => {
expect(screen.getByRole("option", { name: /\/history/i })).toBeInTheDocument();
});
it("does not bring back welcome cards when image mode is enabled", async () => {
const client = makeClient();
const settings = modelSettings("deepseek-v4-pro", "deepseek");
render(
wrap(
client,
<ThreadShell
session={null}
title="nanobot"
onToggleSidebar={() => {}}
onNewChat={() => {}}
settingsSnapshot={{
...settings,
image_generation: {
...settings.image_generation,
enabled: true,
provider_configured: true,
},
}}
/>,
),
);
await act(async () => {});
expect(screen.queryByText("Design an icon")).not.toBeInTheDocument();
expect(screen.queryByText("Write code")).not.toBeInTheDocument();
expect(screen.queryByText("Design an icon")).not.toBeInTheDocument();
expect(screen.queryByText("Write code")).not.toBeInTheDocument();
});
it("surfaces a dismissible banner for an uncorrelated message_too_big error", async () => {
const client = makeClient();
const onNewChat = vi.fn().mockResolvedValue("chat-a");