test: tighten Matrix onboarding review follow-ups

This commit is contained in:
Gustavo Madeira Santana
2026-04-06 22:14:29 -04:00
parent 145a7fe9ef
commit aec7a2249a
3 changed files with 41 additions and 3 deletions

View File

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

View File

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

View File

@@ -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;