Fix "Add Item by Identifier" (broken by 78b1d2ee3
)
And make lookup tests run when not on Travis, though we should still mock the HTTP requests.
This commit is contained in:
parent
69430d74b2
commit
7fc352b9b7
|
@ -202,6 +202,7 @@ Zotero.Translate.Sandbox = {
|
||||||
// TODO: This used to only be used for some modes. Since it's now used for everything with
|
// TODO: This used to only be used for some modes. Since it's now used for everything with
|
||||||
// async saving, there's probably a bunch of code for the non-queued mode that can be removed.
|
// async saving, there's probably a bunch of code for the non-queued mode that can be removed.
|
||||||
translate.saveQueue.push(item);
|
translate.saveQueue.push(item);
|
||||||
|
translate._savingItems++;
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1539,13 +1540,13 @@ Zotero.Translate.Base.prototype = {
|
||||||
* Saves items to the database, taking care to defer attachmentProgress notifications
|
* Saves items to the database, taking care to defer attachmentProgress notifications
|
||||||
* until after save
|
* until after save
|
||||||
*/
|
*/
|
||||||
_saveItems: function (items) {
|
_saveItems: Zotero.Promise.coroutine(function* (items) {
|
||||||
var itemDoneEventsDispatched = false;
|
var itemDoneEventsDispatched = false;
|
||||||
var deferredProgress = [];
|
var deferredProgress = [];
|
||||||
var attachmentsWithProgress = [];
|
var attachmentsWithProgress = [];
|
||||||
|
|
||||||
this._savingItems++;
|
try {
|
||||||
return this._itemSaver.saveItems(
|
var newItems = yield this._itemSaver.saveItems(
|
||||||
items.slice(),
|
items.slice(),
|
||||||
function (attachment, progress, error) {
|
function (attachment, progress, error) {
|
||||||
var attachmentIndex = this._savingAttachments.indexOf(attachment);
|
var attachmentIndex = this._savingAttachments.indexOf(attachment);
|
||||||
|
@ -1569,7 +1570,15 @@ Zotero.Translate.Base.prototype = {
|
||||||
}
|
}
|
||||||
}.bind(this)
|
}.bind(this)
|
||||||
)
|
)
|
||||||
.then(function (newItems) {
|
}
|
||||||
|
catch (e) {
|
||||||
|
this._savingItems -= items.length;
|
||||||
|
Zotero.debug("REDUCING SAVING ITEMS ERROR TO " + this._savingItems);
|
||||||
|
Zotero.logError(e);
|
||||||
|
this.complete(false, e);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
// Remove attachments not being saved from item.attachments
|
// Remove attachments not being saved from item.attachments
|
||||||
for(var i=0; i<items.length; i++) {
|
for(var i=0; i<items.length; i++) {
|
||||||
var item = items[i];
|
var item = items[i];
|
||||||
|
@ -1595,15 +1604,10 @@ Zotero.Translate.Base.prototype = {
|
||||||
deferredProgress[i][1], deferredProgress[i][2]);
|
deferredProgress[i][1], deferredProgress[i][2]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
this._savingItems -= items.length;
|
||||||
this.newItems = this.newItems.concat(newItems);
|
this.newItems = this.newItems.concat(newItems);
|
||||||
this._savingItems--;
|
|
||||||
this._checkIfDone();
|
this._checkIfDone();
|
||||||
}.bind(this))
|
}),
|
||||||
.catch(function (e) {
|
|
||||||
Zotero.logError(e);
|
|
||||||
this.complete(false, e);
|
|
||||||
}.bind(this));
|
|
||||||
},
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Checks if saving done, and if so, fires done event
|
* Checks if saving done, and if so, fires done event
|
||||||
|
|
|
@ -1,19 +1,26 @@
|
||||||
function lookupIdentifier(win, identifier) {
|
var lookupIdentifier = Zotero.Promise.coroutine(function* (win, identifier) {
|
||||||
var textbox = win.document.getElementById("zotero-lookup-textbox");
|
var textbox = win.document.getElementById("zotero-lookup-textbox");
|
||||||
textbox.value = identifier;
|
textbox.value = identifier;
|
||||||
win.Zotero_Lookup.accept(textbox);
|
var promise = waitForItemEvent("add");
|
||||||
return waitForItemEvent("add");
|
yield win.Zotero_Lookup.accept(textbox);
|
||||||
}
|
return promise;
|
||||||
|
});
|
||||||
|
|
||||||
describe.skip("Add Item by Identifier", function() {
|
describe("Add Item by Identifier", function() {
|
||||||
var win;
|
var win;
|
||||||
|
|
||||||
before(function* () {
|
before(function* () {
|
||||||
|
if (Zotero.automatedTest) {
|
||||||
|
this.skip();
|
||||||
|
return;
|
||||||
|
}
|
||||||
win = yield loadZoteroPane();
|
win = yield loadZoteroPane();
|
||||||
});
|
});
|
||||||
|
|
||||||
after(function() {
|
after(function() {
|
||||||
|
if (win) {
|
||||||
win.close();
|
win.close();
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
// TODO: mock external services: https://github.com/zotero/zotero/issues/699
|
// TODO: mock external services: https://github.com/zotero/zotero/issues/699
|
||||||
|
|
Loading…
Reference in New Issue
Block a user