Bug 1427006 - Enhanced the browser_webconsole_console_group test; r=nchevobbe
☠☠ backed out by 85baf8c8549c ☠ ☠
authorabhinav <abhinav.koppula@gmail.com>
Fri, 15 Dec 2017 00:39:34 +0530
changeset 449726 af69a7e1b59f84302226cd0849f43e2348a30eb1
parent 449725 5c4c6942a87a65ea847b0a1b95bda771dcd670c7
child 449727 b9755c321f888e37910aa1b3d4a84921f5274871
push id8527
push userCallek@gmail.com
push dateThu, 11 Jan 2018 21:05:50 +0000
treeherdermozilla-beta@95342d212a7a [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersnchevobbe
bugs1427006
milestone59.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1427006 - Enhanced the browser_webconsole_console_group test; r=nchevobbe MozReview-Commit-ID: Efe5xb8sq7C
devtools/client/webconsole/new-console-output/test/mochitest/browser_webconsole_console_group.js
--- a/devtools/client/webconsole/new-console-output/test/mochitest/browser_webconsole_console_group.js
+++ b/devtools/client/webconsole/new-console-output/test/mochitest/browser_webconsole_console_group.js
@@ -26,63 +26,111 @@ add_task(async function () {
           parameters: message.parameters,
           messageText: message.messageText
         });
         return res;
       }, []);
     info("messages : " + JSON.stringify(messages));
   });
 
+  const onMessagesLogged = waitForMessage(hud, "log-6");
   ContentTask.spawn(gBrowser.selectedBrowser, null, function () {
     content.wrappedJSObject.doLog();
   });
+  await onMessagesLogged;
 
   info("Test a group at root level");
-  let node = await waitFor(() => findMessage(hud, "group-1"));
+  let node = findMessage(hud, "group-1");
   testClass(node, "startGroup");
   testIndent(node, 0);
+  testGroupToggle({
+    node,
+    store,
+    shouldBeOpen: true,
+    visibleMessageIdsAfterExpand: ["1","2","3","4","6","8","9","12"],
+    visibleMessageIdsAfterCollapse: ["1","8","9","12"],
+  });
 
   info("Test a message in a 1 level deep group");
-  node = await waitFor(() => findMessage(hud, "log-1"), undefined, 200);
+  node = findMessage(hud, "log-1");
   testClass(node, "log");
   testIndent(node, 1);
 
   info("Test a group in a 1 level deep group");
-  node = await waitFor(() => findMessage(hud, "group-2"));
+  node = findMessage(hud, "group-2");
   testClass(node, "startGroup");
   testIndent(node, 1);
+  testGroupToggle({
+    node,
+    store,
+    shouldBeOpen: true,
+    visibleMessageIdsAfterExpand: ["1","2","3","4","6","8","9","12"],
+    visibleMessageIdsAfterCollapse: ["1","2","3","6","8","9","12"],
+  });
 
   info("Test a message in a 2 level deep group");
-  node = await waitFor(() => findMessage(hud, "log-2"));
+  node = findMessage(hud, "log-2");
   testClass(node, "log");
   testIndent(node, 2);
 
   info("Test a message in a 1 level deep group, after closing a 2 level deep group");
-  node = await waitFor(() => findMessage(hud, "log-3"));
+  node = findMessage(hud, "log-3");
   testClass(node, "log");
   testIndent(node, 1);
 
   info("Test a message at root level, after closing all the groups");
-  node = await waitFor(() => findMessage(hud, "log-4"));
+  node = findMessage(hud, "log-4");
   testClass(node, "log");
   testIndent(node, 0);
 
   info("Test a collapsed group at root level");
-  node = await waitFor(() => findMessage(hud, "group-3"));
+  node = findMessage(hud, "group-3");
   testClass(node, "startGroupCollapsed");
   testIndent(node, 0);
+  testGroupToggle({
+    node,
+    store,
+    shouldBeOpen: false,
+    visibleMessageIdsAfterExpand: ["1","2","3","4","6","8","9","10","12"],
+    visibleMessageIdsAfterCollapse: ["1","2","3","4","6","8","9","12"]
+  });
+
   info("Test a message at root level, after closing a collapsed group");
-  node = await waitFor(() => findMessage(hud, "log-6"));
+  node = findMessage(hud, "log-6");
   testClass(node, "log");
   testIndent(node, 0);
   let nodes = hud.ui.outputNode.querySelectorAll(".message");
   is(nodes.length, 8, "expected number of messages are displayed");
 });
 
 function testClass(node, className) {
   ok(node.classList.contains(className), `message has the expected "${className}" class`);
 }
 
 function testIndent(node, indent) {
   indent = `${indent * INDENT_WIDTH}px`;
   is(node.querySelector(".indent").style.width, indent,
     "message has the expected level of indentation");
 }
+
+function testGroupToggle({ node, store, shouldBeOpen,
+  visibleMessageIdsAfterExpand, visibleMessageIdsAfterCollapse }) {
+  let toggleArrow = node.querySelector(".theme-twisty");
+  const isOpen = node => node.classList.contains("open");
+  const assertVisibleMessageIds = (expanded) => {
+    let visibleMessageIds = store.getState().messages.visibleMessages;
+    expanded ? is(visibleMessageIds.toString(), visibleMessageIdsAfterExpand.toString()) :
+      is(visibleMessageIds.toString(), visibleMessageIdsAfterCollapse.toString());
+  }
+
+  is(isOpen(node), shouldBeOpen);
+  assertVisibleMessageIds(shouldBeOpen);
+
+  toggleArrow.click();
+  shouldBeOpen = !shouldBeOpen;
+  is(isOpen(node), shouldBeOpen);
+  assertVisibleMessageIds(shouldBeOpen);
+
+  toggleArrow.click();
+  shouldBeOpen = !shouldBeOpen;
+  is(isOpen(node), shouldBeOpen);
+  assertVisibleMessageIds(shouldBeOpen);
+}
\ No newline at end of file