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:
parent
0e33b9c215
commit
356861a100
@ -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;
|
||||
|
@ -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,
|
||||
});
|
||||
|
@ -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),
|
||||
|
@ -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 },
|
||||
"*",
|
||||
);
|
||||
});
|
||||
|
@ -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`,
|
||||
|
Loading…
Reference in New Issue
Block a user