mirror of
https://github.com/openclaw/openclaw.git
synced 2026-04-22 14:41:34 +00:00
test: speed up core unit suites
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
import type { AgentToolResult } from "@mariozechner/pi-agent-core";
|
||||
import { beforeEach, describe, expect, it, vi } from "vitest";
|
||||
import { beforeAll, beforeEach, describe, expect, it, vi } from "vitest";
|
||||
import type { OpenClawConfig } from "../../../config/config.js";
|
||||
import type { ChannelMessageActionAdapter } from "../types.js";
|
||||
|
||||
@@ -194,7 +194,7 @@ async function expectSlackSendRejected(params: Record<string, unknown>, error: R
|
||||
expect(handleSlackAction).not.toHaveBeenCalled();
|
||||
}
|
||||
|
||||
beforeEach(async () => {
|
||||
beforeAll(async () => {
|
||||
vi.resetModules();
|
||||
({ discordMessageActions } = await import("../../../../extensions/discord/runtime-api.js"));
|
||||
({ handleDiscordMessageAction } = await import("./discord/handle-action.js"));
|
||||
@@ -205,6 +205,9 @@ beforeEach(async () => {
|
||||
({ signalMessageActions } = await import("../../../../extensions/signal/src/message-actions.js"));
|
||||
signalReactionModule = await import("../../../../extensions/signal/src/send-reactions.js");
|
||||
({ createSlackActions } = await import("../../../../extensions/slack/src/channel-actions.js"));
|
||||
});
|
||||
|
||||
beforeEach(() => {
|
||||
vi.clearAllMocks();
|
||||
vi.restoreAllMocks();
|
||||
vi.spyOn(discordRuntimeModule, "handleDiscordAction").mockImplementation(
|
||||
|
||||
@@ -156,10 +156,11 @@ describe("onboard (non-interactive): gateway and remote auth", () => {
|
||||
|
||||
tempHome = await makeTempWorkspace("openclaw-onboard-");
|
||||
process.env.HOME = tempHome;
|
||||
|
||||
await loadGatewayOnboardModules();
|
||||
});
|
||||
|
||||
beforeEach(async () => {
|
||||
await loadGatewayOnboardModules();
|
||||
beforeEach(() => {
|
||||
gatewayClientCalls.length = 0;
|
||||
});
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { afterEach, describe, expect, it, vi } from "vitest";
|
||||
import { afterEach, beforeAll, describe, expect, it, vi } from "vitest";
|
||||
import type { OpenClawConfig } from "../config/config.js";
|
||||
import type { PluginWebSearchProviderEntry } from "../plugins/types.js";
|
||||
|
||||
@@ -94,8 +94,14 @@ function createBundledDuckDuckGoEntry(): PluginWebSearchProviderEntry {
|
||||
}
|
||||
|
||||
describe("onboard-search provider resolution", () => {
|
||||
afterEach(() => {
|
||||
let mod: typeof import("./onboard-search.js");
|
||||
|
||||
beforeAll(async () => {
|
||||
vi.resetModules();
|
||||
mod = await import("./onboard-search.js");
|
||||
});
|
||||
|
||||
afterEach(() => {
|
||||
vi.clearAllMocks();
|
||||
});
|
||||
|
||||
@@ -105,7 +111,6 @@ describe("onboard-search provider resolution", () => {
|
||||
params?.config ? [customEntry] : [],
|
||||
);
|
||||
|
||||
const mod = await import("./onboard-search.js");
|
||||
const cfg: OpenClawConfig = {
|
||||
tools: {
|
||||
web: {
|
||||
@@ -146,7 +151,6 @@ describe("onboard-search provider resolution", () => {
|
||||
params?.config ? [customEntry] : [],
|
||||
);
|
||||
|
||||
const mod = await import("./onboard-search.js");
|
||||
const cfg: OpenClawConfig = {
|
||||
plugins: {
|
||||
installs: {
|
||||
@@ -197,7 +201,6 @@ describe("onboard-search provider resolution", () => {
|
||||
mocks.listBundledWebSearchProviders.mockReturnValue([firecrawlEntry]);
|
||||
mocks.resolveBundledWebSearchPluginId.mockReturnValue("firecrawl");
|
||||
|
||||
const mod = await import("./onboard-search.js");
|
||||
const cfg: OpenClawConfig = {
|
||||
tools: {
|
||||
web: {
|
||||
@@ -231,7 +234,6 @@ describe("onboard-search provider resolution", () => {
|
||||
params?.config ? [duckduckgoEntry] : [duckduckgoEntry],
|
||||
);
|
||||
|
||||
const mod = await import("./onboard-search.js");
|
||||
const notes: string[] = [];
|
||||
const prompter = {
|
||||
intro: vi.fn(async () => {}),
|
||||
|
||||
Reference in New Issue
Block a user