From 3949aae8e396f999c21813ae6b0095b52610b27b Mon Sep 17 00:00:00 2001 From: Oscar Hinton Date: Wed, 8 Jan 2025 14:29:26 +0100 Subject: [PATCH] [PM-16838] Fix bad imports for shared and platform code (#12743) Imports containing /src/ are forbidden. --- .../browser/src/background/runtime.background.ts | 2 +- apps/browser/src/popup/app-routing.module.ts | 2 +- apps/desktop/src/app/app-routing.module.ts | 2 +- .../platform/services/electron-key.service.ts | 2 +- .../integrations/integrations.component.spec.ts | 16 ++++++++-------- .../fido2/fido2-active-request-manager.spec.ts | 12 ++++++++---- 6 files changed, 20 insertions(+), 16 deletions(-) diff --git a/apps/browser/src/background/runtime.background.ts b/apps/browser/src/background/runtime.background.ts index 75340e3fbc3..863ca26b36e 100644 --- a/apps/browser/src/background/runtime.background.ts +++ b/apps/browser/src/background/runtime.background.ts @@ -13,12 +13,12 @@ import { ProcessReloadServiceAbstraction } from "@bitwarden/common/key-managemen import { ConfigService } from "@bitwarden/common/platform/abstractions/config/config.service"; import { LogService } from "@bitwarden/common/platform/abstractions/log.service"; import { MessagingService } from "@bitwarden/common/platform/abstractions/messaging.service"; +import { MessageListener, isExternalMessage } from "@bitwarden/common/platform/messaging"; import { devFlagEnabled } from "@bitwarden/common/platform/misc/flags"; import { Utils } from "@bitwarden/common/platform/misc/utils"; import { CipherType } from "@bitwarden/common/vault/enums"; import { BiometricsCommands } from "@bitwarden/key-management"; -import { MessageListener, isExternalMessage } from "../../../../libs/common/src/platform/messaging"; import { closeUnlockPopout, openSsoAuthResultPopout, diff --git a/apps/browser/src/popup/app-routing.module.ts b/apps/browser/src/popup/app-routing.module.ts index 7cc5bbe2f82..8e48104737a 100644 --- a/apps/browser/src/popup/app-routing.module.ts +++ b/apps/browser/src/popup/app-routing.module.ts @@ -18,6 +18,7 @@ import { } from "@bitwarden/angular/auth/guards"; import { canAccessFeature } from "@bitwarden/angular/platform/guard/feature-flag.guard"; import { extensionRefreshSwap } from "@bitwarden/angular/utils/extension-refresh-swap"; +import { twofactorRefactorSwap } from "@bitwarden/angular/utils/two-factor-component-refactor-route-swap"; import { NewDeviceVerificationNoticeGuard } from "@bitwarden/angular/vault/guards"; import { AnonLayoutWrapperComponent, @@ -49,7 +50,6 @@ import { VaultIcons, } from "@bitwarden/vault"; -import { twofactorRefactorSwap } from "../../../../libs/angular/src/utils/two-factor-component-refactor-route-swap"; import { fido2AuthGuard } from "../auth/guards/fido2-auth.guard"; import { AccountSwitcherComponent } from "../auth/popup/account-switching/account-switcher.component"; import { EnvironmentComponent } from "../auth/popup/environment.component"; diff --git a/apps/desktop/src/app/app-routing.module.ts b/apps/desktop/src/app/app-routing.module.ts index cd4932c616a..e4ee5ec0473 100644 --- a/apps/desktop/src/app/app-routing.module.ts +++ b/apps/desktop/src/app/app-routing.module.ts @@ -15,6 +15,7 @@ import { unauthGuardFn, } from "@bitwarden/angular/auth/guards"; import { canAccessFeature } from "@bitwarden/angular/platform/guard/feature-flag.guard"; +import { twofactorRefactorSwap } from "@bitwarden/angular/utils/two-factor-component-refactor-route-swap"; import { NewDeviceVerificationNoticeGuard } from "@bitwarden/angular/vault/guards"; import { AnonLayoutWrapperComponent, @@ -46,7 +47,6 @@ import { VaultIcons, } from "@bitwarden/vault"; -import { twofactorRefactorSwap } from "../../../../libs/angular/src/utils/two-factor-component-refactor-route-swap"; import { AccessibilityCookieComponent } from "../auth/accessibility-cookie.component"; import { maxAccountsGuardFn } from "../auth/guards/max-accounts.guard"; import { HintComponent } from "../auth/hint.component"; diff --git a/apps/desktop/src/platform/services/electron-key.service.ts b/apps/desktop/src/platform/services/electron-key.service.ts index 9a18753e4b5..0db634375ef 100644 --- a/apps/desktop/src/platform/services/electron-key.service.ts +++ b/apps/desktop/src/platform/services/electron-key.service.ts @@ -21,7 +21,7 @@ import { BiometricStateService, } from "@bitwarden/key-management"; -import { DesktopBiometricsService } from "src/key-management/biometrics/desktop.biometrics.service"; +import { DesktopBiometricsService } from "../../key-management/biometrics/desktop.biometrics.service"; export class ElectronKeyService extends DefaultKeyService { constructor( diff --git a/bitwarden_license/bit-web/src/app/secrets-manager/integrations/integrations.component.spec.ts b/bitwarden_license/bit-web/src/app/secrets-manager/integrations/integrations.component.spec.ts index 5d626da9364..2d0a681460a 100644 --- a/bitwarden_license/bit-web/src/app/secrets-manager/integrations/integrations.component.spec.ts +++ b/bitwarden_license/bit-web/src/app/secrets-manager/integrations/integrations.component.spec.ts @@ -4,15 +4,15 @@ import { By } from "@angular/platform-browser"; import { mock } from "jest-mock-extended"; import { of } from "rxjs"; -import { SharedModule } from "@bitwarden/components/src/shared"; -import { IntegrationCardComponent } from "@bitwarden/web-vault/app/admin-console/organizations/shared/components/integrations/integration-card/integration-card.component"; -import { IntegrationGridComponent } from "@bitwarden/web-vault/app/admin-console/organizations/shared/components/integrations/integration-grid/integration-grid.component"; import {} from "@bitwarden/web-vault/app/shared"; -import { SYSTEM_THEME_OBSERVABLE } from "../../../../../../libs/angular/src/services/injection-tokens"; -import { I18nService } from "../../../../../../libs/common/src/platform/abstractions/i18n.service"; -import { ThemeType } from "../../../../../../libs/common/src/platform/enums"; -import { ThemeStateService } from "../../../../../../libs/common/src/platform/theming/theme-state.service"; +import { JslibModule } from "@bitwarden/angular/jslib.module"; +import { SYSTEM_THEME_OBSERVABLE } from "@bitwarden/angular/services/injection-tokens"; +import { I18nService } from "@bitwarden/common/platform/abstractions/i18n.service"; +import { ThemeType } from "@bitwarden/common/platform/enums"; +import { ThemeStateService } from "@bitwarden/common/platform/theming/theme-state.service"; +import { IntegrationCardComponent } from "@bitwarden/web-vault/app/admin-console/organizations/shared/components/integrations/integration-card/integration-card.component"; +import { IntegrationGridComponent } from "@bitwarden/web-vault/app/admin-console/organizations/shared/components/integrations/integration-grid/integration-grid.component"; import { IntegrationsComponent } from "./integrations.component"; @@ -34,7 +34,7 @@ describe("IntegrationsComponent", () => { beforeEach(async () => { await TestBed.configureTestingModule({ declarations: [IntegrationsComponent, MockHeaderComponent, MockNewMenuComponent], - imports: [IntegrationGridComponent, IntegrationCardComponent, SharedModule], + imports: [JslibModule, IntegrationGridComponent, IntegrationCardComponent], providers: [ { provide: I18nService, diff --git a/libs/common/src/platform/services/fido2/fido2-active-request-manager.spec.ts b/libs/common/src/platform/services/fido2/fido2-active-request-manager.spec.ts index ce9426b4db0..8089e081805 100644 --- a/libs/common/src/platform/services/fido2/fido2-active-request-manager.spec.ts +++ b/libs/common/src/platform/services/fido2/fido2-active-request-manager.spec.ts @@ -1,14 +1,18 @@ import { mock } from "jest-mock-extended"; import { firstValueFrom, Observable } from "rxjs"; -// FIXME: remove `/apps` import from `/libs` -// eslint-disable-next-line import/no-restricted-paths -import { flushPromises } from "@bitwarden/browser/src/autofill/spec/testing-utils"; - import { Fido2CredentialView } from "../../../vault/models/view/fido2-credential.view"; import { Fido2ActiveRequestManager } from "./fido2-active-request-manager"; +// Duplicated from `apps/browser/src/autofill/spec/testing-utils.ts`. +const scheduler = typeof setImmediate === "function" ? setImmediate : setTimeout; +function flushPromises() { + return new Promise(function (resolve) { + scheduler(resolve); + }); +} + jest.mock("rxjs", () => { const rxjs = jest.requireActual("rxjs"); const { firstValueFrom } = rxjs;