From 2d396141439c6bdef3961179ebe09b7342a0f46a Mon Sep 17 00:00:00 2001 From: Dan Stillman Date: Mon, 18 Jul 2016 17:15:48 -0400 Subject: [PATCH] Fix subcollections being shown at top level of groups Fixes #1065 --- .../zotero/xpcom/collectionTreeView.js | 2 +- test/tests/collectionTreeViewTest.js | 20 +++++++++++++++++++ 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/chrome/content/zotero/xpcom/collectionTreeView.js b/chrome/content/zotero/xpcom/collectionTreeView.js index c2b2c89d5b..d100d027d3 100644 --- a/chrome/content/zotero/xpcom/collectionTreeView.js +++ b/chrome/content/zotero/xpcom/collectionTreeView.js @@ -1220,7 +1220,7 @@ Zotero.CollectionTreeView.prototype._expandRow = Zotero.Promise.coroutine(functi } if (isLibrary) { - var collections = Zotero.Collections.getByLibrary(libraryID, treeRow.ref.id); + var collections = Zotero.Collections.getByLibrary(libraryID); } else if (isCollection) { var collections = Zotero.Collections.getByParent(treeRow.ref.id); diff --git a/test/tests/collectionTreeViewTest.js b/test/tests/collectionTreeViewTest.js index c1ee3fba53..745c938265 100644 --- a/test/tests/collectionTreeViewTest.js +++ b/test/tests/collectionTreeViewTest.js @@ -139,6 +139,26 @@ describe("Zotero.CollectionTreeView", function() { assert.ok(cv.getRowIndexByID(col2.treeViewID)) assert.ok(cv.getRowIndexByID(col3.treeViewID)) }); + + it("should open a group and show top-level collections", function* () { + var group = yield createGroup(); + var libraryID = group.libraryID; + var col1 = yield createDataObject('collection', { libraryID }); + var col2 = yield createDataObject('collection', { libraryID }); + var col3 = yield createDataObject('collection', { libraryID }); + var col4 = yield createDataObject('collection', { libraryID, parentID: col1.id }); + var col5 = yield createDataObject('collection', { libraryID, parentID: col4.id }); + + // Close everything + [col4, col1, group].forEach(o => cv._closeContainer(cv.getRowIndexByID(o.treeViewID))); + + yield cv.expandLibrary(libraryID); + assert.isNumber(cv.getRowIndexByID(col1.treeViewID)); + assert.isNumber(cv.getRowIndexByID(col2.treeViewID)); + assert.isNumber(cv.getRowIndexByID(col3.treeViewID)); + assert.isFalse(cv.getRowIndexByID(col4.treeViewID)); + assert.isFalse(cv.getRowIndexByID(col5.treeViewID)); + }); }); describe("#expandToCollection()", function () {