























@@ -54,9 +54,7 @@ describe("matrix onboarding", () => {
5454}
5555| undefined;
5656expect(result.accountId).toBe("ops");
57-expect(opsAccount).toMatchObject({
58-enabled: true,
59-});
57+expect(opsAccount?.enabled).toBe(true);
6058expect(opsAccount?.homeserver).toBeUndefined();
6159expect(opsAccount?.accessToken).toBeUndefined();
6260}
@@ -104,15 +102,12 @@ describe("matrix onboarding", () => {
104102}
105103106104expect(result.accountId).toBe("ops");
107-expect(result.cfg.channels?.matrix?.accounts?.ops).toMatchObject({
108-enabled: true,
109-groupPolicy: "allowlist",
110-groups: {
111-"!ops-room:example.org": { enabled: true },
112-},
113-autoJoin: "allowlist",
114-autoJoinAllowlist: ["#ops-invites:example.org"],
115-});
105+const opsAccount = result.cfg.channels?.matrix?.accounts?.ops;
106+expect(opsAccount?.enabled).toBe(true);
107+expect(opsAccount?.groupPolicy).toBe("allowlist");
108+expect(opsAccount?.groups?.["!ops-room:example.org"]?.enabled).toBe(true);
109+expect(opsAccount?.autoJoin).toBe("allowlist");
110+expect(opsAccount?.autoJoinAllowlist).toEqual(["#ops-invites:example.org"]);
116111expect(notes.join("\n")).toContain("WARNING: Matrix invite auto-join defaults to off.");
117112});
118113@@ -136,17 +131,15 @@ describe("matrix onboarding", () => {
136131expect(result.cfg.channels?.matrix?.homeserver).toBeUndefined();
137132expect(result.cfg.channels?.matrix?.accessToken).toBeUndefined();
138133expect(result.cfg.channels?.matrix?.avatarUrl).toBeUndefined();
139-expect(result.cfg.channels?.matrix?.accounts?.default).toMatchObject({
140-homeserver: "https://matrix.main.example.org",
141-userId: "@main:example.org",
142-accessToken: "main-token",
143-avatarUrl: "mxc://matrix.main.example.org/main-avatar",
144-});
145-expect(result.cfg.channels?.matrix?.accounts?.ops).toMatchObject({
146-name: "ops",
147-homeserver: "https://matrix.ops.example.org",
148-accessToken: "ops-token",
149-});
134+const defaultAccount = result.cfg.channels?.matrix?.accounts?.default;
135+expect(defaultAccount?.homeserver).toBe("https://matrix.main.example.org");
136+expect(defaultAccount?.userId).toBe("@main:example.org");
137+expect(defaultAccount?.accessToken).toBe("main-token");
138+expect(defaultAccount?.avatarUrl).toBe("mxc://matrix.main.example.org/main-avatar");
139+const opsAccount = result.cfg.channels?.matrix?.accounts?.ops;
140+expect(opsAccount?.name).toBe("ops");
141+expect(opsAccount?.homeserver).toBe("https://matrix.ops.example.org");
142+expect(opsAccount?.accessToken).toBe("ops-token");
150143});
151144152145it("reuses an existing raw default-like key during onboarding promotion when defaultAccount is unset", async () => {
@@ -183,24 +176,21 @@ describe("matrix onboarding", () => {
183176return;
184177}
185178186-expect(result.cfg.channels?.matrix?.accounts?.Default).toMatchObject({
187-enabled: true,
188-deviceName: "Legacy raw key",
189-homeserver: "https://matrix.main.example.org",
190-userId: "@main:example.org",
191-accessToken: "main-token",
192-avatarUrl: "mxc://matrix.main.example.org/main-avatar",
193-});
179+const defaultAccount = result.cfg.channels?.matrix?.accounts?.Default;
180+expect(defaultAccount?.enabled).toBe(true);
181+expect(defaultAccount?.deviceName).toBe("Legacy raw key");
182+expect(defaultAccount?.homeserver).toBe("https://matrix.main.example.org");
183+expect(defaultAccount?.userId).toBe("@main:example.org");
184+expect(defaultAccount?.accessToken).toBe("main-token");
185+expect(defaultAccount?.avatarUrl).toBe("mxc://matrix.main.example.org/main-avatar");
194186expect(result.cfg.channels?.matrix?.accounts?.default).toBeUndefined();
195-expect(result.cfg.channels?.matrix?.accounts?.support).toMatchObject({
196-homeserver: "https://matrix.support.example.org",
197-accessToken: "support-token",
198-});
199-expect(result.cfg.channels?.matrix?.accounts?.ops).toMatchObject({
200-name: "ops",
201-homeserver: "https://matrix.ops.example.org",
202-accessToken: "ops-token",
203-});
187+const supportAccount = result.cfg.channels?.matrix?.accounts?.support;
188+expect(supportAccount?.homeserver).toBe("https://matrix.support.example.org");
189+expect(supportAccount?.accessToken).toBe("support-token");
190+const opsAccount = result.cfg.channels?.matrix?.accounts?.ops;
191+expect(opsAccount?.name).toBe("ops");
192+expect(opsAccount?.homeserver).toBe("https://matrix.ops.example.org");
193+expect(opsAccount?.accessToken).toBe("ops-token");
204194});
205195206196it("includes device env var names in auth help text", async () => {
@@ -259,13 +249,10 @@ describe("matrix onboarding", () => {
259249return;
260250}
261251262-expect(result.cfg.channels?.matrix).toMatchObject({
263-homeserver: "http://localhost.localdomain:8008",
264-network: {
265-dangerouslyAllowPrivateNetwork: true,
266-},
267-accessToken: "ops-token",
268-});
252+const matrixConfig = result.cfg.channels?.matrix;
253+expect(matrixConfig?.homeserver).toBe("http://localhost.localdomain:8008");
254+expect(matrixConfig?.network?.dangerouslyAllowPrivateNetwork).toBe(true);
255+expect(matrixConfig?.accessToken).toBe("ops-token");
269256});
270257271258it("preserves SecretRef access tokens when keeping existing credentials", async () => {
@@ -357,21 +344,16 @@ describe("matrix onboarding", () => {
357344}
358345359346expect(result.accountId).toBe("ops");
360-expect(result.cfg.channels?.["matrix"]?.accounts?.ops).toMatchObject({
361-homeserver: "https://matrix.ops.example.org",
362-accessToken: "ops-token",
363-deviceName: "Ops Gateway",
364-dm: {
365-policy: "allowlist",
366-allowFrom: ["@alice:example.org"],
367-},
368-groupPolicy: "allowlist",
369-autoJoin: "allowlist",
370-autoJoinAllowlist: ["#ops-invites:example.org"],
371-groups: {
372-"!ops-room:example.org": { enabled: true },
373-},
374-});
347+const opsAccount = result.cfg.channels?.["matrix"]?.accounts?.ops;
348+expect(opsAccount?.homeserver).toBe("https://matrix.ops.example.org");
349+expect(opsAccount?.accessToken).toBe("ops-token");
350+expect(opsAccount?.deviceName).toBe("Ops Gateway");
351+expect(opsAccount?.dm?.policy).toBe("allowlist");
352+expect(opsAccount?.dm?.allowFrom).toEqual(["@alice:example.org"]);
353+expect(opsAccount?.groupPolicy).toBe("allowlist");
354+expect(opsAccount?.autoJoin).toBe("allowlist");
355+expect(opsAccount?.autoJoinAllowlist).toEqual(["#ops-invites:example.org"]);
356+expect(opsAccount?.groups?.["!ops-room:example.org"]?.enabled).toBe(true);
375357expect(result.cfg.channels?.["matrix"]?.dm).toBeUndefined();
376358expect(result.cfg.channels?.["matrix"]?.groups).toBeUndefined();
377359expect(notes.join("\n")).toContain("WARNING: Matrix invite auto-join defaults to off.");
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。