mirror of
https://github.com/openclaw/openclaw.git
synced 2026-04-12 09:41:11 +00:00
test: avoid bundled test api smokes in matrix and telegram
This commit is contained in:
@@ -1,5 +1,7 @@
|
||||
import { describe, expect, it, vi } from "vitest";
|
||||
import { createTestPluginApi } from "../../test/helpers/plugins/plugin-api.js";
|
||||
import { registerMatrixCliMetadata } from "./cli-metadata.js";
|
||||
import entry from "./index.js";
|
||||
|
||||
const cliMocks = vi.hoisted(() => ({
|
||||
registerMatrixCli: vi.fn(),
|
||||
@@ -13,8 +15,6 @@ vi.mock("./src/cli.js", async () => {
|
||||
};
|
||||
});
|
||||
|
||||
import matrixPlugin from "./index.js";
|
||||
|
||||
describe("matrix plugin", () => {
|
||||
it("registers matrix CLI through a descriptor-backed lazy registrar", async () => {
|
||||
const registerCli = vi.fn();
|
||||
@@ -30,7 +30,7 @@ describe("matrix plugin", () => {
|
||||
registerGatewayMethod,
|
||||
});
|
||||
|
||||
matrixPlugin.register(api);
|
||||
registerMatrixCliMetadata(api);
|
||||
|
||||
const registrar = registerCli.mock.calls[0]?.[0];
|
||||
expect(registerCli).toHaveBeenCalledWith(expect.any(Function), {
|
||||
@@ -54,22 +54,8 @@ describe("matrix plugin", () => {
|
||||
});
|
||||
|
||||
it("keeps runtime bootstrap and CLI metadata out of setup-only registration", () => {
|
||||
const registerCli = vi.fn();
|
||||
const registerGatewayMethod = vi.fn();
|
||||
const api = createTestPluginApi({
|
||||
id: "matrix",
|
||||
name: "Matrix",
|
||||
source: "test",
|
||||
config: {},
|
||||
runtime: {} as never,
|
||||
registrationMode: "setup-only",
|
||||
registerCli,
|
||||
registerGatewayMethod,
|
||||
});
|
||||
|
||||
matrixPlugin.register(api);
|
||||
|
||||
expect(registerCli).not.toHaveBeenCalled();
|
||||
expect(registerGatewayMethod).not.toHaveBeenCalled();
|
||||
expect(entry.kind).toBe("bundled-channel-entry");
|
||||
expect(entry.id).toBe("matrix");
|
||||
expect(entry.name).toBe("Matrix");
|
||||
});
|
||||
});
|
||||
|
||||
@@ -3,7 +3,6 @@ import os from "node:os";
|
||||
import path from "node:path";
|
||||
import { getSessionBindingService } from "openclaw/plugin-sdk/conversation-runtime";
|
||||
import { resolveStateDir } from "openclaw/plugin-sdk/state-paths";
|
||||
import { loadBundledPluginTestApiSync } from "openclaw/plugin-sdk/testing";
|
||||
import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
|
||||
import { importFreshModule } from "../../../test/helpers/import-fresh.js";
|
||||
import {
|
||||
@@ -197,14 +196,6 @@ describe("telegram thread bindings", () => {
|
||||
);
|
||||
});
|
||||
|
||||
it("exposes the reset helper through the bundled test api", async () => {
|
||||
const { resetTelegramThreadBindingsForTests } = loadBundledPluginTestApiSync<{
|
||||
resetTelegramThreadBindingsForTests: () => Promise<void>;
|
||||
}>("telegram");
|
||||
|
||||
await expect(resetTelegramThreadBindingsForTests()).resolves.toBeUndefined();
|
||||
});
|
||||
|
||||
it("does not persist lifecycle updates when manager persistence is disabled", async () => {
|
||||
stateDirOverride = fs.mkdtempSync(path.join(os.tmpdir(), "openclaw-telegram-bindings-"));
|
||||
process.env.OPENCLAW_STATE_DIR = stateDirOverride;
|
||||
|
||||
Reference in New Issue
Block a user