mirror of
https://github.com/moltbot/moltbot.git
synced 2026-04-20 13:13:06 +00:00
perf(test): trim more sdk and telegram reload churn
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
import { beforeEach, describe, expect, it, vi } from "vitest";
|
||||
import { beforeAll, beforeEach, describe, expect, it, vi } from "vitest";
|
||||
|
||||
const { performMatrixRequestMock } = vi.hoisted(() => ({
|
||||
performMatrixRequestMock: vi.fn(),
|
||||
@@ -11,9 +11,11 @@ vi.mock("./transport.js", () => ({
|
||||
let MatrixAuthedHttpClient: typeof import("./http-client.js").MatrixAuthedHttpClient;
|
||||
|
||||
describe("MatrixAuthedHttpClient", () => {
|
||||
beforeEach(async () => {
|
||||
vi.resetModules();
|
||||
beforeAll(async () => {
|
||||
({ MatrixAuthedHttpClient } = await import("./http-client.js"));
|
||||
});
|
||||
|
||||
beforeEach(() => {
|
||||
performMatrixRequestMock.mockReset();
|
||||
});
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import type { createChannelPairingChallengeIssuer } from "openclaw/plugin-sdk/channel-pairing";
|
||||
import { beforeEach, describe, expect, it, vi } from "vitest";
|
||||
import { beforeAll, beforeEach, describe, expect, it, vi } from "vitest";
|
||||
|
||||
const createChannelPairingChallengeIssuerMock = vi.hoisted(() => vi.fn());
|
||||
const upsertChannelPairingRequestMock = vi.hoisted(() =>
|
||||
@@ -52,12 +52,14 @@ function createDmMessage(overrides: Partial<Message> = {}): Message {
|
||||
}
|
||||
|
||||
describe("enforceTelegramDmAccess", () => {
|
||||
beforeEach(async () => {
|
||||
vi.resetModules();
|
||||
vi.clearAllMocks();
|
||||
beforeAll(async () => {
|
||||
({ enforceTelegramDmAccess } = await import("./dm-access.js"));
|
||||
});
|
||||
|
||||
beforeEach(() => {
|
||||
vi.clearAllMocks();
|
||||
});
|
||||
|
||||
it("allows DMs when policy is open", async () => {
|
||||
const bot = { api: { sendMessage: vi.fn(async () => undefined) } };
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import type { TelegramNetworkConfig } from "openclaw/plugin-sdk/config-runtime";
|
||||
import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
|
||||
import { afterEach, beforeAll, beforeEach, describe, expect, it, vi } from "vitest";
|
||||
|
||||
vi.mock("openclaw/plugin-sdk/runtime-env", async (importOriginal) => {
|
||||
const actual = await importOriginal<typeof import("openclaw/plugin-sdk/runtime-env")>();
|
||||
@@ -15,7 +15,6 @@ let resolveTelegramAutoSelectFamilyDecision: typeof import("./network-config.js"
|
||||
let resolveTelegramDnsResultOrderDecision: typeof import("./network-config.js").resolveTelegramDnsResultOrderDecision;
|
||||
|
||||
async function loadModule() {
|
||||
vi.resetModules();
|
||||
({ isWSL2Sync } = await import("openclaw/plugin-sdk/runtime-env"));
|
||||
({
|
||||
resetTelegramNetworkConfigStateForTests,
|
||||
@@ -25,10 +24,14 @@ async function loadModule() {
|
||||
}
|
||||
|
||||
describe("resolveTelegramAutoSelectFamilyDecision", () => {
|
||||
beforeEach(async () => {
|
||||
beforeAll(async () => {
|
||||
await loadModule();
|
||||
});
|
||||
|
||||
beforeEach(() => {
|
||||
vi.clearAllMocks();
|
||||
});
|
||||
|
||||
afterEach(async () => {
|
||||
vi.restoreAllMocks();
|
||||
if (!resetTelegramNetworkConfigStateForTests) {
|
||||
@@ -155,8 +158,8 @@ describe("resolveTelegramAutoSelectFamilyDecision", () => {
|
||||
});
|
||||
|
||||
describe("resolveTelegramDnsResultOrderDecision", () => {
|
||||
beforeEach(async () => {
|
||||
await loadModule();
|
||||
beforeEach(() => {
|
||||
vi.clearAllMocks();
|
||||
});
|
||||
|
||||
it.each([
|
||||
|
||||
Reference in New Issue
Block a user