[ui test] leave type,leave control panel and leave allocation in HR (#10136)
* changes in attendance * added test for leave type * added test for leave control panel * added test for leave allocation * codacy fixes
This commit is contained in:
parent
d50da78f28
commit
1c8d8a9720
@ -3,15 +3,8 @@ QUnit.module('hr');
|
||||
QUnit.test("Test: Attendance [HR]", function (assert) {
|
||||
assert.expect(4);
|
||||
let done = assert.async();
|
||||
let employee_code;
|
||||
|
||||
frappe.run_serially([
|
||||
// get employee's auto generated name
|
||||
() => frappe.set_route("List", "Employee", "List"),
|
||||
() => frappe.timeout(0.5),
|
||||
() => frappe.click_link('Test Employee'),
|
||||
() => frappe.timeout(0.5),
|
||||
() => employee_code = frappe.get_route()[2],
|
||||
// test attendance creation for one employee
|
||||
() => frappe.set_route("List", "Attendance", "List"),
|
||||
() => frappe.timeout(0.5),
|
||||
@ -21,7 +14,8 @@ QUnit.test("Test: Attendance [HR]", function (assert) {
|
||||
"Form for new Attendance opened successfully."),
|
||||
// set values in form
|
||||
() => cur_frm.set_value("company", "Test Company"),
|
||||
() => cur_frm.set_value("employee", employee_code),
|
||||
() => frappe.db.get_value('Employee', {'employee_name':'Test Employee 1'}, 'name'),
|
||||
(employee) => cur_frm.set_value("employee", employee.message.name),
|
||||
() => cur_frm.save(),
|
||||
() => frappe.timeout(1),
|
||||
// check docstatus of attendance before submit [Draft]
|
||||
|
@ -10,7 +10,7 @@ QUnit.test("Test: Employee [HR]", function (assert) {
|
||||
() => frappe.set_route("List", "Employee", "List"),
|
||||
() => frappe.new_doc("Employee"),
|
||||
() => frappe.timeout(1),
|
||||
() => cur_frm.set_value("employee_name", "Test Employee"),
|
||||
() => cur_frm.set_value("employee_name", "Test Employee 1"),
|
||||
() => cur_frm.set_value("salutation", "Ms"),
|
||||
() => cur_frm.set_value("company", "Test Company"),
|
||||
() => cur_frm.set_value("date_of_joining", frappe.datetime.add_months(today_date, -2)), // joined 2 month from now
|
||||
@ -26,7 +26,7 @@ QUnit.test("Test: Employee [HR]", function (assert) {
|
||||
() => cur_frm.save(),
|
||||
() => frappe.timeout(1),
|
||||
// check name of employee
|
||||
() => assert.equal("Test Employee", cur_frm.doc.employee_name,
|
||||
() => assert.equal("Test Employee 1", cur_frm.doc.employee_name,
|
||||
'name of employee correctly saved'),
|
||||
// check auto filled gender according to salutation
|
||||
() => assert.equal("Female", cur_frm.doc.gender,
|
||||
|
@ -3,29 +3,46 @@ QUnit.module('hr');
|
||||
QUnit.test("Test: Employee attendance tool [HR]", function (assert) {
|
||||
assert.expect(3);
|
||||
let done = assert.async();
|
||||
let attendance_date = frappe.datetime.add_days(frappe.datetime.nowdate(), -1); // previous day
|
||||
let today_date = frappe.datetime.nowdate();
|
||||
let date_of_attendance = frappe.datetime.add_days(today_date, -1); // previous day
|
||||
|
||||
frappe.run_serially([
|
||||
// create employee
|
||||
() => {
|
||||
return frappe.tests.make('Employee', [
|
||||
{salutation: "Mr"},
|
||||
{employee_name: "Test Employee 2"},
|
||||
{company: "Test Company"},
|
||||
{date_of_joining: frappe.datetime.add_months(today_date, -2)}, // joined 2 month from now
|
||||
{date_of_birth: frappe.datetime.add_months(today_date, -240)}, // age is 20 years
|
||||
{employment_type: "Test Employment type"},
|
||||
{holiday_list: "Test Holiday list"},
|
||||
{branch: "Test Branch"},
|
||||
{department: "Test Department"},
|
||||
{designation: "Test Designation"}
|
||||
]);
|
||||
},
|
||||
() => frappe.set_route("Form", "Employee Attendance Tool"),
|
||||
() => frappe.timeout(0.5),
|
||||
() => assert.equal("Employee Attendance Tool", cur_frm.doctype,
|
||||
"Form for Employee Attendance Tool opened successfully."),
|
||||
// set values in form
|
||||
() => cur_frm.set_value("date", attendance_date),
|
||||
() => cur_frm.set_value("date", date_of_attendance),
|
||||
() => cur_frm.set_value("branch", "Test Branch"),
|
||||
() => cur_frm.set_value("department", "Test Department"),
|
||||
() => cur_frm.set_value("company", "Test Company"),
|
||||
() => frappe.timeout(0.5),
|
||||
() => frappe.click_check('Test Employee'),
|
||||
() => frappe.tests.click_button('Mark Present'),
|
||||
() => frappe.timeout(1),
|
||||
() => frappe.click_button('Check all'),
|
||||
() => frappe.click_button('Mark Present'),
|
||||
// check if attendance is marked
|
||||
() => frappe.set_route("List", "Attendance", "List"),
|
||||
() => frappe.timeout(1),
|
||||
() => {
|
||||
assert.equal("Test Employee", cur_list.data[0].employee_name,
|
||||
"attendance marked correctly saved");
|
||||
assert.equal(attendance_date, cur_list.data[0].attendance_date,
|
||||
"attendance date is set correctly");
|
||||
assert.deepEqual(["Test Employee 2", "Test Employee 1"], [cur_list.data[0].employee_name, cur_list.data[1].employee_name],
|
||||
"marked attendance correctly saved for both employee");
|
||||
let marked_attendance = cur_list.data.filter(d => d.attendance_date == date_of_attendance);
|
||||
assert.equal(marked_attendance.length, 2,
|
||||
'both the attendance are marked for correct date');
|
||||
},
|
||||
() => done()
|
||||
]);
|
||||
|
37
erpnext/hr/doctype/leave_allocation/test_leave_allocation.js
Normal file
37
erpnext/hr/doctype/leave_allocation/test_leave_allocation.js
Normal file
@ -0,0 +1,37 @@
|
||||
QUnit.module('hr');
|
||||
|
||||
QUnit.test("Test: Leave allocation [HR]", function (assert) {
|
||||
assert.expect(3);
|
||||
let done = assert.async();
|
||||
let today_date = frappe.datetime.nowdate();
|
||||
|
||||
frappe.run_serially([
|
||||
// test creating leave alloction
|
||||
() => frappe.set_route("List", "Leave Allocation", "List"),
|
||||
() => frappe.new_doc("Leave Allocation"),
|
||||
() => frappe.timeout(1),
|
||||
() => frappe.db.get_value('Employee', {'employee_name':'Test Employee 1'}, 'name'),
|
||||
(employee) => cur_frm.set_value("employee", employee.message.name),
|
||||
() => cur_frm.set_value("leave_type", "Test Leave type"),
|
||||
() => cur_frm.set_value("to_date", frappe.datetime.add_months(today_date, 2)), // for two months
|
||||
() => cur_frm.set_value("description", "This is just for testing"),
|
||||
() => cur_frm.set_value("new_leaves_allocated", 2),
|
||||
() => frappe.click_check('Add unused leaves from previous allocations'),
|
||||
// save form
|
||||
() => cur_frm.save(),
|
||||
() => frappe.timeout(1),
|
||||
() => cur_frm.savesubmit(),
|
||||
() => frappe.timeout(1),
|
||||
() => assert.equal("Confirm", cur_dialog.title,
|
||||
'confirmation for leave alloction shown'),
|
||||
() => frappe.click_button('Yes'),
|
||||
() => frappe.timeout(1),
|
||||
// check auto filled from date
|
||||
() => assert.equal(today_date, cur_frm.doc.from_date,
|
||||
"from date correctly set"),
|
||||
// check for total leaves
|
||||
() => assert.equal(cur_frm.doc.carry_forwarded_leaves + 2, cur_frm.doc.total_leaves_allocated,
|
||||
"total leave calculation is correctly set"),
|
||||
() => done()
|
||||
]);
|
||||
});
|
@ -0,0 +1,36 @@
|
||||
QUnit.module('hr');
|
||||
|
||||
QUnit.test("Test: Leave control panel [HR]", function (assert) {
|
||||
assert.expect(2);
|
||||
let done = assert.async();
|
||||
let today_date = frappe.datetime.nowdate();
|
||||
|
||||
frappe.run_serially([
|
||||
// test leave allocation using leave control panel
|
||||
() => frappe.set_route("Form", "Leave Control Panel"),
|
||||
() => frappe.timeout(1),
|
||||
() => cur_frm.set_value("leave_type", "Test Leave type"),
|
||||
() => cur_frm.set_value("company", "Test Company"),
|
||||
() => cur_frm.set_value("employment_type", "Test Employment Type"),
|
||||
() => cur_frm.set_value("branch", "Test Branch"),
|
||||
() => cur_frm.set_value("department", "Test Department"),
|
||||
() => cur_frm.set_value("designation", "Test Designation"),
|
||||
() => cur_frm.set_value("from_date", frappe.datetime.add_months(today_date, -2)),
|
||||
() => cur_frm.set_value("to_date", frappe.datetime.add_days(today_date, -1)), // for two months [not today]
|
||||
() => cur_frm.set_value("no_of_days", 3),
|
||||
// allocate leaves
|
||||
() => frappe.click_button('Allocate'),
|
||||
() => frappe.timeout(1),
|
||||
() => assert.equal("Message", cur_dialog.title,
|
||||
"leave alloction message shown"),
|
||||
() => frappe.click_button('Close'),
|
||||
() => frappe.set_route("List", "Leave Allocation", "List"),
|
||||
() => frappe.timeout(1),
|
||||
() => {
|
||||
let leave_allocated = cur_list.data.filter(d => d.leave_type == "Test Leave type");
|
||||
assert.equal(2, leave_allocated.length,
|
||||
'leave allocation successfully done for both the employee');
|
||||
},
|
||||
() => done()
|
||||
]);
|
||||
});
|
22
erpnext/hr/doctype/leave_type/test_leave_type.js
Normal file
22
erpnext/hr/doctype/leave_type/test_leave_type.js
Normal file
@ -0,0 +1,22 @@
|
||||
QUnit.module('hr');
|
||||
|
||||
QUnit.test("Test: Leave type [HR]", function (assert) {
|
||||
assert.expect(1);
|
||||
let done = assert.async();
|
||||
|
||||
frappe.run_serially([
|
||||
// test leave type creation
|
||||
() => frappe.set_route("List", "Leave Type", "List"),
|
||||
() => frappe.new_doc("Leave Type"),
|
||||
() => frappe.timeout(1),
|
||||
() => cur_frm.set_value("leave_type_name", "Test Leave type"),
|
||||
() => cur_frm.set_value("max_days_allowed", "5"),
|
||||
() => frappe.click_check('Is Carry Forward'),
|
||||
// save form
|
||||
() => cur_frm.save(),
|
||||
() => frappe.timeout(1),
|
||||
() => assert.equal("Test Leave type", cur_frm.doc.leave_type_name,
|
||||
'leave type correctly saved'),
|
||||
() => done()
|
||||
]);
|
||||
});
|
@ -20,10 +20,13 @@ erpnext/hr/doctype/employment_type/test_employment_type.js
|
||||
erpnext/hr/doctype/employee/test_employee.js
|
||||
erpnext/hr/doctype/employee_attendance_tool/test_employee_attendance_tool.js
|
||||
erpnext/hr/doctype/attendance/test_attendance.js
|
||||
erpnext/hr/doctype/leave_type/test_leave_type.js
|
||||
erpnext/hr/doctype/leave_control_panel/test_leave_control_panel.js
|
||||
erpnext/hr/doctype/leave_allocation/test_leave_allocation.js
|
||||
erpnext/schools/doctype/academic_year/test_academic_year.js
|
||||
erpnext/schools/doctype/academic_term/test_academic_term.js
|
||||
erpnext/schools/doctype/school_settings/test_school_settings.js
|
||||
erpnext/schools/doctype/student_batch_name/test_student_batch_name.js
|
||||
erpnext/schools/doctype/student_category/test_student_category.js
|
||||
erpnext/schools/doctype/room/test_room.js
|
||||
erpnext/schools/doctype/instructor/test_instructor.js
|
||||
erpnext/schools/doctype/instructor/test_instructor.js
|
Loading…
x
Reference in New Issue
Block a user