commit 3cc92fe1e9c7ed8acdac3d4b824e0eccb5da21ab
parent f99038fd37a2baf14c474e282fe0015ad324f0b0
Author: Dan Stillman <dstillman@zotero.org>
Date: Wed, 28 Feb 2018 17:34:06 -0500
Fix PDF recognition within collection (broken by f8b41c971c)
Diffstat:
2 files changed, 31 insertions(+), 2 deletions(-)
diff --git a/chrome/content/zotero/xpcom/recognizePDF.js b/chrome/content/zotero/xpcom/recognizePDF.js
@@ -256,8 +256,8 @@ Zotero.RecognizePDF = new function () {
let collections = attachment.getCollections();
await Zotero.DB.executeTransaction(async function () {
if (collections.length) {
- for (let collection of collections) {
- parentItem.addToCollection(collection.id);
+ for (let collectionID of collections) {
+ parentItem.addToCollection(collectionID);
}
await parentItem.save();
}
diff --git a/test/tests/recognizePDFTest.js b/test/tests/recognizePDFTest.js
@@ -60,4 +60,33 @@ describe("PDF Recognition", function() {
Zotero.Attachments.getFileBaseNameFromItem(item) + '.pdf'
);
});
+
+ it("should put new item in same collection", async function () {
+ this.timeout(30000);
+ // Import the PDF
+ var testdir = getTestDataDirectory();
+ testdir.append("recognizePDF_test_GS.pdf");
+ var collection = await createDataObject('collection');
+ var attachment = await Zotero.Attachments.importFromFile({
+ file: testdir,
+ collections: [collection.id]
+ });
+
+ win.ZoteroPane.recognizeSelected();
+
+ var addedIDs = await waitForItemEvent("add");
+ var modifiedIDs = await waitForItemEvent("modify");
+ assert.lengthOf(addedIDs, 1);
+ var item = Zotero.Items.get(addedIDs[0]);
+ assert.lengthOf(modifiedIDs, 2);
+
+ // Wait for status to show as complete
+ var progressWindow = getWindows("chrome://zotero/content/recognizePDFDialog.xul")[0];
+ var completeStr = Zotero.getString("recognizePDF.complete.label");
+ while (progressWindow.document.getElementById("label").value != completeStr) {
+ await Zotero.Promise.delay(20);
+ }
+
+ assert.isTrue(collection.hasItem(item.id));
+ });
});
\ No newline at end of file