[ui tests] Student attendance and leave application (#10326)

* spelling error rectified

* setting up leave application

* marking attendance and checking

* typo error fixed
This commit is contained in:
Zarrar 2017-08-08 18:24:15 +05:30 committed by Nabin Hait
parent 135560e170
commit 17e35e6ac7
5 changed files with 190 additions and 2 deletions

View File

@ -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()
]);
});

View File

@ -109,7 +109,7 @@ schools.StudentsEditor = Class.extend({
});
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 = [];

View File

@ -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()
]);
});

View File

@ -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()
]);
});

View File

@ -63,4 +63,7 @@ erpnext/schools/doctype/student_applicant/tests/test_student_applicant.js
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
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