fix(webui): restore full-project typechecking
This commit is contained in:
1 parent
f869212e7d
commit
a1bca7dc50
56 files changed
+622
-583
No files matched your search
@@ -6,11 +6,12 @@ import { RUNTIME_CONFIG_FIELDS, RUNTIME_CONFIG_GROUPS } from "@/components/setti
|
||||
import runtimeConfigKeys from "../../../tests/webui/fixtures/runtime-config-keys.json";
|
||||
import { TimezonePicker } from "@/components/settings/shared/TimezonePicker";
|
||||
import { DEFAULT_AGENT_SETTINGS_DRAFT } from "@/components/settings/models/ModelsSettings";
|
||||
import type { SettingsPayload } from "@/lib/types";
|
||||
import { installSettingsViewTestHooks, jsonResponse, renderSettingsView, requestMutationMock, settingsPayload } from "@/tests/settings-test-utils";
|
||||
|
||||
function runtimeSettings() {
|
||||
const payload = settingsPayload();
|
||||
return { ...payload, advanced: { ...payload.advanced, exec_max_runtime_limit: 86400 }, runtime_config: {
|
||||
const runtimeConfig: NonNullable<SettingsPayload["runtime_config"]> = {
|
||||
"agents.defaults.bot_name": "nanobot",
|
||||
"agents.defaults.bot_icon": "🐈",
|
||||
"agents.defaults.timezone_mode": "auto",
|
||||
@@ -25,7 +26,8 @@ function runtimeSettings() {
|
||||
"tools.exec.sandbox_rw_binds": [],
|
||||
"agents.defaults.max_tool_iterations": 200,
|
||||
"tools.web.proxy": "http://localhost:8080",
|
||||
} };
|
||||
};
|
||||
return { ...payload, advanced: { ...payload.advanced, exec_max_runtime_limit: 86400 }, runtime_config: runtimeConfig };
|
||||
}
|
||||
|
||||
describe("Runtime configuration settings", () => {
|
||||
@@ -64,7 +66,7 @@ describe("Runtime configuration settings", () => {
|
||||
fireEvent.click(screen.getByRole("button", { name: "Capabilities" }));
|
||||
fireEvent.click(screen.getByRole("switch", { name: "Image generation" }));
|
||||
expect(document.getElementById("runtime-tools.image_generation.save_dir")).toBeInTheDocument();
|
||||
fireEvent.click(screen.getByRole("button", { name: "Close", exact: true }));
|
||||
fireEvent.click(screen.getByRole("button", { name: "Close" }));
|
||||
expect(screen.getByRole("switch", { name: "Web access" })).toBeInTheDocument();
|
||||
});
|
||||
|
||||
@@ -90,7 +92,7 @@ describe("Runtime configuration settings", () => {
|
||||
requestMutationMock.mockResolvedValue({ ...payload, runtime_config: { ...payload.runtime_config, "tools.exec.sandbox": backend } });
|
||||
renderSettingsView({ initialSection: "advanced", initialSettings: payload });
|
||||
fireEvent.click(screen.getByRole("combobox", { name: "Command sandbox" }));
|
||||
fireEvent.click(screen.getByRole("option", { name: backend || "None", exact: true }));
|
||||
fireEvent.click(screen.getByRole("option", { name: backend || "None" }));
|
||||
if (backend) expect(document.getElementById("runtime-tools.exec.sandbox_ro_binds")).toBeVisible();
|
||||
else expect(document.getElementById("runtime-tools.exec.sandbox_ro_binds")).not.toBeInTheDocument();
|
||||
await waitFor(() => expect(requestMutationMock).toHaveBeenCalledWith("settings.runtime_config.update", { values: { "tools.exec.sandbox": backend } }, 20_000));
|
||||
@@ -117,7 +119,7 @@ describe("Runtime configuration settings", () => {
|
||||
expect(editor).toHaveValue("TERM");
|
||||
fireEvent.change(editor, { target: { value: " TERM \n\n COLORTERM " } });
|
||||
requestMutationMock.mockRejectedValueOnce(new Error("Could not save list"));
|
||||
fireEvent.click(within(dialog).getByRole("button", { name: "Save", exact: true }));
|
||||
fireEvent.click(within(dialog).getByRole("button", { name: "Save" }));
|
||||
expect(await within(dialog).findByRole("alert")).toHaveTextContent("Could not save list");
|
||||
expect(editor).toHaveValue(" TERM \n\n COLORTERM ");
|
||||
expect(requestMutationMock).toHaveBeenLastCalledWith("settings.runtime_config.update", {
|
||||
@@ -125,7 +127,7 @@ describe("Runtime configuration settings", () => {
|
||||
}, 20_000);
|
||||
requestMutationMock.mockResolvedValueOnce({ ...payload, requires_restart: true,
|
||||
runtime_config: { ...payload.runtime_config, "tools.exec.allowed_env_keys": ["TERM", "COLORTERM"] } });
|
||||
fireEvent.click(within(dialog).getByRole("button", { name: "Save", exact: true }));
|
||||
fireEvent.click(within(dialog).getByRole("button", { name: "Save" }));
|
||||
await waitFor(() => expect(screen.queryByRole("dialog")).not.toBeInTheDocument());
|
||||
expect(await screen.findByText("Saved. Restart to apply changes.")).toBeVisible();
|
||||
fireEvent.click(trigger);
|
||||
@@ -134,7 +136,7 @@ describe("Runtime configuration settings", () => {
|
||||
|
||||
it("starts the API with newly saved advanced settings", async () => {
|
||||
const payload = runtimeSettings();
|
||||
payload.api = { ...payload.api, host: "192.168.1.7", timeout: 77.5, api_key_hint: "set" };
|
||||
payload.api = { ...payload.api, host: "192.168.1.7", port: 8900, timeout: 77.5, api_key_hint: "set" };
|
||||
const action = vi.fn();
|
||||
render(<RuntimeSettings form={DEFAULT_AGENT_SETTINGS_DRAFT} settings={payload}
|
||||
requiresRestartPending={false} apiService={{
|
||||
@@ -212,7 +214,7 @@ describe("Runtime configuration settings", () => {
|
||||
expect(control).toHaveTextContent("1 hour");
|
||||
expect(screen.getByText("Timed runs: up to 24 hours")).toBeVisible();
|
||||
fireEvent.click(control);
|
||||
fireEvent.click(screen.getByRole("option", { name: label, exact: true }));
|
||||
fireEvent.click(screen.getByRole("option", { name: label }));
|
||||
|
||||
await waitFor(() => expect(requestMutationMock).toHaveBeenCalledWith(
|
||||
"settings.runtime_config.update", { values: { "tools.exec.timeout": seconds } }, 20_000,
|
||||
@@ -227,7 +229,7 @@ describe("Runtime configuration settings", () => {
|
||||
} });
|
||||
renderSettingsView({ initialSection: "advanced", initialSettings: payload });
|
||||
fireEvent.click(screen.getByRole("combobox", { name: "Command runtime" }));
|
||||
fireEvent.click(screen.getByRole("option", { name: "Custom (seconds)", exact: true }));
|
||||
fireEvent.click(screen.getByRole("option", { name: "Custom (seconds)" }));
|
||||
const field = screen.getByRole("spinbutton", { name: "Custom runtime (seconds)" });
|
||||
expect(field).toHaveAttribute("max", "86400");
|
||||
fireEvent.change(field, { target: { value: "86401" } });
|
||||
@@ -246,8 +248,8 @@ describe("Runtime configuration settings", () => {
|
||||
expect(field).toHaveValue(86400);
|
||||
expect(screen.getAllByRole("alert")).toHaveLength(1);
|
||||
expect(screen.queryByText("Saved.", { exact: true })).not.toBeInTheDocument();
|
||||
fireEvent.click(screen.getByRole("button", { name: "System", exact: true }));
|
||||
fireEvent.click(screen.getByRole("button", { name: "Advanced", exact: true }));
|
||||
fireEvent.click(screen.getByRole("button", { name: "System" }));
|
||||
fireEvent.click(screen.getByRole("button", { name: "Advanced" }));
|
||||
expect(screen.getByRole("spinbutton", { name: "Custom runtime (seconds)" })).toHaveValue(86400);
|
||||
expect(screen.getByRole("alert")).toHaveTextContent("1 to 86,400");
|
||||
});
|
||||
@@ -260,7 +262,7 @@ describe("Runtime configuration settings", () => {
|
||||
} });
|
||||
renderSettingsView({ initialSection: "advanced", initialSettings: payload });
|
||||
fireEvent.click(screen.getByRole("combobox", { name: "Command runtime" }));
|
||||
fireEvent.click(screen.getByRole("option", { name: "Custom (seconds)", exact: true }));
|
||||
fireEvent.click(screen.getByRole("option", { name: "Custom (seconds)" }));
|
||||
const field = screen.getByRole("spinbutton", { name: "Custom runtime (seconds)" });
|
||||
expect(field).toHaveValue(null);
|
||||
expect(requestMutationMock).not.toHaveBeenCalled();
|
||||
@@ -277,8 +279,8 @@ describe("Runtime configuration settings", () => {
|
||||
expect(screen.getByText("Timed runs: up to 2 hours")).toBeVisible();
|
||||
expect(screen.getByRole("spinbutton", { name: "Custom runtime (seconds)" })).toHaveAttribute("max", "7200");
|
||||
fireEvent.click(screen.getByRole("combobox", { name: "Command runtime" }));
|
||||
expect(screen.getByRole("option", { name: "2 hours", exact: true })).toBeVisible();
|
||||
expect(screen.queryByRole("option", { name: "24 hours", exact: true })).not.toBeInTheDocument();
|
||||
expect(screen.getByRole("option", { name: "2 hours" })).toBeVisible();
|
||||
expect(screen.queryByRole("option", { name: "24 hours" })).not.toBeInTheDocument();
|
||||
});
|
||||
|
||||
it("keeps runtime editing available on a host without limit metadata", async () => {
|
||||
@@ -304,7 +306,7 @@ describe("Runtime configuration settings", () => {
|
||||
openWebSettings();
|
||||
const proxy = screen.getByRole("textbox", { name: "Web proxy" });
|
||||
fireEvent.change(proxy, { target: { value: "" } });
|
||||
fireEvent.click(within(screen.getByRole("dialog", { name: "Web access" })).getByRole("button", { name: "Close", exact: true }));
|
||||
fireEvent.click(within(screen.getByRole("dialog", { name: "Web access" })).getByRole("button", { name: "Close" }));
|
||||
fireEvent.click(screen.getByRole("button", { name: "System" }));
|
||||
fireEvent.click(screen.getByRole("button", { name: "Capabilities" }));
|
||||
openWebSettings();
|
||||
|
||||
Reference in new issue
Block a user