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.
This commit is contained in:
Angelia Dela Cruz
2022-06-10 13:11:00 +08:00
parent ac39bac81b
commit 2409c05065
4 changed files with 24 additions and 58 deletions
@@ -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 |
@@ -96,7 +96,6 @@ Feature: Show/hide course sections
And I should not see "Topic 2" in the "region-main" "region"
And I should see "Topic 1" in the "region-main" "region"
@javascript
Scenario: Students can not navigate to restricted sections
Given I am on "Course 1" course homepage
Given I navigate to "Settings" in current page administration
@@ -104,9 +103,9 @@ Feature: Show/hide course sections
| Course layout | Show one section per page |
| 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 |
| label | C1 | 1 | Test label | 1 |
And I edit the section "2"
And I expand all fieldsets
And I click on "Add restriction..." "button"
+5 -11
View File
@@ -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"
+13 -40
View File
@@ -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" label should be hidden
When I am on "Test" course homepage with editing mode on
Then "Swanky label 2" label should be hidden
And I turn editing mode off
And "Swanky label" label should be hidden
And "Swanky label 2" label 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" label should be hidden
And I open "Swanky label" actions menu
And "Swanky label" actions menu should not have "Show" item