1
0
mirror of https://github.com/bitwarden/browser synced 2025-12-14 15:23:33 +00:00

[PM-6213] Fix Inline Autofill Menu Erasing Filled Form on Hilton.com (#7952)

* [PM-6213] Fix Inline Autofill Menu Erasing Filled Form on Hilton.com

* [PM-6213] Fixing jest test
This commit is contained in:
Cesar Gonzalez
2024-02-22 12:50:21 -06:00
committed by GitHub
parent f9539ef68b
commit e894ecda25
2 changed files with 15 additions and 8 deletions

View File

@@ -208,7 +208,19 @@ describe("AutofillInit", () => {
); );
}); });
it("updates the isCurrentlyFilling properties of the overlay and focus the recent field after filling", async () => { it("removes the overlay when filling the form", async () => {
const blurAndRemoveOverlaySpy = jest.spyOn(autofillInit as any, "blurAndRemoveOverlay");
sendExtensionRuntimeMessage({
command: "fillForm",
fillScript,
pageDetailsUrl: window.location.href,
});
await flushPromises();
expect(blurAndRemoveOverlaySpy).toHaveBeenCalled();
});
it("updates the isCurrentlyFilling property of the overlay to true after filling", async () => {
jest.useFakeTimers(); jest.useFakeTimers();
jest.spyOn(autofillInit as any, "updateOverlayIsCurrentlyFilling"); jest.spyOn(autofillInit as any, "updateOverlayIsCurrentlyFilling");
jest jest
@@ -228,9 +240,6 @@ describe("AutofillInit", () => {
fillScript, fillScript,
); );
expect(autofillInit["updateOverlayIsCurrentlyFilling"]).toHaveBeenNthCalledWith(2, false); expect(autofillInit["updateOverlayIsCurrentlyFilling"]).toHaveBeenNthCalledWith(2, false);
expect(
autofillInit["autofillOverlayContentService"].focusMostRecentOverlayField,
).toHaveBeenCalled();
}); });
it("skips attempting to focus the most recent field if the autofillOverlayContentService is not present", async () => { it("skips attempting to focus the most recent field if the autofillOverlayContentService is not present", async () => {

View File

@@ -98,6 +98,7 @@ class AutofillInit implements AutofillInitInterface {
return; return;
} }
this.blurAndRemoveOverlay();
this.updateOverlayIsCurrentlyFilling(true); this.updateOverlayIsCurrentlyFilling(true);
await this.insertAutofillContentService.fillForm(fillScript); await this.insertAutofillContentService.fillForm(fillScript);
@@ -105,10 +106,7 @@ class AutofillInit implements AutofillInitInterface {
return; return;
} }
setTimeout(() => { setTimeout(() => this.updateOverlayIsCurrentlyFilling(false), 250);
this.updateOverlayIsCurrentlyFilling(false);
this.autofillOverlayContentService.focusMostRecentOverlayField();
}, 250);
} }
/** /**