[ui test] Student Group - manually and using creation tool (#10283)
* fixing issues in original files
* creating a student log
* student group - manually and using creation tool
diff --git a/erpnext/schools/doctype/student_group/test_student_group.js b/erpnext/schools/doctype/student_group/test_student_group.js
new file mode 100644
index 0000000..842d0ba
--- /dev/null
+++ b/erpnext/schools/doctype/student_group/test_student_group.js
@@ -0,0 +1,62 @@
+// Testing Student Module in Schools
+QUnit.module('schools');
+
+QUnit.test('Test: Student Group', function(assert){
+ assert.expect(2);
+ let done = assert.async();
+ let instructor_code;
+ let loop = ["test-batch-wise-group", "test-course-wise-group"];
+ let tasks = [];
+
+ frappe.run_serially([
+ // Saving Instructor code beforehand
+ () => frappe.set_route('List', 'Instructor'),
+ () => frappe.timeout(0.5),
+ () => frappe.tests.click_link('Instructor 1'),
+ () => frappe.timeout(0.5),
+ () => {instructor_code = frappe.get_route()[2];},
+
+ // Creating a Batch and Course based group
+ () => {
+ loop.forEach(index => {
+ tasks.push(() => {
+ return frappe.tests.make('Student Group', [
+ {academic_year: '2016-17'},
+ {academic_term: '2016-17 (Semester 1)'},
+ {program: "Standard Test"},
+ {group_based_on: 'Batch'},
+ {student_group_name: index},
+ {max_strength: 10},
+ {batch: 'A'},
+ {instructors: [
+ [
+ {instructor: instructor_code}
+ ]
+ ]}
+ ]);
+ });
+ });
+ return frappe.run_serially(tasks);
+ },
+
+ // Populating the created group with Students
+ () => {
+ tasks = [];
+ loop.forEach(index => {
+ tasks.push(
+ () => frappe.timeout(0.3),
+ () => frappe.set_route("Form", ('Student Group/' + index)),
+ () => frappe.timeout(0.3),
+ () => frappe.tests.click_button('Get Students'),
+ () => frappe.timeout(0.2),
+ () => {
+ assert.equal(cur_frm.doc.students.length, 5, 'Successfully fetched list of students');
+ },
+ );
+ });
+ return frappe.run_serially(tasks);
+ },
+
+ () => done()
+ ]);
+});
\ No newline at end of file
diff --git a/erpnext/schools/doctype/student_group_creation_tool/student_group_creation_tool.js b/erpnext/schools/doctype/student_group_creation_tool/student_group_creation_tool.js
index 146f11c..d0d7afd 100644
--- a/erpnext/schools/doctype/student_group_creation_tool/student_group_creation_tool.js
+++ b/erpnext/schools/doctype/student_group_creation_tool/student_group_creation_tool.js
@@ -8,7 +8,7 @@
});
frappe.realtime.on("student_group_creation_progress", function(data) {
if(data.progress) {
- frappe.hide_frappe.msgprint(true);
+ frappe.hide_msgprint(true);
frappe.show_progress(__("Creating student groups"), data.progress[0],data.progress[1]);
}
});
diff --git a/erpnext/schools/doctype/student_group_creation_tool/student_group_creation_tool.py b/erpnext/schools/doctype/student_group_creation_tool/student_group_creation_tool.py
index a236508..4a4cec7 100644
--- a/erpnext/schools/doctype/student_group_creation_tool/student_group_creation_tool.py
+++ b/erpnext/schools/doctype/student_group_creation_tool/student_group_creation_tool.py
@@ -64,6 +64,7 @@
student_group.program = self.program
student_group.course = d.course
student_group.batch = d.batch
+ student_group.max_strength = d.max_strength
student_group.academic_term = self.academic_term
student_group.academic_year = self.academic_year
student_group.save()
diff --git a/erpnext/schools/doctype/student_group_creation_tool/test_student_group_creation_tool.js b/erpnext/schools/doctype/student_group_creation_tool/test_student_group_creation_tool.js
new file mode 100644
index 0000000..c0b4dc8
--- /dev/null
+++ b/erpnext/schools/doctype/student_group_creation_tool/test_student_group_creation_tool.js
@@ -0,0 +1,88 @@
+QUnit.module('schools');
+
+QUnit.test('Test: Student Group Creation Tool', function(assert){
+ assert.expect(5);
+ let done = assert.async();
+ let instructor_code;
+
+ frappe.run_serially([
+ // Saving Instructor code beforehand
+ () => frappe.set_route('List', 'Instructor'),
+ () => frappe.timeout(0.5),
+ () => frappe.tests.click_link('Instructor 1'),
+ () => frappe.timeout(0.5),
+ () => {instructor_code = frappe.get_route()[2];},
+
+ // Setting up the creation tool to generate and save Student Group
+ () => frappe.set_route('Form', 'Student Group Creation Tool'),
+ () => frappe.timeout(0.5),
+ () => {
+ cur_frm.set_value("academic_year", "2016-17");
+ cur_frm.set_value("academic_term", "2016-17 (Semester 1)");
+ cur_frm.set_value("program", "Standard Test");
+ frappe.tests.click_button('Get Courses');
+ },
+ () => frappe.timeout(0.5),
+ () => {
+ assert.equal(cur_frm.doc.courses.length, 4, 'Successfully created groups using the tool');
+ },
+
+ () => {
+ let d, grid, grid_row;
+
+ for(d = 0; d < cur_frm.doc.courses.length; d++)
+ {
+ grid = cur_frm.get_field("courses").grid;
+ grid_row = grid.get_row(d).toggle_view(true);
+ if(grid_row.doc.student_group_name == 'Standard Test/A/2016-17 (Semester 1)'){
+ grid_row.doc.max_strength = 10;
+ grid_row.doc.student_group_name = "test-batch-wise-group-2";
+ $(`.octicon.octicon-triangle-up`).click();
+ continue;
+ }
+ else if(grid_row.doc.student_group_name == 'Test_Sub/Standard Test/2016-17 (Semester 1)'){
+ grid_row.doc.max_strength = 10;
+ grid_row.doc.student_group_name = "test-course-wise-group-2";
+ $(`.octicon.octicon-triangle-up`).click();
+ continue;
+ }
+ }
+ },
+
+ // Generating Student Group
+ () => frappe.timeout(0.5),
+ () => frappe.tests.click_button("Create Student Groups"),
+ () => frappe.timeout(0.5),
+ () => frappe.tests.click_button("Close"),
+
+ // Goin to the generated group to set up student and instructor list
+ () => {
+ let loop = ['Student Group/test-batch-wise-group-2', 'Student Group/test-course-wise-group-2'];
+ let tasks = [];
+ loop.forEach(index => {
+ tasks.push(
+ () => frappe.timeout(1),
+ () => frappe.set_route("Form", index),
+ () => frappe.timeout(0.5),
+ () => frappe.tests.click_button("Get Students"),
+ () => frappe.timeout(0.5),
+ () => {
+ assert.equal(cur_frm.doc.students.length, 5, 'Successfully fetched list of students');
+ },
+ () => frappe.timeout(0.5),
+ () => {
+ d = cur_frm.add_child('instructors');
+ d.instructor = instructor_code;
+ cur_frm.save();
+ },
+ () => {
+ assert.equal(cur_frm.doc.instructors.length, 1, 'Instructor detail stored successfully');
+ },
+ );
+ });
+ return frappe.run_serially(tasks);
+ },
+
+ () => done()
+ ]);
+});
\ No newline at end of file
diff --git a/erpnext/schools/doctype/student_log/test_student_log.js b/erpnext/schools/doctype/student_log/test_student_log.js
new file mode 100644
index 0000000..6e03976
--- /dev/null
+++ b/erpnext/schools/doctype/student_log/test_student_log.js
@@ -0,0 +1,38 @@
+// Testing Student Module in Schools
+QUnit.module('schools');
+
+QUnit.test('Test: Student Log', function(assert){
+ assert.expect(9);
+ let done = assert.async();
+ let student_code;
+ frappe.run_serially([
+ () => frappe.set_route("List", "Student"),
+ () => frappe.timeout(0.5),
+ () => frappe.tests.click_link('Fname Mname Lname'),
+ () => frappe.timeout(0.5),
+ () => {student_code = frappe.get_route()[2];},
+ () => {
+ return frappe.tests.make("Student Log", [
+ {student: student_code},
+ {academic_year: '2016-17'},
+ {academic_term: '2016-17 (Semester 1)'},
+ {program: "Standard Test"},
+ {date: '2017-07-31'},
+ {student_batch: 'A'},
+ {log: 'This is Test log.'}
+ ]);
+ },
+ () => {
+ assert.equal(cur_frm.doc.student, student_code, 'Student code was fetched properly');
+ assert.equal(cur_frm.doc.student_name, 'Fname Mname Lname', 'Student name was correctly auto-fetched');
+ assert.equal(cur_frm.doc.type, 'General', 'Default type selected');
+ assert.equal(cur_frm.doc.academic_year, '2016-17');
+ assert.equal(cur_frm.doc.academic_term, '2016-17 (Semester 1)');
+ assert.equal(cur_frm.doc.program, 'Standard Test', 'Program correctly selected');
+ assert.equal(cur_frm.doc.student_batch, 'A');
+ assert.equal(cur_frm.doc.date, '2017-07-31');
+ assert.equal(cur_frm.doc.log, 'This is Test log.');
+ },
+ () => done()
+ ]);
+});
\ No newline at end of file
diff --git a/erpnext/tests/ui/tests.txt b/erpnext/tests/ui/tests.txt
index b08c18e..4ce1675 100644
--- a/erpnext/tests/ui/tests.txt
+++ b/erpnext/tests/ui/tests.txt
@@ -55,4 +55,7 @@
erpnext/schools/doctype/student_admission/test_student_admission.js
erpnext/schools/doctype/student_applicant/tests/test_student_applicant_dummy_data.js
erpnext/schools/doctype/student_applicant/tests/test_student_applicant.js
-erpnext/schools/doctype/student_applicant/tests/test_student_applicant_options.js
\ No newline at end of file
+erpnext/schools/doctype/student_applicant/tests/test_student_applicant_options.js
+erpnext/schools/doctype/student_log/test_student_log.js
+erpnext/schools/doctype/student_group/test_student_group.js
+erpnext/schools/doctype/student_group_creation_tool/test_student_group_creation_tool.js
\ No newline at end of file