Update recognizePDF tests
- Add test for recogning within a collection (follow-up from #1015) - Update/remove some outdated code These tests are still skipped by default, since we don't want to actually do lookups on every test run.
This commit is contained in:
parent
3ef3d943b0
commit
e573ad886f
|
@ -1,42 +1,54 @@
|
||||||
describe.skip("PDF Recognition", function() {
|
describe.skip("PDF Recognition", function() {
|
||||||
Components.utils.import("resource://gre/modules/FileUtils.jsm");
|
|
||||||
|
|
||||||
var win;
|
var win;
|
||||||
before(function() {
|
|
||||||
|
before(function* () {
|
||||||
this.timeout(60000);
|
this.timeout(60000);
|
||||||
// Load Zotero pane, install PDF tools, and load the
|
// Load Zotero pane and install PDF tools
|
||||||
// translators
|
yield Zotero.Promise.all([
|
||||||
return Zotero.Promise.all([loadZoteroPane().then(function(w) {
|
loadZoteroPane().then(w => win = w),
|
||||||
win = w;
|
installPDFTools(),
|
||||||
}), installPDFTools()]);
|
]);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
beforeEach(function* () {
|
||||||
|
yield selectLibrary(win);
|
||||||
|
});
|
||||||
|
|
||||||
afterEach(function() {
|
afterEach(function() {
|
||||||
for(let win of getWindows("chrome://zotero/content/pdfProgress.xul")) {
|
for(let win of getWindows("chrome://zotero/content/pdfProgress.xul")) {
|
||||||
win.close();
|
win.close();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
after(function() {
|
after(function() {
|
||||||
win.close();
|
win.close();
|
||||||
});
|
});
|
||||||
|
|
||||||
it("should recognize a PDF with a DOI", function* () {
|
it("should recognize a PDF with a DOI within a collection", function* () {
|
||||||
this.timeout(30000);
|
this.timeout(30000);
|
||||||
// Import the PDF
|
// Import the PDF
|
||||||
var testdir = getTestDataDirectory();
|
var testdir = getTestDataDirectory();
|
||||||
testdir.append("recognizePDF_test_DOI.pdf");
|
testdir.append("recognizePDF_test_DOI.pdf");
|
||||||
var item = yield Zotero.Attachments.importFromFile({
|
|
||||||
file: testdir
|
var col = yield createDataObject('collection');
|
||||||
|
yield waitForItemsLoad(win);
|
||||||
|
|
||||||
|
var attachment = yield Zotero.Attachments.importFromFile({
|
||||||
|
file: testdir,
|
||||||
|
collections: [col.id]
|
||||||
});
|
});
|
||||||
|
|
||||||
// Recognize the PDF
|
// Recognize the PDF
|
||||||
win.ZoteroPane.selectItem(item.id);
|
|
||||||
win.Zotero_RecognizePDF.recognizeSelected();
|
win.Zotero_RecognizePDF.recognizeSelected();
|
||||||
|
|
||||||
return waitForItemEvent("add").then(function(ids) {
|
var ids = yield waitForItemEvent("add");
|
||||||
var item = Zotero.Items.get(ids[0]);
|
yield waitForNotifierEvent('add', 'collection-item')
|
||||||
assert.equal(item.getField("title"), "Shaping the Research Agenda");
|
|
||||||
assert.equal(item.getField("libraryCatalog"), "CrossRef");
|
var item = Zotero.Items.get(ids[0]);
|
||||||
});
|
assert.equal(item.getField("title"), "Shaping the Research Agenda");
|
||||||
|
assert.equal(item.getField("libraryCatalog"), "CrossRef");
|
||||||
|
assert.equal(attachment.parentID, item.id);
|
||||||
|
assert.isTrue(col.hasItem(item.id));
|
||||||
});
|
});
|
||||||
|
|
||||||
it("should recognize a PDF without a DOI", function* () {
|
it("should recognize a PDF without a DOI", function* () {
|
||||||
|
@ -49,15 +61,13 @@ describe.skip("PDF Recognition", function() {
|
||||||
var item = yield Zotero.Attachments.importFromFile({
|
var item = yield Zotero.Attachments.importFromFile({
|
||||||
file: testdir
|
file: testdir
|
||||||
});
|
});
|
||||||
|
|
||||||
// Recognize the PDF
|
// Recognize the PDF
|
||||||
win.ZoteroPane.selectItem(item.id);
|
|
||||||
win.Zotero_RecognizePDF.recognizeSelected();
|
win.Zotero_RecognizePDF.recognizeSelected();
|
||||||
|
|
||||||
return waitForItemEvent("add").then(function(ids) {
|
var ids = yield waitForItemEvent("add");
|
||||||
var item = Zotero.Items.get(ids[0]);
|
var item = Zotero.Items.get(ids[0]);
|
||||||
assert.equal(item.getField("title"), "Scaling study of an improved fermion action on quenched lattices");
|
assert.equal(item.getField("title"), "Scaling study of an improved fermion action on quenched lattices");
|
||||||
assert.equal(item.getField("libraryCatalog"), "Google Scholar");
|
assert.equal(item.getField("libraryCatalog"), "Google Scholar");
|
||||||
});
|
|
||||||
});
|
});
|
||||||
});
|
});
|
Loading…
Reference in New Issue
Block a user