[ui test] holiday list and branch in HR (#10045)
* added test for holiday list * codacy fixes * added check for all days in list * added test for branch * codacy fixe * minor fixes
This commit is contained in:
parent
65656ec2df
commit
20a862a6b9
22
erpnext/hr/doctype/branch/test_branch.js
Normal file
22
erpnext/hr/doctype/branch/test_branch.js
Normal file
@ -0,0 +1,22 @@
|
||||
QUnit.module('hr');
|
||||
|
||||
QUnit.test("Test: Branch [HR]", function (assert) {
|
||||
assert.expect(1);
|
||||
let done = assert.async();
|
||||
|
||||
frappe.run_serially([
|
||||
// test branch creation
|
||||
() => frappe.set_route("List", "Branch", "List"),
|
||||
() => frappe.new_doc("Branch"),
|
||||
() => frappe.timeout(1),
|
||||
() => frappe.click_link('Edit in full page'),
|
||||
() => cur_frm.set_value("branch", "Branch test"),
|
||||
|
||||
// save form
|
||||
() => cur_frm.save(),
|
||||
() => frappe.timeout(1),
|
||||
() => assert.equal("Branch test", cur_frm.doc.branch,
|
||||
'name of branch correctly saved'),
|
||||
() => done()
|
||||
]);
|
||||
});
|
42
erpnext/hr/doctype/holiday_list/test_holiday_list.js
Normal file
42
erpnext/hr/doctype/holiday_list/test_holiday_list.js
Normal file
@ -0,0 +1,42 @@
|
||||
QUnit.module('hr');
|
||||
|
||||
QUnit.test("Test: Holiday list [HR]", function (assert) {
|
||||
assert.expect(3);
|
||||
let done = assert.async();
|
||||
let date = frappe.datetime.add_months(frappe.datetime.nowdate(), -2); // date 2 months from now
|
||||
|
||||
frappe.run_serially([
|
||||
// test holiday list creation
|
||||
() => frappe.set_route("List", "Holiday List", "List"),
|
||||
() => frappe.new_doc("Holiday List"),
|
||||
() => frappe.timeout(1),
|
||||
() => cur_frm.set_value("holiday_list_name", "Holiday list test"),
|
||||
() => cur_frm.set_value("from_date", date),
|
||||
() => cur_frm.set_value("weekly_off", "Sunday"), // holiday list for sundays
|
||||
() => frappe.click_button('Get Weekly Off Dates'),
|
||||
|
||||
// save form
|
||||
() => cur_frm.save(),
|
||||
() => frappe.timeout(1),
|
||||
() => assert.equal("Holiday list test", cur_frm.doc.holiday_list_name,
|
||||
'name of holiday list correctly saved'),
|
||||
|
||||
// check if holiday list contains correct days
|
||||
() => {
|
||||
var list = cur_frm.doc.holidays;
|
||||
var list_length = list.length;
|
||||
var i = 0;
|
||||
for ( ; i < list_length; i++)
|
||||
if (list[i].description != 'Sunday') break;
|
||||
assert.equal(list_length, i, "all holidays are sundays in holiday list");
|
||||
},
|
||||
|
||||
// check if to_date is set one year from from_date
|
||||
() => {
|
||||
var date_year_later = frappe.datetime.add_days(frappe.datetime.add_months(date, 12), -1); // date after one year
|
||||
assert.equal(date_year_later, cur_frm.doc.to_date,
|
||||
"to date set correctly");
|
||||
},
|
||||
() => done()
|
||||
]);
|
||||
});
|
@ -3,4 +3,6 @@ erpnext/accounts/doctype/account/test_account.js
|
||||
erpnext/crm/doctype/lead/test_lead.js
|
||||
erpnext/crm/doctype/opportunity/test_opportunity.js
|
||||
erpnext/selling/doctype/quotation/test_quotation.js
|
||||
erpnext/crm/doctype/item/test_item.js
|
||||
erpnext/crm/doctype/item/test_item.js
|
||||
erpnext/hr/doctype/holiday_list/test_holiday_list.js
|
||||
erpnext/hr/doctype/branch/test_branch.js
|
Loading…
x
Reference in New Issue
Block a user