mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-10 08:02:42 +00:00
test(commands): dedupe subagent status assertions
This commit is contained in:
@@ -988,37 +988,17 @@ describe("handleCommands subagents", () => {
|
|||||||
expect(result.reply?.text).not.toContain("1k io");
|
expect(result.reply?.text).not.toContain("1k io");
|
||||||
});
|
});
|
||||||
|
|
||||||
it("omits subagent status line when none exist", async () => {
|
it.each([
|
||||||
const cfg = {
|
{
|
||||||
commands: { text: true },
|
name: "omits subagent status line when none exist",
|
||||||
channels: { whatsapp: { allowFrom: ["*"] } },
|
seedRuns: () => undefined,
|
||||||
session: { mainKey: "main", scope: "per-sender" },
|
verboseLevel: "on" as const,
|
||||||
} as OpenClawConfig;
|
expectedText: [] as string[],
|
||||||
const params = buildParams("/status", cfg);
|
unexpectedText: ["Subagents:"],
|
||||||
params.resolvedVerboseLevel = "on";
|
},
|
||||||
const result = await handleCommands(params);
|
{
|
||||||
expect(result.shouldContinue).toBe(false);
|
name: "includes subagent count in /status when active",
|
||||||
expect(result.reply?.text).not.toContain("Subagents:");
|
seedRuns: () => {
|
||||||
});
|
|
||||||
|
|
||||||
it("returns help/usage for invalid or incomplete subagents commands", async () => {
|
|
||||||
const cfg = {
|
|
||||||
commands: { text: true },
|
|
||||||
channels: { whatsapp: { allowFrom: ["*"] } },
|
|
||||||
} as OpenClawConfig;
|
|
||||||
const cases = [
|
|
||||||
{ commandBody: "/subagents foo", expectedText: "/subagents" },
|
|
||||||
{ commandBody: "/subagents info", expectedText: "/subagents info" },
|
|
||||||
] as const;
|
|
||||||
for (const testCase of cases) {
|
|
||||||
const params = buildParams(testCase.commandBody, cfg);
|
|
||||||
const result = await handleCommands(params);
|
|
||||||
expect(result.shouldContinue).toBe(false);
|
|
||||||
expect(result.reply?.text).toContain(testCase.expectedText);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
it("includes subagent count in /status when active", async () => {
|
|
||||||
addSubagentRunForTests({
|
addSubagentRunForTests({
|
||||||
runId: "run-1",
|
runId: "run-1",
|
||||||
childSessionKey: "agent:main:subagent:abc",
|
childSessionKey: "agent:main:subagent:abc",
|
||||||
@@ -1029,18 +1009,14 @@ describe("handleCommands subagents", () => {
|
|||||||
createdAt: 1000,
|
createdAt: 1000,
|
||||||
startedAt: 1000,
|
startedAt: 1000,
|
||||||
});
|
});
|
||||||
const cfg = {
|
},
|
||||||
commands: { text: true },
|
verboseLevel: "off" as const,
|
||||||
channels: { whatsapp: { allowFrom: ["*"] } },
|
expectedText: ["🤖 Subagents: 1 active"],
|
||||||
session: { mainKey: "main", scope: "per-sender" },
|
unexpectedText: [] as string[],
|
||||||
} as OpenClawConfig;
|
},
|
||||||
const params = buildParams("/status", cfg);
|
{
|
||||||
const result = await handleCommands(params);
|
name: "includes subagent details in /status when verbose",
|
||||||
expect(result.shouldContinue).toBe(false);
|
seedRuns: () => {
|
||||||
expect(result.reply?.text).toContain("🤖 Subagents: 1 active");
|
|
||||||
});
|
|
||||||
|
|
||||||
it("includes subagent details in /status when verbose", async () => {
|
|
||||||
addSubagentRunForTests({
|
addSubagentRunForTests({
|
||||||
runId: "run-1",
|
runId: "run-1",
|
||||||
childSessionKey: "agent:main:subagent:abc",
|
childSessionKey: "agent:main:subagent:abc",
|
||||||
@@ -1063,17 +1039,47 @@ describe("handleCommands subagents", () => {
|
|||||||
endedAt: 1200,
|
endedAt: 1200,
|
||||||
outcome: { status: "ok" },
|
outcome: { status: "ok" },
|
||||||
});
|
});
|
||||||
|
},
|
||||||
|
verboseLevel: "on" as const,
|
||||||
|
expectedText: ["🤖 Subagents: 1 active", "· 1 done"],
|
||||||
|
unexpectedText: [] as string[],
|
||||||
|
},
|
||||||
|
])("$name", async ({ seedRuns, verboseLevel, expectedText, unexpectedText }) => {
|
||||||
|
seedRuns();
|
||||||
const cfg = {
|
const cfg = {
|
||||||
commands: { text: true },
|
commands: { text: true },
|
||||||
channels: { whatsapp: { allowFrom: ["*"] } },
|
channels: { whatsapp: { allowFrom: ["*"] } },
|
||||||
session: { mainKey: "main", scope: "per-sender" },
|
session: { mainKey: "main", scope: "per-sender" },
|
||||||
} as OpenClawConfig;
|
} as OpenClawConfig;
|
||||||
const params = buildParams("/status", cfg);
|
const params = buildParams("/status", cfg);
|
||||||
|
if (verboseLevel === "on") {
|
||||||
params.resolvedVerboseLevel = "on";
|
params.resolvedVerboseLevel = "on";
|
||||||
|
}
|
||||||
const result = await handleCommands(params);
|
const result = await handleCommands(params);
|
||||||
expect(result.shouldContinue).toBe(false);
|
expect(result.shouldContinue).toBe(false);
|
||||||
expect(result.reply?.text).toContain("🤖 Subagents: 1 active");
|
for (const expected of expectedText) {
|
||||||
expect(result.reply?.text).toContain("· 1 done");
|
expect(result.reply?.text).toContain(expected);
|
||||||
|
}
|
||||||
|
for (const blocked of unexpectedText) {
|
||||||
|
expect(result.reply?.text).not.toContain(blocked);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
it("returns help/usage for invalid or incomplete subagents commands", async () => {
|
||||||
|
const cfg = {
|
||||||
|
commands: { text: true },
|
||||||
|
channels: { whatsapp: { allowFrom: ["*"] } },
|
||||||
|
} as OpenClawConfig;
|
||||||
|
const cases = [
|
||||||
|
{ commandBody: "/subagents foo", expectedText: "/subagents" },
|
||||||
|
{ commandBody: "/subagents info", expectedText: "/subagents info" },
|
||||||
|
] as const;
|
||||||
|
for (const testCase of cases) {
|
||||||
|
const params = buildParams(testCase.commandBody, cfg);
|
||||||
|
const result = await handleCommands(params);
|
||||||
|
expect(result.shouldContinue).toBe(false);
|
||||||
|
expect(result.reply?.text).toContain(testCase.expectedText);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
it("returns info for a subagent", async () => {
|
it("returns info for a subagent", async () => {
|
||||||
|
|||||||
Reference in New Issue
Block a user