mirror of
https://github.com/bitwarden/browser
synced 2025-12-18 01:03:35 +00:00
* force viewOnly to be true for emergency access * add input to hide password history, applicable when the view is used from emergency view * add extension refresh version of the emergency view dialog * allow emergency access to view password history - `ViewPasswordHistoryService` accepts a cipher id or CipherView. When a CipherView is included, the history component no longer has to fetch the cipher. * remove unused comments * Add fixme comment for removing non-extension refresh code * refactor password history component to accept a full cipher view - Remove the option to pass in only an id
46 lines
1.4 KiB
TypeScript
46 lines
1.4 KiB
TypeScript
import { Overlay } from "@angular/cdk/overlay";
|
|
import { TestBed } from "@angular/core/testing";
|
|
|
|
import { CipherView } from "@bitwarden/common/vault/models/view/cipher.view";
|
|
import { DialogService } from "@bitwarden/components";
|
|
|
|
import { openPasswordHistoryDialog } from "../individual-vault/password-history.component";
|
|
|
|
import { WebViewPasswordHistoryService } from "./web-view-password-history.service";
|
|
|
|
jest.mock("../individual-vault/password-history.component", () => ({
|
|
openPasswordHistoryDialog: jest.fn(),
|
|
}));
|
|
|
|
describe("WebViewPasswordHistoryService", () => {
|
|
let service: WebViewPasswordHistoryService;
|
|
let dialogService: DialogService;
|
|
|
|
beforeEach(async () => {
|
|
const mockDialogService = {
|
|
open: jest.fn(),
|
|
};
|
|
|
|
await TestBed.configureTestingModule({
|
|
providers: [
|
|
WebViewPasswordHistoryService,
|
|
{ provide: DialogService, useValue: mockDialogService },
|
|
Overlay,
|
|
],
|
|
}).compileComponents();
|
|
|
|
service = TestBed.inject(WebViewPasswordHistoryService);
|
|
dialogService = TestBed.inject(DialogService);
|
|
});
|
|
|
|
describe("viewPasswordHistory", () => {
|
|
it("calls openPasswordHistoryDialog with the correct parameters", async () => {
|
|
const mockCipher = { id: "cipher-id" } as CipherView;
|
|
await service.viewPasswordHistory(mockCipher);
|
|
expect(openPasswordHistoryDialog).toHaveBeenCalledWith(dialogService, {
|
|
data: { cipher: mockCipher },
|
|
});
|
|
});
|
|
});
|
|
});
|