commit 1adb8d74f014623aa37bc5bdb51f926ed173577f
parent a3a9cb9c1ebe92216a2e380b1b4e1c07d2848a34
Author: Dan Stillman <dstillman@zotero.org>
Date: Fri, 23 Sep 2016 21:02:36 -0400
Properly save search when using "New Saved Search…" menu option
Diffstat:
2 files changed, 33 insertions(+), 0 deletions(-)
diff --git a/chrome/content/zotero/zoteroPane.js b/chrome/content/zotero/zoteroPane.js
@@ -946,6 +946,12 @@ var ZoteroPane = new function()
Zotero.getString('pane.collections.untitled'));
var io = {dataIn: {search: s, name: untitled}, dataOut: null};
window.openDialog('chrome://zotero/content/searchDialog.xul','','chrome,modal',io);
+ if (!io.dataOut) {
+ return false;
+ }
+ s.fromJSON(io.dataOut.json);
+ yield s.saveTx();
+ return s.id;
});
diff --git a/test/tests/zoteroPaneTest.js b/test/tests/zoteroPaneTest.js
@@ -67,6 +67,33 @@ describe("ZoteroPane", function() {
});
});
+ describe("#newSearch()", function () {
+ it("should create a saved search", function* () {
+ var promise = waitForDialog(
+ // TODO: Test changing a condition
+ function (dialog) {},
+ 'accept',
+ 'chrome://zotero/content/searchDialog.xul'
+ );
+ var id = yield zp.newSearch();
+ yield promise;
+ var search = Zotero.Searches.get(id);
+ assert.ok(search);
+ assert.isTrue(search.name.startsWith(Zotero.getString('pane.collections.untitled')));
+ });
+
+ it("should handle clicking Cancel in the search window", function* () {
+ var promise = waitForDialog(
+ function (dialog) {},
+ 'cancel',
+ 'chrome://zotero/content/searchDialog.xul'
+ );
+ var id = yield zp.newSearch();
+ yield promise;
+ assert.isFalse(id);
+ });
+ });
+
describe("#itemSelected()", function () {
it.skip("should update the item count", function* () {
var collection = new Zotero.Collection;