From 4200c9e837a9750847a1a4ceec913a54fd902517 Mon Sep 17 00:00:00 2001 From: SARAMALI15792 Date: Tue, 14 Apr 2026 04:05:02 +0500 Subject: [PATCH] test(matrix): update repair bootstrap test to assert passwordless bots are repaired --- extensions/matrix/src/matrix/sdk.test.ts | 27 ++++++++++++++++++------ 1 file changed, 20 insertions(+), 7 deletions(-) diff --git a/extensions/matrix/src/matrix/sdk.test.ts b/extensions/matrix/src/matrix/sdk.test.ts index a280bdcdd5a..1f3d992d5d7 100644 --- a/extensions/matrix/src/matrix/sdk.test.ts +++ b/extensions/matrix/src/matrix/sdk.test.ts @@ -1284,16 +1284,24 @@ describe("MatrixClient crypto bootstrapping", () => { }); }); - it("does not force-reset bootstrap when password is unavailable", async () => { + it("attempts repair bootstrap even when no password is configured", async () => { matrixJsClient.getCrypto = vi.fn(() => ({ on: vi.fn() })); const client = new MatrixClient("https://matrix.example.org", "token", { encryption: true, + // no password — passwordless token-auth bot }); - const bootstrapSpy = vi.fn().mockResolvedValue({ - crossSigningReady: false, - crossSigningPublished: false, - ownDeviceVerified: false, - }); + const bootstrapSpy = vi + .fn() + .mockResolvedValueOnce({ + crossSigningReady: false, + crossSigningPublished: false, + ownDeviceVerified: false, + }) + .mockResolvedValueOnce({ + crossSigningReady: true, + crossSigningPublished: true, + ownDeviceVerified: true, + }); await ( client as unknown as { ensureCryptoSupportInitialized: () => Promise; @@ -1307,7 +1315,12 @@ describe("MatrixClient crypto bootstrapping", () => { await client.start(); - expect(bootstrapSpy).toHaveBeenCalledTimes(1); + expect(bootstrapSpy).toHaveBeenCalledTimes(2); + expect((bootstrapSpy.mock.calls as unknown[][])[1]?.[1] ?? {}).toEqual({ + forceResetCrossSigning: true, + allowSecretStorageRecreateWithoutRecoveryKey: true, + strict: true, + }); }); it("provides secret storage callbacks and resolves stored recovery key", async () => {