Fix detection of retractions for items with DOI in Extra
Affected items should be detected on the next retraction updates check
This commit is contained in:
parent
6bbb7ddc09
commit
7422c50076
2 changed files with 53 additions and 9 deletions
|
@ -48,7 +48,30 @@ describe("Retractions", function() {
|
|||
Object.assign(o, options);
|
||||
var item = createUnsavedDataObject('item', o);
|
||||
item.setField('DOI', retractedDOI);
|
||||
if (Zotero.DB.inTransaction) {
|
||||
if (Zotero.DB.inTransaction()) {
|
||||
await item.save();
|
||||
}
|
||||
else {
|
||||
await item.saveTx();
|
||||
}
|
||||
|
||||
while (!checkQueueItemsStub.called) {
|
||||
await Zotero.Promise.delay(50);
|
||||
}
|
||||
await checkQueueItemsStub.returnValues[0];
|
||||
checkQueueItemsStub.resetHistory();
|
||||
|
||||
return item;
|
||||
}
|
||||
|
||||
async function createRetractedItemWithExtraDOI(options = {}) {
|
||||
var o = {
|
||||
itemType: 'journalArticle'
|
||||
};
|
||||
Object.assign(o, options);
|
||||
var item = createUnsavedDataObject('item', o);
|
||||
item.setField('extra', 'DOI: ' + retractedDOI);
|
||||
if (Zotero.DB.inTransaction()) {
|
||||
await item.save();
|
||||
}
|
||||
else {
|
||||
|
@ -219,6 +242,18 @@ describe("Retractions", function() {
|
|||
|
||||
spy.restore();
|
||||
});
|
||||
|
||||
|
||||
it("should identify object with retracted DOI in Extra", async function () {
|
||||
var json = [
|
||||
{
|
||||
extra: `DOI: ${retractedDOI}`
|
||||
}
|
||||
];
|
||||
|
||||
var indexes = await Zotero.Retractions.getRetractionsFromJSON(json);
|
||||
assert.sameMembers(indexes, [0]);
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
|
@ -232,6 +267,15 @@ describe("Retractions", function() {
|
|||
assert.isTrue(bannerShown());
|
||||
});
|
||||
|
||||
it("should show banner when retracted item with DOI in Extra is added", async function () {
|
||||
var banner = win.document.getElementById('retracted-items-container');
|
||||
assert.isFalse(bannerShown());
|
||||
|
||||
await createRetractedItemWithExtraDOI();
|
||||
|
||||
assert.isTrue(bannerShown());
|
||||
});
|
||||
|
||||
it("shouldn't show banner when item in trash is added", async function () {
|
||||
var item = await createRetractedItem({ deleted: true });
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue