From e8caeb85e3877df7dcd3ae1864c6d5e2a693d12d Mon Sep 17 00:00:00 2001 From: Mihail Geshoski Date: Mon, 10 Oct 2022 22:13:59 +0800 Subject: [PATCH] MDL-75513 gradereport_user: Add behat tests --- .../behat/toggle_grade_categories.feature | 55 ++++++++++++++++ .../behat/user_report_navigation.feature | 65 +++++++++++++++++++ 2 files changed, 120 insertions(+) create mode 100644 grade/report/user/tests/behat/toggle_grade_categories.feature create mode 100644 grade/report/user/tests/behat/user_report_navigation.feature diff --git a/grade/report/user/tests/behat/toggle_grade_categories.feature b/grade/report/user/tests/behat/toggle_grade_categories.feature new file mode 100644 index 00000000000..9c24725e908 --- /dev/null +++ b/grade/report/user/tests/behat/toggle_grade_categories.feature @@ -0,0 +1,55 @@ +@core @core_grades @gradereport_user @javascript +Feature: User can toggle the visibility of the grade categories within the user grade report. + In order to focus only on the information that I am interested in + As a teacher + I need to be able to easily toggle the visibility of grade categories in the user grade report + + Background: + Given the following "courses" exist: + | fullname | shortname | category | + | Course | C1 | 0 | + And the following "users" exist: + | username | firstname | lastname | email | idnumber | + | teacher1 | Teacher | 1 | teacher1@example.com | t1 | + | student1 | Student | 1 | student1@example.com | s1 | + And the following "course enrolments" exist: + | user | course | role | + | teacher1 | C1 | editingteacher | + | student1 | C1 | student | + And the following "grade categories" exist: + | fullname | course | + | Category 1 | C1 | + And the following "activities" exist: + | activity | course | idnumber | name | intro | grade | + | assign | C1 | a1 | Test assignment one | Submit something! | 300 | + And the following "activities" exist: + | activity | course | idnumber | name | intro | gradecategory | grade | gradepass | + | assign | C1 | a2 | Test assignment two | Submit something! | Category 1 | 100 | 50 | + And I log in as "teacher1" + And I am on "Course" course homepage + + Scenario: A teacher can search for and find a user to view + Given I navigate to "View > User report" in the course gradebook + And I click on "Student 1" in the "user" search widget + And I should see "Test assignment one" in the "user-grade" "table" + And I should see "Test assignment two" in the "user-grade" "table" + And I should see "Category 1 total" in the "user-grade" "table" + And I should see "Course total" in the "user-grade" "table" + # Hide the grade category 'Category 1'. + When I click on ".toggle-category" "css_element" in the "Category 1" "table_row" + Then I should not see "Test assignment two" in the "user-grade" "table" + And I should not see "Category 1 total" in the "user-grade" "table" + And I should see "Test assignment one" in the "user-grade" "table" + And I should see "Course total" in the "user-grade" "table" + # Show the grade category 'Category 1'. + And I click on ".toggle-category" "css_element" in the "Category 1" "table_row" + And I should see "Test assignment two" in the "user-grade" "table" + And I should see "Category 1 total" in the "user-grade" "table" + And I should see "Test assignment one" in the "user-grade" "table" + And I should see "Course total" in the "user-grade" "table" + # Hide the grade category 'Course'. + And I click on ".toggle-category" "css_element" in the "Course" "table_row" + And I should not see "Test assignment two" in the "user-grade" "table" + And I should not see "Category 1 total" in the "user-grade" "table" + And I should not see "Test assignment one" in the "user-grade" "table" + And I should not see "Course total" in the "user-grade" "table" diff --git a/grade/report/user/tests/behat/user_report_navigation.feature b/grade/report/user/tests/behat/user_report_navigation.feature new file mode 100644 index 00000000000..53afc34fae9 --- /dev/null +++ b/grade/report/user/tests/behat/user_report_navigation.feature @@ -0,0 +1,65 @@ +@core @core_grades @gradereport_user @javascript +Feature: Teacher can navigate to the previous or next user report. + In order to get go the previous or next user report + As a teacher + I need to click on the previous/next navigation links + + Background: + Given the following "courses" exist: + | fullname | shortname | category | + | Course | C1 | 0 | + And the following "users" exist: + | username | firstname | lastname | email | idnumber | + | teacher1 | Teacher | 1 | teacher1@example.com | t1 | + | student1 | Student | 1 | student1@example.com | s1 | + | student2 | Student | 2 | student2@example.com | s2 | + | student3 | Student | 3 | student3@example.com | s3 | + And the following "course enrolments" exist: + | user | course | role | + | teacher1 | C1 | editingteacher | + | student1 | C1 | student | + | student2 | C1 | student | + | student3 | C1 | student | + And the following "activities" exist: + | activity | course | idnumber | name | intro | grade | + | assign | C1 | a1 | Test assignment one | Submit something! | 300 | + And I log in as "teacher1" + And I am on "Course" course homepage + + Scenario: A teacher can navigate to the next user report + Given I navigate to "View > User report" in the course gradebook + And I click on "Student 1" in the "user" search widget + And I should see "Student 1" in the ".user-heading" "css_element" + And ".previous" "css_element" should not exist in the ".user-navigation" "css_element" + And ".next" "css_element" should exist in the ".user-navigation" "css_element" + And I should see "Student 2" in the ".next" "css_element" + When I click on "Student 2" "link" in the ".next" "css_element" + Then I should see "Student 2" in the ".user-heading" "css_element" + And ".previous" "css_element" should exist in the ".user-navigation" "css_element" + And I should see "Student 1" in the ".previous" "css_element" + And ".next" "css_element" should exist in the ".user-navigation" "css_element" + And I should see "Student 3" in the ".next" "css_element" + And I click on "Student 3" "link" in the ".next" "css_element" + And I should see "Student 3" in the ".user-heading" "css_element" + And ".previous" "css_element" should exist in the ".user-navigation" "css_element" + And I should see "Student 2" in the ".previous" "css_element" + And ".next" "css_element" should not exist in the ".user-navigation" "css_element" + + Scenario: A teacher can navigate to the previous user report + Given I navigate to "View > User report" in the course gradebook + And I click on "Student 3" in the "user" search widget + And I should see "Student 3" in the ".user-heading" "css_element" + And ".previous" "css_element" should exist in the ".user-navigation" "css_element" + And I should see "Student 2" in the ".previous" "css_element" + And ".next" "css_element" should not exist in the ".user-navigation" "css_element" + When I click on "Student 2" "link" in the ".previous" "css_element" + Then I should see "Student 2" in the ".user-heading" "css_element" + And ".previous" "css_element" should exist in the ".user-navigation" "css_element" + And I should see "Student 1" in the ".previous" "css_element" + And ".next" "css_element" should exist in the ".user-navigation" "css_element" + And I should see "Student 3" in the ".next" "css_element" + And I click on "Student 1" "link" in the ".previous" "css_element" + And I should see "Student 1" in the ".user-heading" "css_element" + And ".previous" "css_element" should not exist in the ".user-navigation" "css_element" + And ".next" "css_element" should exist in the ".user-navigation" "css_element" + And I should see "Student 2" in the ".next" "css_element"