From 75715efdfa4db9a780658e0ea027a33c10093f41 Mon Sep 17 00:00:00 2001 From: Angelia Dela Cruz Date: Tue, 24 May 2022 18:12:24 +0800 Subject: [PATCH] MDL-74841 behat: Label behat generators use UI Replace steps that manually add Label instances via the UI and use Behat generators. This improves the speed of Behat test runs. --- .../restrict_section_availability.feature | 6 +-- mod/label/tests/behat/label_idnumber.feature | 16 ++---- .../tests/behat/label_visibility.feature | 53 +++++-------------- 3 files changed, 21 insertions(+), 54 deletions(-) diff --git a/completion/tests/behat/restrict_section_availability.feature b/completion/tests/behat/restrict_section_availability.feature index daeec9e06d5..5fbbc64f68b 100644 --- a/completion/tests/behat/restrict_section_availability.feature +++ b/completion/tests/behat/restrict_section_availability.feature @@ -34,9 +34,9 @@ Feature: Restrict sections availability through completion or grade conditions And I set the following fields to these values: | Enable completion tracking | Yes | And I press "Save and display" - And I add a "Label" to section "1" and I fill the form with: - | Label text | Test label | - | Completion tracking | Students can manually mark the activity as completed | + And the following "activities" exist: + | activity | course | section | intro | completion | idnumber | + | label | C1 | 1 | Test label | 1 | 1 | And I add a "Page" to section "2" and I fill the form with: | Name | Test page name | | Description | Test page description | diff --git a/mod/label/tests/behat/label_idnumber.feature b/mod/label/tests/behat/label_idnumber.feature index b6f4004dcdf..e1b0c46843f 100644 --- a/mod/label/tests/behat/label_idnumber.feature +++ b/mod/label/tests/behat/label_idnumber.feature @@ -5,7 +5,6 @@ Feature: set label idnumber As a teacher I should create label activity and set an ID number - @javascript Scenario: label ID number input box should be shown. Given the following "courses" exist: | fullname | shortname | category | @@ -18,12 +17,11 @@ Feature: set label idnumber | user | course | role | | teacher | C1 | editingteacher | | student | C1 | student | - Given I log in as "teacher" + And the following "activities" exist: + | activity | course | section | intro | idnumber | + | label | C1 | 1 | Label with ID number set | C1LABEL1 | + When I log in as "teacher" And I am on "Test" course homepage with editing mode on - When I add a "label" to section "1" and I fill the form with: - | Label text | Label with ID number set | - | Availability | Show on course page | - | ID number | C1LABEL1 | Then "Label with ID number set" activity should be visible And I turn editing mode off And "Label with ID number set" activity should be visible @@ -32,11 +30,7 @@ Feature: set label idnumber And I am on "Test" course homepage And I should see "Label with ID number set" And I log out - And I log in as "teacher" - And I am on "Test" course homepage - And I turn editing mode on - And I open "Label with ID number set" actions menu - And I click on "Edit settings" "link" in the "Label with ID number set" activity + And I am on the "Label with ID number set" "label activity editing" page logged in as teacher And I expand all fieldsets And I should see "ID number" in the "Common module settings" "fieldset" And the field "ID number" matches value "C1LABEL1" diff --git a/mod/label/tests/behat/label_visibility.feature b/mod/label/tests/behat/label_visibility.feature index 8b11660df11..761124f6198 100644 --- a/mod/label/tests/behat/label_visibility.feature +++ b/mod/label/tests/behat/label_visibility.feature @@ -5,8 +5,7 @@ Feature: Check label visibility works As a teacher I should create label activity - @javascript - Scenario: Hidden label activity should be show as hidden. + Background: Given the following "courses" exist: | fullname | shortname | category | | Test | C1 | 0 | @@ -18,38 +17,26 @@ Feature: Check label visibility works | user | course | role | | teacher | C1 | editingteacher | | student | C1 | student | + And the following "activities" exist: + | activity | course | section | intro | idnumber | visible | + | label | C1 | 1 | Swanky label | 1 | 1 | + | label | C1 | 1 | Swanky label 2 | 2 | 0 | + + Scenario: Hidden label activity should be show as hidden. Given I log in as "teacher" - And I am on "Test" course homepage with editing mode on - When I add a "label" to section "1" and I fill the form with: - | Label text | Swanky label | - | Availability | Hide from students | - Then "Swanky label" activity should be hidden + When I am on "Test" course homepage with editing mode on + Then "Swanky label 2" activity should be hidden And I turn editing mode off - And "Swanky label" activity should be hidden + And "Swanky label 2" activity should be hidden And I log out And I log in as "student" And I am on "Test" course homepage - And I should not see "Swanky label" + And I should not see "Swanky label 2" And I log out - @javascript Scenario: Visible label activity should be shown as visible. - Given the following "courses" exist: - | fullname | shortname | category | - | Test | C1 | 0 | - And the following "users" exist: - | username | firstname | lastname | email | - | teacher | Teacher | Frist | teacher1@example.com | - | student | Student | First | student1@example.com | - And the following "course enrolments" exist: - | user | course | role | - | teacher | C1 | editingteacher | - | student | C1 | student | Given I log in as "teacher" - And I am on "Test" course homepage with editing mode on - When I add a "label" to section "1" and I fill the form with: - | Label text | Swanky label | - | Availability | Show on course page | + When I am on "Test" course homepage with editing mode on Then "Swanky label" activity should be visible And I log out And I log in as "student" @@ -59,23 +46,9 @@ Feature: Check label visibility works @javascript Scenario: Teacher can not show label inside the hidden section - Given the following "courses" exist: - | fullname | shortname | category | - | Test | C1 | 0 | - And the following "users" exist: - | username | firstname | lastname | email | - | teacher | Teacher | Frist | teacher1@example.com | - | student | Student | First | student1@example.com | - And the following "course enrolments" exist: - | user | course | role | - | teacher | C1 | editingteacher | - | student | C1 | student | Given I log in as "teacher" And I am on "Test" course homepage with editing mode on - When I add a "label" to section "1" and I fill the form with: - | Label text | Swanky label | - | Availability | Show on course page | - And I hide section "1" + When I hide section "1" Then "Swanky label" activity should be dimmed And I open "Swanky label" actions menu And "Swanky label" actions menu should not have "Show" item