test(agents): dedupe sessions_spawn e2e reset setup

This commit is contained in:
Peter Steinberger
2026-02-22 07:54:50 +00:00
parent 1f0695ba47
commit ad400afb24
2 changed files with 4 additions and 22 deletions

View File

@@ -150,11 +150,11 @@ const waitFor = async (predicate: () => boolean, timeoutMs = 2000) => {
describe("openclaw-tools: subagents (sessions_spawn lifecycle)", () => {
beforeEach(() => {
resetSessionsSpawnConfigOverride();
resetSubagentRegistryForTests();
callGatewayMock.mockReset();
});
it("sessions_spawn runs cleanup flow after subagent completion", async () => {
resetSubagentRegistryForTests();
callGatewayMock.mockReset();
const patchCalls: Array<{ key?: string; label?: string }> = [];
const ctx = setupSessionsSpawnGatewayMock({
@@ -226,8 +226,6 @@ describe("openclaw-tools: subagents (sessions_spawn lifecycle)", () => {
});
it("sessions_spawn runs cleanup via lifecycle events", async () => {
resetSubagentRegistryForTests();
callGatewayMock.mockReset();
let deletedKey: string | undefined;
const ctx = setupSessionsSpawnGatewayMock({
...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 () => {
resetSubagentRegistryForTests();
callGatewayMock.mockReset();
let deletedKey: string | undefined;
const ctx = setupSessionsSpawnGatewayMock({
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 () => {
resetSubagentRegistryForTests();
callGatewayMock.mockReset();
const calls: Array<{ method?: string; params?: unknown }> = [];
let agentCallCount = 0;
@@ -440,8 +434,6 @@ describe("openclaw-tools: subagents (sessions_spawn lifecycle)", () => {
});
it("sessions_spawn announces with requester accountId", async () => {
resetSubagentRegistryForTests();
callGatewayMock.mockReset();
const calls: Array<{ method?: string; params?: unknown }> = [];
let agentCallCount = 0;
let childRunId: string | undefined;