perf: narrow Matrix onboarding resolution test

This commit is contained in:
Peter Steinberger
2026-04-17 16:58:19 +01:00
parent 14c4d6457a
commit d7f9f67296
2 changed files with 19 additions and 6 deletions

View File

@@ -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",

View File

@@ -769,3 +769,7 @@ export const matrixOnboardingAdapter: ChannelSetupWizardAdapter = {
},
}),
};
export const __testing = {
promptMatrixAllowFrom,
};