Fix local room encryption status always not enabled (#30461)

* Fix local room encryption status always not enabled

* refactor: put back the e2e test after merge

* fix: look at e2eStatus in composer of local room

* doc: add docs to `LocalRoom.isEncryptionEnabled`

* test(e2e): check composer doesn't display unencrypted state

* test: update existing tests

* test(e2e): update existing tests

* refactor: move room encryption check in a dedicated function

* refactor: make `isEncryptionEnabled` cleaner

* test: add tests for `LocalRoom.isEncrypted`

* doc: fix `useIsEncrypted` comment

---------

Co-authored-by: Florian Duros <florian.duros@ormaz.fr>
This commit is contained in:
Valere Fedronic
2025-09-10 15:09:17 +00:00
committed by GitHub
co-authored by Florian Duros
parent 8a1fc65beb
commit cd7f1a0638
9 changed files with 106 additions and 35 deletions
@@ -112,16 +112,19 @@ describe("EncryptionEvent", () => {
});
describe("for an encrypted local room", () => {
let localRoom: LocalRoom;
beforeEach(() => {
event.event.content!.algorithm = algorithm;
jest.spyOn(client.getCrypto()!, "isEncryptionEnabledInRoom").mockResolvedValue(true);
const localRoom = new LocalRoom(roomId, client, client.getUserId()!);
// jest.spyOn(client.getCrypto()!, "isEncryptionEnabledInRoom").mockResolvedValue(true);
localRoom = new LocalRoom(roomId, client, client.getUserId()!);
jest.spyOn(localRoom, "isEncryptionEnabled").mockReturnValue(true);
mocked(client.getRoom).mockReturnValue(localRoom);
renderEncryptionEvent(client, event);
});
it("should show the expected texts", async () => {
expect(client.getCrypto()!.isEncryptionEnabledInRoom).toHaveBeenCalledWith(roomId);
expect(localRoom.isEncryptionEnabled).toHaveBeenCalled();
await checkTexts("Encryption enabled", "Messages in this chat will be end-to-end encrypted.");
});
});