1
0
mirror of https://github.com/bitwarden/browser synced 2025-12-14 23:33:31 +00:00

[PM-23596] Redirect to /setup-extension (#15641)

* remove current redirection from auth code

* update timeouts of the web browser interaction

* add guard for setup-extension page

* decrease timeout to 25ms

* avoid redirection for mobile users + add tests

* add tests

* condense variables

* catch error from profile fetch

---------

Co-authored-by: Shane Melton <smelton@bitwarden.com>
This commit is contained in:
Nick Krantz
2025-07-22 19:08:09 -05:00
committed by GitHub
parent 643d0c9a4c
commit 2f47add6f1
17 changed files with 347 additions and 61 deletions

View File

@@ -3,12 +3,14 @@ import { By } from "@angular/platform-browser";
import { Router, RouterModule } from "@angular/router";
import { BehaviorSubject } from "rxjs";
import { AccountService } from "@bitwarden/common/auth/abstractions/account.service";
import { DeviceType } from "@bitwarden/common/enums";
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 { PlatformUtilsService } from "@bitwarden/common/platform/abstractions/platform-utils.service";
import { Utils } from "@bitwarden/common/platform/misc/utils";
import { StateProvider } from "@bitwarden/common/platform/state";
import { WebBrowserInteractionService } from "../../services/web-browser-interaction.service";
@@ -21,11 +23,13 @@ describe("SetupExtensionComponent", () => {
const getFeatureFlag = jest.fn().mockResolvedValue(false);
const navigate = jest.fn().mockResolvedValue(true);
const openExtension = jest.fn().mockResolvedValue(true);
const update = jest.fn().mockResolvedValue(true);
const extensionInstalled$ = new BehaviorSubject<boolean | null>(null);
beforeEach(async () => {
navigate.mockClear();
openExtension.mockClear();
update.mockClear();
getFeatureFlag.mockClear().mockResolvedValue(true);
window.matchMedia = jest.fn().mockReturnValue(false);
@@ -36,6 +40,14 @@ describe("SetupExtensionComponent", () => {
{ provide: ConfigService, useValue: { getFeatureFlag } },
{ provide: WebBrowserInteractionService, useValue: { extensionInstalled$, openExtension } },
{ provide: PlatformUtilsService, useValue: { getDevice: () => DeviceType.UnknownBrowser } },
{
provide: AccountService,
useValue: { activeAccount$: new BehaviorSubject({ account: { id: "account-id" } }) },
},
{
provide: StateProvider,
useValue: { getUser: () => ({ update }) },
},
],
}).compileComponents();
@@ -120,6 +132,10 @@ describe("SetupExtensionComponent", () => {
expect(openExtension).toHaveBeenCalled();
});
it("dismisses the extension page", () => {
expect(update).toHaveBeenCalledTimes(1);
});
});
});
});