1
0
mirror of https://github.com/bitwarden/browser synced 2025-12-17 16:53:34 +00:00

[PM-5189] Refactoring implementation

This commit is contained in:
Cesar Gonzalez
2024-05-03 02:42:58 -05:00
parent 7cc28e8edd
commit e8363b7e8c
5 changed files with 9 additions and 9 deletions

View File

@@ -96,7 +96,7 @@ type OverlayBackgroundExtensionMessageHandlers = {
closeAutofillInlineMenu: ({ message, sender }: BackgroundOnMessageHandlerParams) => void; closeAutofillInlineMenu: ({ message, sender }: BackgroundOnMessageHandlerParams) => void;
autofillOverlayElementClosed: ({ message }: BackgroundMessageParam) => void; autofillOverlayElementClosed: ({ message }: BackgroundMessageParam) => void;
autofillOverlayAddNewVaultItem: ({ message, sender }: BackgroundOnMessageHandlerParams) => void; autofillOverlayAddNewVaultItem: ({ message, sender }: BackgroundOnMessageHandlerParams) => void;
getInlineMenuVisibilitySetting: () => void; getAutofillInlineMenuVisibility: () => void;
checkAutofillInlineMenuFocused: () => void; checkAutofillInlineMenuFocused: () => void;
focusAutofillInlineMenuList: () => void; focusAutofillInlineMenuList: () => void;
updateAutofillInlineMenuPosition: ({ updateAutofillInlineMenuPosition: ({

View File

@@ -638,7 +638,7 @@ describe("OverlayBackground", () => {
}); });
}); });
describe("getInlineMenuVisibilitySetting message handler", () => { describe("getAutofillInlineMenuVisibility message handler", () => {
beforeEach(() => { beforeEach(() => {
jest jest
.spyOn(overlayBackground as any, "getInlineMenuVisibility") .spyOn(overlayBackground as any, "getInlineMenuVisibility")
@@ -646,7 +646,7 @@ describe("OverlayBackground", () => {
}); });
it("will set the overlayVisibility property", async () => { it("will set the overlayVisibility property", async () => {
sendMockExtensionMessage({ command: "getInlineMenuVisibilitySetting" }); sendMockExtensionMessage({ command: "getAutofillInlineMenuVisibility" });
await flushPromises(); await flushPromises();
expect(await overlayBackground["getInlineMenuVisibility"]()).toBe( expect(await overlayBackground["getInlineMenuVisibility"]()).toBe(
@@ -658,7 +658,7 @@ describe("OverlayBackground", () => {
const sendMessageSpy = jest.fn(); const sendMessageSpy = jest.fn();
sendMockExtensionMessage( sendMockExtensionMessage(
{ command: "getInlineMenuVisibilitySetting" }, { command: "getAutofillInlineMenuVisibility" },
undefined, undefined,
sendMessageSpy, sendMessageSpy,
); );

View File

@@ -68,7 +68,7 @@ class OverlayBackground implements OverlayBackgroundInterface {
closeAutofillInlineMenu: ({ message, sender }) => this.closeInlineMenu(sender, message), closeAutofillInlineMenu: ({ message, sender }) => this.closeInlineMenu(sender, message),
autofillOverlayElementClosed: ({ message }) => this.overlayElementClosed(message), autofillOverlayElementClosed: ({ message }) => this.overlayElementClosed(message),
autofillOverlayAddNewVaultItem: ({ message, sender }) => this.addNewVaultItem(message, sender), autofillOverlayAddNewVaultItem: ({ message, sender }) => this.addNewVaultItem(message, sender),
getInlineMenuVisibilitySetting: () => this.getInlineMenuVisibility(), getAutofillInlineMenuVisibility: () => this.getInlineMenuVisibility(),
checkAutofillInlineMenuFocused: () => this.checkInlineMenuFocused(), checkAutofillInlineMenuFocused: () => this.checkInlineMenuFocused(),
focusAutofillInlineMenuList: () => this.focusInlineMenuList(), focusAutofillInlineMenuList: () => this.focusInlineMenuList(),
updateAutofillInlineMenuPosition: ({ message, sender }) => updateAutofillInlineMenuPosition: ({ message, sender }) =>

View File

@@ -230,7 +230,7 @@ describe("AutofillOverlayContentService", () => {
autofillFieldData, autofillFieldData,
); );
expect(sendExtensionMessageSpy).toHaveBeenCalledWith("getInlineMenuVisibilitySetting"); expect(sendExtensionMessageSpy).toHaveBeenCalledWith("getAutofillInlineMenuVisibility");
expect(autofillOverlayContentService["inlineMenuVisibility"]).toEqual( expect(autofillOverlayContentService["inlineMenuVisibility"]).toEqual(
AutofillOverlayVisibility.OnFieldFocus, AutofillOverlayVisibility.OnFieldFocus,
); );

View File

@@ -94,7 +94,7 @@ class AutofillOverlayContentService implements AutofillOverlayContentServiceInte
} }
if (!this.inlineMenuVisibility) { if (!this.inlineMenuVisibility) {
await this.getInlineMenuVisibilitySetting(); await this.getAutofillInlineMenuVisibility();
} }
this.setupFormFieldElementEventListeners(formFieldElement); this.setupFormFieldElementEventListeners(formFieldElement);
@@ -730,8 +730,8 @@ class AutofillOverlayContentService implements AutofillOverlayContentServiceInte
* If the setting is not found, a default value of OnFieldFocus will be used * If the setting is not found, a default value of OnFieldFocus will be used
* @private * @private
*/ */
private async getInlineMenuVisibilitySetting() { private async getAutofillInlineMenuVisibility() {
const overlayVisibility = await this.sendExtensionMessage("getInlineMenuVisibilitySetting"); const overlayVisibility = await this.sendExtensionMessage("getAutofillInlineMenuVisibility");
this.inlineMenuVisibility = overlayVisibility || AutofillOverlayVisibility.OnFieldFocus; this.inlineMenuVisibility = overlayVisibility || AutofillOverlayVisibility.OnFieldFocus;
} }