mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-10 14:44:57 +00:00
test(agents): dedupe sessions_spawn e2e reset setup
This commit is contained in:
@@ -150,11 +150,11 @@ const waitFor = async (predicate: () => boolean, timeoutMs = 2000) => {
|
|||||||
describe("openclaw-tools: subagents (sessions_spawn lifecycle)", () => {
|
describe("openclaw-tools: subagents (sessions_spawn lifecycle)", () => {
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
resetSessionsSpawnConfigOverride();
|
resetSessionsSpawnConfigOverride();
|
||||||
|
resetSubagentRegistryForTests();
|
||||||
|
callGatewayMock.mockReset();
|
||||||
});
|
});
|
||||||
|
|
||||||
it("sessions_spawn runs cleanup flow after subagent completion", async () => {
|
it("sessions_spawn runs cleanup flow after subagent completion", async () => {
|
||||||
resetSubagentRegistryForTests();
|
|
||||||
callGatewayMock.mockReset();
|
|
||||||
const patchCalls: Array<{ key?: string; label?: string }> = [];
|
const patchCalls: Array<{ key?: string; label?: string }> = [];
|
||||||
|
|
||||||
const ctx = setupSessionsSpawnGatewayMock({
|
const ctx = setupSessionsSpawnGatewayMock({
|
||||||
@@ -226,8 +226,6 @@ describe("openclaw-tools: subagents (sessions_spawn lifecycle)", () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it("sessions_spawn runs cleanup via lifecycle events", async () => {
|
it("sessions_spawn runs cleanup via lifecycle events", async () => {
|
||||||
resetSubagentRegistryForTests();
|
|
||||||
callGatewayMock.mockReset();
|
|
||||||
let deletedKey: string | undefined;
|
let deletedKey: string | undefined;
|
||||||
const ctx = setupSessionsSpawnGatewayMock({
|
const ctx = setupSessionsSpawnGatewayMock({
|
||||||
...buildDiscordCleanupHooks((key) => {
|
...buildDiscordCleanupHooks((key) => {
|
||||||
@@ -312,8 +310,6 @@ describe("openclaw-tools: subagents (sessions_spawn lifecycle)", () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it("sessions_spawn deletes session when cleanup=delete via agent.wait", async () => {
|
it("sessions_spawn deletes session when cleanup=delete via agent.wait", async () => {
|
||||||
resetSubagentRegistryForTests();
|
|
||||||
callGatewayMock.mockReset();
|
|
||||||
let deletedKey: string | undefined;
|
let deletedKey: string | undefined;
|
||||||
const ctx = setupSessionsSpawnGatewayMock({
|
const ctx = setupSessionsSpawnGatewayMock({
|
||||||
includeChatHistory: true,
|
includeChatHistory: true,
|
||||||
@@ -372,8 +368,6 @@ describe("openclaw-tools: subagents (sessions_spawn lifecycle)", () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it("sessions_spawn reports timed out when agent.wait returns timeout", async () => {
|
it("sessions_spawn reports timed out when agent.wait returns timeout", async () => {
|
||||||
resetSubagentRegistryForTests();
|
|
||||||
callGatewayMock.mockReset();
|
|
||||||
const calls: Array<{ method?: string; params?: unknown }> = [];
|
const calls: Array<{ method?: string; params?: unknown }> = [];
|
||||||
let agentCallCount = 0;
|
let agentCallCount = 0;
|
||||||
|
|
||||||
@@ -440,8 +434,6 @@ describe("openclaw-tools: subagents (sessions_spawn lifecycle)", () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it("sessions_spawn announces with requester accountId", async () => {
|
it("sessions_spawn announces with requester accountId", async () => {
|
||||||
resetSubagentRegistryForTests();
|
|
||||||
callGatewayMock.mockReset();
|
|
||||||
const calls: Array<{ method?: string; params?: unknown }> = [];
|
const calls: Array<{ method?: string; params?: unknown }> = [];
|
||||||
let agentCallCount = 0;
|
let agentCallCount = 0;
|
||||||
let childRunId: string | undefined;
|
let childRunId: string | undefined;
|
||||||
|
|||||||
@@ -67,8 +67,6 @@ async function expectSpawnUsesConfiguredModel(params: {
|
|||||||
callId: string;
|
callId: string;
|
||||||
expectedModel: string;
|
expectedModel: string;
|
||||||
}) {
|
}) {
|
||||||
resetSubagentRegistryForTests();
|
|
||||||
callGatewayMock.mockReset();
|
|
||||||
if (params.config) {
|
if (params.config) {
|
||||||
setSessionsSpawnConfigOverride(params.config);
|
setSessionsSpawnConfigOverride(params.config);
|
||||||
} else {
|
} else {
|
||||||
@@ -101,11 +99,11 @@ async function expectSpawnUsesConfiguredModel(params: {
|
|||||||
describe("openclaw-tools: subagents (sessions_spawn model + thinking)", () => {
|
describe("openclaw-tools: subagents (sessions_spawn model + thinking)", () => {
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
resetSessionsSpawnConfigOverride();
|
resetSessionsSpawnConfigOverride();
|
||||||
|
resetSubagentRegistryForTests();
|
||||||
|
callGatewayMock.mockReset();
|
||||||
});
|
});
|
||||||
|
|
||||||
it("sessions_spawn applies a model to the child session", async () => {
|
it("sessions_spawn applies a model to the child session", async () => {
|
||||||
resetSubagentRegistryForTests();
|
|
||||||
callGatewayMock.mockReset();
|
|
||||||
const calls: GatewayCall[] = [];
|
const calls: GatewayCall[] = [];
|
||||||
mockLongRunningSpawnFlow({ calls, acceptedAtBase: 3000 });
|
mockLongRunningSpawnFlow({ calls, acceptedAtBase: 3000 });
|
||||||
|
|
||||||
@@ -141,8 +139,6 @@ describe("openclaw-tools: subagents (sessions_spawn model + thinking)", () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it("sessions_spawn forwards thinking overrides to the agent run", async () => {
|
it("sessions_spawn forwards thinking overrides to the agent run", async () => {
|
||||||
resetSubagentRegistryForTests();
|
|
||||||
callGatewayMock.mockReset();
|
|
||||||
const calls: Array<{ method?: string; params?: unknown }> = [];
|
const calls: Array<{ method?: string; params?: unknown }> = [];
|
||||||
|
|
||||||
callGatewayMock.mockImplementation(async (opts: unknown) => {
|
callGatewayMock.mockImplementation(async (opts: unknown) => {
|
||||||
@@ -174,8 +170,6 @@ describe("openclaw-tools: subagents (sessions_spawn model + thinking)", () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it("sessions_spawn rejects invalid thinking levels", async () => {
|
it("sessions_spawn rejects invalid thinking levels", async () => {
|
||||||
resetSubagentRegistryForTests();
|
|
||||||
callGatewayMock.mockReset();
|
|
||||||
const calls: Array<{ method?: string }> = [];
|
const calls: Array<{ method?: string }> = [];
|
||||||
|
|
||||||
callGatewayMock.mockImplementation(async (opts: unknown) => {
|
callGatewayMock.mockImplementation(async (opts: unknown) => {
|
||||||
@@ -252,8 +246,6 @@ describe("openclaw-tools: subagents (sessions_spawn model + thinking)", () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it("sessions_spawn fails when model patch is rejected", async () => {
|
it("sessions_spawn fails when model patch is rejected", async () => {
|
||||||
resetSubagentRegistryForTests();
|
|
||||||
callGatewayMock.mockReset();
|
|
||||||
const calls: GatewayCall[] = [];
|
const calls: GatewayCall[] = [];
|
||||||
mockLongRunningSpawnFlow({
|
mockLongRunningSpawnFlow({
|
||||||
calls,
|
calls,
|
||||||
@@ -285,8 +277,6 @@ describe("openclaw-tools: subagents (sessions_spawn model + thinking)", () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it("sessions_spawn supports legacy timeoutSeconds alias", async () => {
|
it("sessions_spawn supports legacy timeoutSeconds alias", async () => {
|
||||||
resetSubagentRegistryForTests();
|
|
||||||
callGatewayMock.mockReset();
|
|
||||||
let spawnedTimeout: number | undefined;
|
let spawnedTimeout: number | undefined;
|
||||||
|
|
||||||
callGatewayMock.mockImplementation(async (opts: unknown) => {
|
callGatewayMock.mockImplementation(async (opts: unknown) => {
|
||||||
|
|||||||
Reference in New Issue
Block a user