Properly save search when using "New Saved Search…" menu option

This commit is contained in:
Dan Stillman 2016-09-23 21:02:36 -04:00
parent a3a9cb9c1e
commit 1adb8d74f0
2 changed files with 33 additions and 0 deletions

View file

@ -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;
});

View file

@ -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;