Add retracted citation warning tests. Fix a bug with embedded prompts
This commit is contained in:
parent
82e7f67df8
commit
cd14a536dc
2 changed files with 60 additions and 4 deletions
|
@ -1968,14 +1968,14 @@ Zotero.Integration.Session.prototype.handleRetractedItems = async function () {
|
||||||
if (zoteroItem.cslItemID) {
|
if (zoteroItem.cslItemID) {
|
||||||
embeddedZoteroItems.push(zoteroItem);
|
embeddedZoteroItems.push(zoteroItem);
|
||||||
}
|
}
|
||||||
else if (Zotero.Retractions.isRetracted(zoteroItem)) {
|
else if (Zotero.Retractions.shouldShowCitationWarning(zoteroItem)) {
|
||||||
dealWithRetracted(zoteroItem, true);
|
dealWithRetracted(zoteroItem, true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
var retractedIndices = await Promise.race(Zotero.Retractions.getRetractionsFromJSON(
|
var retractedIndices = await Promise.race([Zotero.Retractions.getRetractionsFromJSON(
|
||||||
embeddedZoteroItems.map(item => item.toJSON())
|
embeddedZoteroItems.map(item => item.toJSON())
|
||||||
), Zotero.Promise.delay(1000).then(() => []));
|
), Zotero.Promise.delay(1000).then(() => [])]);
|
||||||
for (let index of retractedIndices) {
|
for (let index of retractedIndices) {
|
||||||
dealWithRetracted(embeddedZoteroItems[index]);
|
dealWithRetracted(embeddedZoteroItems[index]);
|
||||||
}
|
}
|
||||||
|
|
|
@ -309,7 +309,7 @@ describe("Zotero.Integration", function () {
|
||||||
testItems = [];
|
testItems = [];
|
||||||
for (let i = 0; i < 5; i++) {
|
for (let i = 0; i < 5; i++) {
|
||||||
let testItem = yield createDataObject('item', {libraryID: Zotero.Libraries.userLibraryID});
|
let testItem = yield createDataObject('item', {libraryID: Zotero.Libraries.userLibraryID});
|
||||||
testItem.setField('title', `title${1}`);
|
testItem.setField('title', `title${i}`);
|
||||||
testItem.setCreator(0, {creatorType: 'author', name: `Author No${i}`});
|
testItem.setCreator(0, {creatorType: 'author', name: `Author No${i}`});
|
||||||
testItems.push(testItem);
|
testItems.push(testItem);
|
||||||
}
|
}
|
||||||
|
@ -815,6 +815,62 @@ describe("Zotero.Integration", function () {
|
||||||
setCodeSpy.restore();
|
setCodeSpy.restore();
|
||||||
})
|
})
|
||||||
});
|
});
|
||||||
|
|
||||||
|
describe('with retracted items', function () {
|
||||||
|
it('should display a retraction warning for a retracted item in a document', async function () {
|
||||||
|
var docID = this.test.fullTitle();
|
||||||
|
await initDoc(docID);
|
||||||
|
var doc = applications[docID].doc;
|
||||||
|
setAddEditItems(testItems[0]);
|
||||||
|
await execCommand('addEditCitation', docID);
|
||||||
|
|
||||||
|
let stub1 = sinon.stub(Zotero.Retractions, 'isRetracted').returns(true);
|
||||||
|
let stub2 = sinon.stub(Zotero.Retractions, 'shouldShowCitationWarning').returns(true);
|
||||||
|
|
||||||
|
let promise = execCommand('refresh', docID);
|
||||||
|
await assert.isFulfilled(waitForDialog());
|
||||||
|
|
||||||
|
stub1.restore();
|
||||||
|
stub2.restore();
|
||||||
|
await promise;
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should display a retraction warning for an embedded retracted item in a document', async function () {
|
||||||
|
var docID = this.test.fullTitle();
|
||||||
|
await initDoc(docID);
|
||||||
|
var doc = applications[docID].doc;
|
||||||
|
let testItem = await createDataObject('item', { libraryID: Zotero.Libraries.userLibraryID });
|
||||||
|
testItem.setField('title', `embedded title`);
|
||||||
|
testItem.setCreator(0, { creatorType: 'author', name: `Embedded Author` });
|
||||||
|
setAddEditItems(testItem);
|
||||||
|
await execCommand('addEditCitation', docID);
|
||||||
|
await testItem.eraseTx();
|
||||||
|
|
||||||
|
let stub = sinon.stub(Zotero.Retractions, 'getRetractionsFromJSON').resolves([0]);
|
||||||
|
|
||||||
|
let promise = execCommand('refresh', docID);
|
||||||
|
await assert.isFulfilled(waitForDialog());
|
||||||
|
|
||||||
|
stub.restore();
|
||||||
|
await promise;
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should not display retraction warning when disabled for a retracted item', async function () {
|
||||||
|
var docID = this.test.fullTitle();
|
||||||
|
await initDoc(docID);
|
||||||
|
var doc = applications[docID].doc;
|
||||||
|
let testItem = await createDataObject('item', { libraryID: Zotero.Libraries.userLibraryID });
|
||||||
|
testItem.setField('title', `title`);
|
||||||
|
testItem.setCreator(0, { creatorType: 'author', name: `Author` });
|
||||||
|
await Zotero.Retractions.disableCitationWarningsForItem(testItem);
|
||||||
|
setAddEditItems(testItem);
|
||||||
|
await execCommand('addEditCitation', docID);
|
||||||
|
|
||||||
|
await assert.isFulfilled(execCommand('refresh', docID));
|
||||||
|
|
||||||
|
await testItem.eraseTx();
|
||||||
|
});
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('#addEditBibliography', function() {
|
describe('#addEditBibliography', function() {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue