[ui test] fixed tests that used fees in any way (#10279)

* course table dependency on fee structure bypassed

* testing related to fees removed

* added more students data

* codacy fix
diff --git a/erpnext/schools/doctype/program/test_program.js b/erpnext/schools/doctype/program/test_program.js
index 16bc932..a14fe97 100644
--- a/erpnext/schools/doctype/program/test_program.js
+++ b/erpnext/schools/doctype/program/test_program.js
@@ -2,7 +2,7 @@
 QUnit.module('schools');
 
 QUnit.test('Test: Program', function(assert){
-	assert.expect(11);
+	assert.expect(6);
 	let done = assert.async();
 	let fee_structure_code;
 	frappe.run_serially([
@@ -21,45 +21,6 @@
 			]);
 		},
 
-		() => cur_frm.save(),
-		// Setting up Fee Category to select in Program doctype
-		() => {
-			return frappe.tests.make('Fee Category', [
-				{category_name: 'Reservation'},
-				{description: 'Special Provision'}
-			]);
-		},
-		// Setting up Fee Structure to be selected in Program doctype
-		() => {
-			return frappe.tests.make('Fee Structure', [
-				{program: 'Standard Test'},
-				{academic_term: '2016-17 (Semester 1)'},
-				{student_category: 'Reservation'},
-				{components: [
-					[
-						{fees_category: 'Reservation'},
-						{amount: 20000}
-					]
-				]}
-			]);
-		},
-		() => {fee_structure_code = frappe.get_route()[2];}, // Storing naming convention of Fee Structure entry
-		() => frappe.set_route('Form', ('Program/Standard Test')), // Routing to our current Program doctype
-
-		() => $('.shaded-section~ .visible-section+ .visible-section .grid-add-row').trigger('click'), // clicking on Add Row button
-		// Storing data that were inter-dependent
-		() => cur_frm.doc.fees[0].academic_term = '2016-17 (Semester 1)',
-		() => cur_frm.doc.fees[0].student_category = 'Reservation',
-		() => cur_frm.doc.fees[0].due_date = '2016-08-20',
-		() => $('.error').trigger('click'),
-		() => $('.bold.input-sm').trigger('focus'),
-		() => frappe.timeout(1),
-		() => $('.bold.input-sm').trigger('focus'),
-		() => $('.bold.input-sm').val(fee_structure_code),
-		() => $('.bold.input-sm').trigger('focus'),
-		() => frappe.timeout(1),
-		() => cur_frm.save(),
-
 		() => {
 			assert.ok(cur_frm.doc.program_name == 'Standard Test');
 			assert.ok(cur_frm.doc.program_code == 'Standard Test');
@@ -67,11 +28,6 @@
 			assert.ok(cur_frm.doc.program_abbreviation == 'Standard Test');
 			assert.ok(cur_frm.doc.courses[0].course == 'Test_Sub');
 			assert.ok(cur_frm.doc.courses[0].required == true);
-			assert.ok(cur_frm.doc.fees[0].academic_term == '2016-17 (Semester 1)');
-			assert.ok(cur_frm.doc.fees[0].fee_structure == fee_structure_code);
-			assert.ok(cur_frm.doc.fees[0].student_category == 'Reservation');
-			assert.ok(cur_frm.doc.fees[0].due_date == '2016-08-20');
-			assert.ok(cur_frm.doc.fees[0].amount == 20000);
 		},
 		() => done()
 	]);
diff --git a/erpnext/schools/doctype/program_enrollment/program_enrollment.js b/erpnext/schools/doctype/program_enrollment/program_enrollment.js
index d1b703b..8418e85 100644
--- a/erpnext/schools/doctype/program_enrollment/program_enrollment.js
+++ b/erpnext/schools/doctype/program_enrollment/program_enrollment.js
@@ -43,6 +43,7 @@
 	},
 
 	program: function(frm) {
+		frm.events.get_courses(frm);
 		if (frm.doc.program) {
 			frappe.call({
 				method: "erpnext.schools.api.get_fee_schedule",
diff --git a/erpnext/schools/doctype/student_applicant/tests/test_student_applicant_dummy_data.js b/erpnext/schools/doctype/student_applicant/tests/test_student_applicant_dummy_data.js
new file mode 100644
index 0000000..26244ab
--- /dev/null
+++ b/erpnext/schools/doctype/student_applicant/tests/test_student_applicant_dummy_data.js
@@ -0,0 +1,87 @@
+QUnit.module('Admission');
+
+QUnit.test('Make Students', function(assert){
+	assert.expect(0);
+	let done = assert.async();
+	let tasks = [];
+	let loop = [1,2,3,4];
+	let fname;
+
+	frappe.run_serially([
+		// Making School House to be used in this test and later
+		() => frappe.set_route('Form', 'School House/New School House'),
+		() => frappe.timeout(0.5),
+		() => cur_frm.doc.house_name = 'Test_house',
+		() => cur_frm.save(),
+
+		// Making Student Applicant entries
+		() => {
+			loop.forEach(index => {
+				tasks.push(() => {
+					fname = "Fname" + index;
+
+					return frappe.tests.make('Student Applicant', [
+						{first_name: fname},
+						{middle_name: "Mname"},
+						{last_name: "Lname"},
+						{program: "Standard Test"},
+						{student_admission: "2016-17 Admissions"},
+						{date_of_birth: '1995-08-20'},
+						{student_email_id: ('test' + (index+3) + '@testmail.com')},
+						{gender: 'Male'},
+						{student_mobile_number: (9898980000 + index)},
+						{blood_group: 'O+'},
+						{address_line_1: 'Test appt, Test Society,'},
+						{address_line_2: 'Test district, Test city.'},
+						{city: 'Test'},
+						{state: 'Test'},
+						{pincode: '395007'}
+					]);
+				});
+			});
+			return frappe.run_serially(tasks);
+		},
+
+		// Using Program Enrollment Tool to enroll all dummy student at once
+		() => frappe.set_route('Form', 'Program Enrollment Tool'),
+		() => {
+			cur_frm.set_value("get_students_from", "Student Applicants");
+			cur_frm.set_value("academic_year", "2016-17");
+			cur_frm.set_value("program", "Standard Test");
+		},
+		() => frappe.tests.click_button("Get Students"),
+		() => frappe.timeout(1),
+		() => frappe.tests.click_button("Enroll Students"),
+		() => frappe.timeout(1.5),
+		() => frappe.tests.click_button("Close"),
+
+		// Submitting required data for each enrolled Student
+		() => {
+			tasks = [];
+			loop.forEach(index => {
+				tasks.push(
+					() => {fname = "Fname" + index + " Mname Lname";},
+					() => frappe.set_route('List', 'Program Enrollment/List'),
+					() => frappe.timeout(0.6),
+					() => frappe.tests.click_link(fname),
+					() => frappe.timeout(0.4),
+					() => {
+						cur_frm.set_value('program', 'Standard Test');
+						cur_frm.set_value('student_category', 'Reservation');
+						cur_frm.set_value('student_batch_name', 'A');
+						cur_frm.set_value('academic_year', '2016-17');
+						cur_frm.set_value('academic_term', '2016-17 (Semester 1)');
+						cur_frm.set_value('school_house', 'Test_house');
+					},
+					() => cur_frm.save(),
+					() => frappe.timeout(0.5),
+					() => frappe.tests.click_button('Submit'),
+					() => frappe.tests.click_button('Yes'),
+					() => frappe.timeout(0.5)
+				);
+			});
+			return frappe.run_serially(tasks);
+		},
+		() => done()
+	]);
+});
\ No newline at end of file
diff --git a/erpnext/schools/doctype/student_applicant/tests/test_student_applicant_options.js b/erpnext/schools/doctype/student_applicant/tests/test_student_applicant_options.js
index 61f36e2..b983afd 100644
--- a/erpnext/schools/doctype/student_applicant/tests/test_student_applicant_options.js
+++ b/erpnext/schools/doctype/student_applicant/tests/test_student_applicant_options.js
@@ -2,14 +2,10 @@
 QUnit.module('schools');
 
 QUnit.test('test student applicant', function(assert){
-	assert.expect(12);
+	assert.expect(11);
 	let done = assert.async();
 	let testing_status;
 	frappe.run_serially([
-		() => frappe.set_route('Form', 'School House/New School House'),
-		() => frappe.timeout(0.5),
-		() => cur_frm.doc.house_name = 'Test_house',
-		() => cur_frm.save(),
 		() => frappe.set_route('List', 'Student Applicant'),
 		() => frappe.timeout(0.5),
 		() => {$(`a:contains("Fname Mname Lname"):visible`)[0].click();},
@@ -97,26 +93,15 @@
 			cur_frm.set_value('academic_year', '2016-17');
 			cur_frm.set_value('academic_term', '2016-17 (Semester 1)');
 			cur_frm.set_value('school_house', 'Test_house');
-			$('a:contains("Fees"):visible').click();
-		},
-		() => frappe.timeout(1),
-		() => {
-			cur_frm.doc.fees[0].student_category = "Reservation";
 		},
 		() => cur_frm.save(),
+
 		// Submitting Program Enrollment form for our Test Student
-		() => frappe.timeout(0.5),
+		() => frappe.timeout(1),
 		() => frappe.tests.click_button('Submit'),
 		() => frappe.tests.click_button('Yes'),
 		() => {
-			testing_status = $('.msgprint').text();
-			assert.ok("Fee Records Created" == (testing_status.substring(0,19)), "Fee record created for enrolled student test");
-		},
-		() => frappe.timeout(0.5),
-		() => frappe.tests.click_button('Close'),
-		() => {
-			testing_status = $('h1').text();
-			assert.ok(testing_status.indexOf('Submitted') != -1, "Program enrollment successfully submitted"); // Checking if the program enrollment entry shows submitted or not
+			assert.ok(cur_frm.doc.docstatus == 1, "Program enrollment successfully submitted");
 		},
 		() => done()
 	]);
diff --git a/erpnext/tests/ui/tests.txt b/erpnext/tests/ui/tests.txt
index bc930b8..b08c18e 100644
--- a/erpnext/tests/ui/tests.txt
+++ b/erpnext/tests/ui/tests.txt
@@ -53,5 +53,6 @@
 erpnext/schools/doctype/program/test_program.js
 erpnext/schools/doctype/guardian/test_guardian.js
 erpnext/schools/doctype/student_admission/test_student_admission.js
+erpnext/schools/doctype/student_applicant/tests/test_student_applicant_dummy_data.js
 erpnext/schools/doctype/student_applicant/tests/test_student_applicant.js
 erpnext/schools/doctype/student_applicant/tests/test_student_applicant_options.js
\ No newline at end of file