Fix "getNote() can only be called on notes and attachments" CR error

This bug may be as old as the sync system itself. It could occur if
there were conflicts for both a note and a regular item in the same
batch.
This commit is contained in:
Dan Stillman 2019-09-02 09:22:58 -04:00
parent 3f3b6501ce
commit 54343c49fb
2 changed files with 60 additions and 5 deletions

View file

@ -102,11 +102,9 @@
}
// Check for note or attachment
if (!this.type) {
this.type = this._getTypeFromObject(
this._data.left.deleted ? this._data.right : this._data.left
);
}
this.type = this._getTypeFromObject(
this._data.left.deleted ? this._data.right : this._data.left
);
var showButton = this.type != 'item';

View file

@ -994,6 +994,63 @@ describe("Zotero.Sync.Data.Local", function() {
yield promise;
});
it("should switch types by showing regular item after note", async function () {
var note = await createDataObject('item', { itemType: 'note' });
var item = await createDataObject('item');
var promise = waitForWindow('chrome://zotero/content/merge.xul', function (dialog) {
var doc = dialog.document;
var wizard = doc.documentElement;
var mergeGroup = wizard.getElementsByTagName('zoteromergegroup')[0];
// 1 (accept remote deletion)
assert.equal(mergeGroup.leftpane.getAttribute('selected'), 'true');
mergeGroup.rightpane.click();
wizard.getButton('next').click();
// 2 (accept remote deletion)
mergeGroup.rightpane.click();
if (Zotero.isMac) {
assert.isTrue(wizard.getButton('next').hidden);
assert.isFalse(wizard.getButton('finish').hidden);
}
else {
// TODO
}
wizard.getButton('finish').click();
});
var mergeData = Zotero.Sync.Data.Local.showConflictResolutionWindow([
{
libraryID: note.libraryID,
key: note.key,
processed: false,
conflict: true,
left: note.toJSON(),
right: {
deleted: true,
dateDeleted: "2019-09-01 00:00:00"
}
},
{
libraryID: item.libraryID,
key: item.key,
processed: false,
conflict: true,
left: item.toJSON(),
right: {
deleted: true,
dateDeleted: "2019-09-01 01:00:00"
}
}
]);
await promise;
assert.isTrue(mergeData[0].data.deleted);
assert.isTrue(mergeData[1].data.deleted);
});
});