[ui test] Setting up school course+program and their dependencies (#10142)

* setting up course and its dependencies

* rebasing with develop branch

* codacy fix

* added test for Program

* updated test-dada to maintain consistency with future tests
This commit is contained in:
Zarrar 2017-07-31 11:05:52 +05:30 committed by Rushabh Mehta
parent 4e91f28ce5
commit 35d3190822
6 changed files with 178 additions and 0 deletions

View File

@ -0,0 +1,16 @@
// School Assessment module
QUnit.module('schools');
QUnit.test('Test: Assessment Criteria', function(assert){
assert.expect(0);
let done = assert.async();
frappe.run_serially([
() => {
return frappe.tests.make('Assessment Criteria', [
{assessment_criteria: 'Pass'},
{assessment_criteria_group: 'Reservation'}
]);
},
() => done()
]);
});

View File

@ -0,0 +1,15 @@
// School Assessment module
QUnit.module('schools');
QUnit.test('Test: Assessment Criteria Group', function(assert){
assert.expect(0);
let done = assert.async();
frappe.run_serially([
() => {
return frappe.tests.make('Assessment Criteria Group', [
{assessment_criteria_group: 'Reservation'}
]);
},
() => done()
]);
});

View File

@ -0,0 +1,36 @@
// Testing Setup Module in Schools
QUnit.module('schools');
QUnit.test('test course', function(assert) {
assert.expect(8);
let done = assert.async();
frappe.run_serially([
() => {
return frappe.tests.make('Course', [
{course_name: 'Test_Subject'},
{course_code: 'Test_Sub'},
{department: 'Test Department'},
{course_abbreviation: 'Test_Sub'},
{course_intro: 'Test Subject Intro'},
{default_grading_scale: 'GTU'},
{assessment_criteria: [
[
{assessment_criteria: 'Pass'},
{weightage: 100}
]
]}
]);
},
() => {
assert.ok(cur_frm.doc.course_name == 'Test_Subject', 'Course name correctly set');
assert.ok(cur_frm.doc.course_code == 'Test_Sub', 'Course code correctly set');
assert.ok(cur_frm.doc.department == 'Test Department', 'Department selected correctly');
assert.ok(cur_frm.doc.course_abbreviation == 'Test_Sub');
assert.ok(cur_frm.doc.course_intro == 'Test Subject Intro');
assert.ok(cur_frm.doc.default_grading_scale == 'GTU', 'Grading scale selected correctly');
assert.ok(cur_frm.doc.assessment_criteria[0].assessment_criteria == 'Pass', 'Assessment criteria selected correctly');
assert.ok(cur_frm.doc.assessment_criteria[0].weightage == '100');
},
() => done()
]);
});

View File

@ -0,0 +1,28 @@
// School Assessment module
QUnit.module('schools');
QUnit.test('Test: Grading Scale', function(assert){
assert.expect(0);
let done = assert.async();
frappe.run_serially([
() => {
return frappe.tests.make('Grading Scale', [
{grading_scale_name: 'GTU'},
{description: 'The score will be set according to 10 based system.'},
{intervals: [
[
{grade_code: 'AA'},
{threshold: '90'},
{grade_description: 'Distinction'}
],
[
{grade_code: 'FF'},
{threshold: '0'},
{grade_description: 'Fail'}
]
]}
]);
},
() => done()
]);
});

View File

@ -0,0 +1,78 @@
// Testing Setup Module in Schools
QUnit.module('schools');
QUnit.test('Test: Program', function(assert){
assert.expect(11);
let done = assert.async();
let fee_structure_code;
frappe.run_serially([
() => {
return frappe.tests.make('Program', [
{program_name: 'Standard Test'},
{program_code: 'Standard Test'},
{department: 'Test Department'},
{program_abbreviation: 'Standard Test'},
{courses: [
[
{course: 'Test_Sub'},
{required: true}
]
]}
]);
},
() => cur_frm.save(),
// Setting up Fee Category to select in Program doctype
() => {
return frappe.tests.make('Fee Category', [
{category_name: 'Reservation'},
{description: 'Special Provision'}
]);
},
// Setting up Fee Structure to be selected in Program doctype
() => {
return frappe.tests.make('Fee Structure', [
{program: 'Standard Test'},
{academic_term: '2016-17 (Semester 1)'},
{student_category: 'Reservation'},
{components: [
[
{fees_category: 'Reservation'},
{amount: 20000}
]
]}
]);
},
() => {fee_structure_code = frappe.get_route()[2];}, // Storing naming convention of Fee Structure entry
() => frappe.set_route('Form', ('Program/Standard Test')), // Routing to our current Program doctype
() => $('.shaded-section~ .visible-section+ .visible-section .grid-add-row').trigger('click'), // clicking on Add Row button
// Storing data that were inter-dependent
() => cur_frm.doc.fees[0].academic_term = '2016-17 (Semester 1)',
() => cur_frm.doc.fees[0].student_category = 'Reservation',
() => cur_frm.doc.fees[0].due_date = '2016-08-20',
() => $('.error').trigger('click'),
() => $('.bold.input-sm').trigger('focus'),
() => frappe.timeout(1),
() => $('.bold.input-sm').trigger('focus'),
() => $('.bold.input-sm').val(fee_structure_code),
() => $('.bold.input-sm').trigger('focus'),
() => frappe.timeout(1),
() => cur_frm.save(),
() => {
assert.ok(cur_frm.doc.program_name == 'Standard Test');
assert.ok(cur_frm.doc.program_code == 'Standard Test');
assert.ok(cur_frm.doc.department == 'Test Department');
assert.ok(cur_frm.doc.program_abbreviation == 'Standard Test');
assert.ok(cur_frm.doc.courses[0].course == 'Test_Sub');
assert.ok(cur_frm.doc.courses[0].required == true);
assert.ok(cur_frm.doc.fees[0].academic_term == '2016-17 (Semester 1)');
assert.ok(cur_frm.doc.fees[0].fee_structure == fee_structure_code);
assert.ok(cur_frm.doc.fees[0].student_category == 'Reservation');
assert.ok(cur_frm.doc.fees[0].due_date == '2016-08-20');
assert.ok(cur_frm.doc.fees[0].amount == 20000);
},
() => done()
]);
});

View File

@ -36,3 +36,8 @@ erpnext/stock/doctype/warehouse/test_warehouse.js
erpnext/manufacturing/doctype/production_order/test_production_order.js erpnext/manufacturing/doctype/production_order/test_production_order.js
erpnext/accounts/page/pos/test_pos.js erpnext/accounts/page/pos/test_pos.js
erpnext/selling/doctype/product_bundle/test_product_bundle.js erpnext/selling/doctype/product_bundle/test_product_bundle.js
erpnext/schools/doctype/grading_scale/test_grading_scale.js
erpnext/schools/doctype/assessment_criteria_group/test_assessment_criteria_group.js
erpnext/schools/doctype/assessment_criteria/test_assessment_criteria.js
erpnext/schools/doctype/course/test_course.js
erpnext/schools/doctype/program/test_program.js