Bug 1517349 - [release 115] [search] Auto fold files with large number of results (#7567). r=dwalsh
authorJason Laster <jlaster@mozilla.com>
Wed, 02 Jan 2019 16:57:44 -0500
changeset 509430 76d34e0c8a867a4d3277055e29efe92063c5ecd1
parent 509429 3e068f08ef6ba957d9100eee5c14207c8d68b3c7
child 509431 70c4fd323f9c5b46c544c17b832718c4d0cd98e5
push id10547
push userffxbld-merge
push dateMon, 21 Jan 2019 13:03:58 +0000
treeherdermozilla-beta@24ec1916bffe [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersdwalsh
bugs1517349
milestone66.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 1517349 - [release 115] [search] Auto fold files with large number of results (#7567). r=dwalsh
devtools/client/debugger/new/src/components/ProjectSearch.js
devtools/client/debugger/new/test/mochitest/browser_dbg-search-project.js
devtools/client/debugger/new/test/mochitest/helpers.js
--- a/devtools/client/debugger/new/src/components/ProjectSearch.js
+++ b/devtools/client/debugger/new/src/components/ProjectSearch.js
@@ -267,16 +267,17 @@ export class ProjectSearch extends Compo
     if (results.length) {
       return (
         <ManagedTree
           getRoots={() => results}
           getChildren={file => file.matches || []}
           itemHeight={24}
           autoExpandAll={true}
           autoExpandDepth={1}
+          autoExpandNodeChildrenLimit={100}
           getParent={item => null}
           getPath={getFilePath}
           renderItem={this.renderItem}
         />
       );
     }
     const msg =
       status === statusType.fetching
--- a/devtools/client/debugger/new/test/mochitest/browser_dbg-search-project.js
+++ b/devtools/client/debugger/new/test/mochitest/browser_dbg-search-project.js
@@ -1,10 +1,11 @@
-/* Any copyright is dedicated to the Public Domain.
- * http://creativecommons.org/publicdomain/zero/1.0/ */
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at <http://mozilla.org/MPL/2.0/>. */
 
 function openProjectSearch(dbg) {
   synthesizeKeyShortcut("CmdOrCtrl+Shift+F");
   return waitForState(
     dbg,
     state => dbg.selectors.getActiveSearch(state) === "project"
   );
 }
@@ -18,41 +19,60 @@ async function selectResult(dbg) {
   const select = waitForState(
     dbg,
     () => !dbg.selectors.getActiveSearch(dbg.getState())
   );
   await clickElement(dbg, "fileMatch");
   return select;
 }
 
-function getResultsCount(dbg) {
+function getExpandedResultsCount(dbg) {
+  return findAllElements(dbg, "projectSerchExpandedResults").length;
+}
+
+function getResultsFiles(dbg) {
   const matches = dbg.selectors
     .getTextSearchResults(dbg.getState())
     .map(file => file.matches);
 
   return [...matches].length;
 }
 
 // Testing project search
 add_task(async function() {
-  await pushPref("devtools.debugger.project-text-search-enabled", true);
-
   const dbg = await initDebugger("doc-script-switching.html", "switching-01");
 
   await selectSource(dbg, "switching-01");
 
   // test opening and closing
   await openProjectSearch(dbg);
   await closeProjectSearch(dbg);
 
   await openProjectSearch(dbg);
   type(dbg, "first");
   pressKey(dbg, "Enter");
 
-  await waitForState(dbg, () => getResultsCount(dbg) === 1);
+  await waitForState(dbg, () => getResultsFiles(dbg) === 1);
 
   await selectResult(dbg);
 
   is(dbg.selectors.getActiveSearch(dbg.getState()), null);
 
   const selectedSource = dbg.selectors.getSelectedSource(dbg.getState());
   ok(selectedSource.url.includes("switching-01"));
 });
+
+add_task(async function() {
+  const dbg = await initDebugger("doc-react.html", "App.js");
+  await openProjectSearch(dbg);
+  type(dbg, "we");
+  pressKey(dbg, "Enter");
+  await waitForState(dbg, state => state.projectTextSearch.status === "DONE");
+
+  is(getExpandedResultsCount(dbg), 15);
+
+  const collapsedNodes = findAllElements(dbg, "projectSearchCollapsed");
+  is(collapsedNodes.length, 1);
+
+  collapsedNodes[0].click();
+
+  is(getExpandedResultsCount(dbg), 155);
+});
--- a/devtools/client/debugger/new/test/mochitest/helpers.js
+++ b/devtools/client/debugger/new/test/mochitest/helpers.js
@@ -1132,17 +1132,19 @@ const selectors = {
   popup: ".popover",
   tooltip: ".tooltip",
   previewPopup: ".preview-popup",
   outlineItem: i =>
     `.outline-list__element:nth-child(${i}) .function-signature`,
   outlineItems: ".outline-list__element",
   conditionalPanelInput: ".conditional-breakpoint-panel input",
   searchField: ".search-field",
-  blackbox: ".action.black-box"
+  blackbox: ".action.black-box",
+  projectSearchCollapsed: ".project-text-search .arrow:not(.expanded)",
+  projectSerchExpandedResults: ".project-text-search .result",
 };
 
 function getSelector(elementName, ...args) {
   let selector = selectors[elementName];
   if (!selector) {
     throw new Error(`The selector ${elementName} is not defined`);
   }