Your lightweight open-source personal agent.
Python agent-frameworkai-agentai-agentschatbotchatopsdiscord-botllm-agentsllmslocal-llmmcpmodel-context-protocolmulti-agentopenai-compatibleopenclawpersonal-ai-assistantpythonself-hostedtelegram-bot-ai-assistantwebuiworkflow-automation
test: align automation integration coverage with current behavior
chengyongrubfb4f021ed58
diff --git a/tests/cli/test_commands.py b/tests/cli/test_commands.pyindex 6feee3666..6997eddc6 100644--- a/tests/cli/test_commands.py+++ b/tests/cli/test_commands.py@@ -28,7 +28,7 @@ from nanobot.cli.commands import appfrom nanobot.config.schema import Configfrom nanobot.cron.service import CronJobSkippedErrorfrom nanobot.cron.session_turns import CRON_DEFER_UNTIL_IDLE_META, CRON_TRIGGER_META-from nanobot.cron.types import CronJob, CronPayload+from nanobot.cron.types import CronJob, CronPayload, CronRunResultfrom nanobot.cron.webui_metadata import cron_proactive_delivery_metadatafrom nanobot.providers.factory import ProviderSnapshot, make_provider, provider_signaturefrom nanobot.providers.openai_codex_provider import _strip_model_prefix@@ -2192,6 +2192,7 @@ def test_webui_yes_creates_config_and_enables_local_websocket(workspace = tmp_path / "workspace"seen: dict[str, object] = {}_patch_webui_provider_ready(monkeypatch)+ _patch_gateway_ports_free(monkeypatch)monkeypatch.setattr("nanobot.cli.webui.sync_workspace_templates",lambda path: seen.__setitem__("templates", path),@@ -2216,7 +2217,7 @@ def test_webui_yes_creates_config_and_enables_local_websocket(],)- assert result.exit_code == 0+ assert result.exit_code == 0, result.outputdata = json.loads(config_file.read_text(encoding="utf-8"))websocket = data["channels"]["websocket"]assert websocket["enabled"] is True@@ -3272,7 +3273,9 @@ def test_gateway_bound_cron_runs_as_session_turn(response = asyncio.run(cron.on_job(job))- assert response == "Checked the repo."+ assert isinstance(response, CronRunResult)+ assert response.response == "Checked the repo."+ assert response.run_id == seen["run_records"][-1][0]msg = seen["cron_msg"]assert isinstance(msg, InboundMessage)assert msg.channel == "websocket"@@ -3314,7 +3317,9 @@ def test_gateway_bound_cron_runs_as_session_turn(response = asyncio.run(cron.on_job(discord_job))- assert response == "Checked the repo."+ assert isinstance(response, CronRunResult)+ assert response.response == "Checked the repo."+ assert response.run_id == seen["run_records"][-1][0]msg = seen["cron_msg"]assert isinstance(msg, InboundMessage)assert msg.channel == "discord"@@ -3338,7 +3343,9 @@ def test_gateway_bound_cron_runs_as_session_turn(response = asyncio.run(cron.on_job(telegram_job))- assert response == "Checked the repo."+ assert isinstance(response, CronRunResult)+ assert response.response == "Checked the repo."+ assert response.run_id == seen["run_records"][-1][0]msg = seen["cron_msg"]assert isinstance(msg, InboundMessage)assert msg.channel == "telegram"@@ -3364,7 +3371,9 @@ def test_gateway_bound_cron_runs_as_session_turn(response = asyncio.run(cron.on_job(feishu_job))- assert response == "Checked the repo."+ assert isinstance(response, CronRunResult)+ assert response.response == "Checked the repo."+ assert response.run_id == seen["run_records"][-1][0]msg = seen["cron_msg"]assert isinstance(msg, InboundMessage)assert msg.channel == "feishu"diff --git a/webui/src/tests/app-layout.test.tsx b/webui/src/tests/app-layout.test.tsxindex 3253949ea..70872fe11 100644--- a/webui/src/tests/app-layout.test.tsx+++ b/webui/src/tests/app-layout.test.tsx@@ -1463,7 +1463,11 @@ describe("App layout", () => {expect(screen.queryByRole("dialog")).not.toBeInTheDocument();fireEvent.click(screen.getByRole("button", { name: /Daily repo check/ }));expect(within(screen.getByRole("dialog", { name: "Daily repo check" })).getByText("Check the repo status")).toBeVisible();- expect(screen.getAllByText("Release prep").length).toBeGreaterThanOrEqual(1);+ const detail = within(screen.getByRole("dialog", { name: "Daily repo check" }));+ expect(detail.queryByText("Release prep")).not.toBeInTheDocument();+ expect(detail.getByRole("link", { name: "Open a chat" })).toHaveAttribute(+ "href", "#/chat/websocket%3Achat-a",+ );fireEvent.click(screen.getByRole("button", { name: "Close", exact: true }));expect(screen.getByText("WeChat quiz")).toBeInTheDocument();fireEvent.click(screen.getByRole("button", { name: /WeChat quiz/ }));@@ -1471,9 +1475,9 @@ describe("App layout", () => {fireEvent.click(screen.getByRole("button", { name: "Close", exact: true }));expect(screen.queryByText("weixin:wx-chat")).not.toBeInTheDocument();expect(screen.queryByText("memory with dream state")).not.toBeInTheDocument();- expect(screen.getByRole("button", { name: /heartbeat/ })).toBeVisible();- expect(screen.getByRole("button", { name: "System tasks 1" })).toHaveAttribute("aria-expanded", "true");- expect(screen.getByText("heartbeat")).toBeInTheDocument();+ expect(screen.queryByRole("button", { name: /heartbeat/ })).not.toBeInTheDocument();+ expect(screen.queryByRole("button", { name: "System tasks 1" })).not.toBeInTheDocument();+ expect(screen.queryByText("heartbeat")).not.toBeInTheDocument();expect(within(sidebar).getByRole("button", { name: "Automations" })).toHaveAttribute("aria-current","page",@@ -1482,7 +1486,7 @@ describe("App layout", () => {});- it("keeps automation linked-chat titles in sync with live sidebar renames", async () => {+ it("keeps the automation chat link stable across live sidebar renames without duplicating titles", async () => {const key = "websocket:linked-chat";mockSessions = [{key, channel: "websocket", chatId: "linked-chat", createdAt: null, updatedAt: null,@@ -1513,7 +1517,8 @@ describe("App layout", () => {fireEvent.click(within(sidebar).getByRole("button", { name: "Automations" }));fireEvent.click(await screen.findByRole("button", { name: /Drink water/ }));const dialog = screen.getByRole("dialog", { name: "Drink water" });- expect(within(dialog).getByText("推特大战场")).toBeVisible();+ expect(within(dialog).queryByText("推特大战场")).not.toBeInTheDocument();+ expect(within(dialog).queryByText("Stored title")).not.toBeInTheDocument();expect(within(dialog).getByRole("link", { name: "Open a chat" })).toHaveAttribute("href", "#/chat/websocket%3Alinked-chat",);@@ -1525,7 +1530,10 @@ describe("App layout", () => {});const expected = title || "Stored title";expect(within(sidebar).getByText(expected)).toBeInTheDocument();- expect(within(dialog).getByText(expected)).toBeVisible();+ expect(within(dialog).queryByText(expected)).not.toBeInTheDocument();+ expect(within(dialog).getByRole("link", { name: "Open a chat" })).toHaveAttribute(+ "href", "#/chat/websocket%3Alinked-chat",+ );}expect(requestMutationSpy).not.toHaveBeenCalled();});@@ -1576,6 +1584,12 @@ describe("App layout", () => {expect((await screen.findAllByText("Past one-shot")).length).toBeGreaterThanOrEqual(1);fireEvent.click(screen.getByRole("button", { name: /Past one-shot/ }));+ const runDetail = within(screen.getByRole("dialog", { name: "Past one-shot" }));+ expect(runDetail.getByText("Completed")).toBeVisible();+ expect(runDetail.queryByRole("button", { name: "Edit", exact: true })).not.toBeInTheDocument();+ fireEvent.click(runDetail.getByRole("button", { name: "Close", exact: true }));+ 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" });expect(screen.queryByText("Run time must be in the future.")).not.toBeInTheDocument();@@ -1746,7 +1760,9 @@ describe("App layout", () => {fireEvent.click(screen.getByRole("button", { name: /每日检查.*计划运行/ }));const detail = within(screen.getByRole("dialog", { name: "每日检查" }));expect(detail.getByText("检查仓库状态")).toBeVisible();- expect(detail.getByText(/每 1天/)).toBeInTheDocument();+ expect(detail.queryByText(/每 1天/)).not.toBeInTheDocument();+ fireEvent.click(detail.getByRole("button", { name: "任务信息" }));+ expect(within(screen.getByRole("dialog", { name: "任务信息" })).getByText(/每 1天/)).toBeVisible();expect(screen.queryByText("最近健康状态")).not.toBeInTheDocument();expect(screen.queryByText("近期无问题")).not.toBeInTheDocument();expect(screen.queryByText("Workspace automations")).not.toBeInTheDocument();diff --git a/webui/src/tests/automation-run-dialog.test.tsx b/webui/src/tests/automation-run-dialog.test.tsxindex f5a4ceaf4..e69cdfb0c 100644--- a/webui/src/tests/automation-run-dialog.test.tsx+++ b/webui/src/tests/automation-run-dialog.test.tsx@@ -33,6 +33,7 @@ describe("Automation run response", () => {expect(screen.queryByText("This record doesn’t include the response text.")).not.toBeInTheDocument();expect(fetchResult).toHaveBeenCalledWith("test-token", "reminder", 1000, "cron", expect.any(AbortSignal));await act(async () => complete({ response: "**Drink water**" }));+ await act(async () => { await vi.dynamicImportSettled(); });expect(await screen.findByText("Drink water")).toBeVisible();expect(screen.getByText("Drink water").tagName).toBe("STRONG");expect(screen.queryByText("Current instructions")).not.toBeInTheDocument();diff --git a/webui/src/tests/settings-system.test.tsx b/webui/src/tests/settings-system.test.tsxindex 31058e830..71361ab0e 100644--- a/webui/src/tests/settings-system.test.tsx+++ b/webui/src/tests/settings-system.test.tsx@@ -266,9 +266,9 @@ describe("Settings system domains", () => {fireEvent.change(input, { target: { value: "Summarize updates every weekday at 9" } });fireEvent.click(screen.getByRole("button", { name: "Send message" }));await waitFor(() => expect(onStartAutomationChat).toHaveBeenCalledWith(- "Create an automation for this request:\n\nSummarize updates every weekday at 9",- undefined,+ "Summarize updates every weekday at 9",undefined,+ { intent: "create_automation" },"primary",));fireEvent.click(screen.getByRole("button", { name: "Back to chat" }));