mirror of
https://github.com/bitwarden/browser
synced 2025-12-16 08:13:42 +00: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:
@@ -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 () => {
|
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 as any, "getActiveTab").mockResolvedValueOnce(undefined);
|
||||||
jest.spyOn(autofillService, "doAutoFill");
|
jest.spyOn(autofillService, "doAutoFill");
|
||||||
|
|||||||
@@ -314,6 +314,10 @@ export default class AutofillService implements AutofillServiceInterface {
|
|||||||
fromCommand: boolean,
|
fromCommand: boolean,
|
||||||
cipherType?: CipherType
|
cipherType?: CipherType
|
||||||
): Promise<string | null> {
|
): Promise<string | null> {
|
||||||
|
if (!pageDetails[0]?.details?.fields?.length) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
const tab = await this.getActiveTab();
|
const tab = await this.getActiveTab();
|
||||||
|
|
||||||
if (!tab || !tab.url) {
|
if (!tab || !tab.url) {
|
||||||
|
|||||||
Reference in New Issue
Block a user