From 8ed23b0cdaa5e65cde6fcbe134dbba57b03b0ed4 Mon Sep 17 00:00:00 2001 From: Nicolas Chevobbe Date: Thu, 30 Aug 2018 10:42:43 +0000 Subject: [PATCH] Bug 1486768 - Fix mocha tests;r=Honza. Some tests were failing because of change in the code: - arrow icon don't have an expanded class anymore but use aria-expanded - executionPoint property wasn't set on the ConsoleMessageType - networkUpdateRequest action expects a second argument - requestHeadersFromUploadStream is retrieved from requestPostData.uploadHeaders Differential Revision: https://phabricator.services.mozilla.com/D4444 --HG-- extra : moz-landing-system : lando --- .../test/components/console-api-call.test.js | 4 ++-- .../webconsole/test/components/page-error.test.js | 7 ++++--- .../webconsole/test/store/network-messages.test.js | 12 +++++++----- .../webconsole/test/store/private-messages.test.js | 4 ++-- devtools/client/webconsole/types.js | 1 + 5 files changed, 16 insertions(+), 12 deletions(-) diff --git a/devtools/client/webconsole/test/components/console-api-call.test.js b/devtools/client/webconsole/test/components/console-api-call.test.js index 6ece78ed8a51..af39413508d1 100644 --- a/devtools/client/webconsole/test/components/console-api-call.test.js +++ b/devtools/client/webconsole/test/components/console-api-call.test.js @@ -322,7 +322,7 @@ describe("ConsoleAPICall component:", () => { const wrapper = render(ConsoleApiCall({ message, serviceContainer, open: true })); expect(wrapper.find(".message-body").text()).toBe("bar"); - expect(wrapper.find(".collapse-button.expanded").length).toBe(1); + expect(wrapper.find(".collapse-button[aria-expanded=true]").length).toBe(1); }); it("renders group with custom style", () => { @@ -362,7 +362,7 @@ describe("ConsoleAPICall component:", () => { serviceContainer, }) )); - wrapper.find(".collapse-button.expanded").simulate("click"); + wrapper.find(".collapse-button[aria-expanded='true']").simulate("click"); let call = store.dispatch.getCall(0); expect(call.args[0]).toEqual({ id: message.id, diff --git a/devtools/client/webconsole/test/components/page-error.test.js b/devtools/client/webconsole/test/components/page-error.test.js index 79e3ab145604..d6646028f618 100644 --- a/devtools/client/webconsole/test/components/page-error.test.js +++ b/devtools/client/webconsole/test/components/page-error.test.js @@ -114,7 +114,7 @@ describe("PageError component:", () => { const wrapper = render(PageError({ message, serviceContainer, open: true })); // There should be a collapse button. - expect(wrapper.find(".collapse-button.expanded").length).toBe(1); + expect(wrapper.find(".collapse-button[aria-expanded=true]").length).toBe(1); // There should be five stacktrace items. const frameLinks = wrapper.find(`.stack-trace span.frame-link`); @@ -134,7 +134,8 @@ describe("PageError component:", () => { serviceContainer, }) )); - wrapper.find(".collapse-button.expanded").simulate("click"); + + wrapper.find(".collapse-button[aria-expanded='true']").simulate("click"); let call = store.dispatch.getCall(0); expect(call.args[0]).toEqual({ id: message.id, @@ -149,7 +150,7 @@ describe("PageError component:", () => { serviceContainer, }) )); - wrapper.find(".collapse-button").simulate("click"); + wrapper.find(".collapse-button[aria-expanded='false']").simulate("click"); call = store.dispatch.getCall(1); expect(call.args[0]).toEqual({ id: message.id, diff --git a/devtools/client/webconsole/test/store/network-messages.test.js b/devtools/client/webconsole/test/store/network-messages.test.js index b91616840324..efcc3de2fa86 100644 --- a/devtools/client/webconsole/test/store/network-messages.test.js +++ b/devtools/client/webconsole/test/store/network-messages.test.js @@ -67,19 +67,21 @@ describe("Network message reducer:", () => { }); it("adds fetched HTTP post data", () => { + const uploadHeaders = Symbol(); const requestPostData = { postData: { text: "" - } + }, + uploadHeaders, }; dispatch(actions.networkUpdateRequest("message1", { - requestPostData: requestPostData + requestPostData, })); - const networkUpdates = getAllNetworkMessagesUpdateById(getState()); - expect(networkUpdates.message1.requestPostData).toBe(requestPostData); - expect(networkUpdates.message1.requestHeadersFromUploadStream).toExist(); + const {message1} = getAllNetworkMessagesUpdateById(getState()); + expect(message1.requestPostData).toBe(requestPostData); + expect(message1.requestHeadersFromUploadStream).toBe(uploadHeaders); }); }); }); diff --git a/devtools/client/webconsole/test/store/private-messages.test.js b/devtools/client/webconsole/test/store/private-messages.test.js index e1f3c64e2a71..1e8b95f2c40d 100644 --- a/devtools/client/webconsole/test/store/private-messages.test.js +++ b/devtools/client/webconsole/test/store/private-messages.test.js @@ -156,8 +156,8 @@ describe("private messages", () => { const publicMessageId = getFirstMessage(state).id; const privateMessageId = getLastMessage(state).id; - dispatch(actions.networkUpdateRequest(publicMessageId)); - dispatch(actions.networkUpdateRequest(privateMessageId)); + dispatch(actions.networkUpdateRequest(publicMessageId, {})); + dispatch(actions.networkUpdateRequest(privateMessageId, {})); let networkUpdates = getAllNetworkMessagesUpdateById(getState()); expect(Object.keys(networkUpdates)).toEqual([publicMessageId, privateMessageId]); diff --git a/devtools/client/webconsole/types.js b/devtools/client/webconsole/types.js index 6bfd39790ce3..c7ffae5f853d 100644 --- a/devtools/client/webconsole/types.js +++ b/devtools/client/webconsole/types.js @@ -41,6 +41,7 @@ exports.ConsoleMessage = function(props) { frame: null, groupId: null, exceptionDocURL: null, + executionPoint: undefined, userProvidedStyles: null, notes: null, indent: 0,