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 () => {