mirror of
https://github.com/bitwarden/browser
synced 2025-12-06 00:13:28 +00:00
PM-6558 Vault Onboarding Extension Check on Install (#8216)
updated browser runtime background to send hasBWInstalled message on installation
This commit is contained in:
@@ -9,6 +9,7 @@ import { ConfigServiceAbstraction } from "@bitwarden/common/platform/abstraction
|
||||
import { I18nService } from "@bitwarden/common/platform/abstractions/i18n.service";
|
||||
import { PlatformUtilsService } from "@bitwarden/common/platform/abstractions/platform-utils.service";
|
||||
import { StateProvider } from "@bitwarden/common/platform/state";
|
||||
import { VaultOnboardingMessages } from "@bitwarden/common/vault/enums/vault-onboarding.enum";
|
||||
|
||||
import { VaultOnboardingService as VaultOnboardingServiceAbstraction } from "./services/abstraction/vault-onboarding.service";
|
||||
import { VaultOnboardingComponent } from "./vault-onboarding.component";
|
||||
@@ -143,7 +144,9 @@ describe("VaultOnboardingComponent", () => {
|
||||
describe("checkBrowserExtension", () => {
|
||||
it("should call getMessages when showOnboarding is true", () => {
|
||||
const messageEventSubject = new Subject<MessageEvent>();
|
||||
const messageEvent = new MessageEvent("message", { data: "hasBWInstalled" });
|
||||
const messageEvent = new MessageEvent("message", {
|
||||
data: VaultOnboardingMessages.HasBwInstalled,
|
||||
});
|
||||
const getMessagesSpy = jest.spyOn(component, "getMessages");
|
||||
|
||||
(component as any).showOnboarding = true;
|
||||
@@ -151,7 +154,9 @@ describe("VaultOnboardingComponent", () => {
|
||||
messageEventSubject.next(messageEvent);
|
||||
|
||||
void fixture.whenStable().then(() => {
|
||||
expect(window.postMessage).toHaveBeenCalledWith({ command: "checkIfBWExtensionInstalled" });
|
||||
expect(window.postMessage).toHaveBeenCalledWith({
|
||||
command: VaultOnboardingMessages.checkBwInstalled,
|
||||
});
|
||||
expect(getMessagesSpy).toHaveBeenCalled();
|
||||
});
|
||||
});
|
||||
@@ -168,7 +173,7 @@ describe("VaultOnboardingComponent", () => {
|
||||
installExtension: false,
|
||||
});
|
||||
|
||||
const eventData = { data: { command: "hasBWInstalled" } };
|
||||
const eventData = { data: { command: VaultOnboardingMessages.HasBwInstalled } };
|
||||
|
||||
(component as any).showOnboarding = true;
|
||||
|
||||
|
||||
@@ -19,6 +19,7 @@ import { Organization } from "@bitwarden/common/admin-console/models/domain/orga
|
||||
import { FeatureFlag } from "@bitwarden/common/enums/feature-flag.enum";
|
||||
import { ConfigServiceAbstraction } from "@bitwarden/common/platform/abstractions/config/config.service.abstraction";
|
||||
import { PlatformUtilsService } from "@bitwarden/common/platform/abstractions/platform-utils.service";
|
||||
import { VaultOnboardingMessages } from "@bitwarden/common/vault/enums/vault-onboarding.enum";
|
||||
import { CipherView } from "@bitwarden/common/vault/models/view/cipher.view";
|
||||
import { LinkModule } from "@bitwarden/components";
|
||||
|
||||
@@ -95,12 +96,12 @@ export class VaultOnboardingComponent implements OnInit, OnChanges, OnDestroy {
|
||||
void this.getMessages(event);
|
||||
});
|
||||
|
||||
window.postMessage({ command: "checkIfBWExtensionInstalled" });
|
||||
window.postMessage({ command: VaultOnboardingMessages.checkBwInstalled });
|
||||
}
|
||||
}
|
||||
|
||||
async getMessages(event: any) {
|
||||
if (event.data.command === "hasBWInstalled" && this.showOnboarding) {
|
||||
if (event.data.command === VaultOnboardingMessages.HasBwInstalled && this.showOnboarding) {
|
||||
const currentTasks = await firstValueFrom(this.onboardingTasks$);
|
||||
const updatedTasks = {
|
||||
createAccount: currentTasks.createAccount,
|
||||
|
||||
Reference in New Issue
Block a user