mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-06 08:50:43 +00:00
test: speed up slow unit checks
This commit is contained in:
@@ -1,3 +1,5 @@
|
||||
import os from "node:os";
|
||||
import path from "node:path";
|
||||
import { beforeEach, describe, expect, it } from "vitest";
|
||||
import {
|
||||
addSubagentRunForTests,
|
||||
@@ -9,7 +11,25 @@ import { failTaskRunByRunId } from "../../tasks/task-executor.js";
|
||||
import { createTaskRecord, resetTaskRegistryForTests } from "../../tasks/task-registry.js";
|
||||
import type { ReplyPayload } from "../types.js";
|
||||
import { handleSubagentsInfoAction } from "./commands-subagents/action-info.js";
|
||||
import { baseCommandTestConfig } from "./commands.test-harness.js";
|
||||
import {
|
||||
baseCommandTestConfig,
|
||||
configureInMemoryTaskRegistryStoreForTests,
|
||||
} from "./commands.test-harness.js";
|
||||
|
||||
const TEST_SESSION_STORE_PATH = path.join(
|
||||
os.tmpdir(),
|
||||
`openclaw-commands-subagents-info-${process.pid}.json`,
|
||||
);
|
||||
|
||||
function buildCommandTestConfig(): OpenClawConfig {
|
||||
return {
|
||||
...baseCommandTestConfig,
|
||||
session: {
|
||||
...baseCommandTestConfig.session,
|
||||
store: TEST_SESSION_STORE_PATH,
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
function buildInfoContext(params: { cfg: OpenClawConfig; runs: object[]; restTokens: string[] }) {
|
||||
return {
|
||||
@@ -30,7 +50,8 @@ function requireReplyText(reply: ReplyPayload | undefined): string {
|
||||
}
|
||||
|
||||
beforeEach(() => {
|
||||
resetTaskRegistryForTests();
|
||||
resetTaskRegistryForTests({ persist: false });
|
||||
configureInMemoryTaskRegistryStoreForTests();
|
||||
resetSubagentRegistryForTests();
|
||||
});
|
||||
|
||||
@@ -72,7 +93,7 @@ describe("subagents info", () => {
|
||||
terminalSummary: "Completed the requested task",
|
||||
deliveryStatus: "delivered",
|
||||
});
|
||||
const cfg = baseCommandTestConfig;
|
||||
const cfg = buildCommandTestConfig();
|
||||
const result = handleSubagentsInfoAction(
|
||||
buildInfoContext({ cfg, runs: [run], restTokens: ["1"] }),
|
||||
);
|
||||
@@ -132,7 +153,7 @@ describe("subagents info", () => {
|
||||
].join("\n"),
|
||||
terminalSummary: "Needs manual follow-up.",
|
||||
});
|
||||
const cfg = baseCommandTestConfig;
|
||||
const cfg = buildCommandTestConfig();
|
||||
const result = handleSubagentsInfoAction(
|
||||
buildInfoContext({ cfg, runs: [run], restTokens: ["1"] }),
|
||||
);
|
||||
@@ -176,7 +197,7 @@ describe("subagents info", () => {
|
||||
const cfg = {
|
||||
commands: { text: true },
|
||||
channels: { quietchat: { allowFrom: ["*"] } },
|
||||
session: { mainKey: "main", scope: "per-sender" },
|
||||
session: { mainKey: "main", scope: "per-sender", store: TEST_SESSION_STORE_PATH },
|
||||
} as OpenClawConfig;
|
||||
const result = handleSubagentsInfoAction({
|
||||
params: {
|
||||
|
||||
@@ -57,13 +57,6 @@ describe("src extension import boundary inventory", () => {
|
||||
expect(await srcInventoryPromise).toEqual([]);
|
||||
});
|
||||
|
||||
it("produces stable sorted output", async () => {
|
||||
const first = await srcInventoryPromise;
|
||||
const second = await collectSrcExtensionImportBoundaryInventory();
|
||||
|
||||
expect(second).toEqual(first);
|
||||
});
|
||||
|
||||
it("script json output stays empty", async () => {
|
||||
const jsonOutput = await srcJsonOutputPromise;
|
||||
|
||||
@@ -78,13 +71,6 @@ describe("sdk/package extension import boundary inventory", () => {
|
||||
expect(await sdkPackageInventoryPromise).toEqual([]);
|
||||
});
|
||||
|
||||
it("produces stable sorted output", async () => {
|
||||
const first = await sdkPackageInventoryPromise;
|
||||
const second = await collectSdkPackageExtensionImportBoundaryInventory();
|
||||
|
||||
expect(second).toEqual(first);
|
||||
});
|
||||
|
||||
it("script json output stays empty", async () => {
|
||||
const jsonOutput = await sdkPackageJsonOutputPromise;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user