[ui test] student applicant and various actions that can be taken (#10221)

* msgprint error fixed

* student applicant, various actions and its dependencies
diff --git a/erpnext/schools/doctype/guardian/test_guardian.js b/erpnext/schools/doctype/guardian/test_guardian.js
new file mode 100644
index 0000000..a16ba08
--- /dev/null
+++ b/erpnext/schools/doctype/guardian/test_guardian.js
@@ -0,0 +1,34 @@
+// Testing Student Module in Schools
+QUnit.module('schools');
+
+QUnit.test('Test: Guardian', function(assert){
+	assert.expect(9);
+	let done = assert.async();
+	frappe.run_serially([
+		() => {
+			return frappe.tests.make('Guardian', [
+				{guardian_name: 'Test Guardian'},
+				{email_address: 'guardian@testmail.com'},
+				{mobile_number: 9898980000},
+				{alternate_number: 8989890000},
+				{date_of_birth: '1982-07-22'},
+				{education: 'Testing'},
+				{occupation: 'Testing'},
+				{designation: 'Testing'},
+				{work_address: 'Testing address'}
+			]);
+		},
+		() => {
+			assert.ok(cur_frm.doc.guardian_name == 'Test Guardian');
+			assert.ok(cur_frm.doc.email_address == 'guardian@testmail.com');
+			assert.ok(cur_frm.doc.mobile_number == 9898980000);
+			assert.ok(cur_frm.doc.alternate_number == 8989890000);
+			assert.ok(cur_frm.doc.date_of_birth == '1982-07-22');
+			assert.ok(cur_frm.doc.education == 'Testing');
+			assert.ok(cur_frm.doc.occupation == 'Testing');
+			assert.ok(cur_frm.doc.designation == 'Testing');
+			assert.ok(cur_frm.doc.work_address == 'Testing address');
+		},
+		() => done()
+	]);
+});
\ No newline at end of file
diff --git a/erpnext/schools/doctype/student_admission/test_student_admission.js b/erpnext/schools/doctype/student_admission/test_student_admission.js
new file mode 100644
index 0000000..0d7c997
--- /dev/null
+++ b/erpnext/schools/doctype/student_admission/test_student_admission.js
@@ -0,0 +1,34 @@
+// Testing Admission Module in Schools
+QUnit.module('schools');
+
+QUnit.test('Test: Student Admission', function(assert) {
+	assert.expect(9);
+	let done = assert.async();
+	frappe.run_serially([
+		() => {
+			return frappe.tests.make('Student Admission', [
+				{academic_year: '2016-17'},
+				{admission_start_date: '2016-04-20'},
+				{admission_end_date: '2016-05-31'},
+				{title: '2016-17 Admissions'},
+				{program: 'Standard Test'},
+				{application_fee: 1000},
+				{naming_series_for_student_applicant: 'AP'},
+				{introduction: 'Test intro'},
+				{eligibility: 'Test eligibility'}
+			]);
+		},
+		() => {
+			assert.ok(cur_frm.doc.academic_year == '2016-17');
+			assert.ok(cur_frm.doc.admission_start_date == '2016-04-20');
+			assert.ok(cur_frm.doc.admission_end_date == '2016-05-31');
+			assert.ok(cur_frm.doc.title == '2016-17 Admissions');
+			assert.ok(cur_frm.doc.program == 'Standard Test', 'Program correctly selected');
+			assert.ok(cur_frm.doc.application_fee == 1000);
+			assert.ok(cur_frm.doc.naming_series_for_student_applicant == 'AP');
+			assert.ok(cur_frm.doc.introduction == 'Test intro');
+			assert.ok(cur_frm.doc.eligibility == 'Test eligibility');
+		},
+		() => done()
+	]);
+});
\ No newline at end of file
diff --git a/erpnext/schools/doctype/student_applicant/student_applicant.js b/erpnext/schools/doctype/student_applicant/student_applicant.js
index 974d972..9b08ee5 100644
--- a/erpnext/schools/doctype/student_applicant/student_applicant.js
+++ b/erpnext/schools/doctype/student_applicant/student_applicant.js
@@ -28,7 +28,7 @@
 
 		frappe.realtime.on("enroll_student_progress", function(data) {
 			if(data.progress) {
-				frappe.hide_frappe.msgprint(true);
+				frappe.hide_msgprint(true);
 				frappe.show_progress(__("Enrolling student"), data.progress[0],data.progress[1]);
 			}
 		})
diff --git a/erpnext/schools/doctype/student_applicant/tests/test_student_applicant.js b/erpnext/schools/doctype/student_applicant/tests/test_student_applicant.js
new file mode 100644
index 0000000..a45b45a
--- /dev/null
+++ b/erpnext/schools/doctype/student_applicant/tests/test_student_applicant.js
@@ -0,0 +1,95 @@
+// Testing Admission module in Schools
+QUnit.module('schools');
+
+QUnit.test('Test: Student Applicant', function(assert){
+	assert.expect(24);
+	let done = assert.async();
+	let guradian_auto_code;
+	let guardian_name;
+	frappe.run_serially([
+		() => frappe.set_route('List', 'Guardian'),
+		() => frappe.timeout(0.5),
+		() => {$(`a:contains("Test Guardian"):visible`)[0].click();},
+		() => frappe.timeout(1),
+		() => {
+			guardian_name = cur_frm.doc.guardian_name;
+			guradian_auto_code = frappe.get_route()[2];
+		},
+		// Testing data entry for Student Applicant
+		() => {
+			return frappe.tests.make('Student Applicant',[
+				{first_name: 'Fname'},
+				{middle_name: 'Mname'},
+				{last_name: 'Lname'},
+				{program: 'Standard Test'},
+				{student_admission: '2016-17 Admissions'},
+				{academic_year: '2016-17'},
+				{date_of_birth: '1995-07-20'},
+				{student_email_id: 'test@testmail.com'},
+				{gender: 'Male'},
+				{student_mobile_number: '9898980000'},
+				{blood_group: 'O+'},
+				{address_line_1: 'Test appt, Test Society,'},
+				{address_line_2: 'Test district, Test city.'},
+				{city: 'Test'},
+				{state: 'Test'},
+				{pincode: '400086'}
+			]);
+		},
+		// Entry in Guardian child table
+		() => $('a:contains("Guardian Details"):visible').click(),
+		() => $('.btn:contains("Add Row"):visible').click(),
+		() => {
+			cur_frm.get_field("guardians").grid.grid_rows[0].doc.guardian = guradian_auto_code;
+			cur_frm.get_field("guardians").grid.grid_rows[0].doc.relation = "Father";
+			cur_frm.get_field("guardians").grid.grid_rows[0].doc.guardian_name = guardian_name;
+			$('a:contains("Guardian Details"):visible').click();
+		},
+		// Entry in Sibling child table
+		() => $('a:contains("Sibling Details"):visible').click(),
+		() => $('.btn:contains("Add Row"):visible').click(),
+		() => {
+			cur_frm.get_field("siblings").grid.grid_rows[0].doc.full_name = "Test Name";
+			cur_frm.get_field("siblings").grid.grid_rows[0].doc.gender = "Male";
+			cur_frm.get_field("siblings").grid.grid_rows[0].doc.institution = "Test Institution";
+			cur_frm.get_field("siblings").grid.grid_rows[0].doc.program = "Test Program";
+			cur_frm.get_field("siblings").grid.grid_rows[0].doc.date_of_birth = "1995-07-20";
+			$('span.hidden-xs.octicon.octicon-triangle-up').click();
+			cur_frm.save();
+		},
+		() => {
+			assert.ok(cur_frm.doc.first_name == 'Fname');
+			assert.ok(cur_frm.doc.middle_name == 'Mname');
+			assert.ok(cur_frm.doc.last_name == 'Lname');
+			assert.ok(cur_frm.doc.program == 'Standard Test', 'Program selected correctly');
+			assert.ok(cur_frm.doc.student_admission == '2016-17 Admissions', 'Student Admission entry correctly selected');
+			assert.ok(cur_frm.doc.academic_year == '2016-17');
+			assert.ok(cur_frm.doc.date_of_birth == '1995-07-20');
+			assert.ok(cur_frm.doc.student_email_id == 'test@testmail.com');
+			assert.ok(cur_frm.doc.gender == 'Male');
+			assert.ok(cur_frm.doc.student_mobile_number == '9898980000');
+			assert.ok(cur_frm.doc.blood_group == 'O+');
+			assert.ok(cur_frm.doc.address_line_1 == 'Test appt, Test Society,');
+			assert.ok(cur_frm.doc.address_line_2 == 'Test district, Test city.');
+			assert.ok(cur_frm.doc.city == 'Test');
+			assert.ok(cur_frm.doc.state == 'Test');
+			assert.ok(cur_frm.doc.pincode == '400086');
+		},
+		() => frappe.timeout(1),
+		() => $('a:contains("Guardian Details"):visible').click(),
+		() => {
+			assert.ok(cur_frm.get_field("guardians").grid.grid_rows[0].doc.guardian == guradian_auto_code, 'Guardian correctly selected from dropdown');
+			assert.ok(cur_frm.get_field("guardians").grid.grid_rows[0].doc.relation == 'Father');
+			assert.ok(cur_frm.get_field("guardians").grid.grid_rows[0].doc.guardian_name == guardian_name, 'Guardian name was correctly retrieved');
+		},
+		() => $('a:contains("Sibling Details"):visible').click(),
+		() => {
+			assert.ok(cur_frm.get_field("siblings").grid.grid_rows[0].doc.full_name == 'Test Name');
+			assert.ok(cur_frm.get_field("siblings").grid.grid_rows[0].doc.gender == 'Male');
+			assert.ok(cur_frm.get_field("siblings").grid.grid_rows[0].doc.institution == 'Test Institution');
+			assert.ok(cur_frm.get_field("siblings").grid.grid_rows[0].doc.program == 'Test Program');
+			assert.ok(cur_frm.get_field("siblings").grid.grid_rows[0].doc.date_of_birth == '1995-07-20');
+		},
+		() => 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
new file mode 100644
index 0000000..59b2b36
--- /dev/null
+++ b/erpnext/schools/doctype/student_applicant/tests/test_student_applicant_options.js
@@ -0,0 +1,122 @@
+// Testing Admission module in Schools
+QUnit.module('schools');
+
+QUnit.test('test student applicant', function(assert){
+	assert.expect(12);
+	let done = assert.async();
+	let testing_status;
+	frappe.run_serially([
+		() => frappe.set_route('Form', 'School House/New School House'),
+		() => 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();},
+
+		// Checking different options
+		// 1. Moving forward with Submit
+		() => frappe.timeout(0.5),
+		() => frappe.tests.click_button('Submit'),
+		() => frappe.tests.click_button('Yes'),
+		() => {
+			testing_status = $('span.indicator.orange').text();
+			assert.ok(testing_status.indexOf('Submit this document to confirm') == -1); // checking if submit has been successfull
+		},
+
+		// 2. Cancelling the Submit request
+		() => frappe.timeout(0.5),
+		() => frappe.tests.click_button('Cancel'),
+		() => frappe.tests.click_button('Yes'),
+		() => frappe.timeout(0.5),
+		() => {
+			testing_status = $('h1.editable-title').text();
+			assert.ok(testing_status.indexOf('Cancelled') != -1); // checking if cancel request has been successfull
+		},
+
+		// 3. Checking Amend option
+		() => frappe.timeout(0.5),
+		() => frappe.tests.click_button('Amend'),
+		() => cur_frm.doc.student_email_id = "test2@testmail.com", // updating email id since same id again is not allowed
+		() => cur_frm.save(),
+		() => frappe.timeout(0.5),
+		() => frappe.tests.click_button('Submit'),
+		() => frappe.tests.click_button('Yes'), // Submitting again after amend
+		() => {
+			testing_status = $('span.indicator.orange').text();
+			assert.ok(testing_status.indexOf('Submit this document to confirm') == -1); // checking if submit has been successfull after amend
+		},
+
+		// Checking different Application status option
+		() => {
+			testing_status = $('h1.editable-title').text();
+			assert.ok(testing_status.indexOf('Applied') != -1); // checking if Applied has been successfull
+		},
+		() => cur_frm.set_value('application_status', "Rejected"), // Rejected Status
+		() => frappe.tests.click_button('Update'),
+		() => {
+			testing_status = $('h1.editable-title').text();
+			assert.ok(testing_status.indexOf('Rejected') != -1); // checking if Rejected has been successfull
+		},
+		() => cur_frm.set_value('application_status', "Admitted"), // Admitted Status
+		() => frappe.tests.click_button('Update'),
+		() => {
+			testing_status = $('h1.editable-title').text();
+			assert.ok(testing_status.indexOf('Admitted') != -1); // checking if Admitted has been successfull
+		},
+		() => cur_frm.set_value('application_status', "Approved"), // Approved Status
+		() => frappe.tests.click_button('Update'),
+		() => {
+			testing_status = $('h1.editable-title').text();
+			assert.ok(testing_status.indexOf('Approved') != -1); // checking if Approved has been successfull
+		},
+
+		// Clicking on Enroll button should add the applicant's entry in Student doctype, and take you to Program Enrollment page
+		() => frappe.timeout(0.5),
+		() => frappe.tests.click_button('Enroll'),
+		() => frappe.timeout(0.5),
+		() => {
+			assert.ok(frappe.get_route()[0] == 'Form'); // Checking if the current page is Program Enrollment page or not
+			assert.ok(frappe.get_route()[1] == 'Program Enrollment');
+		},
+
+		// Routing to Student List to check if the Applicant's entry has been made or not
+		() => frappe.timeout(0.5),
+		() => frappe.set_route('List', 'Student'),
+		() => frappe.timeout(0.5),
+		() => {$(`a:contains("Fname Mname Lname"):visible`)[0].click();},
+		() => frappe.timeout(0.5),
+		() => {assert.ok(($(`h1.editable-title`).text()).indexOf('Enabled') != -1, 'Student entry successfully created');}, // Checking if the Student entry has been enabled
+		// Enrolling the Student into a Program
+		() => {$('.form-documents .row:nth-child(1) .col-xs-6:nth-child(1) .octicon-plus').click();},
+		() => frappe.timeout(1),
+		() => {
+			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');
+			$('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.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
+		},
+		() => done()
+	]);
+});
\ No newline at end of file
diff --git a/erpnext/tests/ui/tests.txt b/erpnext/tests/ui/tests.txt
index a61c8ec..88b6ca7 100644
--- a/erpnext/tests/ui/tests.txt
+++ b/erpnext/tests/ui/tests.txt
@@ -44,4 +44,8 @@
 erpnext/schools/doctype/assessment_criteria_group/test_assessment_criteria_group.js
 erpnext/schools/doctype/assessment_criteria/test_assessment_criteria.js
 erpnext/schools/doctype/course/test_course.js
-erpnext/schools/doctype/program/test_program.js
\ No newline at end of file
+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.js
+erpnext/schools/doctype/student_applicant/tests/test_student_applicant_options.js
\ No newline at end of file