MDL-75960 behat: Survey behat generators use UI

Replace steps that manually add Survey instances via the UI and use
Behat generators. This improves the speed of the Behat test runs.
This commit is contained in:
Angelia Dela Cruz 2022-10-12 15:38:56 +08:00 committed by Andrew Nicols
parent dded69ad15
commit 5384f872bb
5 changed files with 40 additions and 64 deletions

View File

@ -15,25 +15,18 @@ Feature: Block appearances
| user | course | role |
| teacher1 | C1 | editingteacher |
And the following "activities" exist:
| activity | name | description | course | idnumber | section |
| survey | Test survey name | Test survey description | C1 | survey1 | 1 |
| book | Test book name | Test book description | C1 | book1 | 1 |
| activity | name | description | course | idnumber | section | template |
| survey | Test survey name | | C1 | survey1 | 1 | 4 |
| book | Test book name | Test book description | C1 | book1 | 1 | |
And I log in as "admin"
And I am on "Course 1" course homepage
And I click on "Test survey name" "link" in the "region-main" "region"
And I navigate to "Settings" in current page administration
And I set the following fields to these values:
| Survey type | ATTLS (20 item version) |
And I press "Save and return to course"
And I am on "Course 1" course homepage with editing mode on
And I click on "Test book name" "link" in the "region-main" "region"
And I set the following fields to these values:
| Chapter title | Book title |
| Content | Book content test test |
And I press "Save changes"
And I log out
And I log in as "teacher1"
And I am on "Course 1" course homepage with editing mode on
And I am on the "Course 1" course page logged in as teacher1
And I turn editing mode on
And I add the "Comments" block
And I configure the "Comments" block
And I set the following fields to these values:

View File

@ -14,12 +14,11 @@ Feature: Block region moving
And the following "course enrolments" exist:
| user | course | role |
| teacher1 | C1 | editingteacher |
And the following "activities" exist:
| activity | course | name | template |
| survey | C1 | Test survey name | 4 |
And I log in as "admin"
And I am on "Course 1" course homepage with editing mode on
And I add a "Survey" to section "1" and I fill the form with:
| Name | Test survey name |
| Survey type | ATTLS (20 item version) |
| Description | Test survey description |
And I add a "Book" to section "1" and I fill the form with:
| Name | Test book name |
| Description | Test book description |

View File

@ -20,22 +20,13 @@ Feature: A teacher can use activity completion to track a student progress
Scenario: Require survey view
Given the following "activities" exist:
| activity | name | intro | course | idnumber |
| survey | Test survey name | Test survey description | C1 | survey1 |
And I am on the "Test survey name" "survey activity editing" page
And I set the following fields to these values:
| Survey type | Critical incidents |
| Completion tracking | Show activity as complete when conditions are met |
| completionview | 1 |
| completionsubmit | 0 |
And I press "Save and return to course"
And I follow "Test survey name"
| activity | name | course | idnumber | template | completion | completionview | completionsubmit |
| survey | Test survey name | C1 | survey1 | 5 | 2 | 1 | 0 |
And I am on the "Test survey name" "survey activity" page
# Teacher view.
And "Test survey name" should have the "View" completion condition
And I log out
# Student view.
When I log in as "student1"
And I am on "Course 1" course homepage
When I am on the "Course 1" course page logged in as student1
And the "View" completion condition of "Test survey name" is displayed as "todo"
And I follow "Test survey name"
And I am on "Course 1" course homepage
@ -43,22 +34,13 @@ Feature: A teacher can use activity completion to track a student progress
Scenario: Require survey submission
Given the following "activities" exist:
| activity | name | intro | course | idnumber |
| survey | Test survey name | Test survey description | C1 | survey1 |
And I am on the "Test survey name" "survey activity editing" page
And I set the following fields to these values:
| Survey type | Critical incidents |
| Completion tracking | Show activity as complete when conditions are met |
| completionview | 1 |
| completionsubmit | 1 |
And I press "Save and return to course"
| activity | name | course | idnumber | template | completion | completionview | completionsubmit |
| survey | Test survey name | C1 | survey1 | 5 | 2 | 1 | 1 |
And I am on the "Test survey name" "survey activity" page
# Teacher view.
And "Test survey name" should have the "Submit answers" completion condition
And I log out
# Student view.
When I log in as "student1"
And I am on "Course 1" course homepage
When I am on the "Course 1" course page logged in as student1
And the "Submit answers" completion condition of "Test survey name" is displayed as "todo"
And I follow "Test survey name"
And the "Submit answers" completion condition of "Test survey name" is displayed as "todo"
@ -71,12 +53,11 @@ Feature: A teacher can use activity completion to track a student progress
@javascript
Scenario: Use manual completion
Given the following "activities" exist:
| activity | name | intro | course | idnumber | completion |
| survey | Test survey name | Test survey description | C1 | survey1 | 1 |
| activity | name | course | idnumber | completion |
| survey | Test survey name | C1 | survey1 | 1 |
And I am on "Course 1" course homepage
# Teacher view.
And the manual completion button for "Test survey name" should be disabled
And I log out
# Student view.
When I am on the "survey1" Activity page logged in as student1
Then the manual completion button of "Test survey name" is displayed as "Mark as done"

View File

@ -18,17 +18,11 @@ Feature: A teacher navigates to response reports of students
| student1 | C1 | student |
| student2 | C1 | student |
And the following "activities" exist:
| activity | name | intro | course | idnumber | section |
| survey | Test survey name | Test survey description | C1 | survey1 | 1 |
| activity | name | course | idnumber | template |
| survey | Test survey name | C1 | survey1 | 5 |
Scenario: Only questions and participants page should be available under response reports as teacher
Given I am on the "Test survey name" "survey activity" page logged in as teacher1
And I navigate to "Settings" in current page administration
And I set the following fields to these values:
| Survey type | Critical incidents |
And I press "Save and return to course"
And I log out
And I am on the "Test survey name" "survey activity" page logged in as student1
Given I am on the "Test survey name" "survey activity" page logged in as student1
And I set the field "At what moment in class were you most engaged as a learner?" to "most engaged as student1"
And I set the field "At what moment in class were you most distanced as a learner?" to "most distanced as student1"
And I set the field "What action from anyone in the forums did you find most affirming or helpful?" to "most helpful student1"
@ -36,7 +30,6 @@ Feature: A teacher navigates to response reports of students
And I set the field "What event surprised you most?" to "most surprised student1"
And I press "Submit"
And I press "Continue"
And I log out
And I am on the "Test survey name" "survey activity" page logged in as student2
And I set the field "At what moment in class were you most engaged as a learner?" to "most engaged as student2"
And I set the field "At what moment in class were you most distanced as a learner?" to "most distanced as student2"
@ -45,7 +38,6 @@ Feature: A teacher navigates to response reports of students
And I set the field "What event surprised you most?" to "most surprised student1"
And I press "Submit"
And I press "Continue"
And I log out
When I am on the "Test survey name" "survey activity" page logged in as teacher1
And I navigate to "Response reports" in current page administration
Then I should not see "Summary"

View File

@ -4,7 +4,7 @@ Feature: A teacher can set three types of survey activity
As a teacher
I need to set survey activities and select which survey type suits my needs
Scenario: Switching between the three survey types
Background:
Given the following "users" exist:
| username | firstname | lastname | email |
| teacher1 | Teacher | 1 | teacher1@example.com |
@ -14,17 +14,16 @@ Feature: A teacher can set three types of survey activity
And the following "course enrolments" exist:
| user | course | role |
| teacher1 | C1 | editingteacher |
And the following "activities" exist:
| activity | name | intro | course | idnumber | section |
| survey | Test survey name | Test survey description | C1 | survey1 | 1 |
And I log in as "teacher1"
And I am on "Course 1" course homepage
And I follow "Test survey name"
And I navigate to "Settings" in current page administration
Scenario: Switching between the three survey types
Given the following "activities" exist:
| activity | name | course | idnumber |
| survey | Test survey name | C1 | survey1 |
And I am on the "Test survey name" "survey activity editing" page
And I set the following fields to these values:
| Survey type | ATTLS (20 item version) |
And I press "Save and return to course"
And I follow "Test survey name"
And I press "Save and display"
Then I should see "Attitudes Towards Thinking and Learning"
And I navigate to "Settings" in current page administration
And I set the following fields to these values:
@ -37,3 +36,15 @@ Feature: A teacher can set three types of survey activity
And I press "Save and display"
And I should see "In this online unit..."
And I should see "my learning focuses on issues that interest me."
@javascript
Scenario: Survey activity is created via UI
Given I am on the "Course 1" course page
And I turn editing mode on
And I add a "Survey" to section "1"
And I set the following fields to these values:
| Name | Test survey name |
| Description | Test survey description |
| Survey type | ATTLS (20 item version) |
When I press "Save and return to course"
Then I should see "Test survey name"