[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
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
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.spyOn(autofillInit as any, "updateOverlayIsCurrentlyFilling");
jest
@ -228,9 +240,6 @@ describe("AutofillInit", () => {
fillScript,
);
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 () => {

View File

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