Expand/collapse library fixes

- Fixes #994, 5.0: "+" doesn't expand all collections within a library
- If a container (library, collection) is closed directly, the open state of
  all containers below it are now restored when it's reopened. Previously all
  collections would be closed on a manual reopen (though they might have been
  restored on the next Zotero restart).
- If "-" is pressed, all containers are closed, and reopening the library will
  show only top-level collections.
This commit is contained in:
Dan Stillman 2016-05-07 04:02:42 -04:00
parent 458d110269
commit e1706e15e2
2 changed files with 111 additions and 6 deletions

View file

@ -70,6 +70,52 @@ describe("Zotero.CollectionTreeView", function() {
})
})
describe("#expandLibrary()", function () {
var libraryRow, col1, col2, col3;
before(function* () {
yield cv.selectLibrary(userLibraryID);
libraryRow = cv.selection.currentIndex;
});
beforeEach(function* () {
// My Library
// - A
// - B
// - C
col1 = yield createDataObject('collection');
col2 = yield createDataObject('collection', { parentID: col1.id });
col3 = yield createDataObject('collection', { parentID: col2.id });
});
it("should open a library and respect stored container state", function* () {
// Collapse B
yield cv.toggleOpenState(cv.getRowIndexByID(col2.collectionTreeViewID));
yield cv._rememberOpenStates();
// Close and reopen library
yield cv.toggleOpenState(libraryRow);
yield cv.expandLibrary(userLibraryID);
assert.ok(cv.getRowIndexByID(col1.collectionTreeViewID))
assert.ok(cv.getRowIndexByID(col2.collectionTreeViewID))
assert.isFalse(cv.getRowIndexByID(col3.collectionTreeViewID))
});
it("should open a library and all subcollections in recursive mode", function* () {
yield cv.toggleOpenState(cv.getRowIndexByID(col2.collectionTreeViewID));
yield cv._rememberOpenStates();
// Close and reopen library
yield cv.toggleOpenState(libraryRow);
yield cv.expandLibrary(userLibraryID, true);
assert.ok(cv.getRowIndexByID(col1.collectionTreeViewID))
assert.ok(cv.getRowIndexByID(col2.collectionTreeViewID))
assert.ok(cv.getRowIndexByID(col3.collectionTreeViewID))
});
});
describe("#expandToCollection()", function () {
it("should expand a collection to a subcollection", function* () {
var collection1 = yield createDataObject('collection');