From 800ddf513da877aaa73599307260352eb98e414b Mon Sep 17 00:00:00 2001 From: Sara Arjona Date: Fri, 1 Dec 2023 12:54:37 +0100 Subject: [PATCH] MDL-80248 behat: Fix behat tests --- .../availability_completion_previous.feature | 18 +-- .../tests/behat/display_availability.feature | 3 +- .../format/tests/behat/section_page.feature | 18 +-- .../tests/behat/activity_navigation.feature | 1 + .../behat/course_collapse_sections.feature | 6 +- course/tests/behat/course_controls.feature | 109 ++++++++++-------- .../behat/paged_course_navigation.feature | 66 +++++------ 7 files changed, 113 insertions(+), 108 deletions(-) diff --git a/availability/condition/completion/tests/behat/availability_completion_previous.feature b/availability/condition/completion/tests/behat/availability_completion_previous.feature index f70eb6b1a73..8dff21f5336 100644 --- a/availability/condition/completion/tests/behat/availability_completion_previous.feature +++ b/availability/condition/completion/tests/behat/availability_completion_previous.feature @@ -121,7 +121,7 @@ Feature: Confirm that availability_completion works with previous activity setti Then I should see "Not available unless: The activity Page2 is marked complete" in the "region-main" "region" # Remove Page 2 and check Section 4 depends now on Page1. - When I turn editing mode on + When I am on "Course 1" course homepage with editing mode on And I change window size to "large" And I delete "Page2" activity And I turn editing mode off @@ -175,11 +175,11 @@ Feature: Confirm that availability_completion works with previous activity setti And I press "Save changes" Then I should see "Not available unless: The previous activity with completion" in the "region-main" "region" - When I turn editing mode off - Then I should see "Not available unless: The activity Page1 is marked complete" in the "region-main" "region" + And I turn editing mode off + And I should see "Not available unless: The activity Page1 is marked complete" in the "region-main" "region" # Set section 5 restriction to Previous Activity with completion. - When I turn editing mode on + And I am on "Course 1" course homepage with editing mode on And I edit the section "5" And I expand all fieldsets And I click on "Add restriction..." "button" @@ -187,18 +187,18 @@ Feature: Confirm that availability_completion works with previous activity setti And I click on "Displayed if student doesn't meet this condition • Click to hide" "link" And I set the field "Activity or resource" to "Previous activity with completion" And I press "Save changes" - Then I should see "Not available unless: The previous activity with completion" in the "region-main" "region" + And I should see "Not available unless: The previous activity with completion" in the "region-main" "region" - When I turn editing mode off + And I turn editing mode off Then I should see "Not available unless: The activity Page3 is marked complete" in the "region-main" "region" # Test if I disable completion tracking on Page3 section 5 depends on Page2. - When I turn editing mode on + And I am on "Course 1" course homepage with editing mode on And I open "Page3" actions menu And I click on "Edit settings" "link" in the "Page3" activity And I set the following fields to these values: | None | 1 | And I press "Save and return to course" - When I turn editing mode off - Then I should see "Not available unless: The activity Page2 is marked complete" in the "region-main" "region" + And I turn editing mode off + And I should see "Not available unless: The activity Page2 is marked complete" in the "region-main" "region" diff --git a/availability/tests/behat/display_availability.feature b/availability/tests/behat/display_availability.feature index 3ea2a02f49b..38d17e4e92b 100644 --- a/availability/tests/behat/display_availability.feature +++ b/availability/tests/behat/display_availability.feature @@ -126,7 +126,8 @@ Feature: display_availability And I press "Save changes" # Section 2 is the same but hidden from students - When I edit the section "2" + And I am on "Course 1" course homepage + And I edit the section "2" And I expand all fieldsets And I press "Add restriction..." And I click on "Date" "button" in the "Add restriction..." "dialogue" diff --git a/course/format/tests/behat/section_page.feature b/course/format/tests/behat/section_page.feature index 366bec94d72..96198bd22eb 100644 --- a/course/format/tests/behat/section_page.feature +++ b/course/format/tests/behat/section_page.feature @@ -39,7 +39,7 @@ Feature: Single section course page Scenario: General section is not displayed in the single section page When I click on "Topic 1" "link" in the "region-main" "region" - Then I should not see "General" in the "region-main" "region" + Then I should not see "General" in the "#section-1" "css_element" And I should not see "Activity sample 0.1" in the "region-main" "region" And I should see "Activity sample 1.1" And I should see "Activity sample 1.2" @@ -52,7 +52,7 @@ Feature: Single section course page Given I turn editing mode on And I open section "1" edit menu When I click on "View" "link" in the "Topic 1" "section" - Then I should not see "General" in the "region-main" "region" + Then I should not see "General" in the "#section-1" "css_element" And I should not see "Activity sample 0.1" in the "region-main" "region" And I should see "Activity sample 1.1" And I should see "Activity sample 1.2" @@ -62,21 +62,21 @@ Feature: Single section course page And I am on "Course 1" course homepage And I open section "2" edit menu And I click on "View" "link" in the "Topic 2" "section" - And I should not see "General" in the "region-main" "region" + And I should not see "General" in the "#section-2" "css_element" And I should not see "Activity sample 0.1" in the "region-main" "region" And I should not see "Activity sample 1.1" And I should not see "Activity sample 1.2" And I should not see "Activity sample 1.3" And I should see "Activity sample 2.1" in the "region-main" "region" And I should see "Activity sample 2.1" in the "region-main" "region" - # The following steps will need to be changed in MDL-80248, when the General section will be displayed in isolation. + # The General section is also displayed in isolation. But I am on "Course 1" course homepage And I open section "0" edit menu And I click on "View" "link" in the "General" "section" And I should see "General" in the "region-main" "region" And I should see "Activity sample 0.1" in the "region-main" "region" - And I should see "Activity sample 1.1" - And I should see "Activity sample 1.2" - And I should see "Activity sample 1.3" - And I should see "Activity sample 2.1" in the "region-main" "region" - And I should see "Activity sample 2.1" in the "region-main" "region" + And I should not see "Activity sample 1.1" in the "region-main" "region" + And I should not see "Activity sample 1.2" in the "region-main" "region" + And I should not see "Activity sample 1.3" in the "region-main" "region" + And I should not see "Activity sample 2.1" in the "region-main" "region" + And I should not see "Activity sample 2.1" in the "region-main" "region" diff --git a/course/tests/behat/activity_navigation.feature b/course/tests/behat/activity_navigation.feature index 9184770ae8a..840bf4ef3f2 100644 --- a/course/tests/behat/activity_navigation.feature +++ b/course/tests/behat/activity_navigation.feature @@ -52,6 +52,7 @@ Feature: Activity navigation # Hidden activity. And I click on "Hide" "link" in the "Glossary 1" activity # Hidden section. + And I am on "Course 1" course homepage And I hide section "5" # Set up book. And I follow "Book 1" diff --git a/course/tests/behat/course_collapse_sections.feature b/course/tests/behat/course_collapse_sections.feature index d8516568237..ec8b4b2a376 100644 --- a/course/tests/behat/course_collapse_sections.feature +++ b/course/tests/behat/course_collapse_sections.feature @@ -32,18 +32,18 @@ Feature: Collapse course sections | teacher1 | C1 | editingteacher | And I log in as "admin" And I am on "Course 1" course homepage with editing mode on - When I edit the section "4" + And I hide section "5" + And I edit the section "4" And I expand all fieldsets And I press "Add restriction..." And I click on "Date" "button" in the "Add restriction..." "dialogue" And I set the field "direction" to "until" And I set the field "x[year]" to "2013" And I press "Save changes" - And I hide section "5" @javascript Scenario: No chevron on site home - Given the following activity" exists: + Given the following "activity" exists: | activity | forum | | course | Acceptance test site | | section | 1 | diff --git a/course/tests/behat/course_controls.feature b/course/tests/behat/course_controls.feature index 38270953cb6..38f2ac3f7ce 100644 --- a/course/tests/behat/course_controls.feature +++ b/course/tests/behat/course_controls.feature @@ -18,18 +18,19 @@ Feature: Course activity controls works as expected @javascript @_cross_browser Scenario Outline: Check activities using topics and weeks formats, and paged mode and not paged mode Given the following "users" exist: - | username | firstname | lastname | email | - | teacher1 | Teacher | 1 | teacher1@example.com | + | username | firstname | lastname | email | + | teacher1 | Teacher | 1 | teacher1@example.com | And the following "courses" exist: - | fullname | shortname | format | coursedisplay | numsections | startdate | - | Course 1 | C1 | | | 5 | 0 | + | fullname | shortname | format | coursedisplay | numsections | startdate | + | Course 1 | C1 | | | 5 | 0 | And the following "course enrolments" exist: - | user | course | role | + | user | course | role | | teacher1 | C1 | editingteacher | And the following "activities" exist: - | activity | course | section | name | - | forum | C1 | 1 | Test forum name 1 | - | forum | C1 | 1 | Test forum name 2 | + | activity | course | section | name | + | forum | C1 | | Test forum name 1 | + | forum | C1 | | Test forum name 2 | + | forum | C1 | 1 | Test forum name 3 | And I am on the "Course 1" course page logged in as "teacher1" When I click on "link" in the "region-main" "region" And I turn editing mode on @@ -37,67 +38,72 @@ Feature: Course activity controls works as expected And I open the action menu in "Recent activity" "block" And I click on "Delete Recent activity block" "link" And I click on "Delete" "button" in the "Delete block?" "dialogue" - And "section" exist + And "section" should not exist And I open "Test forum name 1" actions menu And I click on "Edit settings" "link" in the "Test forum name 1" activity - And I should see "Updating Forum" + And I should see "Updating" And I should see "Display description on course page" And I set the following fields to these values: | Forum name | Just to check that I can edit the name | | Description | Just to check that I can edit the description | | Display description on course page | 1 | And I click on "Cancel" "button" - And "section" exist + And "section" should not exist And I open "Test forum name 1" actions menu And I choose "Availability > Hide on course page" in the open action menu - And "section" exist + And "section" should not exist And I delete "Test forum name 1" activity And I should not see "Test forum name 1" in the "region-main" "region" And I duplicate "Test forum name 2" activity editing the new copy with: | Forum name | Edited test forum name 2 | - And "section" exist + And "section" should not exist And I should see "Test forum name 2" And I should see "Edited test forum name 2" + # General section can't be hidden. Check this part using always the first section. + And I am on the "Course 1" course page + And I open section "1" edit menu + And I click on "View" "link" in the "section" And I hide section "1" - And "section" exist + And "section" should not exist And section "1" should be hidden And all activities in section "1" should be hidden And I show section "1" - And "section" exist + And "section" should not exist And section "1" should be visible And the following config values are set as admin: | unaddableblocks | | theme_boost| And I add the "Section links" block - And "section" exist + And "section" should not exist And I should see "1 2 3 4 5" in the "Section links" "block" And I click on "2" "link" in the "Section links" "block" - And I see "Test forum name 2" + And I should not see "Test forum name 2" Examples: - | courseformat | coursedisplay | targetpage | should_see_other_sections | should_see_other_sections_following_block_sections_links | belowpage | - | topics | 0 | "General" | should | should not | "Topic 2" | - | topics | 1 | "General" | should | should not | "Topic 2" | - | topics | 0 | "Topic 1" | should not | should not | "Topic 2" | - | topics | 1 | "Topic 1" | should not | should not | "Topic 2" | - | weeks | 0 | "General" | should | should not | "8 January - 14 January" | - | weeks | 1 | "General" | should | should not | "8 January - 14 January" | - | weeks | 0 | "1 January - 7 January" | should not | should not | "8 January - 14 January" | - | weeks | 1 | "1 January - 7 January" | should not | should not | "8 January - 14 January" | + | courseformat | coursedisplay | targetsectionnum | targetpage | belowpage | firstsection | + | topics | 0 | 0 | "General" | "Topic 2" | "Topic 1" | + | topics | 1 | 0 | "General" | "Topic 2" | "Topic 1" | + | topics | 0 | 1 | "Topic 1" | "Topic 2" | "Topic 1" | + | topics | 1 | 1 | "Topic 1" | "Topic 2" | "Topic 1" | + | weeks | 0 | 0 | "General" | "8 January - 14 January" | "1 January - 7 January" | + | weeks | 1 | 0 | "General" | "8 January - 14 January" | "1 January - 7 January" | + | weeks | 0 | 1 | "1 January - 7 January" | "8 January - 14 January" | "1 January - 7 January" | + | weeks | 1 | 1 | "1 January - 7 January" | "8 January - 14 January" | "1 January - 7 January" | Scenario Outline: Check, without javascript, activities using topics and weeks formats, and paged mode and not paged mode Given the following "users" exist: - | username | firstname | lastname | email | - | teacher1 | Teacher | 1 | teacher1@example.com | + | username | firstname | lastname | email | + | teacher1 | Teacher | 1 | teacher1@example.com | And the following "courses" exist: - | fullname | shortname | format | coursedisplay | numsections | startdate | - | Course 1 | C1 | | | 5 | 0 | + | fullname | shortname | format | coursedisplay | numsections | startdate | + | Course 1 | C1 | | | 5 | 0 | And the following "course enrolments" exist: | user | course | role | | teacher1 | C1 | editingteacher | And the following "activities" exist: - | activity | name | course | idnumber | section | - | forum | Test forum name 1 | C1 | 0001 | 1 | - | forum | Test forum name 2 | C1 | 0002 | 1 | + | activity | course | section | name | idnumber | + | forum | C1 | | Test forum name 1 | 00001 | + | forum | C1 | | Test forum name 2 | 00002 | + | forum | C1 | 1 | Test forum name 3 | 00003 | And I am on the "Course 1" course page logged in as "teacher1" When I click on "link" in the "region-main" "region" And I turn editing mode on @@ -105,22 +111,27 @@ Feature: Course activity controls works as expected And I open the action menu in "Recent activity" "block" And I click on "Delete Recent activity block" "link" And I press "Yes" - And "section" exist + And "section" should not exist And I click on "Edit settings" "link" in the "Test forum name 1" activity - And I should see "Updating Forum" + And I should see "Updating" And I should see "Display description on course page" And I press "Save and return to course" - And "section" exist + And "section" should not exist And I click on "Hide on course page" "link" in the "Test forum name 1" activity - And "section" exist + And "section" should not exist And I delete "Test forum name 1" activity - And "section" exist + And "section" should not exist And I should not see "Test forum name 1" in the "region-main" "region" And I duplicate "Test forum name 2" activity editing the new copy with: | Forum name | Edited test forum name 2 | - And "section" exist + And "section" should not exist And I should see "Test forum name 2" And I should see "Edited test forum name 2" + # General section can't be hidden. Check this part using always the first section. + And I am on the "Course 1" course page + And I turn editing mode off + And I click on "link" in the "region-main" "region" + And I turn editing mode on And I hide section "1" And section "1" should be hidden And all activities in section "1" should be hidden @@ -131,18 +142,18 @@ Feature: Course activity controls works as expected And I add the "Section links" block And I should see "1 2 3 4 5" in the "Section links" "block" And I click on "2" "link" in the "Section links" "block" - And I see "Test forum name 2" + And I should not see "Test forum name 2" Examples: - | courseformat | coursedisplay | targetpage | should_see_other_sections | should_see_other_sections_following_block_sections_links | belowpage | - | topics | 0 | "General" | should | should not | "Topic 2" | - | topics | 1 | "General" | should | should not | "Topic 2" | - | topics | 0 | "Topic 1" | should not | should not | "Topic 2" | - | topics | 1 | "Topic 1" | should not | should not | "Topic 2" | - | weeks | 0 | "General" | should | should not | "8 January - 14 January" | - | weeks | 1 | "General" | should | should not | "8 January - 14 January" | - | weeks | 0 | "1 January - 7 January" | should not | should not | "8 January - 14 January" | - | weeks | 1 | "1 January - 7 January" | should not | should not | "8 January - 14 January" | + | courseformat | coursedisplay | targetsectionnum | targetpage | belowpage | firstsection | + | topics | 0 | 0 | "General" | "Topic 2" | "Topic 1" | + | topics | 1 | 0 | "General" | "Topic 2" | "Topic 1" | + | topics | 0 | 1 | "Topic 1" | "Topic 2" | "Topic 1" | + | topics | 1 | 1 | "Topic 1" | "Topic 2" | "Topic 1" | + | weeks | 0 | 0 | "General" | "8 January - 14 January" | "1 January - 7 January" | + | weeks | 1 | 0 | "General" | "8 January - 14 January" | "1 January - 7 January" | + | weeks | 0 | 1 | "1 January - 7 January" | "8 January - 14 January" | "1 January - 7 January" | + | weeks | 1 | 1 | "1 January - 7 January" | "8 January - 14 January" | "1 January - 7 January" | @javascript Scenario Outline: Indentation should allow one level only diff --git a/course/tests/behat/paged_course_navigation.feature b/course/tests/behat/paged_course_navigation.feature index fefa309bed1..cd48237c493 100644 --- a/course/tests/behat/paged_course_navigation.feature +++ b/course/tests/behat/paged_course_navigation.feature @@ -7,36 +7,32 @@ Feature: Course paged mode @javascript @_cross_browser Scenario Outline: Weekly and topics course formats with Javascript enabled Given the following "courses" exist: - | fullname | shortname | category | format | coursedisplay | numsections | startdate | - | Course 1 | C1 | 0 | | 1 | 3 | 0 | + | fullname | shortname | category | format | coursedisplay | numsections | startdate | + | Course 1 | C1 | 0 | | 1 | 2 | 0 | And I log in as "admin" And I am on "Course 1" course homepage - Then I click on "link" in the "section" - And I am on "Course 1" course homepage - And I click on "link" in the "section" - And I am on "Course 1" course homepage And I click on "link" in the "section" - And I should see in the "div.single-section" "css_element" - And I should see in the ".single-section div.nextsection" "css_element" + And I am on "Course 1" course homepage + And I click on "link" in the "section" + And I am on "Course 1" course homepage + When I click on "link" in the "section" + Then I should see in the "div.single-section" "css_element" + And I should see in the ".single-section div.nextsection" "css_element" And I should not see in the ".single-section" "css_element" - And I click on "link" in the ".single-section" "css_element" - And I should see in the "div.single-section" "css_element" - And I should see in the ".single-section div.prevsection" "css_element" - And I should see in the ".single-section div.nextsection" "css_element" And I click on "link" in the ".single-section" "css_element" And I should see in the "div.single-section" "css_element" + And I should see in the ".single-section div.prevsection" "css_element" + And I should see in the ".single-section div.nextsection" "css_element" And I click on "link" in the ".single-section" "css_element" - And I click on "link" in the ".single-section" "css_element" - And I should see in the "div.single-section" "css_element" - And I should see in the ".single-section div.prevsection" "css_element" - And I should not see in the ".single-section .section-navigation" "css_element" + And I should see in the "div.single-section" "css_element" + And I should not see in the ".single-section .section-navigation" "css_element" And I should not see in the ".single-section" "css_element" And I should not see in the ".single-section" "css_element" Examples: - | courseformat | section1 | section2 | section3 | prevunexistingsection | nextunexistingsection | - | topics | "Topic 1" | "Topic 2" | "Topic 3" | "Topic 0" | "Topic 4" | - | weeks | "1 January - 7 January" | "8 January - 14 January" | "15 January - 21 January" | "25 December - 31 December" | "22 January - 28 January" | + | courseformat | general | section1 | section2 | prevunexistingsection | nextunexistingsection | + | topics | "General" | "Topic 1" | "Topic 2" | "Topic 0" | "Topic 3" | + | weeks | "General" | "1 January - 7 January" | "8 January - 14 January" | "25 December - 31 December" | "15 January - 21 January" | @javascript Scenario Outline: Paged section redirect after creating an activity @@ -64,33 +60,29 @@ Feature: Course paged mode Scenario Outline: Weekly and topics course formats with Javascript disabled Given the following "courses" exist: - | fullname | shortname | category | format | coursedisplay | numsections | startdate | - | Course 1 | C1 | 0 | | 1 | 3 | 0 | + | fullname | shortname | category | format | coursedisplay | numsections | startdate | + | Course 1 | C1 | 0 | | 1 | 2 | 0 | And I log in as "admin" And I am on "Course 1" course homepage - Then I click on "link" in the "section" + Then I click on "link" in the "section" And I am on "Course 1" course homepage - And I click on "link" in the "section" + And I click on "link" in the "section" And I am on "Course 1" course homepage - And I click on "link" in the "section" - And I should see in the "div.single-section" "css_element" - And I should see in the ".single-section div.nextsection" "css_element" + And I click on "link" in the "section" + And I should see in the "div.single-section" "css_element" + And I should see in the ".single-section div.nextsection" "css_element" And I should not see in the ".single-section" "css_element" - And I click on "link" in the ".single-section" "css_element" - And I should see in the "div.single-section" "css_element" - And I should see in the ".single-section div.prevsection" "css_element" - And I should see in the ".single-section div.nextsection" "css_element" And I click on "link" in the ".single-section" "css_element" And I should see in the "div.single-section" "css_element" + And I should see in the ".single-section div.prevsection" "css_element" + And I should see in the ".single-section div.nextsection" "css_element" And I click on "link" in the ".single-section" "css_element" - And I click on "link" in the ".single-section" "css_element" - And I should see in the "div.single-section" "css_element" - And I should see in the ".single-section div.prevsection" "css_element" - And I should not see in the ".single-section .section-navigation" "css_element" + And I should see in the "div.single-section" "css_element" + And I should not see in the ".single-section .section-navigation" "css_element" And I should not see in the ".single-section" "css_element" And I should not see in the ".single-section" "css_element" Examples: - | courseformat | section1 | section2 | section3 | prevunexistingsection | nextunexistingsection | - | topics | "Topic 1" | "Topic 2" | "Topic 3" | "Topic 0" | "Topic 4" | - | weeks | "1 January - 7 January" | "8 January - 14 January" | "15 January - 21 January" | "25 December - 31 December" | "22 January - 28 January" | + | courseformat | general | section1 | section2 | prevunexistingsection | nextunexistingsection | + | topics | "General" | "Topic 1" | "Topic 2" | "Topic 0" | "Topic 3" | + | weeks | "General" | "1 January - 7 January" | "8 January - 14 January" | "25 December - 31 December" | "15 January - 21 January" |