From c33f878443c842bb3cbdff84f306307d98b6a25e Mon Sep 17 00:00:00 2001 From: John Harrington <84741727+harr1424@users.noreply.github.com> Date: Sun, 15 Nov 2026 08:31:42 -0700 Subject: [PATCH] [PM-41494] Show the import result in the popup before the new experience dialog --- .../components/vault/vault.component.spec.ts | 79 +++++++++++++++++++ .../popup/components/vault/vault.component.ts | 10 ++- 2 files changed, 88 insertions(+), 1 deletion(-) diff --git a/apps/browser/src/vault/popup/components/vault/vault.component.spec.ts b/apps/browser/src/vault/popup/components/vault/vault.component.spec.ts index 0a0015a1a7a..94806bcee3e 100644 --- a/apps/browser/src/vault/popup/components/vault/vault.component.spec.ts +++ b/apps/browser/src/vault/popup/components/vault/vault.component.spec.ts @@ -53,6 +53,7 @@ import { import { BrowserApi } from "../../../../platform/browser/browser-api"; import BrowserPopupUtils from "../../../../platform/browser/browser-popup-utils"; +import { ImportConfirmationPopupService } from "../../../../tools/popup/settings/import/import-confirmation-popup.service"; import { ImportUpgradeNavigationService } from "../../../../tools/popup/settings/import/import-upgrade-navigation.service"; import { IntroCarouselService } from "../../services/intro-carousel.service"; import { VaultPopupAutofillService } from "../../services/vault-popup-autofill.service"; @@ -330,6 +331,7 @@ describe("VaultComponent", () => { }; const importUpgradeNavigationSvc = mock(); + const importConfirmationPopupSvc = mock(); const premiumUpsellSvc = { showUpsell: jest.fn().mockReturnValue(false), @@ -345,6 +347,9 @@ describe("VaultComponent", () => { beforeEach(async () => { jest.clearAllMocks(); + // No import result is pending unless a test says so. + importConfirmationPopupSvc.conditionallyOpen.mockReset(); + importConfirmationPopupSvc.conditionallyOpen.mockResolvedValue(false); premiumUpsellSvc.showUpsell.mockReturnValue(false); routeParams$.next(convertToParamMap({})); vaultNav$.next({ vaults: [], organizationDataOwnership: false }); @@ -417,6 +422,10 @@ describe("VaultComponent", () => { provide: ImportUpgradeNavigationService, useValue: importUpgradeNavigationSvc, }, + { + provide: ImportConfirmationPopupService, + useValue: importConfirmationPopupSvc, + }, { provide: SearchService, useValue: { isCipherSearching$: of(false) }, @@ -961,6 +970,19 @@ describe("VaultComponent", () => { flush(); })); + it("ngOnInit shows the active user's own result of an import that finished in a tab", fakeAsync(() => { + importConfirmationPopupSvc.conditionallyOpen.mockClear(); + activeAccount$.next({ id: "user-xyz" }); + + void component.ngOnInit(); + tick(); + + expect(importConfirmationPopupSvc.conditionallyOpen).toHaveBeenCalledTimes(1); + expect(importConfirmationPopupSvc.conditionallyOpen).toHaveBeenCalledWith("user-xyz"); + + flush(); + })); + it("dismissVaultNudgeSpotlight forwards to NudgesService with active user id", fakeAsync(() => { const spy = jest.spyOn(nudgesSvc, "dismissNudge").mockResolvedValue(undefined); @@ -1388,6 +1410,63 @@ describe("VaultComponent", () => { ); })); + it("holds the dialog back on an open that showed the result of an import", fakeAsync(() => { + importConfirmationPopupSvc.conditionallyOpen.mockResolvedValueOnce(true); + + initVault(); + + expect(newExperienceDialogSpy).not.toHaveBeenCalled(); + })); + + it("opens the dialog when there was no import result to show", fakeAsync(() => { + importConfirmationPopupSvc.conditionallyOpen.mockResolvedValueOnce(false); + + initVault(); + + expect(newExperienceDialogSpy).toHaveBeenCalled(); + })); + + it("looks for an import result only after data ownership enforcement has finished", fakeAsync(() => { + let finish!: () => void; + (vaultItemsTransferSvc.enforceOrganizationDataOwnership as jest.Mock).mockReturnValueOnce( + new Promise((resolve) => (finish = resolve)), + ); + + initVault(); + + expect(importConfirmationPopupSvc.conditionallyOpen).not.toHaveBeenCalled(); + + finish(); + tick(); + + expect(importConfirmationPopupSvc.conditionallyOpen).toHaveBeenCalledTimes(1); + })); + + it("leaves the nudge undismissed on an open that showed the result of an import", fakeAsync(() => { + importConfirmationPopupSvc.conditionallyOpen.mockResolvedValueOnce(true); + + initVault(); + + expect(nudgesSvc.dismissNudge).not.toHaveBeenCalledWith( + NudgeType.Vfo1NewExperience, + expect.anything(), + ); + })); + + it("opens the dialog on the next open, after an open that showed the result of an import", fakeAsync(() => { + importConfirmationPopupSvc.conditionallyOpen + .mockResolvedValueOnce(true) + .mockResolvedValueOnce(false); + + initVault(); + + expect(newExperienceDialogSpy).not.toHaveBeenCalled(); + + initVault(); + + expect(newExperienceDialogSpy).toHaveBeenCalledTimes(1); + })); + it("leaves dismissing the nudge to the dialog's actions", fakeAsync(() => { newExperienceDialogSpy.mockReturnValue(new Promise(() => {})); diff --git a/apps/browser/src/vault/popup/components/vault/vault.component.ts b/apps/browser/src/vault/popup/components/vault/vault.component.ts index 663173214de..edad0b46bc2 100644 --- a/apps/browser/src/vault/popup/components/vault/vault.component.ts +++ b/apps/browser/src/vault/popup/components/vault/vault.component.ts @@ -86,6 +86,7 @@ import { CurrentAccountComponent } from "../../../../auth/popup/account-switchin import { PopOutComponent } from "../../../../platform/popup/components/pop-out.component"; import { PopupHeaderComponent } from "../../../../platform/popup/layout/popup-header.component"; import { PopupPageComponent } from "../../../../platform/popup/layout/popup-page.component"; +import { ImportConfirmationPopupService } from "../../../../tools/popup/settings/import/import-confirmation-popup.service"; import { ImportUpgradeNavigationService } from "../../../../tools/popup/settings/import/import-upgrade-navigation.service"; import { IntroCarouselService } from "../../services/intro-carousel.service"; import { VaultPopupItemsService } from "../../services/vault-popup-items.service"; @@ -416,6 +417,7 @@ export class VaultComponent implements OnInit, OnDestroy { } private readonly importUpgradeNavigationService = inject(ImportUpgradeNavigationService); + private readonly importConfirmationPopupService = inject(ImportConfirmationPopupService); /** * Follows the scroll region rather than latching it: the table claims it only once its rows @@ -518,7 +520,13 @@ export class VaultComponent implements OnInit, OnDestroy { this.readySubject.next(true); - await this.openNewExperienceDialog(this.activeUserId, onboardingWelcomeDismissed); + // The next open gets the new experience prompt: it must not open over the import result. + const showedImportResult = await this.importConfirmationPopupService.conditionallyOpen( + this.activeUserId, + ); + if (!showedImportResult) { + await this.openNewExperienceDialog(this.activeUserId, onboardingWelcomeDismissed); + } } /**