Periodically nag the user if their device remains unverified (#33346)

* nag the user to verify their device 2 days after they dismiss the toast

* lint

* recheck doesn't need to be awaited

* call setDeviceState
This commit is contained in:
Hubert Chathi
2026-05-26 23:49:40 +00:00
committed by GitHub
parent 2b4f983bb7
commit 220f68935e
2 changed files with 67 additions and 4 deletions
@@ -381,6 +381,50 @@ describe("DeviceListener", () => {
expect(SetupEncryptionToast.hideToast).toHaveBeenCalled();
});
it("re-shows toast after two days", async () => {
const instance = await createAndStart();
expect(SetupEncryptionToast.showToast).toHaveBeenCalledTimes(1);
jest.useFakeTimers({ advanceTimers: true });
instance.dismissEncryptionSetup();
await flushPromises();
expect(SetupEncryptionToast.hideToast).toHaveBeenCalled();
// 1.5 days after the toast was dismissed, we don't re-show the
// toast yet.
jest.advanceTimersByTime(1.5 * 24 * 60 * 60 * 1000);
expect(SetupEncryptionToast.showToast).toHaveBeenCalledTimes(1);
// 2 days after the toast was dismissed, we re-show the toast.
jest.advanceTimersByTime(0.5 * 24 * 60 * 60 * 1000);
expect(SetupEncryptionToast.showToast).toHaveBeenCalledTimes(2);
jest.useRealTimers();
});
it("doesn't re-show toast if the device is now verified", async () => {
const instance = await createAndStart();
expect(SetupEncryptionToast.showToast).toHaveBeenCalledTimes(1);
jest.useFakeTimers({ advanceTimers: true });
instance.dismissEncryptionSetup();
await flushPromises();
expect(SetupEncryptionToast.hideToast).toHaveBeenCalled();
// If the device becomes verified before the end of two days, we
// don't re-show the toast.
mockCrypto!.getDeviceVerificationStatus.mockResolvedValue(
new DeviceVerificationStatus({
trustCrossSignedDevices: true,
crossSigningVerified: true,
}),
);
instance.recheck();
await flushPromises();
jest.advanceTimersByTime(2 * 24 * 60 * 60 * 1000);
expect(SetupEncryptionToast.showToast).toHaveBeenCalledTimes(1);
jest.useRealTimers();
});
it("does not show any toasts when secret storage is being accessed", async () => {
mocked(isSecretStorageBeingAccessed).mockReturnValue(true);
await createAndStart();