Test for appraisal (#10525)
diff --git a/erpnext/hr/doctype/appraisal/test_appraisal.js b/erpnext/hr/doctype/appraisal/test_appraisal.js
new file mode 100644
index 0000000..91da7d3
--- /dev/null
+++ b/erpnext/hr/doctype/appraisal/test_appraisal.js
@@ -0,0 +1,58 @@
+QUnit.module('hr');
+
+QUnit.test("Test: Expense Claim [HR]", function (assert) {
+ assert.expect(3);
+ let done = assert.async();
+ let employee_name;
+
+ frappe.run_serially([
+ // Creating Appraisal
+ () => frappe.set_route('List','Appraisal','List'),
+ () => frappe.timeout(0.3),
+ () => frappe.click_button('Make a new Appraisal'),
+ () => {
+ cur_frm.set_value('kra_template','Test Appraisal 1'),
+ cur_frm.set_value('start_date','2017-08-21'),
+ cur_frm.set_value('end_date','2017-09-21');
+ },
+ () => frappe.timeout(1),
+ () => frappe.model.set_value('Appraisal Goal','New Appraisal Goal 1','score',4),
+ () => frappe.model.set_value('Appraisal Goal','New Appraisal Goal 1','score_earned',2),
+ () => frappe.model.set_value('Appraisal Goal','New Appraisal Goal 2','score',4),
+ () => frappe.model.set_value('Appraisal Goal','New Appraisal Goal 2','score_earned',2),
+ () => frappe.timeout(1),
+ () => frappe.db.get_value('Employee', {'employee_name': 'Test Employee 1'}, 'name'),
+ (r) => {
+ employee_name = r.message.name;
+ },
+
+ () => frappe.timeout(1),
+ () => cur_frm.set_value('employee',employee_name),
+ () => cur_frm.set_value('employee_name','Test Employee 1'),
+ () => cur_frm.set_value('company','Test Company'),
+ () => frappe.click_button('Calculate Total Score'),
+ () => frappe.timeout(1),
+ () => cur_frm.save(),
+ () => frappe.timeout(1),
+ () => cur_frm.save(),
+
+ // Submitting the Appraisal
+ () => frappe.click_button('Submit'),
+ () => frappe.click_button('Yes'),
+ () => frappe.timeout(3),
+
+ // Checking if the appraisal is correctly set for the employee
+ () => {
+ assert.equal('Submitted',cur_frm.get_field('status').value,
+ 'Appraisal is submitted');
+
+ assert.equal('Test Employee 1',cur_frm.get_field('employee_name').value,
+ 'Appraisal is created for correct employee');
+
+ assert.equal(4,cur_frm.get_field('total_score').value,
+ 'Total score is correctly calculated');
+ },
+ () => done()
+ ]);
+});
+
diff --git a/erpnext/hr/doctype/appraisal_template/test_appraisal_template.js b/erpnext/hr/doctype/appraisal_template/test_appraisal_template.js
new file mode 100644
index 0000000..4e245c7
--- /dev/null
+++ b/erpnext/hr/doctype/appraisal_template/test_appraisal_template.js
@@ -0,0 +1,30 @@
+QUnit.module('hr');
+QUnit.test("Test: Appraisal Template [HR]", function (assert) {
+ assert.expect(1);
+ let done = assert.async();
+ frappe.run_serially([
+ // Job Opening creation
+ () => {
+ frappe.tests.make('Appraisal Template', [
+ { kra_title: 'Test Appraisal 1'},
+ { description: 'This is just a test'},
+ { goals: [
+ [
+ { kra: 'Design'},
+ { per_weightage: 50}
+ ],
+ [
+ { kra: 'Code creation'},
+ { per_weightage: 50}
+ ]
+ ]},
+ ]);
+ },
+ () => frappe.timeout(5),
+ () => {
+ assert.equal('Test Appraisal 1',cur_frm.doc.kra_title, 'Appraisal name correctly set');
+ },
+ () => done()
+ ]);
+});
+
diff --git a/erpnext/tests/ui/tests.txt b/erpnext/tests/ui/tests.txt
index f76b1c0..970b00d 100644
--- a/erpnext/tests/ui/tests.txt
+++ b/erpnext/tests/ui/tests.txt
@@ -66,6 +66,8 @@
erpnext/hr/doctype/job_opening/test_job_opening.js
erpnext/hr/doctype/job_applicant/test_job_applicant.js
erpnext/hr/doctype/offer_letter/test_offer_letter.js
+erpnext/hr/doctype/appraisal_template/test_appraisal_template.js
+erpnext/hr/doctype/appraisal/test_appraisal.js
erpnext/buying/doctype/supplier/test_supplier.js
erpnext/buying/doctype/request_for_quotation/tests/test_request_for_quotation.js
erpnext/buying/doctype/supplier_quotation/tests/test_supplier_quotation.js
@@ -102,5 +104,5 @@
erpnext/schools/doctype/assessment_plan/test_assessment_plan.js
erpnext/schools/doctype/assessment_result/test_assessment_result.js
erpnext/schools/doctype/assessment_result_tool/test_assessment_result_tool.js
-erpnext/stock/doctype/stock_reconciliation/test_stock_reconciliation.js
erpnext/accounts/doctype/journal_entry/test_journal_entry.js
+erpnext/stock/doctype/stock_reconciliation/test_stock_reconciliation.js
\ No newline at end of file