























@@ -211,7 +211,9 @@ describe("matrix CLI verification commands", () => {
211211});
212212const program = buildProgram();
213213214-await program.parseAsync(["matrix", "verify", "bootstrap", "--json"], { from: "user" });
214+await program.parseAsync(["matrix", "verify", "bootstrap", "--json"], {
215+from: "user",
216+});
215217216218expect(process.exitCode).toBe(1);
217219});
@@ -267,6 +269,76 @@ describe("matrix CLI verification commands", () => {
267269expect(process.exitCode).toBe(1);
268270});
269271272+it("passes loaded cfg to verify status action", async () => {
273+const fakeCfg = { channels: { matrix: {} } };
274+matrixRuntimeLoadConfigMock.mockReturnValue(fakeCfg);
275+mockMatrixVerificationStatus({ recoveryKeyCreatedAt: null });
276+const program = buildProgram();
277+278+await program.parseAsync(["matrix", "verify", "status"], { from: "user" });
279+280+expect(getMatrixVerificationStatusMock).toHaveBeenCalledWith(
281+expect.objectContaining({ cfg: fakeCfg }),
282+);
283+});
284+285+it("passes loaded cfg to all verify subcommands", async () => {
286+const fakeCfg = { channels: { matrix: {} } };
287+matrixRuntimeLoadConfigMock.mockReturnValue(fakeCfg);
288+289+// verify bootstrap
290+const program1 = buildProgram();
291+await program1.parseAsync(["matrix", "verify", "bootstrap"], {
292+from: "user",
293+});
294+expect(bootstrapMatrixVerificationMock).toHaveBeenCalledWith(
295+expect.objectContaining({ cfg: fakeCfg }),
296+);
297+298+// verify device
299+verifyMatrixRecoveryKeyMock.mockResolvedValue({ success: true });
300+const program2 = buildProgram();
301+await program2.parseAsync(["matrix", "verify", "device", "test-key"], {
302+from: "user",
303+});
304+expect(verifyMatrixRecoveryKeyMock).toHaveBeenCalledWith(
305+"test-key",
306+expect.objectContaining({ cfg: fakeCfg }),
307+);
308+309+// verify backup status
310+getMatrixRoomKeyBackupStatusMock.mockResolvedValue({});
311+const program3 = buildProgram();
312+await program3.parseAsync(["matrix", "verify", "backup", "status"], {
313+from: "user",
314+});
315+expect(getMatrixRoomKeyBackupStatusMock).toHaveBeenCalledWith(
316+expect.objectContaining({ cfg: fakeCfg }),
317+);
318+319+// verify backup reset
320+const program4 = buildProgram();
321+await program4.parseAsync(["matrix", "verify", "backup", "reset", "--yes"], { from: "user" });
322+expect(resetMatrixRoomKeyBackupMock).toHaveBeenCalledWith(
323+expect.objectContaining({ cfg: fakeCfg }),
324+);
325+326+// verify backup restore
327+restoreMatrixRoomKeyBackupMock.mockResolvedValue({
328+success: true,
329+imported: 0,
330+total: 0,
331+backup: {},
332+});
333+const program5 = buildProgram();
334+await program5.parseAsync(["matrix", "verify", "backup", "restore"], {
335+from: "user",
336+});
337+expect(restoreMatrixRoomKeyBackupMock).toHaveBeenCalledWith(
338+expect.objectContaining({ cfg: fakeCfg }),
339+);
340+});
341+270342it("lists matrix devices", async () => {
271343listMatrixOwnDevicesMock.mockResolvedValue([
272344{
@@ -332,7 +404,9 @@ describe("matrix CLI verification commands", () => {
332404from: "user",
333405});
334406335-expect(pruneMatrixStaleGatewayDevicesMock).toHaveBeenCalledWith({ accountId: "poe" });
407+expect(pruneMatrixStaleGatewayDevicesMock).toHaveBeenCalledWith({
408+accountId: "poe",
409+});
336410expect(console.log).toHaveBeenCalledWith("Deleted stale OpenClaw devices: BritdXC6iL");
337411expect(console.log).toHaveBeenCalledWith("Current device: A7hWrQ70ea");
338412expect(console.log).toHaveBeenCalledWith("Remaining devices: 1");
@@ -452,7 +526,9 @@ describe("matrix CLI verification commands", () => {
452526{ from: "user" },
453527);
454528455-expect(bootstrapMatrixVerificationMock).toHaveBeenCalledWith({ accountId: "ops" });
529+expect(bootstrapMatrixVerificationMock).toHaveBeenCalledWith({
530+accountId: "ops",
531+});
456532expect(console.log).toHaveBeenCalledWith("Matrix verification bootstrap: complete");
457533expect(console.log).toHaveBeenCalledWith(
458534`Recovery key created at: ${formatExpectedLocalTimestamp("2026-03-09T06:00:00.000Z")}`,
@@ -705,7 +781,9 @@ describe("matrix CLI verification commands", () => {
705781});
706782const program = buildProgram();
707783708-await program.parseAsync(["matrix", "verify", "bootstrap", "--json"], { from: "user" });
784+await program.parseAsync(["matrix", "verify", "bootstrap", "--json"], {
785+from: "user",
786+});
709787710788expect(process.exitCode).toBe(0);
711789});
@@ -715,7 +793,9 @@ describe("matrix CLI verification commands", () => {
715793mockMatrixVerificationStatus({ recoveryKeyCreatedAt: recoveryCreatedAt });
716794const program = buildProgram();
717795718-await program.parseAsync(["matrix", "verify", "status", "--verbose"], { from: "user" });
796+await program.parseAsync(["matrix", "verify", "status", "--verbose"], {
797+from: "user",
798+});
719799720800expect(console.log).toHaveBeenCalledWith(
721801`Recovery key created at: ${formatExpectedLocalTimestamp(recoveryCreatedAt)}`,
@@ -920,7 +1000,9 @@ describe("matrix CLI verification commands", () => {
9201000it("requires --yes before resetting the Matrix room-key backup", async () => {
9211001const program = buildProgram();
9221002923-await program.parseAsync(["matrix", "verify", "backup", "reset"], { from: "user" });
1003+await program.parseAsync(["matrix", "verify", "backup", "reset"], {
1004+from: "user",
1005+});
92410069251007expect(process.exitCode).toBe(1);
9261008expect(resetMatrixRoomKeyBackupMock).not.toHaveBeenCalled();
@@ -936,7 +1018,10 @@ describe("matrix CLI verification commands", () => {
9361018from: "user",
9371019});
9381020939-expect(resetMatrixRoomKeyBackupMock).toHaveBeenCalledWith({ accountId: "default" });
1021+expect(resetMatrixRoomKeyBackupMock).toHaveBeenCalledWith({
1022+accountId: "default",
1023+cfg: {},
1024+});
9401025expect(console.log).toHaveBeenCalledWith("Reset success: yes");
9411026expect(console.log).toHaveBeenCalledWith("Previous backup version: 1");
9421027expect(console.log).toHaveBeenCalledWith("Deleted backup version: 1");
@@ -981,6 +1066,7 @@ describe("matrix CLI verification commands", () => {
98110669821067expect(getMatrixVerificationStatusMock).toHaveBeenCalledWith({
9831068accountId: "assistant",
1069+cfg: {},
9841070includeRecoveryKey: false,
9851071});
9861072expect(console.log).toHaveBeenCalledWith("Account: assistant");
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。