From 081b255ab05059b863c309c81853ffffff5c2bca Mon Sep 17 00:00:00 2001 From: Peter Dias Date: Mon, 14 Feb 2022 17:52:27 +0800 Subject: [PATCH] MDL-73462 navigation: Behat test update --- course/tests/behat/behat_course.php | 24 ++++++----- .../tests/behat/category_management.feature | 11 ++--- ...course_category_management_listing.feature | 40 +++++++++---------- .../behat/course_change_visibility.feature | 3 +- course/tests/behat/course_request.feature | 22 ++++++---- my/tests/behat/my_courses.feature | 2 +- .../behat/category_role_assignment.feature | 8 ++-- .../behat/category_role_assignment.feature | 10 ++--- 8 files changed, 62 insertions(+), 58 deletions(-) diff --git a/course/tests/behat/behat_course.php b/course/tests/behat/behat_course.php index 261ae7cd76d..fbf62e09234 100644 --- a/course/tests/behat/behat_course.php +++ b/course/tests/behat/behat_course.php @@ -93,7 +93,7 @@ class behat_course extends behat_base { // Go to course management page. $this->i_go_to_the_courses_management_page(); // Ensure you are on course management page. - $this->execute("behat_course::i_should_see_the_courses_management_page", get_string('categories')); + $this->execute("behat_course::i_should_see_the_courses_management_page", get_string('categoriesandcourses')); // Select default course category. $this->i_click_on_category_in_the_management_interface(get_string('defaultcategoryname')); @@ -1729,28 +1729,31 @@ class behat_course extends behat_base { * @param string $mode The mode to expected. One of 'Courses', 'Course categories' or 'Course categories and courses' */ public function i_should_see_the_courses_management_page($mode) { - $this->execute("behat_general::assert_element_contains_text", - array("Course and category management", "h2", "css_element") - ); - switch ($mode) { case "Courses": + $heading = "Manage courses"; $this->execute("behat_general::should_not_exist", array("#category-listing", "css_element")); $this->execute("behat_general::should_exist", array("#course-listing", "css_element")); break; case "Course categories": + $heading = "Manage course categories"; $this->execute("behat_general::should_exist", array("#category-listing", "css_element")); - $this->execute("behat_general::should_exist", array("#course-listing", "css_element")); + $this->execute("behat_general::should_not_exist", array("#course-listing", "css_element")); break; case "Courses categories and courses": default: + $heading = "Manage course categories and courses"; $this->execute("behat_general::should_exist", array("#category-listing", "css_element")); $this->execute("behat_general::should_exist", array("#course-listing", "css_element")); break; } + $this->execute("behat_general::assert_element_contains_text", + array($heading, "h2", "css_element") + ); + $this->execute("behat_general::should_not_exist", array("#course-detail", "css_element")); } @@ -1761,27 +1764,30 @@ class behat_course extends behat_base { * @param string $mode The mode to expected. One of 'Courses', 'Course categories' or 'Course categories and courses' */ public function i_should_see_the_courses_management_page_with_a_course_selected($mode) { - $this->execute("behat_general::assert_element_contains_text", - array("Course and category management", "h2", "css_element")); - switch ($mode) { case "Courses": + $heading = "Manage courses"; $this->execute("behat_general::should_not_exist", array("#category-listing", "css_element")); $this->execute("behat_general::should_exist", array("#course-listing", "css_element")); break; case "Course categories": + $heading = "Manage course categories"; $this->execute("behat_general::should_exist", array("#category-listing", "css_element")); $this->execute("behat_general::should_exist", array("#course-listing", "css_element")); break; case "Courses categories and courses": default: + $heading = "Manage course categories and courses"; $this->execute("behat_general::should_exist", array("#category-listing", "css_element")); $this->execute("behat_general::should_exist", array("#course-listing", "css_element")); break; } + $this->execute("behat_general::assert_element_contains_text", + array($heading, "h2", "css_element")); + $this->execute("behat_general::should_exist", array("#course-detail", "css_element")); } diff --git a/course/tests/behat/category_management.feature b/course/tests/behat/category_management.feature index 94772c03b23..309cd5babdc 100644 --- a/course/tests/behat/category_management.feature +++ b/course/tests/behat/category_management.feature @@ -242,18 +242,14 @@ Feature: Test category management actions And the following "courses" exist: | category | fullname | shortname | idnumber | | CAT1 | Course 1 | Course 1 | C1 | - And I log in as "admin" And I go to the courses management page And I should see the "Course categories and courses" management page - And I click on "assignroles" action for "Cat 1" in management category listing + And I click on "permissions" action for "Cat 1" in management category listing + And I select "Assign roles" from the "jump" singleselect # Redirect And I should see "Assign roles in Category: Cat 1" And I should see "Please choose a role to assign" - And I click on "Back" "button" - # Redirect - And I should see the "Course categories and courses" management page - And "Cat 1" "link" should exist in the "#category-listing" "css_element" Scenario: Test I can set access permissions for a category through the management interface. Given the following "categories" exist: @@ -271,8 +267,7 @@ Feature: Test category management actions And I should see "Permissions in Category: Cat 1" And I click on "Back to Category: Cat 1" "link" # Redirect - And I should see the "Course categories and courses" management page - And I should see "Cat 1" in the "#course-listing" "css_element" + And I should see "Cat 1" in the "h1" "css_element" Scenario: Test clicking to manage cohorts for a category through the management interface. Given the following "categories" exist: diff --git a/course/tests/behat/course_category_management_listing.feature b/course/tests/behat/course_category_management_listing.feature index 42e0987b69c..e6ba2dc5a3e 100644 --- a/course/tests/behat/course_category_management_listing.feature +++ b/course/tests/behat/course_category_management_listing.feature @@ -5,16 +5,23 @@ Feature: Course category management interface performs as expected I need to expand and collapse categories. @javascript - Scenario: Test general look of management interface + Scenario Outline: Test general look of management interface Given the following "categories" exist: | name | category | idnumber | | Cat 1 | 0 | CAT1 | And I log in as "admin" And I go to the courses management page - And I should see "Course and category management" in the "h2" "css_element" - And I should see "Course categories" in the ".view-mode-selector" "css_element" - And I should see "Course categories" in the "#page-content" "css_element" - And I should see the "Course categories and courses" management page + And I select "" from the "Viewing" singleselect + And I should see "" in the "h2" "css_element" + And I should see "" in the "Viewing" "select" + And I should see "" in the "#page-content" "css_element" + And I should see the "" management page + + Examples: + | heading | selected | pagecontent | + | Manage course categories and courses | Course categories and courses | Course categories | + | Manage course categories | Course categories | Course categories | + | Manage courses | Courses | Cat 1 | @javascript Scenario: Test view mode functionality @@ -30,20 +37,12 @@ Feature: Course category management interface performs as expected And I should see the "Course categories and courses" management page And I should see "Course categories" in the "#category-listing h3" "css_element" And I should see "Cat 1" in the "#category-listing" "css_element" - And I should see "Course categories" in the ".view-mode-selector" "css_element" - And I should not see "Course categories and courses" in the ".view-mode-selector .menu" "css_element" - And I should not see "Course categories" in the ".view-mode-selector .menu" "css_element" - And I should not see "Courses" in the ".view-mode-selector .menu" "css_element" - And I open the action menu in ".view-mode-selector" "css_element" + And I should see "Course categories" in the "Viewing" "select" + And the field "jump" matches value "Course categories and courses" And I start watching to see if a new page loads - Then I should see "Course categories and courses" in the ".view-mode-selector .menu" "css_element" - And I should see "Course categories" in the ".view-mode-selector .menu" "css_element" - And I should see "Courses" in the ".view-mode-selector .menu" "css_element" - And I click on "Course categories and courses" "link" in the ".view-mode-selector .menu" "css_element" - And a new page should have loaded since I started watching - And I start watching to see if a new page loads - And I should see the "Course categories and courses" management page - And I should see "Course categories" in the "#category-listing h3" "css_element" + Then I should see "Course categories and courses" in the "Viewing" "select" + And I should see "Course categories" in the "Viewing" "select" + And I should see "Courses" in the "Viewing" "select" And I should see "Category 1" in the "#course-listing h3" "css_element" And I should see "Cat 1" in the "#category-listing" "css_element" And I should see "No courses in this category" in the "#course-listing" "css_element" @@ -55,9 +54,8 @@ Feature: Course category management interface performs as expected And I should see "Cat 1" in the "#course-listing h3" "css_element" And I should see "Cat 1" in the "#category-listing" "css_element" And I should see "Course 1" in the "#course-listing" "css_element" - And I open the action menu in ".view-mode-selector" "css_element" - Then I should see "Courses" in the ".view-mode-selector .menu" "css_element" - And I click on "Courses" "link" in the ".view-mode-selector .menu" "css_element" + Then I should see "Courses" in the "Viewing" "select" + And I select "Courses" from the "jump" singleselect And a new page should have loaded since I started watching And I start watching to see if a new page loads And I should see the "Courses" management page diff --git a/course/tests/behat/course_change_visibility.feature b/course/tests/behat/course_change_visibility.feature index 70f2addba6a..fd175fac1c4 100644 --- a/course/tests/behat/course_change_visibility.feature +++ b/course/tests/behat/course_change_visibility.feature @@ -94,8 +94,7 @@ Feature: We can change the visibility of courses in the management interface. And course in management listing should be dimmed "C1" And I toggle visibility of category "CAT1" in management listing And I toggle visibility of course "C1" in management listing - And I open the action menu in ".view-mode-selector" "css_element" - And I click on "Courses" "link" in the ".view-mode-selector" "css_element" + And I select "Courses" from the "Viewing" singleselect And a new page should have loaded since I started watching And I start watching to see if a new page loads And I should see "Course 1" in the "#course-listing ul.course-list" "css_element" diff --git a/course/tests/behat/course_request.feature b/course/tests/behat/course_request.feature index 6fc76aa271c..f9ba5f7b3c9 100644 --- a/course/tests/behat/course_request.feature +++ b/course/tests/behat/course_request.feature @@ -1,4 +1,4 @@ -@core @core_course +@core @core_course @javascript Feature: Users can request and approve courses As a moodle admin In order to improve course creation process @@ -24,7 +24,8 @@ Feature: Users can request and approve courses And I log out When I log in as "user1" And I am on course index - And I press "Request a course" + And I click on "More actions" "button" + And I click on "Request a course" "link" And I set the following fields to these values: | Course full name | My new course | | Course short name | Mynewcourse | @@ -37,7 +38,8 @@ Feature: Users can request and approve courses And I log out And I log in as "user2" And I am on course index - And I press "Courses pending approval" + And I click on "More actions" "button" + And I click on "Courses pending approval" "link" And I should see "Category 1" in the "My new course" "table_row" And I click on "Approve" "button" in the "My new course" "table_row" And I press "Save and return" @@ -75,8 +77,9 @@ Feature: Users can request and approve courses And I log in as "user1" And I am on course index And I follow "English category" - And I press "Request a course" - And the "Course category" select box should contain "English category" + And I click on "More actions" "button" + And I click on "Request a course" "link" + And I should see "English category" in the ".form-autocomplete-selection" "css_element" And I set the following fields to these values: | Course full name | My new course | | Course short name | Mynewcourse | @@ -86,17 +89,20 @@ Feature: Users can request and approve courses And I log in as "user2" And I am on course index And I follow "English category" - And "Courses pending approval" "button" should not exist + And I should not see "More" in the "region-main" "region" + And I should not see "Courses pending approval" And I am on course index And I follow "Science category" - And I press "Courses pending approval" + And I click on "More actions" "button" + And I click on "Courses pending approval" "link" And I should not see "Mynewcourse" And I press "Back to course listing" And I log out And I log in as "user3" And I am on course index And I follow "English category" - And I press "Courses pending approval" + And I click on "More actions" "button" + And I click on "Courses pending approval" "link" And I should see "English category" in the "Mynewcourse" "table_row" And I click on "Approve" "button" in the "Mynewcourse" "table_row" And I press "Save and return" diff --git a/my/tests/behat/my_courses.feature b/my/tests/behat/my_courses.feature index bddf5f1e542..8814c7e0c1e 100644 --- a/my/tests/behat/my_courses.feature +++ b/my/tests/behat/my_courses.feature @@ -10,4 +10,4 @@ Feature: Run tests over my courses. And I am on the "My courses" page And I click on "Course management options" "link" And I click on "Manage courses" "link" - And I should see "Course and category management" + And I should see "Manage course categories and courses" diff --git a/theme/boost/tests/behat/category_role_assignment.feature b/theme/boost/tests/behat/category_role_assignment.feature index 3a3d6fd9951..00a8ffb3cac 100644 --- a/theme/boost/tests/behat/category_role_assignment.feature +++ b/theme/boost/tests/behat/category_role_assignment.feature @@ -1,4 +1,4 @@ -@core @core_course +@core @core_course @theme_boost Feature: Role assignments can be made at the category level In order to grant a user different capabilities As a user @@ -24,7 +24,8 @@ Feature: Role assignments can be made at the category level And I log in as "manager" And I am on course index When I follow "Cat 1" - Then "Assign roles" "link" should exist in current page administration + And I navigate to "Permissions" in current page administration + Then I should see "Assign roles" in the "jump" "select" @javascript Scenario: A user with a category role cannot assign roles if there are no roles to assign @@ -39,4 +40,5 @@ Feature: Role assignments can be made at the category level And I log in as "manager" And I am on course index When I follow "Cat 1" - Then "Assign roles" "link" should not exist in current page administration + And I navigate to "Permissions" in current page administration + Then I should not see "Assign roles" in the "jump" "select" diff --git a/theme/classic/tests/behat/category_role_assignment.feature b/theme/classic/tests/behat/category_role_assignment.feature index 865050c30ec..f2656275899 100644 --- a/theme/classic/tests/behat/category_role_assignment.feature +++ b/theme/classic/tests/behat/category_role_assignment.feature @@ -1,5 +1,5 @@ -@core @core_course -Feature: Role assignments can be made at the category level +@core @core_course @theme_classic +Feature: Role assignments can be made at the category level in classic In order to grant a user different capabilities As a user I can assign roles in categories @@ -24,8 +24,7 @@ Feature: Role assignments can be made at the category level And I log in as "manager" And I am on course index When I follow "Cat 1" - And I navigate to "Permissions" in current page administration - Then I should see "Assign roles" in the "jump" "select" + Then "Assign roles" "link" should exist in current page administration @javascript Scenario: A user with a category role cannot assign roles if there are no roles to assign @@ -40,5 +39,4 @@ Feature: Role assignments can be made at the category level And I log in as "manager" And I am on course index When I follow "Cat 1" - And I navigate to "Permissions" in current page administration - Then I should not see "Assign roles" in the "jump" "select" + Then "Assign roles" "link" should not exist in current page administration