From 291ff443a5158b34b94cafe5c5f29baec24bee55 Mon Sep 17 00:00:00 2001 From: Amaia Anabitarte Date: Fri, 5 Feb 2021 17:36:24 +0100 Subject: [PATCH] MDL-70726 behat: Fixing existing fail tests Some of the current behat tests were wrong but not failing because of the bug in 'should not exist' step. Once the bug is fixed, we must fix also wrong behats. --- .../uploaduser/tests/behat/upload_users.feature | 4 ++-- .../tests/behat/tour_accessibility.feature | 4 ++-- badges/tests/behat/backpack.feature | 12 ++++++------ .../h5p/tests/behat/manage_content.feature | 2 +- .../tests/behat/teacher_replace_content.feature | 8 ++++---- contentbank/tests/behat/delete_content.feature | 2 +- contentbank/tests/behat/search_content.feature | 16 +++++++++++----- course/tests/behat/activity_chooser.feature | 16 +++++++++------- 8 files changed, 36 insertions(+), 28 deletions(-) diff --git a/admin/tool/uploaduser/tests/behat/upload_users.feature b/admin/tool/uploaduser/tests/behat/upload_users.feature index d21da4e95d0..4cdfbd29b0f 100644 --- a/admin/tool/uploaduser/tests/behat/upload_users.feature +++ b/admin/tool/uploaduser/tests/behat/upload_users.feature @@ -132,12 +132,12 @@ Feature: Upload users # Boost check. And I log in as "jonest" And I am on "Maths" course homepage - And "Turn editing on" "button" should not exist + And "Calendar" "link" should be visible And I log out # Classic check. And I log in as "reznor" And I am on "Maths" course homepage - And "Turn editing on" "button" should exist + And "Calendar" "link" should not be visible @javascript Scenario: Upload users setting their user theme when allowuserthemes is false diff --git a/admin/tool/usertours/tests/behat/tour_accessibility.feature b/admin/tool/usertours/tests/behat/tour_accessibility.feature index 8979ced877b..9fde9af5cca 100644 --- a/admin/tool/usertours/tests/behat/tour_accessibility.feature +++ b/admin/tool/usertours/tests/behat/tour_accessibility.feature @@ -76,10 +76,10 @@ Feature: Apply accessibility to a tour And "input[tabindex],button[tabindex]" "css_element" should exist When I click on "Next" "button" Then "input[aria-describedby^='tour-step-tool_usertours'],button[aria-describedby^='tour-step-tool_usertours']" "css_element" should not exist - And "input[tabindex],button[tabindex]" "css_element" should not exist + And "input[tabindex]:not([tabindex='-1']),button[tabindex]:not([tabindex='-1'])" "css_element" should not exist When I click on "Previous" "button" Then "input[aria-describedby^='tour-step-tool_usertours'],button[aria-describedby^='tour-step-tool_usertours']" "css_element" should exist And "input[tabindex],button[tabindex]" "css_element" should exist When I click on "End tour" "button" Then "input[aria-describedby^='tour-step-tool_usertours'],button[aria-describedby^='tour-step-tool_usertours']" "css_element" should not exist - And "input[tabindex],button[tabindex]" "css_element" should not exist + And "input[tabindex]:not([tabindex='0']),button[tabindex]:not([tabindex='0'])" "css_element" should not exist diff --git a/badges/tests/behat/backpack.feature b/badges/tests/behat/backpack.feature index 3a979f6def0..7abc278671e 100644 --- a/badges/tests/behat/backpack.feature +++ b/badges/tests/behat/backpack.feature @@ -120,7 +120,7 @@ Feature: Backpack badges And I click on "Delete" "button" in the "Delete site backpack" "dialogue" Then I should see "The site backpack has been deleted." And I should not see "https://dc.imsglobal.org" - And "Delete" "button" should not exist + And "Delete" "button" should not be visible @javascript Scenario: Add a new site backpack with authentication details checkbox @@ -131,27 +131,27 @@ Feature: Backpack badges And I set the field "backpackapiurl" to "http://backpackapiurl.cat" And I set the field "backpackweburl" to "http://backpackweburl.cat" And I set the field "apiversion" to "2.1" - Then "Include authentication details with the backpack" "checkbox" should not exist + Then "Include authentication details with the backpack" "checkbox" should not be visible And I should not see "Badge issuer email address" And I should not see "Badge issuer password" And I set the field "apiversion" to "1" - And "Include authentication details with the backpack" "checkbox" should exist + And "Include authentication details with the backpack" "checkbox" should be visible And I click on "includeauthdetails" "checkbox" And I should see "Badge issuer email address" And I should not see "Badge issuer password" And I set the field "apiversion" to "2" - And "Include authentication details with the backpack" "checkbox" should exist + And "Include authentication details with the backpack" "checkbox" should be visible And I should see "Badge issuer email address" And I should see "Badge issuer password" And I set the field "backpackemail" to "test@test.com" And I set the field "password" to "123456" And I press "Save changes" And I click on "Edit" "link" in the "http://backpackweburl.cat" "table_row" - And "input[name=includeauthdetails][type=checkbox][value=1]" "css_element" should exist + And the field "Include authentication details with the backpack" matches value "1" And I click on "includeauthdetails" "checkbox" And I press "Save changes" And I click on "Edit" "link" in the "http://backpackweburl.cat" "table_row" - And "input[name=includeauthdetails][type=checkbox][value=1]" "css_element" should not exist + And the field "Include authentication details with the backpack" matches value "0" And I click on "includeauthdetails" "checkbox" And I should not see "test@test.com" And I log out diff --git a/contentbank/contenttype/h5p/tests/behat/manage_content.feature b/contentbank/contenttype/h5p/tests/behat/manage_content.feature index 65f2e2a488e..505b9771c50 100644 --- a/contentbank/contenttype/h5p/tests/behat/manage_content.feature +++ b/contentbank/contenttype/h5p/tests/behat/manage_content.feature @@ -44,4 +44,4 @@ Feature: Manage H5P content from the content bank And I expand "Site pages" node And I click on "Content bank" "link" When I follow "filltheblanks.h5p" - Then "region-main-settings-menu" "region" should not exist + Then "Rename" "link" should not exist in the "region-main-settings-menu" "region" diff --git a/contentbank/contenttype/h5p/tests/behat/teacher_replace_content.feature b/contentbank/contenttype/h5p/tests/behat/teacher_replace_content.feature index 5a53f5ca616..a08ad1b182b 100644 --- a/contentbank/contenttype/h5p/tests/behat/teacher_replace_content.feature +++ b/contentbank/contenttype/h5p/tests/behat/teacher_replace_content.feature @@ -43,25 +43,25 @@ Feature: Replace H5P file from an existing content requires special capabilities Scenario: Teacher cannot replace another user's H5P files When I click on "admincontent" "link" - Then "region-main-settings-menu" "region" should not exist + Then "Replace with file" "link" should not exist in the "region-main-settings-menu" "region" Scenario: Teacher cannot replace a content without having upload capability Given the following "permission overrides" exist: | capability | permission | role | contextlevel | reference | | moodle/contentbank:upload | Prevent | editingteacher | Course | C1 | When I click on "teachercontent" "link" - Then "region-main-settings-menu" "region" should not exist + Then "Replace with file" "link" should not exist in the "region-main-settings-menu" "region" Scenario: Teacher cannot replace a content without having the H5P upload capability Given the following "permission overrides" exist: | capability | permission | role | contextlevel | reference | | contenttype/h5p:upload | Prevent | editingteacher | Course | C1 | When I click on "teachercontent" "link" - Then "region-main-settings-menu" "region" should not exist + Then "Replace with file" "link" should not exist in the "region-main-settings-menu" "region" Scenario: Teacher cannot replace a content without having the manage own content capability Given the following "permission overrides" exist: | capability | permission | role | contextlevel | reference | | moodle/contentbank:manageowncontent | Prevent | editingteacher | Course | C1 | When I click on "teachercontent" "link" - Then "region-main-settings-menu" "region" should not exist + Then "Replace with file" "link" should not exist in the "region-main-settings-menu" "region" diff --git a/contentbank/tests/behat/delete_content.feature b/contentbank/tests/behat/delete_content.feature index 1a41bb6f267..1302b02a12b 100644 --- a/contentbank/tests/behat/delete_content.feature +++ b/contentbank/tests/behat/delete_content.feature @@ -60,7 +60,7 @@ Feature: Delete H5P file from the content bank And I click on "Content bank" "link" in the "Navigation" "block" And I should see "content2delete.h5p" And I follow "content2delete.h5p" - Then ".header-actions-container" "css_element" should not exist + Then "Delete" "link" should not exist in the "region-main-settings-menu" "region" And I click on "Content bank" "link" And I click on "Upload" "link" And I click on "Choose a file..." "button" diff --git a/contentbank/tests/behat/search_content.feature b/contentbank/tests/behat/search_content.feature index 54f9ecd37e8..9193a83a06f 100644 --- a/contentbank/tests/behat/search_content.feature +++ b/contentbank/tests/behat/search_content.feature @@ -24,16 +24,18 @@ Feature: Search content in the content bank And I expand "Site pages" node And I click on "Content bank" "link" And I should see "santjordi.h5p" - And "Clear search input" "button" should not exist + And "Clear search input" "button" should not be visible And I should not see "items found" When I set the field "Search" to "book" - Then "Clear search input" "button" should exist + # Waiting for the animation to show the button to finish. + And I wait "1" seconds + Then "Clear search input" "button" should be visible And I should see "3 items found" And I should see "SantJordi_book" And I should see "mathsbook.h5p" And I should see "historybook.h5p" And I set the field "Search" to "sant" - And "Clear search input" "button" should exist + And "Clear search input" "button" should be visible And I should see "5 items found" And I set the field "Search" to "santjordi" And I should see "4 items found" @@ -42,10 +44,14 @@ Feature: Search content in the content bank And I should see "SantJordi_book" And I should see "Dragon_santjordi.h5p" And I click on "Clear search input" "button" - And "Clear search input" "button" should not exist + # Waiting for the animation to hide the button to finish. + And I wait "1" seconds + And "Clear search input" "button" should not be visible And I should not see "items found" And I set the field "Search" to ".h5p" - And "Clear search input" "button" should exist + # Waiting for the animation to show the button to finish. + And I wait "1" seconds + And "Clear search input" "button" should be visible And I should see "7 items found" And I set the field "Search" to "friend" And I should see "0 items found" diff --git a/course/tests/behat/activity_chooser.feature b/course/tests/behat/activity_chooser.feature index 3748d0fe3fa..330bac07281 100644 --- a/course/tests/behat/activity_chooser.feature +++ b/course/tests/behat/activity_chooser.feature @@ -51,8 +51,8 @@ Feature: Display and choose from the available activities in course 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" When I click on "Back" "button" in the "help" "core_course > Activity chooser screen" - Then "modules" "core_course > Activity chooser screen" should exist - And "help" "core_course > Activity chooser screen" should not exist + Then "modules" "core_course > Activity chooser screen" should be visible + And "help" "core_course > Activity chooser screen" should not be visible And "Back" "button" should not exist in the "modules" "core_course > Activity chooser screen" 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" @@ -123,24 +123,26 @@ Feature: Display and choose from the available activities in course And I should see "Lesson" in the "Add an activity or resource" "dialogue" When I set the field "search" to "" And I should not see "1 results found" in the "Add an activity or resource" "dialogue" - Then ".searchresultscontainer" "css_element" should not exist + Then ".searchresultscontainer" "css_element" should not be visible 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 "Topic 1" "section" - Then "Clear search input" "button" should not exist + 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 "Topic 1" "section" When I set the field "search" to "Search query" - Then "Clear search input" "button" should not exist + 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 "Topic 1" "section" And I set the field "search" to "Search query" And "Clear search input" "button" should exist When I set the field "search" to "" - Then "Clear search input" "button" should not exist + # Waiting for the animation to hide the button to finish. + And I wait "1" seconds + 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 "Topic 1" "section" @@ -148,7 +150,7 @@ Feature: Display and choose from the available activities in course And I should see "results found" in the "Add an activity or resource" "dialogue" When I click on "Clear search input" "button" Then I should not see "Search query" - And ".searchresultscontainer" "css_element" should not exist + And ".searchresultscontainer" "css_element" should not be visible And ".optionscontainer" "css_element" should exist Scenario: Teacher gets the base case for the Activity Chooser tab mode