mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-26 06:15:13 +00:00
test: tighten status and onboarding assertions
This commit is contained in:
@@ -264,8 +264,8 @@ describe("promptRemoteGatewayConfig", () => {
|
||||
const next = await promptRemoteGatewayConfig({} as OpenClawConfig, prompter);
|
||||
|
||||
expect(next.gateway?.remote?.url).toBe("ws://127.0.0.1:18789");
|
||||
expect(select).not.toHaveBeenCalledWith(
|
||||
expect.objectContaining({ message: "Connection method" }),
|
||||
expect(vi.mocked(select).mock.calls.map(([params]) => params.message)).not.toContain(
|
||||
"Connection method",
|
||||
);
|
||||
});
|
||||
|
||||
@@ -391,7 +391,9 @@ describe("promptRemoteGatewayConfig", () => {
|
||||
const next = await promptRemoteGatewayConfig(cfg, prompter);
|
||||
|
||||
expect(next.gateway?.remote?.token).toBe("preexisting-remote-token");
|
||||
expect(text).not.toHaveBeenCalledWith(expect.objectContaining({ message: "Gateway token" }));
|
||||
expect(vi.mocked(text).mock.calls.map(([params]) => params.message)).not.toContain(
|
||||
"Gateway token",
|
||||
);
|
||||
});
|
||||
|
||||
it("keeps an existing remote gateway password when user confirms via masked-preview prompt", async () => {
|
||||
@@ -427,6 +429,8 @@ describe("promptRemoteGatewayConfig", () => {
|
||||
const next = await promptRemoteGatewayConfig(cfg, prompter);
|
||||
|
||||
expect(next.gateway?.remote?.password).toBe("preexisting-remote-password");
|
||||
expect(text).not.toHaveBeenCalledWith(expect.objectContaining({ message: "Gateway password" }));
|
||||
expect(vi.mocked(text).mock.calls.map(([params]) => params.message)).not.toContain(
|
||||
"Gateway password",
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -77,31 +77,20 @@ describe("buildChannelsTable", () => {
|
||||
},
|
||||
);
|
||||
|
||||
expect(table.rows).toContainEqual(
|
||||
expect.objectContaining({
|
||||
id: "discord",
|
||||
state: "ok",
|
||||
detail: expect.not.stringContaining("unavailable"),
|
||||
}),
|
||||
);
|
||||
expect(table.details[0]?.rows[0]).toEqual(
|
||||
expect.objectContaining({
|
||||
Status: "OK",
|
||||
Notes: expect.stringContaining("credential available in gateway runtime"),
|
||||
}),
|
||||
);
|
||||
const row = table.rows.find((entry) => entry.id === "discord");
|
||||
expect(row?.state).toBe("ok");
|
||||
expect(row?.detail).not.toContain("unavailable");
|
||||
const detailRow = table.details[0]?.rows[0];
|
||||
expect(detailRow?.Status).toBe("OK");
|
||||
expect(detailRow?.Notes).toContain("credential available in gateway runtime");
|
||||
});
|
||||
|
||||
it("warns when a configured token is unavailable and there is no live account proof", async () => {
|
||||
const table = await buildChannelsTable({ channels: { discord: { enabled: true } } });
|
||||
|
||||
expect(table.rows).toContainEqual(
|
||||
expect.objectContaining({
|
||||
id: "discord",
|
||||
state: "warn",
|
||||
detail: expect.stringContaining("unavailable"),
|
||||
}),
|
||||
);
|
||||
const row = table.rows.find((entry) => entry.id === "discord");
|
||||
expect(row?.state).toBe("warn");
|
||||
expect(row?.detail).toContain("unavailable");
|
||||
});
|
||||
|
||||
it("shows configured official external channels when the plugin is missing", async () => {
|
||||
|
||||
@@ -9,67 +9,60 @@ import {
|
||||
createStatusCommandOverviewRowsParams,
|
||||
} from "./status.test-support.ts";
|
||||
|
||||
function findRowValue(rows: Array<{ Item: string; Value: string }>, item: string) {
|
||||
return rows.find((row) => row.Item === item)?.Value;
|
||||
}
|
||||
|
||||
describe("status-overview-rows", () => {
|
||||
it("builds command overview rows from the shared surface", () => {
|
||||
expect(buildStatusCommandOverviewRows(createStatusCommandOverviewRowsParams())).toEqual(
|
||||
expect.arrayContaining([
|
||||
{ Item: "OS", Value: `macOS · node ${process.versions.node}` },
|
||||
{
|
||||
Item: "Memory",
|
||||
Value:
|
||||
"1 files · 2 chunks · plugin memory · ok(vector ready) · warn(fts ready) · muted(cache warm)",
|
||||
},
|
||||
{ Item: "Plugin compatibility", Value: "warn(1 notice · 1 plugin)" },
|
||||
{ Item: "Sessions", Value: "2 active · default gpt-5.5 (12k ctx) · store.json" },
|
||||
]),
|
||||
const rows = buildStatusCommandOverviewRows(createStatusCommandOverviewRowsParams());
|
||||
|
||||
expect(findRowValue(rows, "OS")).toBe(`macOS · node ${process.versions.node}`);
|
||||
expect(findRowValue(rows, "Memory")).toBe(
|
||||
"1 files · 2 chunks · plugin memory · ok(vector ready) · warn(fts ready) · muted(cache warm)",
|
||||
);
|
||||
expect(findRowValue(rows, "Plugin compatibility")).toBe("warn(1 notice · 1 plugin)");
|
||||
expect(findRowValue(rows, "Sessions")).toBe(
|
||||
"2 active · default gpt-5.5 (12k ctx) · store.json",
|
||||
);
|
||||
});
|
||||
|
||||
it("marks skipped memory inspection as not checked in fast status output", () => {
|
||||
expect(
|
||||
buildStatusCommandOverviewRows(
|
||||
createStatusCommandOverviewRowsParams({
|
||||
memory: null,
|
||||
memoryPlugin: { enabled: true, slot: "memory-lancedb-pro" },
|
||||
}),
|
||||
),
|
||||
).toEqual(
|
||||
expect.arrayContaining([
|
||||
{
|
||||
Item: "Memory",
|
||||
Value: "muted(enabled (plugin memory-lancedb-pro) · not checked)",
|
||||
},
|
||||
]),
|
||||
const rows = buildStatusCommandOverviewRows(
|
||||
createStatusCommandOverviewRowsParams({
|
||||
memory: null,
|
||||
memoryPlugin: { enabled: true, slot: "memory-lancedb-pro" },
|
||||
}),
|
||||
);
|
||||
|
||||
expect(findRowValue(rows, "Memory")).toBe(
|
||||
"muted(enabled (plugin memory-lancedb-pro) · not checked)",
|
||||
);
|
||||
});
|
||||
|
||||
it("builds status-all overview rows from the shared surface", () => {
|
||||
expect(
|
||||
buildStatusAllOverviewRows({
|
||||
surface: {
|
||||
...baseStatusOverviewSurface,
|
||||
tailscaleMode: "off",
|
||||
tailscaleHttpsUrl: null,
|
||||
gatewayConnection: { url: "wss://gateway.example.com", urlSource: "config" },
|
||||
},
|
||||
osLabel: "macOS",
|
||||
configPath: "/tmp/openclaw.json",
|
||||
secretDiagnosticsCount: 2,
|
||||
agentStatus: {
|
||||
bootstrapPendingCount: 1,
|
||||
totalSessions: 2,
|
||||
agents: [{ id: "main", lastActiveAgeMs: 60_000 }],
|
||||
},
|
||||
tailscaleBackendState: "Running",
|
||||
}),
|
||||
).toEqual(
|
||||
expect.arrayContaining([
|
||||
{ Item: "Version", Value: VERSION },
|
||||
{ Item: "OS", Value: "macOS" },
|
||||
{ Item: "Config", Value: "/tmp/openclaw.json" },
|
||||
{ Item: "Security", Value: "Run: openclaw security audit --deep" },
|
||||
{ Item: "Secrets", Value: "2 diagnostics" },
|
||||
]),
|
||||
);
|
||||
const rows = buildStatusAllOverviewRows({
|
||||
surface: {
|
||||
...baseStatusOverviewSurface,
|
||||
tailscaleMode: "off",
|
||||
tailscaleHttpsUrl: null,
|
||||
gatewayConnection: { url: "wss://gateway.example.com", urlSource: "config" },
|
||||
},
|
||||
osLabel: "macOS",
|
||||
configPath: "/tmp/openclaw.json",
|
||||
secretDiagnosticsCount: 2,
|
||||
agentStatus: {
|
||||
bootstrapPendingCount: 1,
|
||||
totalSessions: 2,
|
||||
agents: [{ id: "main", lastActiveAgeMs: 60_000 }],
|
||||
},
|
||||
tailscaleBackendState: "Running",
|
||||
});
|
||||
|
||||
expect(findRowValue(rows, "Version")).toBe(VERSION);
|
||||
expect(findRowValue(rows, "OS")).toBe("macOS");
|
||||
expect(findRowValue(rows, "Config")).toBe("/tmp/openclaw.json");
|
||||
expect(findRowValue(rows, "Security")).toBe("Run: openclaw security audit --deep");
|
||||
expect(findRowValue(rows, "Secrets")).toBe("2 diagnostics");
|
||||
});
|
||||
});
|
||||
|
||||
@@ -265,10 +265,8 @@ describe("tasks commands", () => {
|
||||
};
|
||||
expect(payload.maintenance.sessions.pruned).toBe(1);
|
||||
expect(payload.maintenance.sessions.runningCronJobs).toBe(1);
|
||||
expect(payload.maintenance.sessions.stores[0]).toMatchObject({
|
||||
pruned: 1,
|
||||
preservedRunning: 1,
|
||||
});
|
||||
expect(payload.maintenance.sessions.stores[0]?.pruned).toBe(1);
|
||||
expect(payload.maintenance.sessions.stores[0]?.preservedRunning).toBe(1);
|
||||
|
||||
const updated = JSON.parse(await fs.readFile(storePath, "utf-8")) as Record<string, unknown>;
|
||||
expect(updated["agent:main:cron:done-job:run:old-run"]).toBeUndefined();
|
||||
|
||||
Reference in New Issue
Block a user