mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-06 07:40:44 +00:00
perf: narrow Matrix onboarding resolution test
This commit is contained in:
@@ -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",
|
||||
|
||||
@@ -769,3 +769,7 @@ export const matrixOnboardingAdapter: ChannelSetupWizardAdapter = {
|
||||
},
|
||||
}),
|
||||
};
|
||||
|
||||
export const __testing = {
|
||||
promptMatrixAllowFrom,
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user