From fdc993e779a92bbd2ce37be081551f3667b42d51 Mon Sep 17 00:00:00 2001 From: Peter Steinberger Date: Sun, 22 Mar 2026 12:35:14 -0700 Subject: [PATCH] test: fix extension thread proof regressions --- extensions/matrix/src/matrix/send.test.ts | 32 ++------------------ extensions/nostr/src/channel.inbound.test.ts | 2 +- 2 files changed, 4 insertions(+), 30 deletions(-) diff --git a/extensions/matrix/src/matrix/send.test.ts b/extensions/matrix/src/matrix/send.test.ts index c49c0ff878b..e50510a90d1 100644 --- a/extensions/matrix/src/matrix/send.test.ts +++ b/extensions/matrix/src/matrix/send.test.ts @@ -1,6 +1,8 @@ -import { beforeAll, beforeEach, describe, expect, it, vi } from "vitest"; +import { beforeEach, describe, expect, it, vi } from "vitest"; import type { PluginRuntime } from "../../runtime-api.js"; import { setMatrixRuntime } from "../runtime.js"; +import { voteMatrixPoll } from "./actions/polls.js"; +import { sendMessageMatrix, sendTypingMatrix } from "./send.js"; const loadWebMediaMock = vi.fn().mockResolvedValue({ buffer: Buffer.from("media"), @@ -44,10 +46,6 @@ const runtimeStub = { }, } as unknown as PluginRuntime; -let sendMessageMatrix: typeof import("./send.js").sendMessageMatrix; -let sendTypingMatrix: typeof import("./send.js").sendTypingMatrix; -let voteMatrixPoll: typeof import("./actions/polls.js").voteMatrixPoll; - const makeClient = () => { const sendMessage = vi.fn().mockResolvedValue("evt1"); const sendEvent = vi.fn().mockResolvedValue("evt-poll-vote"); @@ -68,13 +66,6 @@ const makeClient = () => { }; describe("sendMessageMatrix media", () => { - beforeAll(async () => { - setMatrixRuntime(runtimeStub); - ({ sendMessageMatrix } = await import("./send.js")); - ({ sendTypingMatrix } = await import("./send.js")); - ({ voteMatrixPoll } = await import("./actions/polls.js")); - }); - beforeEach(() => { loadWebMediaMock.mockReset().mockResolvedValue({ buffer: Buffer.from("media"), @@ -326,13 +317,6 @@ describe("sendMessageMatrix media", () => { }); describe("sendMessageMatrix threads", () => { - beforeAll(async () => { - setMatrixRuntime(runtimeStub); - ({ sendMessageMatrix } = await import("./send.js")); - ({ sendTypingMatrix } = await import("./send.js")); - ({ voteMatrixPoll } = await import("./actions/polls.js")); - }); - beforeEach(() => { vi.clearAllMocks(); loadConfigMock.mockReset().mockReturnValue({}); @@ -377,11 +361,6 @@ describe("sendMessageMatrix threads", () => { }); describe("voteMatrixPoll", () => { - beforeAll(async () => { - setMatrixRuntime(runtimeStub); - ({ voteMatrixPoll } = await import("./actions/polls.js")); - }); - beforeEach(() => { vi.clearAllMocks(); loadConfigMock.mockReset().mockReturnValue({}); @@ -523,11 +502,6 @@ describe("voteMatrixPoll", () => { }); describe("sendTypingMatrix", () => { - beforeAll(async () => { - setMatrixRuntime(runtimeStub); - ({ sendTypingMatrix } = await import("./send.js")); - }); - beforeEach(() => { vi.clearAllMocks(); loadConfigMock.mockReset().mockReturnValue({}); diff --git a/extensions/nostr/src/channel.inbound.test.ts b/extensions/nostr/src/channel.inbound.test.ts index ab09b9433da..bc05d93a5a5 100644 --- a/extensions/nostr/src/channel.inbound.test.ts +++ b/extensions/nostr/src/channel.inbound.test.ts @@ -35,8 +35,8 @@ function createRuntimeHarness() { }, commands: { shouldComputeCommandAuthorized: vi.fn(() => true), + resolveCommandAuthorizedFromAuthorizers: vi.fn(() => true), }, - resolveCommandAuthorizedFromAuthorizers: vi.fn(() => true), routing: { resolveAgentRoute: vi.fn(({ accountId, peer }) => ({ agentId: "agent-nostr",