From 6994c63a0eb1d00f66d3d67606af53dcae1106ef Mon Sep 17 00:00:00 2001 From: Dan Stillman Date: Sat, 17 Dec 2016 08:01:25 -0500 Subject: [PATCH] Tweak recognizePDF fix, add test coverage, and enable manual tests Still disabled in Travis until we mock the remote services --- .../xpcom/translation/translate_item.js | 2 +- test/tests/recognizePDFTest.js | 19 +++++++++++++++---- 2 files changed, 16 insertions(+), 5 deletions(-) diff --git a/chrome/content/zotero/xpcom/translation/translate_item.js b/chrome/content/zotero/xpcom/translation/translate_item.js index aaf0e8291d..b3ce142f58 100644 --- a/chrome/content/zotero/xpcom/translation/translate_item.js +++ b/chrome/content/zotero/xpcom/translation/translate_item.js @@ -258,7 +258,7 @@ Zotero.Translate.ItemSaver.prototype = { newAttachment = yield this._saveAttachmentFile.apply(this, arguments); } else { Zotero.debug('Translate: Ignoring attachment due to ATTACHMENT_MODE_IGNORE'); - attachmentCallback(attachment, false, e); + attachmentCallback(attachment, false); return false; } diff --git a/test/tests/recognizePDFTest.js b/test/tests/recognizePDFTest.js index df119caf1f..3f4b48af53 100644 --- a/test/tests/recognizePDFTest.js +++ b/test/tests/recognizePDFTest.js @@ -1,4 +1,4 @@ -describe.skip("PDF Recognition", function() { +describe("PDF Recognition", function() { var win; before(function* () { @@ -52,7 +52,7 @@ describe.skip("PDF Recognition", function() { }); it("should recognize a PDF without a DOI", function* () { - if (Zotero.automatedTest) this.skip(); // CAPTCHAs make this fail + if (Zotero.automatedTest) this.skip(); // TODO: Mock this.timeout(30000); // Import the PDF @@ -65,9 +65,20 @@ describe.skip("PDF Recognition", function() { // Recognize the PDF win.Zotero_RecognizePDF.recognizeSelected(); - var ids = yield waitForItemEvent("add"); - var item = Zotero.Items.get(ids[0]); + var addedIDs = yield waitForItemEvent("add"); + var modifiedIDs = yield waitForItemEvent("modify"); + assert.lengthOf(addedIDs, 1); + var item = Zotero.Items.get(addedIDs[0]); assert.equal(item.getField("title"), "Scaling study of an improved fermion action on quenched lattices"); assert.equal(item.getField("libraryCatalog"), "Google Scholar"); + assert.lengthOf(modifiedIDs, 2); + + yield Zotero.Promise.delay(0); + + var progressWindow = getWindows("chrome://zotero/content/pdfProgress.xul")[0]; + assert.equal( + progressWindow.document.getElementById("label").value, + Zotero.getString("recognizePDF.complete.label") + ); }); }); \ No newline at end of file