Make the DeviceListener listen to KeyBackupDecryptionKeyCached events (#32811)

Fixes #31916
This commit is contained in:
Andy Balaam
2026-03-16 13:19:42 +00:00
committed by GitHub
parent cace9d918f
commit 35babd83d6
2 changed files with 30 additions and 0 deletions
@@ -161,6 +161,28 @@ describe("DeviceListener", () => {
expect(unwatchSettingSpy).toHaveBeenCalled();
});
it("responds to KeyBackupDecryptionKeyCached events", async () => {
// Given a Device Listener
const recheck = jest.fn();
const deviceListener = await createAndStart();
deviceListener.recheck = recheck;
// When a KeyBackupDecryptionKeyCached event happens
mockClient.emit(CryptoEvent.KeyBackupDecryptionKeyCached, "3");
// Then we rechecked the device information
expect(recheck).toHaveBeenCalled();
// And when we stop our device listener
const removeListener = jest.fn(() => {});
// @ts-ignore overwriting with a mock
mockClient.removeListener = removeListener;
deviceListener.stop();
// Then it should stop listening
expect(removeListener).toHaveBeenCalledWith(CryptoEvent.KeyBackupDecryptionKeyCached, expect.any(Function));
});
describe("when device client information feature is enabled", () => {
beforeEach(() => {
jest.spyOn(SettingsStore, "getValue").mockImplementation(