diff --git a/chrome/content/zotero/collectionTree.jsx b/chrome/content/zotero/collectionTree.jsx index 156c7c4197..b46b65cf98 100644 --- a/chrome/content/zotero/collectionTree.jsx +++ b/chrome/content/zotero/collectionTree.jsx @@ -1615,7 +1615,7 @@ var CollectionTree = class CollectionTree extends LibraryTree { return false; } - let newAttachment = Zotero.Attachments.copyAttachmentToLibrary(item, targetLibraryID); + let newAttachment = await Zotero.Attachments.copyAttachmentToLibrary(item, targetLibraryID); if (options.annotations) { await Zotero.Items.copyChildItems(item, newAttachment); } diff --git a/test/tests/collectionTreeTest.js b/test/tests/collectionTreeTest.js index ab3be2bfa3..c49f6d72cb 100644 --- a/test/tests/collectionTreeTest.js +++ b/test/tests/collectionTreeTest.js @@ -891,6 +891,24 @@ describe("Zotero.CollectionTree", function() { return group.eraseTx(); }); + it("should copy a standalone attachment to a group", async function () { + await Zotero.Users.setCurrentUserID(1); + await Zotero.Users.setName(1, 'Name 1'); + await Zotero.Users.setName(12345, 'Name 2'); + + var group = await createGroup(); + + var item = await importPDFAttachment(); + + var ids = (await onDrop('item', 'L' + group.libraryID, [item.id])).ids; + var newItem = Zotero.Items.get(ids[0]); + + assert.equal(newItem.libraryID, group.libraryID); + assert.isTrue(newItem.isPDFAttachment()); + + return group.eraseTx(); + }); + it("should not copy an item or its attachment to a group twice", function* () { var group = yield getGroup();