mirror of
https://github.com/bitwarden/clients.git
synced 2026-11-16 07:03:29 +00:00
[PM-41494] Show the import result in the popup before the new experience dialog
This commit is contained in:
@@ -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<ImportUpgradeNavigationService>();
|
||||
const importConfirmationPopupSvc = mock<ImportConfirmationPopupService>();
|
||||
|
||||
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<void>((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(() => {}));
|
||||
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user