mirror of
https://github.com/bitwarden/browser.git
synced 2024-11-29 12:55:21 +01:00
[PM-3704] Autofill Command Should Not Attempt to Fill If Fields Are Not Found in Page Details (#6318)
* [PM-3704] Autofil Command Should Not Attempt to Fill If Fields Are Not Found in Page Details * [PM-2319] Adding jest test to ensure workflow is captured in future refactors
This commit is contained in:
parent
a42cea8570
commit
20564f2f54
@ -780,6 +780,18 @@ describe("AutofillService", () => {
|
||||
];
|
||||
});
|
||||
|
||||
it("returns a null vault without doing autofill if the page details does not contain fields ", async () => {
|
||||
pageDetails[0].details.fields = [];
|
||||
jest.spyOn(autofillService as any, "getActiveTab");
|
||||
jest.spyOn(autofillService, "doAutoFill");
|
||||
|
||||
const result = await autofillService.doAutoFillActiveTab(pageDetails, false);
|
||||
|
||||
expect(autofillService["getActiveTab"]).not.toHaveBeenCalled();
|
||||
expect(autofillService.doAutoFill).not.toHaveBeenCalled();
|
||||
expect(result).toBeNull();
|
||||
});
|
||||
|
||||
it("returns a null value without doing autofill if the active tab cannot be found", async () => {
|
||||
jest.spyOn(autofillService as any, "getActiveTab").mockResolvedValueOnce(undefined);
|
||||
jest.spyOn(autofillService, "doAutoFill");
|
||||
|
@ -314,6 +314,10 @@ export default class AutofillService implements AutofillServiceInterface {
|
||||
fromCommand: boolean,
|
||||
cipherType?: CipherType
|
||||
): Promise<string | null> {
|
||||
if (!pageDetails[0]?.details?.fields?.length) {
|
||||
return null;
|
||||
}
|
||||
|
||||
const tab = await this.getActiveTab();
|
||||
|
||||
if (!tab || !tab.url) {
|
||||
|
Loading…
Reference in New Issue
Block a user