diff --git a/chrome/content/zotero/xpcom/annotations.js b/chrome/content/zotero/xpcom/annotations.js index 34446bb56e..83dfd7e2c2 100644 --- a/chrome/content/zotero/xpcom/annotations.js +++ b/chrome/content/zotero/xpcom/annotations.js @@ -33,7 +33,7 @@ Zotero.Annotations = new function () { Zotero.defineProperty(this, 'ANNOTATION_TYPE_INK', { value: 4 }); Zotero.defineProperty(this, 'PROPS', { - value: ['type', 'text', 'comment', 'color', 'pageLabel', 'sortIndex', 'position'], + value: ['type', 'authorName', 'text', 'comment', 'color', 'pageLabel', 'sortIndex', 'position'], writable: false }); diff --git a/test/tests/collectionTreeTest.js b/test/tests/collectionTreeTest.js index 8d095813bd..437c85ddaa 100644 --- a/test/tests/collectionTreeTest.js +++ b/test/tests/collectionTreeTest.js @@ -873,6 +873,7 @@ describe("Zotero.CollectionTree", function() { var annotation = await createAnnotation('highlight', attachment); await Zotero.Users.setName(12345, 'Name'); annotation.createdByUserID = 12345; + await annotation.saveTx(); var ids = (await onDrop('item', 'L1', [groupItem.id])).ids; var newItem = Zotero.Items.get(ids[0]); @@ -882,11 +883,42 @@ describe("Zotero.CollectionTree", function() { // Check annotation var annotations = newAttachment.getAnnotations(); assert.lengthOf(annotations, 1); + // Name transferred by Zotero.Items.copyChildItems() assert.equal(annotations[0].annotationAuthorName, 'Name'); return group.eraseTx(); }); + it("should preserve an explicit annotation author name when copied from a group to a personal library", async function () { + var group = await createGroup(); + await cv.selectLibrary(group.libraryID); + + var groupItem = await createDataObject('item', { libraryID: group.libraryID }); + var file = getTestDataDirectory(); + file.append('test.pdf'); + var attachment = await Zotero.Attachments.importFromFile({ + file, + parentItemID: groupItem.id + }); + var annotation = await createAnnotation('highlight', attachment); + await Zotero.Users.setName(1, 'Name'); + annotation.createdByUserID = 1; + annotation.annotationAuthorName = 'Another Name'; + + var ids = (await onDrop('item', 'L1', [groupItem.id])).ids; + var newItem = Zotero.Items.get(ids[0]); + + var newAttachment = Zotero.Items.get(newItem.getAttachments())[0]; + + // Check annotation + var annotations = newAttachment.getAnnotations(); + assert.lengthOf(annotations, 1); + // Name transferred by Zotero.Items.copyChildItems() + assert.equal(annotations[0].annotationAuthorName, 'Another Name'); + + return group.eraseTx(); + }); + it("should not copy an item or its attachment to a group twice", function* () { var group = yield getGroup();