diff --git a/erpnext/hr/doctype/branch/test_branch.js b/erpnext/hr/doctype/branch/test_branch.js new file mode 100644 index 0000000000..25ea2fc392 --- /dev/null +++ b/erpnext/hr/doctype/branch/test_branch.js @@ -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() + ]); +}); \ No newline at end of file diff --git a/erpnext/hr/doctype/holiday_list/test_holiday_list.js b/erpnext/hr/doctype/holiday_list/test_holiday_list.js new file mode 100644 index 0000000000..ed75285a65 --- /dev/null +++ b/erpnext/hr/doctype/holiday_list/test_holiday_list.js @@ -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() + ]); +}); \ No newline at end of file diff --git a/erpnext/tests/ui/tests.txt b/erpnext/tests/ui/tests.txt index 98f83999c9..c149226628 100644 --- a/erpnext/tests/ui/tests.txt +++ b/erpnext/tests/ui/tests.txt @@ -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 \ No newline at end of file +erpnext/crm/doctype/item/test_item.js +erpnext/hr/doctype/holiday_list/test_holiday_list.js +erpnext/hr/doctype/branch/test_branch.js \ No newline at end of file