Skip to content
Closed
Show file tree
Hide file tree
Changes from 13 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ describe("AccountSwitcherService", () => {

expect(messagingService.send).toHaveBeenCalledWith("switchAccount", { userId: null });

expect(removeListenerSpy).toBeCalledTimes(1);
expect(removeListenerSpy).toHaveBeenCalledTimes(1);
});

it("initiates an account switch with an account id", async () => {
Expand All @@ -198,13 +198,13 @@ describe("AccountSwitcherService", () => {
await selectAccountPromise;

expect(messagingService.send).toHaveBeenCalledWith("switchAccount", { userId: "1" });
expect(messagingService.send).toBeCalledWith(
expect(messagingService.send).toHaveBeenCalledWith(
"switchAccount",
matches((payload) => {
return payload.userId === "1";
}),
);
expect(removeListenerSpy).toBeCalledTimes(1);
expect(removeListenerSpy).toHaveBeenCalledTimes(1);
});
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -130,9 +130,12 @@ describe("AutoSubmitLoginBackground", () => {
url: validAutoSubmitUrl,
tabId: webRequestDetails.tabId,
});
expect(chrome.webNavigation.onCompleted.addListener).toBeCalledWith(expect.any(Function), {
url: [{ hostEquals: validAutoSubmitHost }],
});
expect(chrome.webNavigation.onCompleted.addListener).toHaveBeenCalledWith(
expect.any(Function),
{
url: [{ hostEquals: validAutoSubmitHost }],
},
);
});

it("sets up the auto-submit workflow when the web request occurs in a sub frame and the initiator of the request is a valid auto-submit host", async () => {
Expand All @@ -145,9 +148,12 @@ describe("AutoSubmitLoginBackground", () => {

triggerWebRequestOnBeforeRequestEvent(webRequestDetails);

expect(chrome.webNavigation.onCompleted.addListener).toBeCalledWith(expect.any(Function), {
url: [{ hostEquals: subFrameHost }],
});
expect(chrome.webNavigation.onCompleted.addListener).toHaveBeenCalledWith(
expect.any(Function),
{
url: [{ hostEquals: subFrameHost }],
},
);
});

describe("injecting the auto-submit login content script", () => {
Expand Down Expand Up @@ -182,7 +188,7 @@ describe("AutoSubmitLoginBackground", () => {
triggerWebNavigationOnCompletedEvent(webNavigationDetails);
await flushPromises();

expect(scriptInjectorService.inject).toBeCalledWith({
expect(scriptInjectorService.inject).toHaveBeenCalledWith({
tabId: webRequestDetails.tabId,
injectDetails: {
file: "content/auto-submit-login.js",
Expand Down Expand Up @@ -306,7 +312,7 @@ describe("AutoSubmitLoginBackground", () => {

triggerWebRequestOnBeforeRequestEvent(webRequestDetails);

expect(chrome.webNavigation.onCompleted.addListener).toBeCalledWith(
expect(chrome.webNavigation.onCompleted.addListener).toHaveBeenCalledWith(
autoSubmitLoginBackground["handleAutoSubmitHostNavigationCompleted"],
{ url: [{ hostEquals: validAutoSubmitHost }] },
);
Expand Down Expand Up @@ -426,9 +432,12 @@ describe("AutoSubmitLoginBackground", () => {
}),
);

expect(chrome.webNavigation.onCompleted.addListener).toBeCalledWith(expect.any(Function), {
url: [{ hostEquals: validAutoSubmitHost }],
});
expect(chrome.webNavigation.onCompleted.addListener).toHaveBeenCalledWith(
expect.any(Function),
{
url: [{ hostEquals: validAutoSubmitHost }],
},
);
});
});

Expand Down Expand Up @@ -477,7 +486,7 @@ describe("AutoSubmitLoginBackground", () => {
sendMockExtensionMessage(message, sender);
await flushPromises();

expect(autofillService.doAutoFillOnTab).toBeCalledWith(
expect(autofillService.doAutoFillOnTab).toHaveBeenCalledWith(
[
{
frameId: sender.frameId,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2878,7 +2878,7 @@ describe("OverlayBackground", () => {
{ command: "closeAutofillInlineMenu", overlayElement: undefined },
{ frameId: 0 },
);
expect(tabSendMessageDataSpy).toBeCalledWith(
expect(tabSendMessageDataSpy).toHaveBeenCalledWith(
sender.tab,
"addToLockedVaultPendingNotifications",
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,9 +105,9 @@ describe("ContextMenuClickedHandler", () => {
it("can generate password", async () => {
await sut.run(createData(GENERATE_PASSWORD_ID), { id: 5 } as any);

expect(generatePasswordToClipboard).toBeCalledTimes(1);
expect(generatePasswordToClipboard).toHaveBeenCalledTimes(1);

expect(generatePasswordToClipboard).toBeCalledWith({
expect(generatePasswordToClipboard).toHaveBeenCalledWith({
id: 5,
});
});
Expand All @@ -118,9 +118,9 @@ describe("ContextMenuClickedHandler", () => {

await sut.run(createData(`${AUTOFILL_ID}_1`, AUTOFILL_ID), { id: 5 } as any);

expect(autofill).toBeCalledTimes(1);
expect(autofill).toHaveBeenCalledTimes(1);

expect(autofill).toBeCalledWith({ id: 5 }, cipher);
expect(autofill).toHaveBeenCalledWith({ id: 5 }, cipher);
});

it("copies username to clipboard", async () => {
Expand All @@ -132,7 +132,7 @@ describe("ContextMenuClickedHandler", () => {
url: "https://test.com",
} as any);

expect(copyToClipboard).toBeCalledTimes(1);
expect(copyToClipboard).toHaveBeenCalledTimes(1);

expect(copyToClipboard).toHaveBeenCalledWith({
text: "TEST_USERNAME",
Expand All @@ -149,7 +149,7 @@ describe("ContextMenuClickedHandler", () => {
url: "https://test.com",
} as any);

expect(copyToClipboard).toBeCalledTimes(1);
expect(copyToClipboard).toHaveBeenCalledTimes(1);

expect(copyToClipboard).toHaveBeenCalledWith({
text: "TEST_PASSWORD",
Expand Down
2 changes: 1 addition & 1 deletion apps/browser/src/autofill/content/autofill-init.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,7 @@ describe("AutofillInit", () => {
await flushPromises();

expect(autofillInit["collectAutofillContentService"].getPageDetails).toHaveBeenCalled();
expect(sendResponse).toBeCalledWith(pageDetails);
expect(sendResponse).toHaveBeenCalledWith(pageDetails);
expect(chrome.runtime.sendMessage).not.toHaveBeenCalledWith({
command: "collectPageDetailsResponse",
tab: message.tab,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -372,7 +372,7 @@ describe("AutofillInlineMenuList", () => {

firstFillCipherElement.dispatchEvent(new KeyboardEvent("keyup", { code: "ArrowDown" }));

expect((secondFillCipherElement as HTMLElement).focus).toBeCalled();
expect((secondFillCipherElement as HTMLElement).focus).toHaveBeenCalled();
});

it("directs focus to the first item in the cipher list if no cipher is present after the current one when pressing ArrowDown and no new item button exists", () => {
Expand All @@ -386,7 +386,7 @@ describe("AutofillInlineMenuList", () => {

lastFillCipherElement.dispatchEvent(new KeyboardEvent("keyup", { code: "ArrowDown" }));

expect((firstFillCipherElement as HTMLElement).focus).toBeCalled();
expect((firstFillCipherElement as HTMLElement).focus).toHaveBeenCalled();
});

it("directs focus to the new item button if no cipher is present after the current one when pressing ArrowDown", async () => {
Expand All @@ -406,7 +406,7 @@ describe("AutofillInlineMenuList", () => {

lastFillCipherElement.dispatchEvent(new KeyboardEvent("keyup", { code: "ArrowDown" }));

expect(autofillInlineMenuList["newItemButtonElement"].focus).toBeCalled();
expect(autofillInlineMenuList["newItemButtonElement"].focus).toHaveBeenCalled();
});

it("allows the user to move keyboard focus to the previous cipher element on ArrowUp", () => {
Expand All @@ -420,7 +420,7 @@ describe("AutofillInlineMenuList", () => {

secondFillCipherElement.dispatchEvent(new KeyboardEvent("keyup", { code: "ArrowUp" }));

expect((firstFillCipherElement as HTMLElement).focus).toBeCalled();
expect((firstFillCipherElement as HTMLElement).focus).toHaveBeenCalled();
});

it("directs focus to the last item in the cipher list if no cipher is present before the current one when pressing ArrowUp", () => {
Expand All @@ -434,7 +434,7 @@ describe("AutofillInlineMenuList", () => {

firstFillCipherElement.dispatchEvent(new KeyboardEvent("keyup", { code: "ArrowUp" }));

expect((lastFillCipherElement as HTMLElement).focus).toBeCalled();
expect((lastFillCipherElement as HTMLElement).focus).toHaveBeenCalled();
});

it("directs focus to the new item button if no cipher is present before the current one when pressing ArrowUp", async () => {
Expand All @@ -454,7 +454,7 @@ describe("AutofillInlineMenuList", () => {

firstFillCipherElement.dispatchEvent(new KeyboardEvent("keyup", { code: "ArrowUp" }));

expect(autofillInlineMenuList["newItemButtonElement"].focus).toBeCalled();
expect(autofillInlineMenuList["newItemButtonElement"].focus).toHaveBeenCalled();
});

it("allows the user to move keyboard focus to the view cipher button on ArrowRight", () => {
Expand All @@ -466,7 +466,7 @@ describe("AutofillInlineMenuList", () => {

fillCipherElement.dispatchEvent(new KeyboardEvent("keyup", { code: "ArrowRight" }));

expect((viewCipherButton as HTMLElement).focus).toBeCalled();
expect((viewCipherButton as HTMLElement).focus).toHaveBeenCalled();
});

it("ignores keyup events that do not include ArrowUp, ArrowDown, or ArrowRight", () => {
Expand All @@ -476,7 +476,7 @@ describe("AutofillInlineMenuList", () => {

fillCipherElement.dispatchEvent(new KeyboardEvent("keyup", { code: "ArrowLeft" }));

expect((fillCipherElement as HTMLElement).focus).not.toBeCalled();
expect((fillCipherElement as HTMLElement).focus).not.toHaveBeenCalled();
});
});

Expand Down Expand Up @@ -506,7 +506,7 @@ describe("AutofillInlineMenuList", () => {

viewCipherButton.dispatchEvent(new KeyboardEvent("keyup", { code: "ArrowLeft" }));

expect((fillCipherButton as HTMLElement).focus).toBeCalled();
expect((fillCipherButton as HTMLElement).focus).toHaveBeenCalled();
});

it("allows the user to move keyboard to the next cipher element on ArrowDown", () => {
Expand All @@ -519,7 +519,7 @@ describe("AutofillInlineMenuList", () => {

viewCipherButton.dispatchEvent(new KeyboardEvent("keyup", { code: "ArrowDown" }));

expect((secondFillCipherButton as HTMLElement).focus).toBeCalled();
expect((secondFillCipherButton as HTMLElement).focus).toHaveBeenCalled();
});

it("allows the user to move keyboard focus to the previous cipher element on ArrowUp", () => {
Expand All @@ -532,7 +532,7 @@ describe("AutofillInlineMenuList", () => {

viewCipherButton.dispatchEvent(new KeyboardEvent("keyup", { code: "ArrowUp" }));

expect((firstFillCipherButton as HTMLElement).focus).toBeCalled();
expect((firstFillCipherButton as HTMLElement).focus).toHaveBeenCalled();
});

it("ignores keyup events that do not include ArrowUp, ArrowDown, or ArrowRight", () => {
Expand All @@ -542,7 +542,7 @@ describe("AutofillInlineMenuList", () => {

viewCipherButton.dispatchEvent(new KeyboardEvent("keyup", { code: "ArrowRight" }));

expect((viewCipherButton as HTMLElement).focus).not.toBeCalled();
expect((viewCipherButton as HTMLElement).focus).not.toHaveBeenCalled();
});
});

Expand Down Expand Up @@ -769,7 +769,7 @@ describe("AutofillInlineMenuList", () => {

viewCipherButton.dispatchEvent(new KeyboardEvent("keyup", { code: "ArrowDown" }));

expect((fillCipherButton as HTMLElement).focus).toBeCalled();
expect((fillCipherButton as HTMLElement).focus).toHaveBeenCalled();
});

it("skips the passkeys heading when the user presses ArrowDown to focus the first list item", () => {
Expand All @@ -781,7 +781,7 @@ describe("AutofillInlineMenuList", () => {

viewCipherButton.dispatchEvent(new KeyboardEvent("keyup", { code: "ArrowDown" }));

expect((fillCipherButton as HTMLElement).focus).toBeCalled();
expect((fillCipherButton as HTMLElement).focus).toHaveBeenCalled();
});

it("skips the logins heading when the user presses ArrowUp to focus the previous list item", () => {
Expand All @@ -793,7 +793,7 @@ describe("AutofillInlineMenuList", () => {

viewCipherButton.dispatchEvent(new KeyboardEvent("keyup", { code: "ArrowUp" }));

expect((fillCipherButton as HTMLElement).focus).toBeCalled();
expect((fillCipherButton as HTMLElement).focus).toHaveBeenCalled();
});
});
});
Expand Down Expand Up @@ -875,7 +875,7 @@ describe("AutofillInlineMenuList", () => {
new KeyboardEvent("keyup", { code: "ArrowRight" }),
);

expect((refreshGeneratedPasswordButton as HTMLElement).focus).toBeCalled();
expect((refreshGeneratedPasswordButton as HTMLElement).focus).toHaveBeenCalled();
});
});
});
Expand Down Expand Up @@ -945,7 +945,7 @@ describe("AutofillInlineMenuList", () => {
new KeyboardEvent("keyup", { code: "ArrowLeft" }),
);

expect((fillGeneratedPasswordButton as HTMLElement).focus).toBeCalled();
expect((fillGeneratedPasswordButton as HTMLElement).focus).toHaveBeenCalled();
});
});
});
Expand Down Expand Up @@ -1163,7 +1163,7 @@ describe("AutofillInlineMenuList", () => {

postWindowMessage({ command: "focusAutofillInlineMenuList" });

expect((unlockButton as HTMLElement).focus).toBeCalled();
expect((unlockButton as HTMLElement).focus).toHaveBeenCalled();
});

it("focuses the new item button element if the cipher list is empty", async () => {
Expand All @@ -1175,7 +1175,7 @@ describe("AutofillInlineMenuList", () => {

postWindowMessage({ command: "focusAutofillInlineMenuList" });

expect((newItemButton as HTMLElement).focus).toBeCalled();
expect((newItemButton as HTMLElement).focus).toHaveBeenCalled();
});

it("focuses the first cipher button element if the cipher list is populated", () => {
Expand All @@ -1186,7 +1186,7 @@ describe("AutofillInlineMenuList", () => {

postWindowMessage({ command: "focusAutofillInlineMenuList" });

expect((firstCipherItem as HTMLElement).focus).toBeCalled();
expect((firstCipherItem as HTMLElement).focus).toHaveBeenCalled();
});
});

Expand Down
Loading
Loading