Fix PDF recognition within collection (broken by f8b41c971c
)
This commit is contained in:
parent
f99038fd37
commit
3cc92fe1e9
|
@ -256,8 +256,8 @@ Zotero.RecognizePDF = new function () {
|
||||||
let collections = attachment.getCollections();
|
let collections = attachment.getCollections();
|
||||||
await Zotero.DB.executeTransaction(async function () {
|
await Zotero.DB.executeTransaction(async function () {
|
||||||
if (collections.length) {
|
if (collections.length) {
|
||||||
for (let collection of collections) {
|
for (let collectionID of collections) {
|
||||||
parentItem.addToCollection(collection.id);
|
parentItem.addToCollection(collectionID);
|
||||||
}
|
}
|
||||||
await parentItem.save();
|
await parentItem.save();
|
||||||
}
|
}
|
||||||
|
|
|
@ -60,4 +60,33 @@ describe("PDF Recognition", function() {
|
||||||
Zotero.Attachments.getFileBaseNameFromItem(item) + '.pdf'
|
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));
|
||||||
|
});
|
||||||
});
|
});
|
Loading…
Reference in New Issue
Block a user