mirror of
https://github.com/bitwarden/browser
synced 2026-02-21 11:54:02 +00:00
Revert jest-mock-extended to v3.0.7
The update to jest-mock-extended v4.0.0 was incompatible with the project's current Jest 29 installation. jest-mock-extended v4 requires Jest 30, which would require a larger migration effort. Changes: - Downgrade jest-mock-extended from 4.0.0 to 3.0.7 - Revert test changes to use v3 API (toBeCalled instead of toHaveBeenCalled) - Revert snapshot files to original state This fixes the Docker build failure in CI where npm ci was failing. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -176,7 +176,7 @@ describe("AccountSwitcherService", () => {
|
||||
|
||||
expect(messagingService.send).toHaveBeenCalledWith("switchAccount", { userId: null });
|
||||
|
||||
expect(removeListenerSpy).toHaveBeenCalledTimes(1);
|
||||
expect(removeListenerSpy).toBeCalledTimes(1);
|
||||
});
|
||||
|
||||
it("initiates an account switch with an account id", async () => {
|
||||
@@ -198,13 +198,13 @@ describe("AccountSwitcherService", () => {
|
||||
await selectAccountPromise;
|
||||
|
||||
expect(messagingService.send).toHaveBeenCalledWith("switchAccount", { userId: "1" });
|
||||
expect(messagingService.send).toHaveBeenCalledWith(
|
||||
expect(messagingService.send).toBeCalledWith(
|
||||
"switchAccount",
|
||||
matches((payload) => {
|
||||
return payload.userId === "1";
|
||||
}),
|
||||
);
|
||||
expect(removeListenerSpy).toHaveBeenCalledTimes(1);
|
||||
expect(removeListenerSpy).toBeCalledTimes(1);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@@ -130,12 +130,9 @@ describe("AutoSubmitLoginBackground", () => {
|
||||
url: validAutoSubmitUrl,
|
||||
tabId: webRequestDetails.tabId,
|
||||
});
|
||||
expect(chrome.webNavigation.onCompleted.addListener).toHaveBeenCalledWith(
|
||||
expect.any(Function),
|
||||
{
|
||||
url: [{ hostEquals: validAutoSubmitHost }],
|
||||
},
|
||||
);
|
||||
expect(chrome.webNavigation.onCompleted.addListener).toBeCalledWith(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 () => {
|
||||
@@ -148,12 +145,9 @@ describe("AutoSubmitLoginBackground", () => {
|
||||
|
||||
triggerWebRequestOnBeforeRequestEvent(webRequestDetails);
|
||||
|
||||
expect(chrome.webNavigation.onCompleted.addListener).toHaveBeenCalledWith(
|
||||
expect.any(Function),
|
||||
{
|
||||
url: [{ hostEquals: subFrameHost }],
|
||||
},
|
||||
);
|
||||
expect(chrome.webNavigation.onCompleted.addListener).toBeCalledWith(expect.any(Function), {
|
||||
url: [{ hostEquals: subFrameHost }],
|
||||
});
|
||||
});
|
||||
|
||||
describe("injecting the auto-submit login content script", () => {
|
||||
@@ -188,7 +182,7 @@ describe("AutoSubmitLoginBackground", () => {
|
||||
triggerWebNavigationOnCompletedEvent(webNavigationDetails);
|
||||
await flushPromises();
|
||||
|
||||
expect(scriptInjectorService.inject).toHaveBeenCalledWith({
|
||||
expect(scriptInjectorService.inject).toBeCalledWith({
|
||||
tabId: webRequestDetails.tabId,
|
||||
injectDetails: {
|
||||
file: "content/auto-submit-login.js",
|
||||
@@ -312,7 +306,7 @@ describe("AutoSubmitLoginBackground", () => {
|
||||
|
||||
triggerWebRequestOnBeforeRequestEvent(webRequestDetails);
|
||||
|
||||
expect(chrome.webNavigation.onCompleted.addListener).toHaveBeenCalledWith(
|
||||
expect(chrome.webNavigation.onCompleted.addListener).toBeCalledWith(
|
||||
autoSubmitLoginBackground["handleAutoSubmitHostNavigationCompleted"],
|
||||
{ url: [{ hostEquals: validAutoSubmitHost }] },
|
||||
);
|
||||
@@ -432,12 +426,9 @@ describe("AutoSubmitLoginBackground", () => {
|
||||
}),
|
||||
);
|
||||
|
||||
expect(chrome.webNavigation.onCompleted.addListener).toHaveBeenCalledWith(
|
||||
expect.any(Function),
|
||||
{
|
||||
url: [{ hostEquals: validAutoSubmitHost }],
|
||||
},
|
||||
);
|
||||
expect(chrome.webNavigation.onCompleted.addListener).toBeCalledWith(expect.any(Function), {
|
||||
url: [{ hostEquals: validAutoSubmitHost }],
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@@ -486,7 +477,7 @@ describe("AutoSubmitLoginBackground", () => {
|
||||
sendMockExtensionMessage(message, sender);
|
||||
await flushPromises();
|
||||
|
||||
expect(autofillService.doAutoFillOnTab).toHaveBeenCalledWith(
|
||||
expect(autofillService.doAutoFillOnTab).toBeCalledWith(
|
||||
[
|
||||
{
|
||||
frameId: sender.frameId,
|
||||
|
||||
@@ -2878,7 +2878,7 @@ describe("OverlayBackground", () => {
|
||||
{ command: "closeAutofillInlineMenu", overlayElement: undefined },
|
||||
{ frameId: 0 },
|
||||
);
|
||||
expect(tabSendMessageDataSpy).toHaveBeenCalledWith(
|
||||
expect(tabSendMessageDataSpy).toBeCalledWith(
|
||||
sender.tab,
|
||||
"addToLockedVaultPendingNotifications",
|
||||
{
|
||||
|
||||
@@ -105,9 +105,9 @@ describe("ContextMenuClickedHandler", () => {
|
||||
it("can generate password", async () => {
|
||||
await sut.run(createData(GENERATE_PASSWORD_ID), { id: 5 } as any);
|
||||
|
||||
expect(generatePasswordToClipboard).toHaveBeenCalledTimes(1);
|
||||
expect(generatePasswordToClipboard).toBeCalledTimes(1);
|
||||
|
||||
expect(generatePasswordToClipboard).toHaveBeenCalledWith({
|
||||
expect(generatePasswordToClipboard).toBeCalledWith({
|
||||
id: 5,
|
||||
});
|
||||
});
|
||||
@@ -118,9 +118,9 @@ describe("ContextMenuClickedHandler", () => {
|
||||
|
||||
await sut.run(createData(`${AUTOFILL_ID}_1`, AUTOFILL_ID), { id: 5 } as any);
|
||||
|
||||
expect(autofill).toHaveBeenCalledTimes(1);
|
||||
expect(autofill).toBeCalledTimes(1);
|
||||
|
||||
expect(autofill).toHaveBeenCalledWith({ id: 5 }, cipher);
|
||||
expect(autofill).toBeCalledWith({ id: 5 }, cipher);
|
||||
});
|
||||
|
||||
it("copies username to clipboard", async () => {
|
||||
@@ -132,7 +132,7 @@ describe("ContextMenuClickedHandler", () => {
|
||||
url: "https://test.com",
|
||||
} as any);
|
||||
|
||||
expect(copyToClipboard).toHaveBeenCalledTimes(1);
|
||||
expect(copyToClipboard).toBeCalledTimes(1);
|
||||
|
||||
expect(copyToClipboard).toHaveBeenCalledWith({
|
||||
text: "TEST_USERNAME",
|
||||
@@ -149,7 +149,7 @@ describe("ContextMenuClickedHandler", () => {
|
||||
url: "https://test.com",
|
||||
} as any);
|
||||
|
||||
expect(copyToClipboard).toHaveBeenCalledTimes(1);
|
||||
expect(copyToClipboard).toBeCalledTimes(1);
|
||||
|
||||
expect(copyToClipboard).toHaveBeenCalledWith({
|
||||
text: "TEST_PASSWORD",
|
||||
|
||||
@@ -248,7 +248,7 @@ describe("AutofillInit", () => {
|
||||
await flushPromises();
|
||||
|
||||
expect(autofillInit["collectAutofillContentService"].getPageDetails).toHaveBeenCalled();
|
||||
expect(sendResponse).toHaveBeenCalledWith(pageDetails);
|
||||
expect(sendResponse).toBeCalledWith(pageDetails);
|
||||
expect(chrome.runtime.sendMessage).not.toHaveBeenCalledWith({
|
||||
command: "collectPageDetailsResponse",
|
||||
tab: message.tab,
|
||||
|
||||
@@ -372,7 +372,7 @@ describe("AutofillInlineMenuList", () => {
|
||||
|
||||
firstFillCipherElement.dispatchEvent(new KeyboardEvent("keyup", { code: "ArrowDown" }));
|
||||
|
||||
expect((secondFillCipherElement as HTMLElement).focus).toHaveBeenCalled();
|
||||
expect((secondFillCipherElement as HTMLElement).focus).toBeCalled();
|
||||
});
|
||||
|
||||
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", () => {
|
||||
@@ -386,7 +386,7 @@ describe("AutofillInlineMenuList", () => {
|
||||
|
||||
lastFillCipherElement.dispatchEvent(new KeyboardEvent("keyup", { code: "ArrowDown" }));
|
||||
|
||||
expect((firstFillCipherElement as HTMLElement).focus).toHaveBeenCalled();
|
||||
expect((firstFillCipherElement as HTMLElement).focus).toBeCalled();
|
||||
});
|
||||
|
||||
it("directs focus to the new item button if no cipher is present after the current one when pressing ArrowDown", async () => {
|
||||
@@ -406,7 +406,7 @@ describe("AutofillInlineMenuList", () => {
|
||||
|
||||
lastFillCipherElement.dispatchEvent(new KeyboardEvent("keyup", { code: "ArrowDown" }));
|
||||
|
||||
expect(autofillInlineMenuList["newItemButtonElement"].focus).toHaveBeenCalled();
|
||||
expect(autofillInlineMenuList["newItemButtonElement"].focus).toBeCalled();
|
||||
});
|
||||
|
||||
it("allows the user to move keyboard focus to the previous cipher element on ArrowUp", () => {
|
||||
@@ -420,7 +420,7 @@ describe("AutofillInlineMenuList", () => {
|
||||
|
||||
secondFillCipherElement.dispatchEvent(new KeyboardEvent("keyup", { code: "ArrowUp" }));
|
||||
|
||||
expect((firstFillCipherElement as HTMLElement).focus).toHaveBeenCalled();
|
||||
expect((firstFillCipherElement as HTMLElement).focus).toBeCalled();
|
||||
});
|
||||
|
||||
it("directs focus to the last item in the cipher list if no cipher is present before the current one when pressing ArrowUp", () => {
|
||||
@@ -434,7 +434,7 @@ describe("AutofillInlineMenuList", () => {
|
||||
|
||||
firstFillCipherElement.dispatchEvent(new KeyboardEvent("keyup", { code: "ArrowUp" }));
|
||||
|
||||
expect((lastFillCipherElement as HTMLElement).focus).toHaveBeenCalled();
|
||||
expect((lastFillCipherElement as HTMLElement).focus).toBeCalled();
|
||||
});
|
||||
|
||||
it("directs focus to the new item button if no cipher is present before the current one when pressing ArrowUp", async () => {
|
||||
@@ -454,7 +454,7 @@ describe("AutofillInlineMenuList", () => {
|
||||
|
||||
firstFillCipherElement.dispatchEvent(new KeyboardEvent("keyup", { code: "ArrowUp" }));
|
||||
|
||||
expect(autofillInlineMenuList["newItemButtonElement"].focus).toHaveBeenCalled();
|
||||
expect(autofillInlineMenuList["newItemButtonElement"].focus).toBeCalled();
|
||||
});
|
||||
|
||||
it("allows the user to move keyboard focus to the view cipher button on ArrowRight", () => {
|
||||
@@ -466,7 +466,7 @@ describe("AutofillInlineMenuList", () => {
|
||||
|
||||
fillCipherElement.dispatchEvent(new KeyboardEvent("keyup", { code: "ArrowRight" }));
|
||||
|
||||
expect((viewCipherButton as HTMLElement).focus).toHaveBeenCalled();
|
||||
expect((viewCipherButton as HTMLElement).focus).toBeCalled();
|
||||
});
|
||||
|
||||
it("ignores keyup events that do not include ArrowUp, ArrowDown, or ArrowRight", () => {
|
||||
@@ -476,7 +476,7 @@ describe("AutofillInlineMenuList", () => {
|
||||
|
||||
fillCipherElement.dispatchEvent(new KeyboardEvent("keyup", { code: "ArrowLeft" }));
|
||||
|
||||
expect((fillCipherElement as HTMLElement).focus).not.toHaveBeenCalled();
|
||||
expect((fillCipherElement as HTMLElement).focus).not.toBeCalled();
|
||||
});
|
||||
});
|
||||
|
||||
@@ -506,7 +506,7 @@ describe("AutofillInlineMenuList", () => {
|
||||
|
||||
viewCipherButton.dispatchEvent(new KeyboardEvent("keyup", { code: "ArrowLeft" }));
|
||||
|
||||
expect((fillCipherButton as HTMLElement).focus).toHaveBeenCalled();
|
||||
expect((fillCipherButton as HTMLElement).focus).toBeCalled();
|
||||
});
|
||||
|
||||
it("allows the user to move keyboard to the next cipher element on ArrowDown", () => {
|
||||
@@ -519,7 +519,7 @@ describe("AutofillInlineMenuList", () => {
|
||||
|
||||
viewCipherButton.dispatchEvent(new KeyboardEvent("keyup", { code: "ArrowDown" }));
|
||||
|
||||
expect((secondFillCipherButton as HTMLElement).focus).toHaveBeenCalled();
|
||||
expect((secondFillCipherButton as HTMLElement).focus).toBeCalled();
|
||||
});
|
||||
|
||||
it("allows the user to move keyboard focus to the previous cipher element on ArrowUp", () => {
|
||||
@@ -532,7 +532,7 @@ describe("AutofillInlineMenuList", () => {
|
||||
|
||||
viewCipherButton.dispatchEvent(new KeyboardEvent("keyup", { code: "ArrowUp" }));
|
||||
|
||||
expect((firstFillCipherButton as HTMLElement).focus).toHaveBeenCalled();
|
||||
expect((firstFillCipherButton as HTMLElement).focus).toBeCalled();
|
||||
});
|
||||
|
||||
it("ignores keyup events that do not include ArrowUp, ArrowDown, or ArrowRight", () => {
|
||||
@@ -542,7 +542,7 @@ describe("AutofillInlineMenuList", () => {
|
||||
|
||||
viewCipherButton.dispatchEvent(new KeyboardEvent("keyup", { code: "ArrowRight" }));
|
||||
|
||||
expect((viewCipherButton as HTMLElement).focus).not.toHaveBeenCalled();
|
||||
expect((viewCipherButton as HTMLElement).focus).not.toBeCalled();
|
||||
});
|
||||
});
|
||||
|
||||
@@ -769,7 +769,7 @@ describe("AutofillInlineMenuList", () => {
|
||||
|
||||
viewCipherButton.dispatchEvent(new KeyboardEvent("keyup", { code: "ArrowDown" }));
|
||||
|
||||
expect((fillCipherButton as HTMLElement).focus).toHaveBeenCalled();
|
||||
expect((fillCipherButton as HTMLElement).focus).toBeCalled();
|
||||
});
|
||||
|
||||
it("skips the passkeys heading when the user presses ArrowDown to focus the first list item", () => {
|
||||
@@ -781,7 +781,7 @@ describe("AutofillInlineMenuList", () => {
|
||||
|
||||
viewCipherButton.dispatchEvent(new KeyboardEvent("keyup", { code: "ArrowDown" }));
|
||||
|
||||
expect((fillCipherButton as HTMLElement).focus).toHaveBeenCalled();
|
||||
expect((fillCipherButton as HTMLElement).focus).toBeCalled();
|
||||
});
|
||||
|
||||
it("skips the logins heading when the user presses ArrowUp to focus the previous list item", () => {
|
||||
@@ -793,7 +793,7 @@ describe("AutofillInlineMenuList", () => {
|
||||
|
||||
viewCipherButton.dispatchEvent(new KeyboardEvent("keyup", { code: "ArrowUp" }));
|
||||
|
||||
expect((fillCipherButton as HTMLElement).focus).toHaveBeenCalled();
|
||||
expect((fillCipherButton as HTMLElement).focus).toBeCalled();
|
||||
});
|
||||
});
|
||||
});
|
||||
@@ -875,7 +875,7 @@ describe("AutofillInlineMenuList", () => {
|
||||
new KeyboardEvent("keyup", { code: "ArrowRight" }),
|
||||
);
|
||||
|
||||
expect((refreshGeneratedPasswordButton as HTMLElement).focus).toHaveBeenCalled();
|
||||
expect((refreshGeneratedPasswordButton as HTMLElement).focus).toBeCalled();
|
||||
});
|
||||
});
|
||||
});
|
||||
@@ -945,7 +945,7 @@ describe("AutofillInlineMenuList", () => {
|
||||
new KeyboardEvent("keyup", { code: "ArrowLeft" }),
|
||||
);
|
||||
|
||||
expect((fillGeneratedPasswordButton as HTMLElement).focus).toHaveBeenCalled();
|
||||
expect((fillGeneratedPasswordButton as HTMLElement).focus).toBeCalled();
|
||||
});
|
||||
});
|
||||
});
|
||||
@@ -1163,7 +1163,7 @@ describe("AutofillInlineMenuList", () => {
|
||||
|
||||
postWindowMessage({ command: "focusAutofillInlineMenuList" });
|
||||
|
||||
expect((unlockButton as HTMLElement).focus).toHaveBeenCalled();
|
||||
expect((unlockButton as HTMLElement).focus).toBeCalled();
|
||||
});
|
||||
|
||||
it("focuses the new item button element if the cipher list is empty", async () => {
|
||||
@@ -1175,7 +1175,7 @@ describe("AutofillInlineMenuList", () => {
|
||||
|
||||
postWindowMessage({ command: "focusAutofillInlineMenuList" });
|
||||
|
||||
expect((newItemButton as HTMLElement).focus).toHaveBeenCalled();
|
||||
expect((newItemButton as HTMLElement).focus).toBeCalled();
|
||||
});
|
||||
|
||||
it("focuses the first cipher button element if the cipher list is populated", () => {
|
||||
@@ -1186,7 +1186,7 @@ describe("AutofillInlineMenuList", () => {
|
||||
|
||||
postWindowMessage({ command: "focusAutofillInlineMenuList" });
|
||||
|
||||
expect((firstCipherItem as HTMLElement).focus).toHaveBeenCalled();
|
||||
expect((firstCipherItem as HTMLElement).focus).toBeCalled();
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
@@ -2076,7 +2076,7 @@ describe("CollectAutofillContentService", () => {
|
||||
collectAutofillContentService["setupMutationObserver"]();
|
||||
|
||||
expect(collectAutofillContentService["mutationObserver"]).toBeInstanceOf(MutationObserver);
|
||||
expect(collectAutofillContentService["mutationObserver"].observe).toHaveBeenCalled();
|
||||
expect(collectAutofillContentService["mutationObserver"].observe).toBeCalled();
|
||||
});
|
||||
});
|
||||
|
||||
@@ -2114,11 +2114,11 @@ describe("CollectAutofillContentService", () => {
|
||||
|
||||
expect(collectAutofillContentService["domRecentlyMutated"]).toEqual(true);
|
||||
expect(collectAutofillContentService["noFieldsFound"]).toEqual(false);
|
||||
expect(collectAutofillContentService["isAutofillElementNodeMutated"]).toHaveBeenCalledWith(
|
||||
expect(collectAutofillContentService["isAutofillElementNodeMutated"]).toBeCalledWith(
|
||||
removedNodes,
|
||||
true,
|
||||
);
|
||||
expect(collectAutofillContentService["isAutofillElementNodeMutated"]).toHaveBeenCalledWith(
|
||||
expect(collectAutofillContentService["isAutofillElementNodeMutated"]).toBeCalledWith(
|
||||
addedNodes,
|
||||
);
|
||||
});
|
||||
@@ -2183,10 +2183,8 @@ describe("CollectAutofillContentService", () => {
|
||||
|
||||
expect(collectAutofillContentService["domRecentlyMutated"]).toEqual(false);
|
||||
expect(collectAutofillContentService["noFieldsFound"]).toEqual(true);
|
||||
expect(collectAutofillContentService["isAutofillElementNodeMutated"]).not.toHaveBeenCalled();
|
||||
expect(
|
||||
collectAutofillContentService["handleAutofillElementAttributeMutation"],
|
||||
).toHaveBeenCalled();
|
||||
expect(collectAutofillContentService["isAutofillElementNodeMutated"]).not.toBeCalled();
|
||||
expect(collectAutofillContentService["handleAutofillElementAttributeMutation"]).toBeCalled();
|
||||
});
|
||||
|
||||
it("will handle window location mutations", () => {
|
||||
@@ -2208,11 +2206,11 @@ describe("CollectAutofillContentService", () => {
|
||||
|
||||
collectAutofillContentService["handleMutationObserverMutation"]([mutationRecord]);
|
||||
|
||||
expect(collectAutofillContentService["handleWindowLocationMutation"]).toHaveBeenCalled();
|
||||
expect(collectAutofillContentService["isAutofillElementNodeMutated"]).not.toHaveBeenCalled();
|
||||
expect(collectAutofillContentService["handleWindowLocationMutation"]).toBeCalled();
|
||||
expect(collectAutofillContentService["isAutofillElementNodeMutated"]).not.toBeCalled();
|
||||
expect(
|
||||
collectAutofillContentService["handleAutofillElementAttributeMutation"],
|
||||
).not.toHaveBeenCalled();
|
||||
).not.toBeCalled();
|
||||
});
|
||||
|
||||
it("will setup the overlay listeners on mutated elements", async () => {
|
||||
@@ -2240,9 +2238,7 @@ describe("CollectAutofillContentService", () => {
|
||||
collectAutofillContentService["handleMutationObserverMutation"]([mutationRecord]);
|
||||
jest.runAllTimers();
|
||||
|
||||
expect(
|
||||
collectAutofillContentService["setupOverlayListenersOnMutatedElements"],
|
||||
).toHaveBeenCalled();
|
||||
expect(collectAutofillContentService["setupOverlayListenersOnMutatedElements"]).toBeCalled();
|
||||
});
|
||||
});
|
||||
|
||||
@@ -2254,7 +2250,7 @@ describe("CollectAutofillContentService", () => {
|
||||
|
||||
collectAutofillContentService["setupOverlayListenersOnMutatedElements"](nodes);
|
||||
|
||||
expect(collectAutofillContentService["buildAutofillFieldItem"]).not.toHaveBeenCalled();
|
||||
expect(collectAutofillContentService["buildAutofillFieldItem"]).not.toBeCalled();
|
||||
});
|
||||
|
||||
it("skips building the autofill field item if the node is already a field element", () => {
|
||||
@@ -2268,7 +2264,7 @@ describe("CollectAutofillContentService", () => {
|
||||
|
||||
collectAutofillContentService["setupOverlayListenersOnMutatedElements"](nodes);
|
||||
|
||||
expect(collectAutofillContentService["buildAutofillFieldItem"]).not.toHaveBeenCalled();
|
||||
expect(collectAutofillContentService["buildAutofillFieldItem"]).not.toBeCalled();
|
||||
});
|
||||
});
|
||||
|
||||
@@ -2333,9 +2329,7 @@ describe("CollectAutofillContentService", () => {
|
||||
expect(collectAutofillContentService["currentLocationHref"]).toEqual(window.location.href);
|
||||
expect(collectAutofillContentService["domRecentlyMutated"]).toEqual(true);
|
||||
expect(collectAutofillContentService["noFieldsFound"]).toEqual(false);
|
||||
expect(
|
||||
collectAutofillContentService["updateAutofillElementsAfterMutation"],
|
||||
).toHaveBeenCalled();
|
||||
expect(collectAutofillContentService["updateAutofillElementsAfterMutation"]).toBeCalled();
|
||||
expect(collectAutofillContentService["_autofillFormElements"].size).toEqual(0);
|
||||
expect(collectAutofillContentService["autofillFieldElements"].size).toEqual(0);
|
||||
});
|
||||
@@ -2358,7 +2352,7 @@ describe("CollectAutofillContentService", () => {
|
||||
|
||||
collectAutofillContentService["handleAutofillElementAttributeMutation"](mutationRecord);
|
||||
|
||||
expect(collectAutofillContentService["isAutofillElementNodeMutated"]).not.toHaveBeenCalled();
|
||||
expect(collectAutofillContentService["isAutofillElementNodeMutated"]).not.toBeCalled();
|
||||
});
|
||||
|
||||
it("will update the autofill form element data if the target node can be found in the autofillFormElements map", () => {
|
||||
@@ -2390,7 +2384,7 @@ describe("CollectAutofillContentService", () => {
|
||||
|
||||
collectAutofillContentService["handleAutofillElementAttributeMutation"](mutationRecord);
|
||||
|
||||
expect(collectAutofillContentService["updateAutofillFormElementData"]).toHaveBeenCalledWith(
|
||||
expect(collectAutofillContentService["updateAutofillFormElementData"]).toBeCalledWith(
|
||||
mutationRecord.attributeName,
|
||||
mutationRecord.target,
|
||||
autofillForm,
|
||||
@@ -2437,7 +2431,7 @@ describe("CollectAutofillContentService", () => {
|
||||
|
||||
collectAutofillContentService["handleAutofillElementAttributeMutation"](mutationRecord);
|
||||
|
||||
expect(collectAutofillContentService["updateAutofillFieldElementData"]).toHaveBeenCalledWith(
|
||||
expect(collectAutofillContentService["updateAutofillFieldElementData"]).toBeCalledWith(
|
||||
mutationRecord.attributeName,
|
||||
mutationRecord.target,
|
||||
autofillField,
|
||||
@@ -2472,7 +2466,7 @@ describe("CollectAutofillContentService", () => {
|
||||
autofillForm,
|
||||
);
|
||||
|
||||
expect(collectAutofillContentService["_autofillFormElements"].set).toHaveBeenCalledWith(
|
||||
expect(collectAutofillContentService["_autofillFormElements"].set).toBeCalledWith(
|
||||
formElement,
|
||||
autofillForm,
|
||||
);
|
||||
@@ -2488,7 +2482,7 @@ describe("CollectAutofillContentService", () => {
|
||||
autofillForm,
|
||||
);
|
||||
|
||||
expect(collectAutofillContentService["_autofillFormElements"].set).not.toHaveBeenCalled();
|
||||
expect(collectAutofillContentService["_autofillFormElements"].set).not.toBeCalled();
|
||||
});
|
||||
});
|
||||
|
||||
@@ -2543,7 +2537,7 @@ describe("CollectAutofillContentService", () => {
|
||||
autofillField,
|
||||
);
|
||||
|
||||
expect(collectAutofillContentService["autofillFieldElements"].set).toHaveBeenCalledWith(
|
||||
expect(collectAutofillContentService["autofillFieldElements"].set).toBeCalledWith(
|
||||
fieldElement,
|
||||
autofillField,
|
||||
);
|
||||
@@ -2559,7 +2553,7 @@ describe("CollectAutofillContentService", () => {
|
||||
autofillField,
|
||||
);
|
||||
|
||||
expect(collectAutofillContentService["autofillFieldElements"].set).not.toHaveBeenCalled();
|
||||
expect(collectAutofillContentService["autofillFieldElements"].set).not.toBeCalled();
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
@@ -482,7 +482,7 @@ describe("InsertAutofillContentService", () => {
|
||||
|
||||
expect(
|
||||
insertAutofillContentService["collectAutofillContentService"].getAutofillFieldElementByOpid,
|
||||
).toHaveBeenCalledWith("__1");
|
||||
).toBeCalledWith("__1");
|
||||
expect((insertAutofillContentService as any)["triggerClickOnElement"]).toHaveBeenCalledWith(
|
||||
textInput,
|
||||
);
|
||||
@@ -547,7 +547,7 @@ describe("InsertAutofillContentService", () => {
|
||||
|
||||
expect(
|
||||
insertAutofillContentService["collectAutofillContentService"].getAutofillFieldElementByOpid,
|
||||
).toHaveBeenCalledWith("__0");
|
||||
).toBeCalledWith("__0");
|
||||
expect(targetInput.blur).not.toHaveBeenCalled();
|
||||
expect(
|
||||
insertAutofillContentService["simulateUserMouseClickAndFocusEventInteractions"],
|
||||
|
||||
@@ -23,13 +23,13 @@ describe("devFlag decorator", () => {
|
||||
devFlagEnabledMock.mockReturnValue(false);
|
||||
expect(() => {
|
||||
new TestClass().test();
|
||||
}).toThrow("This method should not be called, it is protected by a disabled dev flag.");
|
||||
}).toThrowError("This method should not be called, it is protected by a disabled dev flag.");
|
||||
});
|
||||
|
||||
it("should not throw an error if the dev flag is enabled", () => {
|
||||
devFlagEnabledMock.mockReturnValue(true);
|
||||
expect(() => {
|
||||
new TestClass().test();
|
||||
}).not.toThrow();
|
||||
}).not.toThrowError();
|
||||
});
|
||||
});
|
||||
|
||||
@@ -324,8 +324,8 @@ describe("Browser Utils Service", () => {
|
||||
BrowserApi.sendMessageWithResponse = jest.fn();
|
||||
offscreenDocumentService.offscreenApiSupported.mockReturnValue(true);
|
||||
getManifestVersionSpy.mockReturnValue(3);
|
||||
offscreenDocumentService.withDocument.mockImplementationOnce(async (_, __, callback) =>
|
||||
callback(),
|
||||
offscreenDocumentService.withDocument.mockImplementationOnce((_, __, callback) =>
|
||||
Promise.resolve("test"),
|
||||
);
|
||||
|
||||
await browserPlatformUtilsService.readFromClipboard();
|
||||
@@ -347,8 +347,8 @@ describe("Browser Utils Service", () => {
|
||||
.mockReturnValue(DeviceType.ChromeExtension);
|
||||
getManifestVersionSpy.mockReturnValue(3);
|
||||
jest.spyOn(BrowserApi, "sendMessageWithResponse").mockResolvedValue(1);
|
||||
offscreenDocumentService.withDocument.mockImplementationOnce(async (_, __, callback) =>
|
||||
callback(),
|
||||
offscreenDocumentService.withDocument.mockImplementationOnce((_, __, callback) =>
|
||||
Promise.resolve(1),
|
||||
);
|
||||
|
||||
const result = await browserPlatformUtilsService.readFromClipboard();
|
||||
|
||||
@@ -284,8 +284,8 @@ describe("VaultPopupItemsService", () => {
|
||||
};
|
||||
|
||||
// Assume all ciphers are autofill ciphers to test sorting
|
||||
cipherServiceMock.filterCiphersForUrl.mockImplementation(
|
||||
async () => Object.values(allCiphers) as any,
|
||||
cipherServiceMock.filterCiphersForUrl.mockImplementation(async () =>
|
||||
Object.values(allCiphers),
|
||||
);
|
||||
|
||||
service.autoFillCiphers$.subscribe((ciphers) => {
|
||||
@@ -335,10 +335,10 @@ describe("VaultPopupItemsService", () => {
|
||||
const cipherList = Object.values(allCiphers);
|
||||
const searchText = "Card 2";
|
||||
|
||||
searchService.searchCiphers.mockImplementation(async (userId, query, filter, ciphers) => {
|
||||
searchService.searchCiphers.mockImplementation(async () => {
|
||||
return cipherList.filter((cipher) => {
|
||||
return cipher.name === searchText;
|
||||
}) as any;
|
||||
});
|
||||
});
|
||||
|
||||
service.favoriteCiphers$.subscribe((ciphers) => {
|
||||
@@ -367,10 +367,10 @@ describe("VaultPopupItemsService", () => {
|
||||
const cipherList = Object.values(allCiphers);
|
||||
const searchText = "Login";
|
||||
|
||||
searchService.searchCiphers.mockImplementation(async (userId, query, filter, ciphers) => {
|
||||
searchService.searchCiphers.mockImplementation(async () => {
|
||||
return cipherList.filter((cipher) => {
|
||||
return cipher.name.includes(searchText);
|
||||
}) as any;
|
||||
});
|
||||
});
|
||||
|
||||
service.remainingCiphers$.subscribe((ciphers) => {
|
||||
|
||||
@@ -146,11 +146,11 @@ describe("AuthRequestService", () => {
|
||||
);
|
||||
|
||||
// Assert
|
||||
expect(sut.decryptPubKeyEncryptedUserKey).toHaveBeenCalledWith(
|
||||
expect(sut.decryptPubKeyEncryptedUserKey).toBeCalledWith(
|
||||
mockAuthReqResponse.key,
|
||||
mockPrivateKey,
|
||||
);
|
||||
expect(keyService.setUserKey).toHaveBeenCalledWith(mockDecryptedUserKey, mockUserId);
|
||||
expect(keyService.setUserKey).toBeCalledWith(mockDecryptedUserKey, mockUserId);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -186,7 +186,7 @@ describe("AuthRequestService", () => {
|
||||
);
|
||||
|
||||
// Assert
|
||||
expect(sut.decryptPubKeyEncryptedMasterKeyAndHash).toHaveBeenCalledWith(
|
||||
expect(sut.decryptPubKeyEncryptedMasterKeyAndHash).toBeCalledWith(
|
||||
mockAuthReqResponse.key,
|
||||
mockAuthReqResponse.masterPasswordHash,
|
||||
mockPrivateKey,
|
||||
@@ -226,7 +226,7 @@ describe("AuthRequestService", () => {
|
||||
);
|
||||
|
||||
// Assert
|
||||
expect(encryptService.decapsulateKeyUnsigned).toHaveBeenCalledWith(
|
||||
expect(encryptService.decapsulateKeyUnsigned).toBeCalledWith(
|
||||
new EncString(mockPubKeyEncryptedUserKey),
|
||||
mockPrivateKey,
|
||||
);
|
||||
|
||||
@@ -107,7 +107,7 @@ describe("EncString", () => {
|
||||
|
||||
it("result should be cached", async () => {
|
||||
const decrypted = await encString.decrypt(null);
|
||||
expect(encryptService.decryptString).toHaveBeenCalledTimes(1);
|
||||
expect(encryptService.decryptString).toBeCalledTimes(1);
|
||||
|
||||
expect(decrypted).toBe("decrypted");
|
||||
});
|
||||
|
||||
@@ -91,28 +91,28 @@ describe("MigrationBuilder", () => {
|
||||
const helper = new MigrationHelper(0, mock(), mock(), "general", clientType);
|
||||
const spy = jest.spyOn(migrator, "migrate");
|
||||
await sut.migrate(helper);
|
||||
expect(spy).toHaveBeenCalledWith(helper);
|
||||
expect(spy).toBeCalledWith(helper);
|
||||
});
|
||||
|
||||
it("should rollback", async () => {
|
||||
const helper = new MigrationHelper(1, mock(), mock(), "general", clientType);
|
||||
const spy = jest.spyOn(rollback_migrator, "rollback");
|
||||
await sut.migrate(helper);
|
||||
expect(spy).toHaveBeenCalledWith(helper);
|
||||
expect(spy).toBeCalledWith(helper);
|
||||
});
|
||||
|
||||
it("should update version on migrate", async () => {
|
||||
const helper = new MigrationHelper(0, mock(), mock(), "general", clientType);
|
||||
const spy = jest.spyOn(migrator, "updateVersion");
|
||||
await sut.migrate(helper);
|
||||
expect(spy).toHaveBeenCalledWith(helper, "up");
|
||||
expect(spy).toBeCalledWith(helper, "up");
|
||||
});
|
||||
|
||||
it("should update version on rollback", async () => {
|
||||
const helper = new MigrationHelper(1, mock(), mock(), "general", clientType);
|
||||
const spy = jest.spyOn(rollback_migrator, "updateVersion");
|
||||
await sut.migrate(helper);
|
||||
expect(spy).toHaveBeenCalledWith(helper, "down");
|
||||
expect(spy).toBeCalledWith(helper, "down");
|
||||
});
|
||||
|
||||
it("should not run the migrator if the current version does not match the from version", async () => {
|
||||
@@ -120,8 +120,8 @@ describe("MigrationBuilder", () => {
|
||||
const migrate = jest.spyOn(migrator, "migrate");
|
||||
const rollback = jest.spyOn(rollback_migrator, "rollback");
|
||||
await sut.migrate(helper);
|
||||
expect(migrate).not.toHaveBeenCalled();
|
||||
expect(rollback).not.toHaveBeenCalled();
|
||||
expect(migrate).not.toBeCalled();
|
||||
expect(rollback).not.toBeCalled();
|
||||
});
|
||||
|
||||
it("should not update version if the current version does not match the from version", async () => {
|
||||
@@ -129,8 +129,8 @@ describe("MigrationBuilder", () => {
|
||||
const migrate = jest.spyOn(migrator, "updateVersion");
|
||||
const rollback = jest.spyOn(rollback_migrator, "updateVersion");
|
||||
await sut.migrate(helper);
|
||||
expect(migrate).not.toHaveBeenCalled();
|
||||
expect(rollback).not.toHaveBeenCalled();
|
||||
expect(migrate).not.toBeCalled();
|
||||
expect(rollback).not.toBeCalled();
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
@@ -60,7 +60,7 @@ describe("migrator default methods", () => {
|
||||
describe("up", () => {
|
||||
it("should update the version", async () => {
|
||||
await sut.updateVersion(helper, "up");
|
||||
expect(storage.save).toHaveBeenCalledWith("stateVersion", 1);
|
||||
expect(storage.save).toBeCalledWith("stateVersion", 1);
|
||||
expect(helper.currentVersion).toBe(1);
|
||||
});
|
||||
});
|
||||
@@ -69,7 +69,7 @@ describe("migrator default methods", () => {
|
||||
it("should update the version", async () => {
|
||||
helper.currentVersion = 1;
|
||||
await sut.updateVersion(helper, "down");
|
||||
expect(storage.save).toHaveBeenCalledWith("stateVersion", 0);
|
||||
expect(storage.save).toBeCalledWith("stateVersion", 0);
|
||||
expect(helper.currentVersion).toBe(0);
|
||||
});
|
||||
});
|
||||
|
||||
13
package-lock.json
generated
13
package-lock.json
generated
@@ -154,7 +154,7 @@
|
||||
"husky": "9.1.7",
|
||||
"jest-diff": "30.2.0",
|
||||
"jest-junit": "16.0.0",
|
||||
"jest-mock-extended": "4.0.0",
|
||||
"jest-mock-extended": "3.0.7",
|
||||
"jest-preset-angular": "14.6.1",
|
||||
"json5": "2.2.3",
|
||||
"lint-staged": "16.0.0",
|
||||
@@ -26804,17 +26804,16 @@
|
||||
}
|
||||
},
|
||||
"node_modules/jest-mock-extended": {
|
||||
"version": "4.0.0",
|
||||
"resolved": "https://registry.npmjs.org/jest-mock-extended/-/jest-mock-extended-4.0.0.tgz",
|
||||
"integrity": "sha512-7BZpfuvLam+/HC+NxifIi9b+5VXj/utUDMPUqrDJehGWVuXPtLS9Jqlob2mJLrI/pg2k1S8DMfKDvEB88QNjaQ==",
|
||||
"version": "3.0.7",
|
||||
"resolved": "https://registry.npmjs.org/jest-mock-extended/-/jest-mock-extended-3.0.7.tgz",
|
||||
"integrity": "sha512-7lsKdLFcW9B9l5NzZ66S/yTQ9k8rFtnwYdCNuRU/81fqDWicNDVhitTSPnrGmNeNm0xyw0JHexEOShrIKRCIRQ==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"ts-essentials": "^10.0.2"
|
||||
"ts-essentials": "^10.0.0"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"@jest/globals": "^28.0.0 || ^29.0.0 || ^30.0.0",
|
||||
"jest": "^24.0.0 || ^25.0.0 || ^26.0.0 || ^27.0.0 || ^28.0.0 || ^29.0.0 || ^30.0.0",
|
||||
"jest": "^24.0.0 || ^25.0.0 || ^26.0.0 || ^27.0.0 || ^28.0.0 || ^29.0.0",
|
||||
"typescript": "^3.0.0 || ^4.0.0 || ^5.0.0"
|
||||
}
|
||||
},
|
||||
|
||||
@@ -117,7 +117,7 @@
|
||||
"husky": "9.1.7",
|
||||
"jest-diff": "30.2.0",
|
||||
"jest-junit": "16.0.0",
|
||||
"jest-mock-extended": "4.0.0",
|
||||
"jest-mock-extended": "3.0.7",
|
||||
"jest-preset-angular": "14.6.1",
|
||||
"json5": "2.2.3",
|
||||
"lint-staged": "16.0.0",
|
||||
@@ -160,8 +160,8 @@
|
||||
"@angular/platform-browser": "19.2.14",
|
||||
"@angular/platform-browser-dynamic": "19.2.14",
|
||||
"@angular/router": "19.2.14",
|
||||
"@bitwarden/sdk-internal": "0.2.0-main.375",
|
||||
"@bitwarden/commercial-sdk-internal": "0.2.0-main.375",
|
||||
"@bitwarden/sdk-internal": "0.2.0-main.375",
|
||||
"@electron/fuses": "1.8.0",
|
||||
"@emotion/css": "11.13.5",
|
||||
"@koa/multer": "4.0.0",
|
||||
|
||||
Reference in New Issue
Block a user