mirror of
https://github.com/openclaw/openclaw.git
synced 2026-04-12 01:31:08 +00:00
test: tighten Matrix onboarding review follow-ups
This commit is contained in:
@@ -103,6 +103,44 @@ describe("updateMatrixAccountConfig", () => {
|
||||
expect(updated.channels?.["matrix"]?.accounts?.default?.proxy).toBeUndefined();
|
||||
});
|
||||
|
||||
it("stores and clears Matrix invite auto-join settings", () => {
|
||||
const cfg = {
|
||||
channels: {
|
||||
matrix: {
|
||||
accounts: {
|
||||
default: {
|
||||
autoJoin: "allowlist",
|
||||
autoJoinAllowlist: ["#ops:example.org"],
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
} as CoreConfig;
|
||||
|
||||
const allowlistUpdated = updateMatrixAccountConfig(cfg, "default", {
|
||||
autoJoin: "allowlist",
|
||||
autoJoinAllowlist: ["!ops-room:example.org", "#ops:example.org"],
|
||||
});
|
||||
expect(allowlistUpdated.channels?.matrix?.accounts?.default).toMatchObject({
|
||||
autoJoin: "allowlist",
|
||||
autoJoinAllowlist: ["!ops-room:example.org", "#ops:example.org"],
|
||||
});
|
||||
|
||||
const offUpdated = updateMatrixAccountConfig(cfg, "default", {
|
||||
autoJoin: "off",
|
||||
autoJoinAllowlist: null,
|
||||
});
|
||||
expect(offUpdated.channels?.matrix?.accounts?.default?.autoJoin).toBe("off");
|
||||
expect(offUpdated.channels?.matrix?.accounts?.default?.autoJoinAllowlist).toBeUndefined();
|
||||
|
||||
const alwaysUpdated = updateMatrixAccountConfig(cfg, "default", {
|
||||
autoJoin: "always",
|
||||
autoJoinAllowlist: null,
|
||||
});
|
||||
expect(alwaysUpdated.channels?.matrix?.accounts?.default?.autoJoin).toBe("always");
|
||||
expect(alwaysUpdated.channels?.matrix?.accounts?.default?.autoJoinAllowlist).toBeUndefined();
|
||||
});
|
||||
|
||||
it("normalizes account id and defaults account enabled=true", () => {
|
||||
const updated = updateMatrixAccountConfig({} as CoreConfig, "Main Bot", {
|
||||
name: "Main Bot",
|
||||
|
||||
@@ -138,7 +138,7 @@ export async function runMatrixAddAccountAllowlistConfigure(params: {
|
||||
"Matrix allowFrom (full @user:server; display name only if unique)": params.allowFromInput,
|
||||
"Matrix rooms allowlist (comma-separated)": params.roomsAllowlistInput,
|
||||
"Matrix invite auto-join allowlist (comma-separated)":
|
||||
params.autoJoinAllowlistInput ?? "!ops-room:example.org",
|
||||
params.autoJoinAllowlistInput ?? "#ops-invites:example.org",
|
||||
},
|
||||
confirm: {
|
||||
"Enable end-to-end encryption (E2EE)?": false,
|
||||
|
||||
@@ -35,10 +35,10 @@ import {
|
||||
type WizardPrompter,
|
||||
} from "./runtime-api.js";
|
||||
import { moveSingleMatrixAccountConfigToNamedAccount } from "./setup-config.js";
|
||||
import type { CoreConfig } from "./types.js";
|
||||
import type { CoreConfig, MatrixConfig } from "./types.js";
|
||||
|
||||
const channel = "matrix" as const;
|
||||
type MatrixInviteAutoJoinPolicy = "allowlist" | "always" | "off";
|
||||
type MatrixInviteAutoJoinPolicy = NonNullable<MatrixConfig["autoJoin"]>;
|
||||
|
||||
const matrixInviteAutoJoinOptions: Array<{
|
||||
value: MatrixInviteAutoJoinPolicy;
|
||||
|
||||
Reference in New Issue
Block a user