From f87d36d750b17b6ca990ca6460ddc875472ced7b Mon Sep 17 00:00:00 2001 From: Amaia Anabitarte Date: Fri, 22 Nov 2024 12:15:37 +0100 Subject: [PATCH] MDL-82034 core_course: Fix Activity chooser opening issues on behat --- .../tests/behat/testscenario_steps.feature | 2 +- .../behat/default_activity_completion.feature | 9 ++- .../tests/behat/create_course.feature | 1 - .../tests/behat/edit_format_course.feature | 1 - .../behat/course_manageactivities.feature | 2 + .../templates/activitychooserbutton.mustache | 4 ++ course/tests/behat/activity_chooser.feature | 68 ++++++++++--------- .../tests/behat/activity_chooser_plus.feature | 13 ++-- course/tests/behat/behat_course.php | 15 +++- .../restrict_available_activities.feature | 2 +- .../tests/behat/default_grade_values.feature | 4 +- mod/data/tests/behat/create_activity.feature | 4 +- mod/lti/tests/behat/managecoursetools.feature | 16 ++--- .../tests/behat/default_completion.feature | 11 +-- .../subsection_access_restrictions.feature | 3 +- .../tests/behat/subsection_actionmenu.feature | 3 +- .../tests/behat/subsection_coursepage.feature | 3 +- .../behat/subsection_disabled_plugin.feature | 3 +- .../tests/behat/subsection_limit.feature | 3 +- .../tests/behat/subsection_navigation.feature | 3 +- .../behat/subsection_no_completion.feature | 3 +- .../tests/behat/subsection_rename.feature | 3 +- .../behat/subsection_sectionpage.feature | 10 +-- .../tests/behat/subsection_visibility.feature | 3 +- .../behat/subsection_visibility_badge.feature | 3 +- .../tests/behat/subsection_reports.feature | 3 +- report/outline/tests/behat/outline.feature | 3 +- .../tests/behat/subsection_reports.feature | 3 +- 28 files changed, 108 insertions(+), 93 deletions(-) diff --git a/admin/tool/generator/tests/behat/testscenario_steps.feature b/admin/tool/generator/tests/behat/testscenario_steps.feature index d14e63ffb25..28a50669951 100644 --- a/admin/tool/generator/tests/behat/testscenario_steps.feature +++ b/admin/tool/generator/tests/behat/testscenario_steps.feature @@ -13,6 +13,6 @@ Feature: Make test scenario can execute specific steps And I press "Import" And I should see "Scenario: Course with some disabled plugins" When I am on "C1" course homepage with editing mode on - And I click on "Add an activity or resource" "button" in the "Section 1" "section" + And I open the activity chooser Then I should see "Page" in the "Add an activity or resource" "dialogue" And I should not see "Book" in the "Add an activity or resource" "dialogue" diff --git a/completion/tests/behat/default_activity_completion.feature b/completion/tests/behat/default_activity_completion.feature index 1d203700168..b4fa3657ea2 100644 --- a/completion/tests/behat/default_activity_completion.feature +++ b/completion/tests/behat/default_activity_completion.feature @@ -43,7 +43,8 @@ Feature: Allow teachers to edit the default activity completion rules in a cours | completionview_assign | 0 | And I click on "Save changes" "button" in the "[data-region='activitycompletion-assign']" "css_element" And I am on "Course 1" course homepage with editing mode on - And I click on "Add an activity or resource" "button" in the "New section" "section" + And I click on "Add content" "button" in the "New section" "section" + And I click on "Activity or resource" "button" in the "New section" "section" And I click on "Add a new Assignment" "link" in the "Add an activity or resource" "dialogue" And I expand all fieldsets # Completion tracking 2 = Add requirements. @@ -83,7 +84,8 @@ Feature: Allow teachers to edit the default activity completion rules in a cours And I click on "Save changes" "button" in the "[data-region='activitycompletion-forum']" "css_element" Then I should see "Changes saved" And I am on "Course 1" course homepage with editing mode on - And I click on "Add an activity or resource" "button" in the "New section" "section" + And I click on "Add content" "button" in the "New section" "section" + And I click on "Activity or resource" "button" in the "New section" "section" And I click on "Add a new Forum" "link" in the "Add an activity or resource" "dialogue" And I expand all fieldsets # Completion tracking 2 = Add requirements. @@ -122,7 +124,8 @@ Feature: Allow teachers to edit the default activity completion rules in a cours And I click on "Save changes" "button" in the "[data-region='activitycompletion-glossary']" "css_element" Then I should see "Changes saved" And I am on "Course 1" course homepage with editing mode on - And I click on "Add an activity or resource" "button" in the "New section" "section" + And I click on "Add content" "button" in the "New section" "section" + And I click on "Activity or resource" "button" in the "New section" "section" And I click on "Add a new Glossary" "link" in the "Add an activity or resource" "dialogue" And I expand all fieldsets # Completion tracking 2 = Add requirements. diff --git a/course/format/singleactivity/tests/behat/create_course.feature b/course/format/singleactivity/tests/behat/create_course.feature index 057709d460e..de1abe860e7 100644 --- a/course/format/singleactivity/tests/behat/create_course.feature +++ b/course/format/singleactivity/tests/behat/create_course.feature @@ -21,7 +21,6 @@ Feature: Courses can be created in Single Activity mode | moodle/course:manageactivities | allow | | moodle/course:viewparticipants | allow | | moodle/role:assign | allow | - And I enable "subsection" "mod" plugin When I log in as "kevin" And I am on site homepage And I press "Add a new course" diff --git a/course/format/singleactivity/tests/behat/edit_format_course.feature b/course/format/singleactivity/tests/behat/edit_format_course.feature index fff755b6469..e5df4eb02f5 100644 --- a/course/format/singleactivity/tests/behat/edit_format_course.feature +++ b/course/format/singleactivity/tests/behat/edit_format_course.feature @@ -14,7 +14,6 @@ Feature: Edit format course to Single Activity format And the following "course enrolments" exist: | user | course | role | | teacher1 | C1 | editingteacher | - And I enable "subsection" "mod" plugin And I log in as "teacher1" And I am on "Course 1" course homepage When I navigate to "Settings" in current page administration diff --git a/course/format/tests/behat/course_manageactivities.feature b/course/format/tests/behat/course_manageactivities.feature index de3614dc2b9..0d1239af7f6 100644 --- a/course/format/tests/behat/course_manageactivities.feature +++ b/course/format/tests/behat/course_manageactivities.feature @@ -36,7 +36,9 @@ Feature: Verify edit utils availability Given I log in as "teacher1" When I am on "Course 1" course homepage And I turn editing mode on + And I open the activity chooser Then I should see "Add an activity or resource" + And I click on "Close" "button" in the "Add an activity or resource" "dialogue" And I open "Activity sample 1" actions menu And I should see "Edit settings" And ".section_action_menu" "css_element" should exist in the "Section 1" "section" diff --git a/course/templates/activitychooserbutton.mustache b/course/templates/activitychooserbutton.mustache index 673135bcba8..4f6997132f8 100644 --- a/course/templates/activitychooserbutton.mustache +++ b/course/templates/activitychooserbutton.mustache @@ -41,6 +41,10 @@ type="button" id="dropdownMenuButton-{{#modid}}{{modid}}{{/modid}}{{^modid}}{{uniqid}}{{/modid}}" data-toggle="dropdown" + data-action="open-addingcontent" + {{#modid}} + data-beforemod="{{modid}}" + {{/modid}} aria-haspopup="true" aria-expanded="false" aria-label="{{#str}}insertcontentbefore, core, { "activityname": {{#quote}} {{activityname}} {{/quote}} } {{/str}}" diff --git a/course/tests/behat/activity_chooser.feature b/course/tests/behat/activity_chooser.feature index cc8731a4706..d340efa6ad6 100644 --- a/course/tests/behat/activity_chooser.feature +++ b/course/tests/behat/activity_chooser.feature @@ -22,39 +22,40 @@ Feature: Display and choose from the available activities in course And I am on "Course" course homepage with editing mode on Scenario: The available activities are displayed to the teacher in the activity chooser - Given I click on "Add an activity or resource" "button" in the "New section" "section" + Given I open the activity chooser Then I should see "Add an activity or resource" in the ".modal-title" "css_element" And I should see "Assignment" in the ".modal-body" "css_element" Scenario: The teacher can choose to add an activity from the activity items in the activity chooser - Given I click on "Add an activity or resource" "button" in the "New section" "section" + Given I open the activity chooser When I click on "Add a new Assignment" "link" in the "Add an activity or resource" "dialogue" Then I should see "New Assignment" And I set the following fields to these values: | Assignment name | Test Assignment | And I press "Save and return to course" - Then I should see "Test Assignment" in the "New section" "section" + Then I should see "Test Assignment" in the "General" "section" Scenario: The teacher can choose to add an activity from the activity summary in the activity chooser - Given I click on "Add an activity or resource" "button" in the "New section" "section" + Given I open the activity chooser When I click on "Information about the Assignment activity" "button" in the "Add an activity or resource" "dialogue" When I click on "Add a new Assignment" "link" in the "help" "core_course > Activity chooser screen" Then I should see "New Assignment" Scenario: Show summary - Given I click on "Add an activity or resource" "button" in the "New section" "section" + Given I open the activity chooser When I click on "Information about the Assignment activity" "button" in the "Add an activity or resource" "dialogue" Then I should see "Assignment" in the "help" "core_course > Activity chooser screen" And I should see "The assignment activity module enables a teacher to communicate tasks, collect work and provide grades and feedback." # Confirm show summary also works for weekly format course And I am on "C2" course homepage with editing mode on - And I click on "Add an activity or resource" "button" in the "13 January - 19 January" "section" + And I click on "Add content" "button" in the "13 January - 19 January" "section" + And I click on "Activity or resource" "button" in the "13 January - 19 January" "section" And I click on "Information about the Assignment activity" "button" in the "Add an activity or resource" "dialogue" And I should see "Assignment" in the "help" "core_course > Activity chooser screen" And I should see "The assignment activity module enables a teacher to communicate tasks, collect work and provide grades and feedback." Scenario: Hide summary - Given I click on "Add an activity or resource" "button" in the "New section" "section" + Given I open the activity chooser When I click on "Information about the Assignment activity" "button" in the "modules" "core_course > Activity chooser screen" And I should see "The assignment activity module enables a teacher to communicate tasks, collect work and provide grades and feedback." in the "help" "core_course > Activity chooser screen" And I should see "Back" in the "help" "core_course > Activity chooser screen" @@ -65,7 +66,8 @@ Feature: Display and choose from the available activities in course And I should not see "The assignment activity module enables a teacher to communicate tasks, collect work and provide grades and feedback." in the "Add an activity or resource" "dialogue" # Confirm hide summary also works for weekly format course And I am on "C2" course homepage with editing mode on - And I click on "Add an activity or resource" "button" in the "13 January - 19 January" "section" + And I click on "Add content" "button" in the "13 January - 19 January" "section" + And I click on "Activity or resource" "button" in the "13 January - 19 January" "section" And I click on "Information about the Assignment activity" "button" in the "Add an activity or resource" "dialogue" And I click on "Back" "button" in the "help" "core_course > Activity chooser screen" And "modules" "core_course > Activity chooser screen" should be visible @@ -104,7 +106,8 @@ Feature: Display and choose from the available activities in course And I click on "Star Forum activity" "button" in the "Add an activity or resource" "dialogue" And I should see "Starred" in the "Add an activity or resource" "dialogue" And I click on "Close" "button" in the "Add an activity or resource" "dialogue" - When I click on "Add an activity or resource" "button" in the "New section" "section" + And I click on "Add content" "button" in the "New section" "section" + And I click on "Activity or resource" "button" in the "New section" "section" And I click on "Starred" "link" in the "Add an activity or resource" "dialogue" Then I should see "Forum" in the "favourites" "core_course > Activity chooser tab" @@ -116,7 +119,7 @@ Feature: Display and choose from the available activities in course Then I should not see "Starred" in the "Add an activity or resource" "dialogue" Scenario: The teacher can search for an activity by it's name - Given I click on "Add an activity or resource" "button" in the "New section" "section" + Given I open the activity chooser When I set the field "search" to "Lesson" Then I should see "1 results found" in the "Add an activity or resource" "dialogue" And I should see "Lesson" in the "Add an activity or resource" "dialogue" @@ -128,13 +131,13 @@ Feature: Display and choose from the available activities in course And I should see "Lesson" in the "Add an activity or resource" "dialogue" Scenario: Search results are not returned if the search query does not match any activity name or description - Given I click on "Add an activity or resource" "button" in the "New section" "section" + Given I open the activity chooser When I set the field "search" to "Random search query" Then I should see "0 results found" in the "Add an activity or resource" "dialogue" And ".option" "css_element" should not exist in the ".searchresultitemscontainer" "css_element" Scenario: Teacher can return to the default activity chooser state by manually removing the search query - Given I click on "Add an activity or resource" "button" in the "New section" "section" + Given I open the activity chooser And I set the field "search" to "Lesson" And I should see "1 results found" in the "Add an activity or resource" "dialogue" And I should see "Lesson" in the "Add an activity or resource" "dialogue" @@ -144,16 +147,16 @@ Feature: Display and choose from the available activities in course And ".optionscontainer" "css_element" should exist Scenario: Teacher can not see a "clear" button if a search query is not entered in the activity chooser search bar - When I click on "Add an activity or resource" "button" in the "New section" "section" + When I open the activity chooser Then "Clear search input" "button" should not be visible Scenario: Teacher can see a "clear" button after entering a search query in the activity chooser search bar - Given I click on "Add an activity or resource" "button" in the "New section" "section" + Given I open the activity chooser When I set the field "search" to "Search query" Then "Clear search input" "button" should not be visible Scenario: Teacher can not see a "clear" button if the search query is removed in the activity chooser search bar - Given I click on "Add an activity or resource" "button" in the "New section" "section" + Given I open the activity chooser And I set the field "search" to "Search query" And "Clear search input" "button" should exist When I set the field "search" to "" @@ -162,7 +165,7 @@ Feature: Display and choose from the available activities in course Then "Clear search input" "button" should not be visible Scenario: Teacher can instantly remove the search query from the activity search bar by clicking on the "clear" button - Given I click on "Add an activity or resource" "button" in the "New section" "section" + Given I open the activity chooser And I set the field "search" to "Search query" And I should see "results found" in the "Add an activity or resource" "dialogue" When I click on "Clear search input" "button" @@ -171,7 +174,7 @@ Feature: Display and choose from the available activities in course And ".optionscontainer" "css_element" should exist Scenario: Teacher gets the base case for the Activity Chooser tab mode - Given I click on "Add an activity or resource" "button" in the "New section" "section" + Given I open the activity chooser And I should see "Activities" in the "Add an activity or resource" "dialogue" When I click on "Activities" "link" in the "Add an activity or resource" "dialogue" Then I should not see "Book" in the "activity" "core_course > Activity chooser tab" @@ -188,7 +191,7 @@ Feature: Display and choose from the available activities in course And I log out And I log in as "teacher" And I am on "Course" course homepage with editing mode on - And I click on "Add an activity or resource" "button" in the "New section" "section" + And I open the activity chooser Then I should not see "Activities" in the "Add an activity or resource" "dialogue" And I should not see "Resources" in the "Add an activity or resource" "dialogue" @@ -202,7 +205,7 @@ Feature: Display and choose from the available activities in course And I log out And I log in as "teacher" And I am on "Course" course homepage with editing mode on - And I click on "Add an activity or resource" "button" in the "New section" "section" + And I open the activity chooser Then I should not see "All" in the "Add an activity or resource" "dialogue" And I should see "Activities" in the "Add an activity or resource" "dialogue" And I should see "Resources" in the "Add an activity or resource" "dialogue" @@ -218,41 +221,41 @@ Feature: Display and choose from the available activities in course And I log out And I log in as "teacher" And I am on "Course" course homepage with editing mode on - When I click on "Add an activity or resource" "button" in the "New section" "section" + When I open the activity chooser Then "Recommended" "link" should appear before "All" "link" in the "Add an activity or resource" "dialogue" But the following config values are set as admin: # 0 = Starred, All, Activities, Resources, Recommended | activitychoosertabmode | 0 | And I reload the page - And I click on "Add an activity or resource" "button" in the "New section" "section" + And I open the activity chooser And "Recommended" "link" should appear after "Resources" "link" in the "Add an activity or resource" "dialogue" But the following config values are set as admin: # 1 = Starred, All, Recommended | activitychoosertabmode | 1 | And I reload the page - And I click on "Add an activity or resource" "button" in the "New section" "section" + And I open the activity chooser And "Recommended" "link" should appear after "All" "link" in the "Add an activity or resource" "dialogue" But the following config values are set as admin: # 2 = Starred, Activities, Resources, Recommended | activitychoosertabmode | 2 | And I reload the page - And I click on "Add an activity or resource" "button" in the "New section" "section" + And I open the activity chooser And "Recommended" "link" should appear after "Resources" "link" in the "Add an activity or resource" "dialogue" But the following config values are set as admin: # 4 = Starred, Recommended, All | activitychoosertabmode | 4 | And I reload the page - And I click on "Add an activity or resource" "button" in the "New section" "section" + And I open the activity chooser And "Recommended" "link" should appear before "All" "link" in the "Add an activity or resource" "dialogue" But the following config values are set as admin: # 5 = Starred, Recommended, Activities, Resources | activitychoosertabmode | 5 | And I reload the page - And I click on "Add an activity or resource" "button" in the "New section" "section" + And I open the activity chooser And "Recommended" "link" should appear before "Activities" "link" in the "Add an activity or resource" "dialogue" Scenario: Teacher can navigate through activity chooser in Topics format course - When I click on "Add an activity or resource" "button" in the "New section" "section" + When I open the activity chooser Then I should see "All" in the "Add an activity or resource" "dialogue" And I press the tab key And I press the tab key @@ -268,14 +271,15 @@ Feature: Display and choose from the available activities in course # Confirm clicking "x" button closes modal And I click on "Close" "button" in the "Add an activity or resource" "dialogue" And "Add an activity or resource" "dialogue" should not be visible - And I click on "Add an activity or resource" "button" in the "New section" "section" + And I open the activity chooser # Confirm escape key closes the modal And I press the escape key And "Add an activity or resource" "dialogue" should not be visible Scenario: Teacher can navigate through activity chooser in Weekly format course Given I am on "C2" course homepage with editing mode on - When I click on "Add an activity or resource" "button" in the "13 January - 19 January" "section" + And I click on "Add content" "button" in the "13 January - 19 January" "section" + When I click on "Activity or resource" "button" in the "13 January - 19 January" "section" Then I should see "All" in the "Add an activity or resource" "dialogue" And I press the tab key And I press the tab key @@ -291,13 +295,14 @@ Feature: Display and choose from the available activities in course # Confirm clicking "x" button closes modal And I click on "Close" "button" in the "Add an activity or resource" "dialogue" And "Add an activity or resource" "dialogue" should not be visible - And I click on "Add an activity or resource" "button" in the "13 January - 19 January" "section" + And I click on "Add content" "button" in the "13 January - 19 January" "section" + And I click on "Activity or resource" "button" in the "13 January - 19 January" "section" # Confirm escape key closes the modal And I press the escape key And "Add an activity or resource" "dialogue" should not be visible Scenario: Teacher can access 'More help' from activity information in activity chooser - Given I click on "Add an activity or resource" "button" in the "New section" "section" + Given I open the activity chooser When I click on "Information about the Assignment activity" "button" in the "Add an activity or resource" "dialogue" # Confirm more help link exists Then "More help" "link" should exist @@ -307,7 +312,8 @@ Feature: Display and choose from the available activities in course And "Opens in new window" "link" should be visible # Confirm the same behaviour for weekly format course And I am on "C2" course homepage with editing mode on - And I click on "Add an activity or resource" "button" in the "13 January - 19 January" "section" + And I click on "Add content" "button" in the "13 January - 19 January" "section" + And I click on "Activity or resource" "button" in the "13 January - 19 January" "section" And I should see "All" in the "Add an activity or resource" "dialogue" And I click on "Information about the Assignment activity" "button" in the "Add an activity or resource" "dialogue" # Confirm more help link exists diff --git a/course/tests/behat/activity_chooser_plus.feature b/course/tests/behat/activity_chooser_plus.feature index 876e9321292..f87a7baf37b 100644 --- a/course/tests/behat/activity_chooser_plus.feature +++ b/course/tests/behat/activity_chooser_plus.feature @@ -26,14 +26,15 @@ Feature: Use the activity chooser to insert activities anywhere in a section Scenario: The activity chooser icon is hidden by default and be made visible on hover Given I hover ".navbar-brand" "css_element" - And "Insert an activity or resource before 'Test Forum'" "button" should not be visible - When I hover "Insert an activity or resource before 'Test Forum'" "button" - Then "Insert an activity or resource before 'Test Forum'" "button" should be visible + And "Insert content before 'Test Forum'" "button" should not be visible + When I hover "Insert content before 'Test Forum'" "button" + Then "Insert content before 'Test Forum'" "button" should be visible Scenario: The activity chooser can be used to insert modules before existing modules - Given I hover "Insert an activity or resource before 'Test Forum'" "button" - And I press "Insert an activity or resource before 'Test Forum'" - And I should see "Add an activity or resource" in the ".modal-title" "css_element" + Given I change window size to "large" + And I hover "Insert content before 'Test Forum'" "button" + And I press "Insert content before 'Test Forum'" + And I click on "Activity or resource" "button" in the ".dropdown .show" "css_element" When I click on "Add a new Assignment" "link" in the "Add an activity or resource" "dialogue" And I set the following fields to these values: | Assignment name | Test Assignment | diff --git a/course/tests/behat/behat_course.php b/course/tests/behat/behat_course.php index 26452572235..ac689614ed1 100644 --- a/course/tests/behat/behat_course.php +++ b/course/tests/behat/behat_course.php @@ -275,8 +275,10 @@ class behat_course extends behat_base { $this->require_javascript('Please use the \'the following "activity" exists:\' data generator instead.'); + $infrontpage = false; if ($this->getSession()->getPage()->find('css', 'body#page-site-index') && (int) $sectionnum <= 1) { // We are on the frontpage. + $infrontpage = true; if ($sectionnum) { // Section 1 represents the contents on the frontpage. $sectionxpath = "//body[@id='page-site-index']" . @@ -292,6 +294,14 @@ class behat_course extends behat_base { // Clicks add activity or resource section link. $sectionnode = $this->find('xpath', $sectionxpath); + if (!$infrontpage) { + $this->execute('behat_general::i_click_on_in_the', [ + "//button[@data-action='open-addingcontent' and not(@data-beforemod)]", + 'xpath', + $sectionnode, + 'NodeElement', + ]); + } $this->execute('behat_general::i_click_on_in_the', [ "//button[@data-action='open-chooser' and not(@data-beforemod)]", 'xpath', @@ -2157,8 +2167,11 @@ class behat_course extends behat_base { * @Given /^I open the activity chooser$/ */ public function i_open_the_activity_chooser() { + // Open the "Activity or resource and Subsection" dropdown first. $this->execute('behat_general::i_click_on', - array('//button[@data-action="open-chooser"]', 'xpath_element')); + ['//button[@data-action="open-addingcontent"]', 'xpath_element']); + $this->execute('behat_general::i_click_on', + ['//button[@data-action="open-chooser"]', 'xpath_element']); $node = $this->get_selected_node('xpath_element', '//div[@data-region="modules"]'); $this->ensure_node_is_visible($node); diff --git a/course/tests/behat/restrict_available_activities.feature b/course/tests/behat/restrict_available_activities.feature index 2ca3e8d2a64..0400dfd9439 100644 --- a/course/tests/behat/restrict_available_activities.feature +++ b/course/tests/behat/restrict_available_activities.feature @@ -38,6 +38,6 @@ Feature: Restrict activities availability And I log out And I log in as "teacher1" When I am on "Course 1" course homepage with editing mode on - And I click on "Add an activity or resource" "button" in the "New section" "section" + And I open the activity chooser Then "Add a new Assignment" "link" should not exist in the "Add an activity or resource" "dialogue" Then "Add a new Glossary" "link" should not exist in the "Add an activity or resource" "dialogue" diff --git a/mod/assign/tests/behat/default_grade_values.feature b/mod/assign/tests/behat/default_grade_values.feature index bf41c0c8210..4fb5f8605db 100644 --- a/mod/assign/tests/behat/default_grade_values.feature +++ b/mod/assign/tests/behat/default_grade_values.feature @@ -24,8 +24,8 @@ Feature: Assignments can have default grades and scales defined When I am on the "Course 1" course page logged in as teacher1 And I wait until the page is ready And I switch editing mode on - And I click on "Add an activity or resource" "button" - And I follow "Assignment" + And I open the activity chooser + And I click on "Add a new Assignment" "link" in the "Add an activity or resource" "dialogue" And I set the following fields to these values: | name | Test assignment | Then the following fields match these values: diff --git a/mod/data/tests/behat/create_activity.feature b/mod/data/tests/behat/create_activity.feature index da6ed205deb..f1d58a6f05f 100644 --- a/mod/data/tests/behat/create_activity.feature +++ b/mod/data/tests/behat/create_activity.feature @@ -20,7 +20,7 @@ Feature: Teachers can enable comments only if comments are enabled at site level @javascript Scenario: Teacher can enable comments if they are enabled at site level - Given I press "Add an activity or resource" + Given I open the activity chooser And I click on "Add a new Database" "link" in the "Add an activity or resource" "dialogue" When I expand all fieldsets And "Allow comments on entries" "field" should exist @@ -34,7 +34,7 @@ Feature: Teachers can enable comments only if comments are enabled at site level # Disable comments in site config. Given the following config values are set as admin: | usecomments | 0 | - And I press "Add an activity or resource" + And I open the activity chooser And I click on "Add a new Database" "link" in the "Add an activity or resource" "dialogue" When I expand all fieldsets And I set the field "Name" to "Test Database name 2" diff --git a/mod/lti/tests/behat/managecoursetools.feature b/mod/lti/tests/behat/managecoursetools.feature index 6a1fb22a552..a15e7207bb3 100644 --- a/mod/lti/tests/behat/managecoursetools.feature +++ b/mod/lti/tests/behat/managecoursetools.feature @@ -171,7 +171,7 @@ Feature: Manage course tools | teacher1 | C2 | editingteacher | And I log in as "teacher1" And I am on "Course 1" course homepage with editing mode on - And I click on "Add an activity or resource" "button" in the "New section" "section" + And I open the activity chooser And I should see "Teaching Tool 1" in the ".modal-body" "css_element" And I should not see "Teaching Tool 2" in the ".modal-body" "css_element" And I should not see "Teaching Tool 3" in the ".modal-body" "css_element" @@ -181,7 +181,7 @@ Feature: Manage course tools And I click on "Don't show in activity chooser" "field" in the "Teaching Tool 1" "table_row" And I click on "Show in activity chooser" "field" in the "Teaching Tool 2" "table_row" And I am on "Course 1" course homepage - And I click on "Add an activity or resource" "button" in the "New section" "section" + And I open the activity chooser And I should not see "Teaching Tool 1" in the ".modal-body" "css_element" And I should see "Teaching Tool 2" in the ".modal-body" "css_element" And I should not see "Teaching Tool 3" in the ".modal-body" "css_element" @@ -189,7 +189,7 @@ Feature: Manage course tools # Should not affect other courses. And I am on "Course 2" course homepage - And I click on "Add an activity or resource" "button" in the "New section" "section" + And I open the activity chooser And I should see "Teaching Tool 1" in the ".modal-body" "css_element" And I should not see "Teaching Tool 2" in the ".modal-body" "css_element" And I should not see "Teaching Tool 3" in the ".modal-body" "css_element" @@ -200,7 +200,7 @@ Feature: Manage course tools And I click on "Show in activity chooser" "field" in the "Teaching Tool 1" "table_row" And I click on "Don't show in activity chooser" "field" in the "Teaching Tool 2" "table_row" And I am on "Course 1" course homepage - And I click on "Add an activity or resource" "button" in the "New section" "section" + And I open the activity chooser And I should see "Teaching Tool 1" in the ".modal-body" "css_element" And I should not see "Teaching Tool 2" in the ".modal-body" "css_element" And I should not see "Teaching Tool 3" in the ".modal-body" "css_element" @@ -221,7 +221,7 @@ Feature: Manage course tools | Course Tool 2 | /mod/lti/tests/fixtures/tool_provider.php | C1 | 1 | And I log in as "teacher1" And I am on "Course 1" course homepage with editing mode on - And I click on "Add an activity or resource" "button" in the "New section" "section" + And I open the activity chooser And I should see "Course Tool 1" in the ".modal-body" "css_element" And I should not see "Course Tool 2" in the ".modal-body" "css_element" And I click on "Close" "button" in the ".modal-dialog" "css_element" @@ -229,7 +229,7 @@ Feature: Manage course tools And I click on "Don't show in activity chooser" "field" in the "Course Tool 1" "table_row" And I click on "Show in activity chooser" "field" in the "Course Tool 2" "table_row" And I am on "Course 1" course homepage - And I click on "Add an activity or resource" "button" in the "New section" "section" + And I open the activity chooser And I should not see "Course Tool 1" in the ".modal-body" "css_element" And I should see "Course Tool 2" in the ".modal-body" "css_element" And I click on "Close" "button" in the ".modal-dialog" "css_element" @@ -237,7 +237,7 @@ Feature: Manage course tools And I click on "Show in activity chooser" "field" in the "Course Tool 1" "table_row" And I click on "Don't show in activity chooser" "field" in the "Course Tool 2" "table_row" And I am on "Course 1" course homepage - And I click on "Add an activity or resource" "button" in the "New section" "section" + And I open the activity chooser And I should see "Course Tool 1" in the ".modal-body" "css_element" And I should not see "Course Tool 2" in the ".modal-body" "css_element" @@ -279,7 +279,7 @@ Feature: Manage course tools And I restore "test_backup.mbz" backup into a new course using this options: | Schema | Course name | Restored course | And I should see "Restored course" - And I click on "Add an activity or resource" "button" in the "General" "section" + And I open the activity chooser Then I should not see "Teaching Tool 1" in the ".modal-body" "css_element" And I should see "Teaching Tool 2" in the ".modal-body" "css_element" And I should not see "Course Tool 2" in the ".modal-body" "css_element" diff --git a/mod/scorm/tests/behat/default_completion.feature b/mod/scorm/tests/behat/default_completion.feature index d9f400b9dd6..c679c070cd4 100644 --- a/mod/scorm/tests/behat/default_completion.feature +++ b/mod/scorm/tests/behat/default_completion.feature @@ -19,7 +19,7 @@ Feature: Scorm activity default completion Scenario: Completion conditions when there is no default set at site or course level. Given I log in as "teacher1" And I am on "Course 1" course homepage with editing mode on - And I press "Add an activity or resource" + And I open the activity chooser When I click on "Add a new SCORM" "link" in the "Add an activity or resource" "dialogue" And I expand all fieldsets Then the field "None" matches value "1" @@ -40,7 +40,7 @@ Feature: Scorm activity default completion | completionstatusrequired_scorm[2] | 0 | And I click on "Save changes" "button" in the "[data-region='activitycompletion-scorm']" "css_element" And I am on "Course 1" course homepage with editing mode on - And I press "Add an activity or resource" + And I open the activity chooser When I click on "Add a new SCORM" "link" in the "Add an activity or resource" "dialogue" And I expand all fieldsets Then the field "None" matches value "0" @@ -62,7 +62,7 @@ Feature: Scorm activity default completion | completionstatusrequired_scorm[2] | 0 | And I click on "Save changes" "button" in the "[data-region='activitycompletion-scorm']" "css_element" And I am on "Course 1" course homepage with editing mode on - And I press "Add an activity or resource" + And I open the activity chooser When I click on "Add a new SCORM" "link" in the "Add an activity or resource" "dialogue" And I expand all fieldsets Then the field "None" matches value "0" @@ -86,7 +86,7 @@ Feature: Scorm activity default completion | course | module | completion | | C1 | scorm | 1 | And I am on "Course 1" course homepage with editing mode on - And I press "Add an activity or resource" + And I open the activity chooser When I click on "Add a new SCORM" "link" in the "Add an activity or resource" "dialogue" And I expand all fieldsets Then the field "None" matches value "0" @@ -105,7 +105,8 @@ Feature: Scorm activity default completion | completionstatusrequired_scorm[2] | 1 | And I click on "Save changes" "button" in the "[data-region='activitycompletion-scorm']" "css_element" And I am on "Course 1" course homepage with editing mode on - And I press "Add an activity or resource" +# When I add a "Teaching Tool 1" to section "1" using the activity chooser + And I open the activity chooser When I click on "Add a new SCORM" "link" in the "Add an activity or resource" "dialogue" And I expand all fieldsets Then the field "None" matches value "0" diff --git a/mod/subsection/tests/behat/subsection_access_restrictions.feature b/mod/subsection/tests/behat/subsection_access_restrictions.feature index 408f5c13672..e87d5355a5b 100644 --- a/mod/subsection/tests/behat/subsection_access_restrictions.feature +++ b/mod/subsection/tests/behat/subsection_access_restrictions.feature @@ -5,8 +5,7 @@ Feature: Testing subsection_access_restrictions in mod_subsection I need to set subsection conditions which prevent student access Background: - Given I enable "subsection" "mod" plugin - And the following "users" exist: + Given the following "users" exist: | username | firstname | lastname | | teacher1 | Teacher | 1 | | student1 | Student | 1 | diff --git a/mod/subsection/tests/behat/subsection_actionmenu.feature b/mod/subsection/tests/behat/subsection_actionmenu.feature index 5eb37ab1fd4..4530de1ccea 100644 --- a/mod/subsection/tests/behat/subsection_actionmenu.feature +++ b/mod/subsection/tests/behat/subsection_actionmenu.feature @@ -5,8 +5,7 @@ Feature: The module menu replaces the delegated section menu I need to see the delegated section action menu instead of module menu. Background: - Given I enable "subsection" "mod" plugin - And the following "users" exist: + Given the following "users" exist: | username | firstname | lastname | email | | teacher1 | Teacher | 1 | teacher1@example.com | And the following "courses" exist: diff --git a/mod/subsection/tests/behat/subsection_coursepage.feature b/mod/subsection/tests/behat/subsection_coursepage.feature index c5d362ab6ad..1c2af2c0686 100644 --- a/mod/subsection/tests/behat/subsection_coursepage.feature +++ b/mod/subsection/tests/behat/subsection_coursepage.feature @@ -5,8 +5,7 @@ Feature: Users view subsections on course page I need to view subsections on course page Background: - Given I enable "subsection" "mod" plugin - And the following "users" exist: + Given the following "users" exist: | username | firstname | lastname | email | | teacher1 | Teacher | 1 | teacher1@example.com | | student1 | Student | 1 | student1@example.com | diff --git a/mod/subsection/tests/behat/subsection_disabled_plugin.feature b/mod/subsection/tests/behat/subsection_disabled_plugin.feature index fc54005695b..7feff0d78d4 100644 --- a/mod/subsection/tests/behat/subsection_disabled_plugin.feature +++ b/mod/subsection/tests/behat/subsection_disabled_plugin.feature @@ -5,8 +5,7 @@ Feature: Courses should not lose subsection contents when mod_subsection is disa Courses needs to be usable with mod_subsection disabled Background: - Given I enable "subsection" "mod" plugin - And the following "users" exist: + Given the following "users" exist: | username | firstname | lastname | | teacher1 | Teacher | 1 | | student1 | Student | 1 | diff --git a/mod/subsection/tests/behat/subsection_limit.feature b/mod/subsection/tests/behat/subsection_limit.feature index f9c6579f124..de53f65d1e3 100644 --- a/mod/subsection/tests/behat/subsection_limit.feature +++ b/mod/subsection/tests/behat/subsection_limit.feature @@ -5,8 +5,7 @@ Feature: Teacher can only add subsection when certain conditions are met I need to create subsections only when possible Background: - Given I enable "subsection" "mod" plugin - And the following "users" exist: + Given the following "users" exist: | username | firstname | lastname | email | | teacher1 | Teacher | 1 | teacher1@example.com | And the following "courses" exist: diff --git a/mod/subsection/tests/behat/subsection_navigation.feature b/mod/subsection/tests/behat/subsection_navigation.feature index 310bd4f6597..277589ef2bb 100644 --- a/mod/subsection/tests/behat/subsection_navigation.feature +++ b/mod/subsection/tests/behat/subsection_navigation.feature @@ -5,8 +5,7 @@ Feature: Teachers navigate to subsections I need to navigate to subsections Background: - Given I enable "subsection" "mod" plugin - And the following "users" exist: + Given the following "users" exist: | username | firstname | lastname | email | | teacher1 | Teacher | 1 | teacher1@example.com | And the following "courses" exist: diff --git a/mod/subsection/tests/behat/subsection_no_completion.feature b/mod/subsection/tests/behat/subsection_no_completion.feature index d8a926f7195..2bf2a857fc7 100644 --- a/mod/subsection/tests/behat/subsection_no_completion.feature +++ b/mod/subsection/tests/behat/subsection_no_completion.feature @@ -5,8 +5,7 @@ Feature: Subsection does not have completion. I need to use subsection activity without completion Background: - Given I enable "subsection" "mod" plugin - And the following "users" exist: + Given the following "users" exist: | username | firstname | lastname | email | | teacher1 | Teacher | 1 | teacher1@example.com | And the following "courses" exist: diff --git a/mod/subsection/tests/behat/subsection_rename.feature b/mod/subsection/tests/behat/subsection_rename.feature index ec310da2a98..ca1b8713020 100644 --- a/mod/subsection/tests/behat/subsection_rename.feature +++ b/mod/subsection/tests/behat/subsection_rename.feature @@ -5,8 +5,7 @@ Feature: Teachers can rename subsections I need to sync subsection and activity names Background: - Given I enable "subsection" "mod" plugin - And the following "users" exist: + Given the following "users" exist: | username | firstname | lastname | email | | teacher1 | Teacher | 1 | teacher1@example.com | And the following "courses" exist: diff --git a/mod/subsection/tests/behat/subsection_sectionpage.feature b/mod/subsection/tests/behat/subsection_sectionpage.feature index 3e99c1bccc5..8a4881165f5 100644 --- a/mod/subsection/tests/behat/subsection_sectionpage.feature +++ b/mod/subsection/tests/behat/subsection_sectionpage.feature @@ -5,8 +5,7 @@ Feature: Teachers create and destroy subsections on section page I need to create and destroy subsections Background: - Given I enable "subsection" "mod" plugin - And the following "users" exist: + Given the following "users" exist: | username | firstname | lastname | email | | teacher1 | Teacher | 1 | teacher1@example.com | And the following "courses" exist: @@ -34,9 +33,10 @@ Feature: Teachers create and destroy subsections on section page Given the following "activities" exist: | activity | name | course | idnumber | section | | subsection | Subsection1 | C1 | forum1 | 1 | - When I am on "Course 1" course homepage with editing mode on - And I click on "Subsection1" "link" in the "region-main" "region" - And I add a "Assignment" to section "3" using the activity chooser + When I am on the "C1 > Subsection1" "course > section" page + And I turn editing mode on + And I click on "Add an activity or resource" "button" + And I click on "Add a new Assignment" "link" And I set the following fields to these values: | Assignment name | Test assignment name | | ID number | Test assignment name | diff --git a/mod/subsection/tests/behat/subsection_visibility.feature b/mod/subsection/tests/behat/subsection_visibility.feature index f885a123a9e..1e22f9f14b2 100644 --- a/mod/subsection/tests/behat/subsection_visibility.feature +++ b/mod/subsection/tests/behat/subsection_visibility.feature @@ -5,8 +5,7 @@ Feature: Subsection visibility should work as a module I need subsections to behave as any other module Background: - Given I enable "subsection" "mod" plugin - And the following "course" exists: + Given the following "course" exists: | fullname | Course 1 | | shortname | C1 | | category | 0 | diff --git a/mod/subsection/tests/behat/subsection_visibility_badge.feature b/mod/subsection/tests/behat/subsection_visibility_badge.feature index c0e5c28ccfa..d23b2a6ae07 100644 --- a/mod/subsection/tests/behat/subsection_visibility_badge.feature +++ b/mod/subsection/tests/behat/subsection_visibility_badge.feature @@ -5,8 +5,7 @@ Feature: Subsections visibility badges I need to see edit visibility from the section card badges when possible. Background: - Given I enable "subsection" "mod" plugin - And the following "users" exist: + Given the following "users" exist: | username | firstname | lastname | email | | teacher1 | Teacher | 1 | teacher1@example.com | And the following "courses" exist: diff --git a/report/log/tests/behat/subsection_reports.feature b/report/log/tests/behat/subsection_reports.feature index 921383ff511..6937a2d6d90 100644 --- a/report/log/tests/behat/subsection_reports.feature +++ b/report/log/tests/behat/subsection_reports.feature @@ -2,8 +2,7 @@ Feature: Subsection behavior in Log report. Background: - Given I enable "subsection" "mod" plugin - And the following "courses" exist: + Given the following "courses" exist: | fullname | shortname | category | numsections | initsections | | Course 1 | C1 | 0 | 2 | 1 | And the following "users" exist: diff --git a/report/outline/tests/behat/outline.feature b/report/outline/tests/behat/outline.feature index 6c8461fbc08..5f5f5d8ce5b 100644 --- a/report/outline/tests/behat/outline.feature +++ b/report/outline/tests/behat/outline.feature @@ -90,8 +90,7 @@ Feature: View an outline report And I should see "-" in the "Book name" "table_row" Scenario: The outline report can represent courses with subsections - Given I enable "subsection" "mod" plugin - And the following "activities" exist: + Given the following "activities" exist: | activity | name | course | section | visible | assignsubmission_onlinetext_enabled | assignsubmission_file_enabled | | assign | Activity1 | C1 | 1 | 1 | 1 | 0 | And the following "activities" exist: diff --git a/report/outline/tests/behat/subsection_reports.feature b/report/outline/tests/behat/subsection_reports.feature index 29e4dd1b17d..e038b929337 100644 --- a/report/outline/tests/behat/subsection_reports.feature +++ b/report/outline/tests/behat/subsection_reports.feature @@ -5,8 +5,7 @@ Feature: Subsections are shown in reports I need to see sections and subsections structure in reports Background: - Given I enable "subsection" "mod" plugin - And the following "users" exist: + Given the following "users" exist: | username | firstname | lastname | email | | teacher1 | Teacher | 1 | teacher1@example.com | And the following "courses" exist: