[ui tests] Student attendance and leave application (#10326)
* spelling error rectified
* setting up leave application
* marking attendance and checking
* typo error fixed
diff --git a/erpnext/schools/doctype/student_attendance/test_student_attendance.js b/erpnext/schools/doctype/student_attendance/test_student_attendance.js
new file mode 100644
index 0000000..af83e77
--- /dev/null
+++ b/erpnext/schools/doctype/student_attendance/test_student_attendance.js
@@ -0,0 +1,31 @@
+// Testing Attendance Module in Schools
+QUnit.module('schools');
+
+QUnit.test('Test: Student Attendance', function(assert){
+ assert.expect(2);
+ let done = assert.async();
+ let student_code;
+
+ frappe.run_serially([
+ () => frappe.db.get_value('Student', {'student_email_id': 'test2@testmail.com'}, 'name'),
+ (student) => {student_code = student.message.name;}, // fetching student code from db
+
+ () => {
+ return frappe.tests.make('Student Attendance', [
+ {student: student_code},
+ {date: frappe.datetime.nowdate()},
+ {student_group: "test-batch-wise-group-2"},
+ {status: "Absent"}
+ ]);
+ },
+
+ () => frappe.timeout(0.5),
+ () => {assert.equal(cur_frm.doc.status, "Absent", "Attendance correctly saved");},
+
+ () => frappe.timeout(0.5),
+ () => cur_frm.set_value("status", "Present"),
+ () => {assert.equal(cur_frm.doc.status, "Present", "Attendance correctly saved");},
+
+ () => done()
+ ]);
+});
\ No newline at end of file
diff --git a/erpnext/schools/doctype/student_attendance_tool/student_attendance_tool.js b/erpnext/schools/doctype/student_attendance_tool/student_attendance_tool.js
index c5ff917..23ec408 100644
--- a/erpnext/schools/doctype/student_attendance_tool/student_attendance_tool.js
+++ b/erpnext/schools/doctype/student_attendance_tool/student_attendance_tool.js
@@ -109,7 +109,7 @@
});
student_toolbar.find(".btn-mark-att")
- .html(__('Mark Attendence'))
+ .html(__('Mark Attendance'))
.on("click", function() {
$(me.wrapper.find(".btn-mark-att")).attr("disabled", true);
var studs = [];
diff --git a/erpnext/schools/doctype/student_attendance_tool/test_student_attendance_tool.js b/erpnext/schools/doctype/student_attendance_tool/test_student_attendance_tool.js
new file mode 100644
index 0000000..3044f20
--- /dev/null
+++ b/erpnext/schools/doctype/student_attendance_tool/test_student_attendance_tool.js
@@ -0,0 +1,85 @@
+// Testing Attendance Module in Schools
+QUnit.module('schools');
+
+QUnit.test('Test: Student Attendace Tool', function(assert){
+ assert.expect(10);
+ let done = assert.async();
+ let i, count = 0;
+
+ frappe.run_serially([
+ () => frappe.timeout(0.2),
+ () => frappe.set_route('Form', 'Student Attendance Tool'),
+ () => frappe.timeout(0.5),
+
+ () => {
+ if(cur_frm.doc.based_on == 'Student Group' || cur_frm.doc.based_on == 'Course Schedule'){
+ cur_frm.doc.based_on = 'Student Group';
+ assert.equal(1, 1, 'Attendance basis correctly set');
+ cur_frm.set_value("group_based_on", 'Batch');
+ cur_frm.set_value("student_group", "test-batch-wise-group");
+ cur_frm.set_value("date", frappe.datetime.nowdate());
+ }
+ },
+ () => frappe.timeout(0.5),
+ () => {
+ assert.equal($('input.students-check').size(), 5, "Student list based on batch correctly fetched");
+ assert.equal(frappe.datetime.nowdate(), cur_frm.doc.date, 'Current date correctly set');
+
+ cur_frm.set_value("student_group", "test-batch-wise-group-2");
+ assert.equal($('input.students-check').size(), 5, "Student list based on batch 2 correctly fetched");
+
+ cur_frm.set_value("group_based_on", 'Course');
+
+ cur_frm.set_value("student_group", "test-course-wise-group");
+ assert.equal($('input.students-check').size(), 5, "Student list based on course correctly fetched");
+
+ cur_frm.set_value("student_group", "test-course-wise-group-2");
+ assert.equal($('input.students-check').size(), 5, "Student list based on course 2 correctly fetched");
+ },
+
+ () => frappe.timeout(1),
+ () => frappe.tests.click_button('Check all'), // Marking all Student as checked
+ () => {
+ for(i = 0; i < $('input.students-check').size(); i++){
+ if($('input.students-check')[i].checked == true)
+ count++;
+ }
+
+ if(count == $('input.students-check').size())
+ assert.equal($('input.students-check').size(), count, "All students marked checked");
+ },
+
+ () => frappe.timeout(1),
+ () => frappe.tests.click_button('Uncheck all'), // Marking all Student as unchecked
+ () => {
+ count = 0;
+ for(i = 0; i < $('input.students-check').size(); i++){
+ if(!($('input.students-check')[i].checked))
+ count++;
+ }
+
+ if(count == $('input.students-check').size())
+ assert.equal($('input.students-check').size(), count, "All students marked checked");
+ },
+
+ () => frappe.timeout(1),
+ () => frappe.tests.click_button('Check all'),
+ () => frappe.tests.click_button('Mark Attendance'),
+ () => frappe.timeout(1),
+ () => frappe.tests.click_button('Yes'),
+ () => frappe.timeout(1),
+ () => {
+ assert.equal($('.msgprint').text(), "Attendance has been marked successfully.", "Attendance successfully marked");
+ frappe.tests.click_button('Close');
+ },
+
+ () => frappe.timeout(1),
+ () => frappe.set_route('List', 'Student Attendance/List'),
+ () => frappe.timeout(1),
+ () => {
+ assert.equal(($('div.list-item').size() - 1), count, "Attendance list created");
+ },
+
+ () => done()
+ ]);
+});
\ No newline at end of file
diff --git a/erpnext/schools/doctype/student_leave_application/test_student_leave_application.js b/erpnext/schools/doctype/student_leave_application/test_student_leave_application.js
new file mode 100644
index 0000000..d7a6973
--- /dev/null
+++ b/erpnext/schools/doctype/student_leave_application/test_student_leave_application.js
@@ -0,0 +1,69 @@
+// Testing Attendance Module in Schools
+QUnit.module('schools');
+
+QUnit.test('Test: Student Leave Application', function(assert){
+ assert.expect(4);
+ let done = assert.async();
+ let student_code;
+ let leave_code;
+ frappe.run_serially([
+ () => frappe.db.get_value('Student', {'student_email_id': 'test2@testmail.com'}, 'name'),
+ (student) => {student_code = student.message.name;}, // fetching student code from db
+
+ () => {
+ return frappe.tests.make('Student Leave Application', [
+ {student: student_code},
+ {from_date: '2017-08-02'},
+ {to_date: '2017-08-04'},
+ {mark_as_present: 0},
+ {reason: "Sick Leave."}
+ ]);
+ },
+ () => frappe.tests.click_button('Submit'), // Submitting the leave application
+ () => frappe.timeout(0.7),
+ () => frappe.tests.click_button('Yes'),
+ () => frappe.timeout(0.7),
+ () => {
+ assert.equal(cur_frm.doc.docstatus, 1, "Submitted leave application");
+ leave_code = frappe.get_route()[2];
+ },
+ () => frappe.tests.click_button('Cancel'), // Cancelling the leave application
+ () => frappe.timeout(0.7),
+ () => frappe.tests.click_button('Yes'),
+ () => frappe.timeout(1),
+ () => {assert.equal(cur_frm.doc.docstatus, 2, "Cancelled leave application");},
+ () => frappe.tests.click_button('Amend'), // Amending the leave application
+ () => frappe.timeout(1),
+ () => {
+ cur_frm.doc.mark_as_present = 1;
+ cur_frm.save();
+ },
+ () => frappe.timeout(0.7),
+ () => frappe.tests.click_button('Submit'),
+ () => frappe.timeout(0.7),
+ () => frappe.tests.click_button('Yes'),
+ () => frappe.timeout(0.7),
+ () => {assert.equal(cur_frm.doc.amended_from, leave_code, "Amended successfully");},
+
+ () => frappe.timeout(0.5),
+ () => {
+ return frappe.tests.make('Student Leave Application', [
+ {student: student_code},
+ {from_date: '2017-08-07'},
+ {to_date: '2017-08-09'},
+ {mark_as_present: 0},
+ {reason: "Sick Leave."}
+ ]);
+ },
+ () => frappe.tests.click_button('Submit'),
+ () => frappe.timeout(0.7),
+ () => frappe.tests.click_button('Yes'),
+ () => frappe.timeout(0.7),
+ () => {
+ assert.equal(cur_frm.doc.docstatus, 1, "Submitted leave application");
+ leave_code = frappe.get_route()[2];
+ },
+
+ () => done()
+ ]);
+});
\ No newline at end of file
diff --git a/erpnext/tests/ui/tests.txt b/erpnext/tests/ui/tests.txt
index 1a539c3..3b1b78e 100644
--- a/erpnext/tests/ui/tests.txt
+++ b/erpnext/tests/ui/tests.txt
@@ -63,4 +63,7 @@
erpnext/schools/doctype/student_applicant/tests/test_student_applicant_options.js
erpnext/schools/doctype/student_log/test_student_log.js
erpnext/schools/doctype/student_group/test_student_group.js
-erpnext/schools/doctype/student_group_creation_tool/test_student_group_creation_tool.js
\ No newline at end of file
+erpnext/schools/doctype/student_group_creation_tool/test_student_group_creation_tool.js
+erpnext/schools/doctype/student_leave_application/test_student_leave_application.js
+erpnext/schools/doctype/student_attendance_tool/test_student_attendance_tool.js
+erpnext/schools/doctype/student_attendance/test_student_attendance.js
\ No newline at end of file