From d7f9f672964902cda7f7d1522d0603f73d8040be Mon Sep 17 00:00:00 2001 From: Peter Steinberger Date: Fri, 17 Apr 2026 16:58:19 +0100 Subject: [PATCH] perf: narrow Matrix onboarding resolution test --- .../matrix/src/onboarding.resolve.test.ts | 21 +++++++++++++------ extensions/matrix/src/onboarding.ts | 4 ++++ 2 files changed, 19 insertions(+), 6 deletions(-) diff --git a/extensions/matrix/src/onboarding.resolve.test.ts b/extensions/matrix/src/onboarding.resolve.test.ts index 81bb22dc3b2..a4cdb86e70c 100644 --- a/extensions/matrix/src/onboarding.resolve.test.ts +++ b/extensions/matrix/src/onboarding.resolve.test.ts @@ -1,4 +1,5 @@ import { afterEach, beforeAll, beforeEach, describe, expect, it, vi } from "vitest"; +import type { WizardPrompter } from "../runtime-api.js"; import { installMatrixTestRuntime } from "./test-runtime.js"; import type { CoreConfig } from "./types.js"; @@ -10,11 +11,11 @@ vi.mock("./resolve-targets.js", () => ({ resolveMatrixTargets: resolveMatrixTargetsMock, })); -let runMatrixAddAccountAllowlistConfigure: typeof import("./onboarding.test-harness.js").runMatrixAddAccountAllowlistConfigure; +let promptMatrixAllowFrom: typeof import("./onboarding.js").__testing.promptMatrixAllowFrom; describe("matrix onboarding account-scoped resolution", () => { beforeAll(async () => { - ({ runMatrixAddAccountAllowlistConfigure } = await import("./onboarding.test-harness.js")); + ({ promptMatrixAllowFrom } = (await import("./onboarding.js")).__testing); }); beforeEach(() => { @@ -27,7 +28,11 @@ describe("matrix onboarding account-scoped resolution", () => { }); it("passes accountId into Matrix allowlist target resolution during onboarding", async () => { - const result = await runMatrixAddAccountAllowlistConfigure({ + const prompter = { + note: vi.fn(async () => {}), + text: vi.fn(async () => "Alice"), + } as unknown as WizardPrompter; + const result = await promptMatrixAllowFrom({ cfg: { channels: { matrix: { @@ -36,15 +41,19 @@ describe("matrix onboarding account-scoped resolution", () => { homeserver: "https://matrix.main.example.org", accessToken: "main-token", }, + ops: { + homeserver: "https://matrix.ops.example.org", + accessToken: "ops-token", + }, }, }, }, } as CoreConfig, - allowFromInput: "Alice", - roomsAllowlistInput: "", + prompter, + accountId: "ops", }); - expect(result).not.toBe("skip"); + expect(result.channels?.matrix?.accounts?.ops?.dm?.allowFrom).toEqual(["@alice:example.org"]); expect(resolveMatrixTargetsMock).toHaveBeenCalledWith({ cfg: expect.any(Object), accountId: "ops", diff --git a/extensions/matrix/src/onboarding.ts b/extensions/matrix/src/onboarding.ts index 981ae599118..b192295a7cd 100644 --- a/extensions/matrix/src/onboarding.ts +++ b/extensions/matrix/src/onboarding.ts @@ -769,3 +769,7 @@ export const matrixOnboardingAdapter: ChannelSetupWizardAdapter = { }, }), }; + +export const __testing = { + promptMatrixAllowFrom, +};