1
0
mirror of https://github.com/bitwarden/browser.git synced 2025-01-24 21:41:33 +01:00

[PM-5189] Refactoring implementation

This commit is contained in:
Cesar Gonzalez 2024-06-07 09:42:05 -05:00
parent 0e33b9c215
commit 356861a100
No known key found for this signature in database
GPG Key ID: 3381A5457F8CCECF
5 changed files with 10 additions and 10 deletions

View File

@ -151,7 +151,7 @@ export type InlineMenuListPortMessageHandlers = {
checkAutofillInlineMenuButtonFocused: () => void;
autofillInlineMenuBlurred: () => void;
unlockVault: ({ port }: PortConnectionParam) => void;
fillSelectedAutofillInlineMenuListItem: ({ message, port }: PortOnMessageHandlerParams) => void;
fillAutofillInlineMenuCipher: ({ message, port }: PortOnMessageHandlerParams) => void;
addNewVaultItem: ({ port }: PortConnectionParam) => void;
viewSelectedCipher: ({ message, port }: PortOnMessageHandlerParams) => void;
redirectAutofillInlineMenuFocusOut: ({ message, port }: PortOnMessageHandlerParams) => void;

View File

@ -1621,14 +1621,14 @@ describe("OverlayBackground", () => {
});
});
describe("fillSelectedAutofillInlineMenuListItem message handler", () => {
describe("fillAutofillInlineMenuCipher message handler", () => {
const pageDetails = createAutofillPageDetailsMock({
login: { username: "username1", password: "password1" },
});
it("ignores the fill request if the overlay cipher id is not provided", async () => {
sendPortMessage(listMessageConnectorSpy, {
command: "fillSelectedAutofillInlineMenuListItem",
command: "fillAutofillInlineMenuCipher",
portKey,
});
await flushPromises();
@ -1639,7 +1639,7 @@ describe("OverlayBackground", () => {
it("ignores the fill request if the tab does not contain any identified page details", async () => {
sendPortMessage(listMessageConnectorSpy, {
command: "fillSelectedAutofillInlineMenuListItem",
command: "fillAutofillInlineMenuCipher",
inlineMenuCipherId: "inline-menu-cipher-1",
portKey,
});
@ -1661,7 +1661,7 @@ describe("OverlayBackground", () => {
autofillService.isPasswordRepromptRequired.mockResolvedValue(true);
sendPortMessage(listMessageConnectorSpy, {
command: "fillSelectedAutofillInlineMenuListItem",
command: "fillAutofillInlineMenuCipher",
inlineMenuCipherId: "inline-menu-cipher-1",
portKey,
});
@ -1691,7 +1691,7 @@ describe("OverlayBackground", () => {
autofillService.isPasswordRepromptRequired.mockResolvedValue(false);
sendPortMessage(listMessageConnectorSpy, {
command: "fillSelectedAutofillInlineMenuListItem",
command: "fillAutofillInlineMenuCipher",
inlineMenuCipherId: "inline-menu-cipher-2",
portKey,
});
@ -1730,7 +1730,7 @@ describe("OverlayBackground", () => {
autofillService.doAutoFill.mockResolvedValue("totp-code");
sendPortMessage(listMessageConnectorSpy, {
command: "fillSelectedAutofillInlineMenuListItem",
command: "fillAutofillInlineMenuCipher",
inlineMenuCipherId: "inline-menu-cipher-2",
portKey,
});

View File

@ -112,7 +112,7 @@ export class OverlayBackground implements OverlayBackgroundInterface {
checkAutofillInlineMenuButtonFocused: () => this.checkInlineMenuButtonFocused(),
autofillInlineMenuBlurred: () => this.checkInlineMenuButtonFocused(),
unlockVault: ({ port }) => this.unlockVault(port),
fillSelectedAutofillInlineMenuListItem: ({ message, port }) =>
fillAutofillInlineMenuCipher: ({ message, port }) =>
this.fillSelectedInlineMenuListItem(message, port),
addNewVaultItem: ({ port }) => this.getNewVaultItemDetails(port),
viewSelectedCipher: ({ message, port }) => this.viewSelectedCipher(message, port),

View File

@ -140,7 +140,7 @@ describe("AutofillInlineMenuList", () => {
fillCipherButton.dispatchEvent(new Event("click"));
expect(globalThis.parent.postMessage).toHaveBeenCalledWith(
{ command: "fillSelectedAutofillInlineMenuListItem", inlineMenuCipherId: "1", portKey },
{ command: "fillAutofillInlineMenuCipher", inlineMenuCipherId: "1", portKey },
"*",
);
});

View File

@ -285,7 +285,7 @@ export class AutofillInlineMenuList extends AutofillInlineMenuPageElement {
return this.useEventHandlersMemo(
() =>
this.postMessageToParent({
command: "fillSelectedAutofillInlineMenuListItem",
command: "fillAutofillInlineMenuCipher",
inlineMenuCipherId: cipher.id,
}),
`${cipher.id}-fill-cipher-button-click-handler`,