<commit_before>describe("PDF Recognition", function() {
	var win;
	
	before(function* () {
		this.timeout(60000);
		// Load Zotero pane and install PDF tools
		yield Zotero.Promise.all([
			loadZoteroPane().then(w => win = w),
			installPDFTools(),
		]);
	});
	
	beforeEach(function* () {
		yield selectLibrary(win);
	});
	
	afterEach(function() {
		for(let win of getWindows("chrome://zotero/content/pdfProgress.xul")) {
			win.close();
		}
	});
	
	after(function() {
		win.close();
	});

	it("should recognize a PDF with a DOI within a collection", function* () {
		this.timeout(30000);
		// Import the PDF
		var testdir = getTestDataDirectory();
		testdir.append("recognizePDF_test_DOI.pdf");
		
		var col = yield createDataObject('collection');
		yield waitForItemsLoad(win);
		
		var attachment = yield Zotero.Attachments.importFromFile({
			file: testdir,
			collections: [col.id]
		});

		// Recognize the PDF
		win.Zotero_RecognizePDF.recognizeSelected();

		var ids = yield waitForItemEvent("add");
		yield waitForNotifierEvent('add', 'collection-item')
		
		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* () {
		if (Zotero.automatedTest) this.skip(); // TODO: Mock
		
		this.timeout(30000);
		// Import the PDF
		var testdir = getTestDataDirectory();
		testdir.append("recognizePDF_test_GS.pdf");
		var item = yield Zotero.Attachments.importFromFile({
			file: testdir
		});
		
		// Recognize the PDF
		win.Zotero_RecognizePDF.recognizeSelected();

		var addedIDs = yield waitForItemEvent("add");
		var modifiedIDs = yield waitForItemEvent("modify");
		assert.lengthOf(addedIDs, 1);
		var item = Zotero.Items.get(addedIDs[0]);
		assert.equal(item.getField("title"), "Scaling study of an improved fermion action on quenched lattices");
		assert.equal(item.getField("libraryCatalog"), "Google Scholar");
		assert.lengthOf(modifiedIDs, 2);
		
		yield Zotero.Promise.delay(0);
		
		var progressWindow = getWindows("chrome://zotero/content/pdfProgress.xul")[0];
		assert.equal(
			progressWindow.document.getElementById("label").value,
			Zotero.getString("recognizePDF.complete.label")
		);
	});
});<commit_msg>Disable all recognizePDF tests in Travis<commit_after>describe("PDF Recognition", function() {
	var win;
	
	before(function* () {
		if (Zotero.automatedTest) this.skip(); // TODO: Mock services
		
		this.timeout(60000);
		// Load Zotero pane and install PDF tools
		yield Zotero.Promise.all([
			loadZoteroPane().then(w => win = w),
			installPDFTools(),
		]);
	});
	
	beforeEach(function* () {
		yield selectLibrary(win);
	});
	
	afterEach(function() {
		for(let win of getWindows("chrome://zotero/content/pdfProgress.xul")) {
			win.close();
		}
	});
	
	after(function() {
		win.close();
	});

	it("should recognize a PDF with a DOI within a collection", function* () {
		this.timeout(30000);
		// Import the PDF
		var testdir = getTestDataDirectory();
		testdir.append("recognizePDF_test_DOI.pdf");
		
		var col = yield createDataObject('collection');
		yield waitForItemsLoad(win);
		
		var attachment = yield Zotero.Attachments.importFromFile({
			file: testdir,
			collections: [col.id]
		});

		// Recognize the PDF
		win.Zotero_RecognizePDF.recognizeSelected();

		var ids = yield waitForItemEvent("add");
		yield waitForNotifierEvent('add', 'collection-item')
		
		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* () {
		this.timeout(30000);
		// Import the PDF
		var testdir = getTestDataDirectory();
		testdir.append("recognizePDF_test_GS.pdf");
		var item = yield Zotero.Attachments.importFromFile({
			file: testdir
		});
		
		// Recognize the PDF
		win.Zotero_RecognizePDF.recognizeSelected();

		var addedIDs = yield waitForItemEvent("add");
		var modifiedIDs = yield waitForItemEvent("modify");
		assert.lengthOf(addedIDs, 1);
		var item = Zotero.Items.get(addedIDs[0]);
		assert.equal(item.getField("title"), "Scaling study of an improved fermion action on quenched lattices");
		assert.equal(item.getField("libraryCatalog"), "Google Scholar");
		assert.lengthOf(modifiedIDs, 2);
		
		yield Zotero.Promise.delay(0);
		
		var progressWindow = getWindows("chrome://zotero/content/pdfProgress.xul")[0];
		assert.equal(
			progressWindow.document.getElementById("label").value,
			Zotero.getString("recognizePDF.complete.label")
		);
	});
});
{'fraction_non_alphanumeric': 0.14945878434637802, 'fraction_numerical': 0.008742714404662781, 'mean_word_length': 4.491428571428571, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3721216', 'n_tokens_mistral': 1787, 'n_tokens_neox': 1543, 'n_words': 318}