mirror of
https://github.com/bitwarden/browser.git
synced 2024-11-22 11:45:59 +01:00
[PM-11393] Remove the need for TotpCaptureService in Autofill Options View component (#11093)
This commit is contained in:
parent
1a961ee294
commit
99ba56785d
@ -20,17 +20,15 @@ import { CollectionView } from "@bitwarden/common/vault/models/view/collection.v
|
||||
import { FolderView } from "@bitwarden/common/vault/models/view/folder.view";
|
||||
import {
|
||||
AsyncActionsModule,
|
||||
SearchModule,
|
||||
ButtonModule,
|
||||
IconButtonModule,
|
||||
DialogService,
|
||||
IconButtonModule,
|
||||
SearchModule,
|
||||
ToastService,
|
||||
} from "@bitwarden/components";
|
||||
import { TotpCaptureService } from "@bitwarden/vault";
|
||||
|
||||
import { CipherViewComponent } from "../../../../../../../../libs/vault/src/cipher-view";
|
||||
import { PopOutComponent } from "../../../../../platform/popup/components/pop-out.component";
|
||||
import { BrowserTotpCaptureService } from "../../../services/browser-totp-capture.service";
|
||||
|
||||
import { PopupFooterComponent } from "./../../../../../platform/popup/layout/popup-footer.component";
|
||||
import { PopupHeaderComponent } from "./../../../../../platform/popup/layout/popup-header.component";
|
||||
@ -41,7 +39,6 @@ import { VaultPopupAutofillService } from "./../../../services/vault-popup-autof
|
||||
selector: "app-view-v2",
|
||||
templateUrl: "view-v2.component.html",
|
||||
standalone: true,
|
||||
providers: [{ provide: TotpCaptureService, useClass: BrowserTotpCaptureService }],
|
||||
imports: [
|
||||
CommonModule,
|
||||
SearchModule,
|
||||
|
@ -13,15 +13,10 @@ describe("BrowserTotpCaptureService", () => {
|
||||
let testBed: TestBed;
|
||||
let service: BrowserTotpCaptureService;
|
||||
let mockCaptureVisibleTab: jest.SpyInstance;
|
||||
let createNewTabSpy: jest.SpyInstance;
|
||||
|
||||
const validTotpUrl = "otpauth://totp/label?secret=123";
|
||||
|
||||
beforeEach(() => {
|
||||
const tabReturn = new Promise<chrome.tabs.Tab>((resolve) =>
|
||||
resolve({ url: "google.com", active: true } as chrome.tabs.Tab),
|
||||
);
|
||||
createNewTabSpy = jest.spyOn(BrowserApi, "createNewTab").mockReturnValue(tabReturn);
|
||||
mockCaptureVisibleTab = jest.spyOn(BrowserApi, "captureVisibleTab");
|
||||
mockCaptureVisibleTab.mockResolvedValue("screenshot");
|
||||
|
||||
@ -71,10 +66,4 @@ describe("BrowserTotpCaptureService", () => {
|
||||
|
||||
expect(result).toBeNull();
|
||||
});
|
||||
|
||||
it("should call BrowserApi.createNewTab with a given loginURI", async () => {
|
||||
await service.openAutofillNewTab("www.google.com");
|
||||
|
||||
expect(createNewTabSpy).toHaveBeenCalledWith("www.google.com");
|
||||
});
|
||||
});
|
||||
|
@ -20,8 +20,4 @@ export class BrowserTotpCaptureService implements TotpCaptureService {
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
async openAutofillNewTab(loginUri: string) {
|
||||
await BrowserApi.createNewTab(loginUri);
|
||||
}
|
||||
}
|
||||
|
@ -1,8 +1,3 @@
|
||||
/**
|
||||
* TODO: PM-10727 - Rename and Refactor this service
|
||||
* This service is being used in both CipherForm and CipherView. Update this service to reflect that
|
||||
*/
|
||||
|
||||
/**
|
||||
* Service to capture TOTP secret from a client application.
|
||||
*/
|
||||
@ -11,5 +6,4 @@ export abstract class TotpCaptureService {
|
||||
* Captures a TOTP secret and returns it as a string. Returns null if no TOTP secret was found.
|
||||
*/
|
||||
abstract captureTotpSecret(): Promise<string | null>;
|
||||
abstract openAutofillNewTab(loginUri: string): void;
|
||||
}
|
||||
|
@ -2,18 +2,17 @@ import { CommonModule } from "@angular/common";
|
||||
import { Component, Input } from "@angular/core";
|
||||
|
||||
import { JslibModule } from "@bitwarden/angular/jslib.module";
|
||||
import { PlatformUtilsService } from "@bitwarden/common/platform/abstractions/platform-utils.service";
|
||||
import { LoginUriView } from "@bitwarden/common/vault/models/view/login-uri.view";
|
||||
import {
|
||||
CardComponent,
|
||||
FormFieldModule,
|
||||
IconButtonModule,
|
||||
SectionComponent,
|
||||
SectionHeaderComponent,
|
||||
TypographyModule,
|
||||
IconButtonModule,
|
||||
} from "@bitwarden/components";
|
||||
|
||||
import { TotpCaptureService } from "../../cipher-form";
|
||||
|
||||
@Component({
|
||||
selector: "app-autofill-options-view",
|
||||
templateUrl: "autofill-options-view.component.html",
|
||||
@ -32,9 +31,9 @@ import { TotpCaptureService } from "../../cipher-form";
|
||||
export class AutofillOptionsViewComponent {
|
||||
@Input() loginUris: LoginUriView[];
|
||||
|
||||
constructor(private totpCaptureService: TotpCaptureService) {}
|
||||
constructor(private platformUtilsService: PlatformUtilsService) {}
|
||||
|
||||
async openWebsite(selectedUri: string) {
|
||||
await this.totpCaptureService.openAutofillNewTab(selectedUri);
|
||||
openWebsite(selectedUri: string) {
|
||||
this.platformUtilsService.launchUri(selectedUri);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user