test: speed up extension suites

This commit is contained in:
Peter Steinberger
2026-03-31 02:11:53 +01:00
parent 1f6a964e57
commit f7285e0a9e
53 changed files with 762 additions and 675 deletions

View File

@@ -1,7 +1,7 @@
import { readFileSync } from "node:fs";
import path from "node:path";
import ts from "typescript";
import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
import { afterEach, beforeAll, beforeEach, describe, expect, it, vi } from "vitest";
import { bundledPluginRoot } from "../../../test/helpers/bundled-plugin-paths.js";
import { loadRuntimeApiExportTypesViaJiti } from "../../../test/helpers/plugins/jiti-runtime-api.ts";
import {
@@ -177,14 +177,16 @@ describe("line setup wizard", () => {
});
describe("probeLineBot", () => {
beforeEach(async () => {
vi.resetModules();
beforeAll(async () => {
({ probeLineBot } = await import("./probe.js"));
});
beforeEach(() => {
getBotInfoMock.mockReset();
MessagingApiClientMock.mockReset();
MessagingApiClientMock.mockImplementation(function () {
return { getBotInfo: getBotInfoMock };
});
({ probeLineBot } = await import("./probe.js"));
});
afterEach(() => {
@@ -233,10 +235,6 @@ describe("linePlugin status.probeAccount", () => {
pictureUrl: "https://example.com/bot.png",
});
const { linePlugin: freshLinePlugin } = await import("./channel.js");
const { clearLineRuntime: clearFreshLineRuntime } = await import("./runtime.js");
const { probeLineBot: directProbeLineBot } = await import("./probe.js");
clearFreshLineRuntime();
const params = {
cfg: {} as OpenClawConfig,
account: {
@@ -249,8 +247,10 @@ describe("linePlugin status.probeAccount", () => {
timeoutMs: 50,
};
await expect(freshLinePlugin.status!.probeAccount!(params)).resolves.toEqual(
await directProbeLineBot("token", 50),
clearLineRuntime();
await expect(linePlugin.status!.probeAccount!(params)).resolves.toEqual(
await probeLineBot("token", 50),
);
});
});