From 28de4532003c7a7aa978dd5d3d53075cd14b4357 Mon Sep 17 00:00:00 2001 From: sam marshall Date: Wed, 22 Apr 2020 17:24:22 +0100 Subject: [PATCH] MDL-68492 Behat: Use faster direct link steps in lib/tests/behat --- lib/tests/behat/action_modal.feature | 8 ++---- lib/tests/behat/alpha_chooser.feature | 30 +++++++---------------- lib/tests/behat/largeforms.feature | 3 +-- lib/tests/behat/locking.feature | 24 ++++++------------ lib/tests/behat/permissionmanager.feature | 3 +-- lib/tests/behat/readonlyform.feature | 6 ++--- lib/tests/behat/securelayout.feature | 3 +-- 7 files changed, 24 insertions(+), 53 deletions(-) diff --git a/lib/tests/behat/action_modal.feature b/lib/tests/behat/action_modal.feature index 8ddcae49b5e..2d5b2a535f9 100644 --- a/lib/tests/behat/action_modal.feature +++ b/lib/tests/behat/action_modal.feature @@ -12,9 +12,7 @@ Feature: Close modals by clicking outside them And the following "activities" exist: | activity | name | intro | course | idnumber | | quiz | Test quiz name | Test quiz description | C1 | quiz1 | - And I log in as "admin" - And I am on "Course 1" course homepage - And I follow "Test quiz name" + And I am on the "quiz1" "Activity" page logged in as "admin" And I click on "Edit quiz" "button" And I click on "Add" "link" And I click on "a new question" "link" @@ -43,9 +41,7 @@ Feature: Close modals by clicking outside them And the following "activities" exist: | activity | name | intro | course | idnumber | | quiz | Test quiz name | Test quiz description | C1 | quiz1 | - And I log in as "admin" - And I am on "Course 1" course homepage - And I follow "Test quiz name" + And I am on the "quiz1" "Activity" page logged in as "admin" And I click on "Edit quiz" "button" And I click on "Help with Editing quiz" "icon" And I should see "More help" diff --git a/lib/tests/behat/alpha_chooser.feature b/lib/tests/behat/alpha_chooser.feature index e81eca36b01..327ede9a262 100644 --- a/lib/tests/behat/alpha_chooser.feature +++ b/lib/tests/behat/alpha_chooser.feature @@ -68,9 +68,7 @@ Feature: Initials bar Given the following "activities" exist: | activity | course | idnumber | name | intro | assignsubmission_onlinetext_enabled | assignsubmission_file_enabled | | assign | C1 | assign1 | TestAssignment | Test assignment description | 0 | 0 | - And I log in as "teacher" - And I am on "Course 1" course homepage - And I follow "TestAssignment" + And I am on the "assign1" "Activity" page logged in as "teacher" When I navigate to "View all submissions" in current page administration And ".initialbarall.page-item.active" "css_element" should exist in the ".initialbar.firstinitial" "css_element" And ".initialbarall.page-item.active" "css_element" should exist in the ".initialbar.lastinitial" "css_element" @@ -95,8 +93,7 @@ Feature: Initials bar And I should not see "Astudent Astudent" And I should see "Bstudent Astudent" And I should not see "Cstudent Cstudent" - And I am on "Course 1" course homepage - And I follow "TestAssignment" + And I am on the "assign1" "Activity" page When I navigate to "View all submissions" in current page administration And ".initialbarall.page-item.active" "css_element" should not exist in the ".initialbar.firstinitial" "css_element" And ".initialbarall.page-item.active" "css_element" should not exist in the ".initialbar.lastinitial" "css_element" @@ -126,9 +123,7 @@ Feature: Initials bar Given the following "activities" exist: | activity | course | idnumber | name | intro | assignsubmission_onlinetext_enabled | assignsubmission_file_enabled | | assign | C1 | assign1 | TestAssignment | Test assignment description | 0 | 0 | - And I log in as "teacher" - And I am on "Course 1" course homepage - And I follow "TestAssignment" + And I am on the "assign1" "Activity" page logged in as "teacher" When I navigate to "View all submissions" in current page administration And I select "View gradebook" from the "jump" singleselect And ".initialbarall.page-item.active" "css_element" should exist in the ".initialbar.firstinitial" "css_element" @@ -154,8 +149,7 @@ Feature: Initials bar And I should not see "Astudent Astudent" And I should see "Bstudent Astudent" And I should not see "Cstudent Cstudent" - And I am on "Course 1" course homepage - And I follow "TestAssignment" + And I am on the "assign1" "Activity" page When I navigate to "View all submissions" in current page administration And I select "View gradebook" from the "jump" singleselect And ".initialbarall.page-item.active" "css_element" should not exist in the ".initialbar.firstinitial" "css_element" @@ -186,14 +180,11 @@ Feature: Initials bar Given the following "activities" exist: | activity | course | idnumber | name | intro | assignsubmission_onlinetext_enabled | assignsubmission_file_enabled | | assign | C1 | assign1 | TestAssignment | Test assignment description | 0 | 0 | - And I log in as "student1" - And I am on "Course 1" course homepage + And I am on the "C1" "Course" page logged in as "student1" And I log out - And I log in as "student2" - And I am on "Course 1" course homepage + And I am on the "C1" "Course" page logged in as "student2" And I log out - And I log in as "teacher" - And I am on "Course 1" course homepage + And I am on the "C1" "Course" page logged in as "teacher" And I follow "Participants" And ".initialbarall.page-item.active" "css_element" should exist in the ".initialbar.firstinitial" "css_element" And ".initialbarall.page-item.active" "css_element" should exist in the ".initialbar.lastinitial" "css_element" @@ -249,9 +240,7 @@ Feature: Initials bar Given the following "activities" exist: | activity | course | idnumber | name | intro | assignsubmission_onlinetext_enabled | assignsubmission_file_enabled | | assign | C1 | assign1 | TestAssignment | Test assignment description | 0 | 0 | - And I log in as "admin" - And I am on "Course 1" course homepage - And I follow "TestAssignment" + And I am on the "assign1" "Activity" page logged in as "admin" And I navigate to "Edit settings" in current page administration And I expand all fieldsets And I set the field "Completion tracking" to "1" @@ -261,8 +250,7 @@ Feature: Initials bar And I click on "Assignment - TestAssignment" "checkbox" And I click on "Save changes" "button" And I log out - And I log in as "teacher" - And I am on "Course 1" course homepage + And I am on the "C1" "Course" page logged in as "teacher" And I navigate to "Reports > Activity completion" in current page administration And ".initialbarall.page-item.active" "css_element" should exist in the ".initialbar.firstinitial" "css_element" And ".initialbarall.page-item.active" "css_element" should exist in the ".initialbar.lastinitial" "css_element" diff --git a/lib/tests/behat/largeforms.feature b/lib/tests/behat/largeforms.feature index 82b745b385f..69a638e637d 100644 --- a/lib/tests/behat/largeforms.feature +++ b/lib/tests/behat/largeforms.feature @@ -12,8 +12,7 @@ Feature: Forms with a large number of fields And the following "activities" exist: | activity | name | intro | course | idnumber | | label | L1 | FixtureLink | C1 | label1 | - When I log in as "admin" - And I am on "Course 1" course homepage + When I am on the "C1" "Course" page logged in as "admin" And I follow "FixtureLink" # Note: These tests do not actually use JavaScript but they don't work with diff --git a/lib/tests/behat/locking.feature b/lib/tests/behat/locking.feature index 3bfdfd27fb9..ad2c1bf9f49 100644 --- a/lib/tests/behat/locking.feature +++ b/lib/tests/behat/locking.feature @@ -37,8 +37,7 @@ Feature: Context freezing apply to child contexts | student1 | courseb | student | Scenario: Freeze course module module should freeze just that module - Given I log in as "admin" - And I am on "courseaa1" course homepage + Given I am on the "courseaa1" "Course" page logged in as "admin" And I follow "faa1" And "Add a new discussion topic" "link" should exist When I follow "Freeze this context" @@ -58,8 +57,7 @@ Feature: Context freezing apply to child contexts Then "Add a new discussion topic" "link" should exist And I log out - When I log in as "teacher" - And I am on "courseaa1" course homepage + When I am on the "courseaa1" "Course" page logged in as "teacher" And I follow "faa1" Then "Add a new discussion topic" "link" should not exist When I am on "courseaa1" course homepage @@ -76,8 +74,7 @@ Feature: Context freezing apply to child contexts And "Add a new discussion topic" "link" should exist And I log out - When I log in as "student1" - And I am on "courseaa1" course homepage + When I am on the "courseaa1" "Course" page logged in as "student1" And I follow "faa1" Then "Add a new discussion topic" "link" should not exist When I am on "courseaa1" course homepage @@ -91,8 +88,7 @@ Feature: Context freezing apply to child contexts Then "Add a new discussion topic" "link" should exist Scenario: Freeze course should freeze all children - Given I log in as "admin" - And I am on "courseaa1" course homepage + Given I am on the "courseaa1" "Course" page logged in as "admin" And I should see "Turn editing on" When I follow "Freeze this context" And I click on "Continue" "button" @@ -114,8 +110,7 @@ Feature: Context freezing apply to child contexts Then "Add a new discussion topic" "link" should exist And I log out - When I log in as "teacher" - And I am on "courseaa1" course homepage + When I am on the "courseaa1" "Course" page logged in as "teacher" And I follow "faa1" Then "Add a new discussion topic" "link" should not exist When I am on "courseaa1" course homepage @@ -132,8 +127,7 @@ Feature: Context freezing apply to child contexts Then "Add a new discussion topic" "link" should exist And I log out - When I log in as "student1" - And I am on "courseaa1" course homepage + When I am on the "courseaa1" "Course" page logged in as "student1" And I follow "faa1" Then "Add a new discussion topic" "link" should not exist When I am on "courseaa1" course homepage @@ -171,8 +165,7 @@ Feature: Context freezing apply to child contexts Then "Add a new discussion topic" "link" should exist And I log out - When I log in as "teacher" - And I am on "courseaa1" course homepage + When I am on the "courseaa1" "Course" page logged in as "teacher" Then I should not see "Turn editing on" And I follow "faa1" Then "Add a new discussion topic" "link" should not exist @@ -190,8 +183,7 @@ Feature: Context freezing apply to child contexts Then "Add a new discussion topic" "link" should exist And I log out - When I log in as "student1" - And I am on "courseaa1" course homepage + When I am on the "courseaa1" "Course" page logged in as "student1" And I follow "faa1" Then "Add a new discussion topic" "link" should not exist When I am on "courseaa1" course homepage diff --git a/lib/tests/behat/permissionmanager.feature b/lib/tests/behat/permissionmanager.feature index bd96363e0b9..3a69af170ed 100644 --- a/lib/tests/behat/permissionmanager.feature +++ b/lib/tests/behat/permissionmanager.feature @@ -16,8 +16,7 @@ Feature: Override permissions on a context | teacher1 | C1 | editingteacher | Scenario: Default system capabilities modification - Given I log in as "admin" - And I am on "Course 1" course homepage + Given I am on the "C1" "Course" page logged in as "admin" And I navigate to "Users > Permissions" in current page administration When I click on "Allow" "icon" in the "mod/forum:addnews" "table_row" And I press "Student" diff --git a/lib/tests/behat/readonlyform.feature b/lib/tests/behat/readonlyform.feature index 269dc88c409..bcf217ab527 100644 --- a/lib/tests/behat/readonlyform.feature +++ b/lib/tests/behat/readonlyform.feature @@ -12,8 +12,7 @@ Feature: Read-only forms should work And the following "activities" exist: | activity | name | intro | course | idnumber | | label | L1 | Fixture link | C1 | label1 | - And I log in as "admin" - And I am on "Course 1" course homepage + Given I am on the "C1" "Course" page logged in as "admin" And I follow "Fixture link" When I expand all fieldsets Then the field "Name" matches value "Important information" @@ -26,8 +25,7 @@ Feature: Read-only forms should work And the following "activities" exist: | activity | name | intro | course | idnumber | | label | L1 | Fixture link | C1 | label1 | - And I log in as "admin" - And I am on "Course 1" course homepage + Given I am on the "C1" "Course" page logged in as "admin" And I follow "Fixture link" When I expand all fieldsets Then the field "Name" matches value "Important information" diff --git a/lib/tests/behat/securelayout.feature b/lib/tests/behat/securelayout.feature index f20c7c2dfc9..71627e0e32e 100644 --- a/lib/tests/behat/securelayout.feature +++ b/lib/tests/behat/securelayout.feature @@ -14,8 +14,7 @@ Feature: Page displaying with secure layout | label | L1 | Fixture link | C1 | label1 | Scenario: Confirm that there is no header link - Given I log in as "admin" - And I am on "Course 1" course homepage + Given I am on the "C1" "Course" page logged in as "admin" When I follow "Fixture link" Then I should see "Acceptance test site" in the "nav" "css_element" But "Acceptance test site" "link" should not exist