1
0
mirror of https://github.com/bitwarden/browser synced 2025-12-16 16:23:44 +00:00

[PM-5189] Refactoring implementation

This commit is contained in:
Cesar Gonzalez
2024-06-11 10:07:01 -05:00
parent 3a8b13917b
commit e0ee50f43c
5 changed files with 10 additions and 8 deletions

View File

@@ -988,7 +988,9 @@ describe("OverlayBackground", () => {
sendMockExtensionMessage({ command: "focusAutofillInlineMenuList" }); sendMockExtensionMessage({ command: "focusAutofillInlineMenuList" });
expect(listPortSpy.postMessage).toHaveBeenCalledWith({ command: "focusInlineMenuList" }); expect(listPortSpy.postMessage).toHaveBeenCalledWith({
command: "focusAutofillInlineMenuList",
});
}); });
}); });

View File

@@ -821,7 +821,7 @@ export class OverlayBackground implements OverlayBackgroundInterface {
* Facilitates redirecting focus to the inline menu list. * Facilitates redirecting focus to the inline menu list.
*/ */
private focusInlineMenuList() { private focusInlineMenuList() {
this.inlineMenuListPort?.postMessage({ command: "focusInlineMenuList" }); this.inlineMenuListPort?.postMessage({ command: "focusAutofillInlineMenuList" });
} }
/** /**

View File

@@ -26,5 +26,5 @@ export type AutofillInlineMenuListWindowMessageHandlers = {
}: { }: {
message: UpdateAutofillInlineMenuListCiphersMessage; message: UpdateAutofillInlineMenuListCiphersMessage;
}) => void; }) => void;
focusInlineMenuList: () => void; focusAutofillInlineMenuList: () => void;
}; };

View File

@@ -338,7 +338,7 @@ describe("AutofillInlineMenuList", () => {
"setAttribute", "setAttribute",
); );
postWindowMessage({ command: "focusInlineMenuList" }); postWindowMessage({ command: "focusAutofillInlineMenuList" });
expect(inlineMenuContainerSetAttributeSpy).toHaveBeenCalledWith("role", "dialog"); expect(inlineMenuContainerSetAttributeSpy).toHaveBeenCalledWith("role", "dialog");
expect(inlineMenuContainerSetAttributeSpy).toHaveBeenCalledWith("aria-modal", "true"); expect(inlineMenuContainerSetAttributeSpy).toHaveBeenCalledWith("aria-modal", "true");
@@ -356,7 +356,7 @@ describe("AutofillInlineMenuList", () => {
autofillInlineMenuList["inlineMenuListContainer"].querySelector("#unlock-button"); autofillInlineMenuList["inlineMenuListContainer"].querySelector("#unlock-button");
jest.spyOn(unlockButton as HTMLElement, "focus"); jest.spyOn(unlockButton as HTMLElement, "focus");
postWindowMessage({ command: "focusInlineMenuList" }); postWindowMessage({ command: "focusAutofillInlineMenuList" });
expect((unlockButton as HTMLElement).focus).toBeCalled(); expect((unlockButton as HTMLElement).focus).toBeCalled();
}); });
@@ -368,7 +368,7 @@ describe("AutofillInlineMenuList", () => {
autofillInlineMenuList["inlineMenuListContainer"].querySelector("#new-item-button"); autofillInlineMenuList["inlineMenuListContainer"].querySelector("#new-item-button");
jest.spyOn(newItemButton as HTMLElement, "focus"); jest.spyOn(newItemButton as HTMLElement, "focus");
postWindowMessage({ command: "focusInlineMenuList" }); postWindowMessage({ command: "focusAutofillInlineMenuList" });
expect((newItemButton as HTMLElement).focus).toBeCalled(); expect((newItemButton as HTMLElement).focus).toBeCalled();
}); });
@@ -379,7 +379,7 @@ describe("AutofillInlineMenuList", () => {
autofillInlineMenuList["inlineMenuListContainer"].querySelector(".fill-cipher-button"); autofillInlineMenuList["inlineMenuListContainer"].querySelector(".fill-cipher-button");
jest.spyOn(firstCipherItem as HTMLElement, "focus"); jest.spyOn(firstCipherItem as HTMLElement, "focus");
postWindowMessage({ command: "focusInlineMenuList" }); postWindowMessage({ command: "focusAutofillInlineMenuList" });
expect((firstCipherItem as HTMLElement).focus).toBeCalled(); expect((firstCipherItem as HTMLElement).focus).toBeCalled();
}); });

View File

@@ -27,7 +27,7 @@ export class AutofillInlineMenuList extends AutofillInlineMenuPageElement {
initAutofillInlineMenuList: ({ message }) => this.initAutofillInlineMenuList(message), initAutofillInlineMenuList: ({ message }) => this.initAutofillInlineMenuList(message),
checkAutofillInlineMenuListFocused: () => this.checkInlineMenuListFocused(), checkAutofillInlineMenuListFocused: () => this.checkInlineMenuListFocused(),
updateAutofillInlineMenuListCiphers: ({ message }) => this.updateListItems(message.ciphers), updateAutofillInlineMenuListCiphers: ({ message }) => this.updateListItems(message.ciphers),
focusInlineMenuList: () => this.focusInlineMenuList(), focusAutofillInlineMenuList: () => this.focusInlineMenuList(),
}; };
constructor() { constructor() {