From f20d5376db05290616e2a5bfc2d29a7505763848 Mon Sep 17 00:00:00 2001 From: Isaac Ivins Date: Fri, 23 Jan 2026 11:47:59 -0500 Subject: [PATCH] updated Toast alerts --- .../src/auth/delete-account.component.spec.ts | 33 +++++++++++++++++-- .../src/auth/delete-account.component.ts | 5 +++ apps/desktop/src/locales/en/messages.json | 3 ++ 3 files changed, 39 insertions(+), 2 deletions(-) diff --git a/apps/desktop/src/auth/delete-account.component.spec.ts b/apps/desktop/src/auth/delete-account.component.spec.ts index b699045519b..e700e853eae 100644 --- a/apps/desktop/src/auth/delete-account.component.spec.ts +++ b/apps/desktop/src/auth/delete-account.component.spec.ts @@ -3,6 +3,7 @@ import { MockProxy, mock } from "jest-mock-extended"; import { AccountApiService } from "@bitwarden/common/auth/abstractions/account-api.service"; import { VerificationWithSecret } from "@bitwarden/common/auth/types/verification"; +import { FeatureFlag } from "@bitwarden/common/enums/feature-flag.enum"; import { ConfigService } from "@bitwarden/common/platform/abstractions/config/config.service"; import { I18nService } from "@bitwarden/common/platform/abstractions/i18n.service"; import { ToastService } from "@bitwarden/components"; @@ -37,6 +38,30 @@ describe("DeleteAccountComponent", () => { ); }); + describe("ngOnInit", () => { + it("should set migrationMilestone4 to true when flag is enabled", async () => { + configService.getFeatureFlag.mockResolvedValue(true); + + await component.ngOnInit(); + + expect(component["migrationMilestone4"]).toBe(true); + expect(configService.getFeatureFlag).toHaveBeenCalledWith( + FeatureFlag.DesktopUiMigrationMilestone4, + ); + }); + + it("should set migrationMilestone4 to false when flag is disabled", async () => { + configService.getFeatureFlag.mockResolvedValue(false); + + await component.ngOnInit(); + + expect(component["migrationMilestone4"]).toBe(false); + expect(configService.getFeatureFlag).toHaveBeenCalledWith( + FeatureFlag.DesktopUiMigrationMilestone4, + ); + }); + }); + describe("submit", () => { const mockVerification: VerificationWithSecret = { type: 0, @@ -68,13 +93,17 @@ describe("DeleteAccountComponent", () => { expect(component["invalidSecret"]).toBe(false); }); - it("should set invalidSecret to true when deletion fails", async () => { + it("should set invalidSecret to true and show error toast when deletion fails", async () => { accountApiService.deleteAccount.mockRejectedValue(new Error("Invalid credentials")); await component.submit(); expect(accountApiService.deleteAccount).toHaveBeenCalledWith(mockVerification); - expect(toastService.showToast).not.toHaveBeenCalled(); + expect(toastService.showToast).toHaveBeenCalledWith({ + variant: "error", + title: "errorOccurred", + message: "userVerificationFailed", + }); expect(component["invalidSecret"]).toBe(true); }); diff --git a/apps/desktop/src/auth/delete-account.component.ts b/apps/desktop/src/auth/delete-account.component.ts index 15c2b9d669d..82db661c909 100644 --- a/apps/desktop/src/auth/delete-account.component.ts +++ b/apps/desktop/src/auth/delete-account.component.ts @@ -91,6 +91,11 @@ export class DeleteAccountComponent implements OnInit { } catch { if (this.migrationMilestone4) { this.invalidSecret = true; + this.toastService.showToast({ + variant: "error", + title: this.i18nService.t("errorOccurred"), + message: this.i18nService.t("userVerificationFailed"), + }); } } }; diff --git a/apps/desktop/src/locales/en/messages.json b/apps/desktop/src/locales/en/messages.json index 0ce98b8c62b..68898ca28fa 100644 --- a/apps/desktop/src/locales/en/messages.json +++ b/apps/desktop/src/locales/en/messages.json @@ -189,6 +189,9 @@ "verificationCodeTotp": { "message": "Verification code (TOTP)" }, + "userVerificationFailed": { + "message": "User verification failed." + }, "website": { "message": "Website" },