Add a test for PDF recognition by DOI (#1496)
This commit is contained in:
parent
8f39e9cb36
commit
c0a4fa43f0
2 changed files with 34 additions and 1 deletions
BIN
test/tests/data/recognizePDF_test_DOI.pdf
Normal file
BIN
test/tests/data/recognizePDF_test_DOI.pdf
Normal file
Binary file not shown.
|
@ -28,7 +28,40 @@ describe("PDF Recognition", function() {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
it.skip("should recognize a PDF by DOI");
|
it("should recognize a PDF by DOI", async function () {
|
||||||
|
this.timeout(30000);
|
||||||
|
// Import the PDF
|
||||||
|
var testdir = getTestDataDirectory();
|
||||||
|
testdir.append("recognizePDF_test_DOI.pdf");
|
||||||
|
var collection = await createDataObject('collection');
|
||||||
|
var attachment = await Zotero.Attachments.importFromFile({
|
||||||
|
file: testdir,
|
||||||
|
collections: [collection.id]
|
||||||
|
});
|
||||||
|
|
||||||
|
win.ZoteroPane.recognizeSelected();
|
||||||
|
|
||||||
|
var addedIDs = await waitForItemEvent("add");
|
||||||
|
var modifiedIDs = await waitForItemEvent("modify");
|
||||||
|
assert.lengthOf(addedIDs, 1);
|
||||||
|
var item = Zotero.Items.get(addedIDs[0]);
|
||||||
|
assert.equal(item.getField("title"), "Shaping the Research Agenda");
|
||||||
|
assert.equal(item.getField("libraryCatalog"), "Crossref");
|
||||||
|
assert.lengthOf(modifiedIDs, 2);
|
||||||
|
|
||||||
|
// Wait for status to show as complete
|
||||||
|
var progressWindow = getWindows("chrome://zotero/content/recognizePDFDialog.xul")[0];
|
||||||
|
var completeStr = Zotero.getString("recognizePDF.complete.label");
|
||||||
|
while (progressWindow.document.getElementById("label").value != completeStr) {
|
||||||
|
await Zotero.Promise.delay(20);
|
||||||
|
}
|
||||||
|
|
||||||
|
// The file should have been renamed
|
||||||
|
assert.equal(
|
||||||
|
attachment.attachmentFilename,
|
||||||
|
Zotero.Attachments.getFileBaseNameFromItem(item) + '.pdf'
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
it("should recognize a PDF by arXiv ID", async function () {
|
it("should recognize a PDF by arXiv ID", async function () {
|
||||||
this.timeout(30000);
|
this.timeout(30000);
|
||||||
|
|
Loading…
Add table
Reference in a new issue