test(slack,line): reduce hot extension test imports

This commit is contained in:
Peter Steinberger
2026-04-23 06:27:26 +01:00
parent a46d41156d
commit 2194be201d
4 changed files with 96 additions and 77 deletions

View File

@@ -1,4 +1,4 @@
import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
import { afterEach, beforeAll, beforeEach, describe, expect, it, vi } from "vitest";
const {
pushMessageMock,
@@ -93,8 +93,11 @@ const LINE_TEST_CFG = {
};
describe("LINE send helpers", () => {
beforeEach(async () => {
vi.resetModules();
beforeAll(async () => {
sendModule = await import("./send.js");
});
beforeEach(() => {
pushMessageMock.mockReset();
replyMessageMock.mockReset();
showLoadingAnimationMock.mockReset();
@@ -125,7 +128,6 @@ describe("LINE send helpers", () => {
pushMessageMock.mockResolvedValue({});
replyMessageMock.mockResolvedValue({});
showLoadingAnimationMock.mockResolvedValue({});
sendModule = await import("./send.js");
});
afterEach(() => {

View File

@@ -3,7 +3,6 @@ import path from "node:path";
import ts from "typescript";
import { afterEach, 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 {
createPluginSetupWizardConfigure,
createTestWizardPrompter,
@@ -375,30 +374,6 @@ describe("linePlugin status.probeAccount", () => {
});
describe("line runtime api", () => {
it("loads through Jiti without duplicate export errors", () => {
const runtimeApiPath = path.join(process.cwd(), "extensions", "line", "runtime-api.ts");
expect(
loadRuntimeApiExportTypesViaJiti({
modulePath: runtimeApiPath,
exportNames: [
"buildTemplateMessageFromPayload",
"downloadLineMedia",
"isSenderAllowed",
"probeLineBot",
"pushMessageLine",
],
realPluginSdkSpecifiers: ["openclaw/plugin-sdk/line-runtime"],
}),
).toEqual({
buildTemplateMessageFromPayload: "function",
downloadLineMedia: "function",
isSenderAllowed: "function",
probeLineBot: "function",
pushMessageLine: "function",
});
}, 240_000);
it("keeps the LINE runtime barrel self-contained", () => {
const runtimeApiPath = path.join(process.cwd(), "extensions", "line", "runtime-api.ts");
expect(collectRuntimeApiPreExports(runtimeApiPath)).toEqual([]);