MDL-71162 mod_survey: Improve behat testing for completion conditions

This commit is contained in:
Michael Hawkins 2021-04-20 18:41:46 +08:00
parent f9c276632a
commit 9fec71fe27

View File

@ -20,14 +20,22 @@ Feature: A teacher can use activity completion to track a student progress
And I am on "Course 1" course homepage with editing mode on
Scenario: Require survey view
Given I add a "Survey" to section "1" and I fill the form with:
| Name | Test survey name |
| Survey type | Critical incidents |
| Description | Test survey description |
Given the following "activities" exist:
| activity | name | intro | course | idnumber |
| survey | Test survey name | Test survey description | C1 | survey1 |
And I am on "Course 1" course homepage
And I follow "Test survey name"
And I navigate to "Edit settings" in current page administration
And I set the following fields to these values:
| Completion tracking | Show activity as complete when conditions are met |
| id_completionview | 1 |
| id_completionsubmit | 0 |
| completionview | 1 |
| completionsubmit | 0 |
And I press "Save and return to course"
And I follow "Test survey name"
# 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
And the "View" completion condition of "Test survey name" is displayed as "todo"
@ -36,17 +44,47 @@ Feature: A teacher can use activity completion to track a student progress
Then the "View" completion condition of "Test survey name" is displayed as "done"
Scenario: Require survey submission
Given I add a "Survey" to section "1" and I fill the form with:
| Name | Test survey name |
Given the following "activities" exist:
| activity | name | intro | course | idnumber |
| survey | Test survey name | Test survey description | C1 | survey1 |
And I am on "Course 1" course homepage
And I follow "Test survey name"
And I navigate to "Edit settings" in current page administration
And I set the following fields to these values:
| Survey type | Critical incidents |
| Description | Test survey description |
| Completion tracking | Show activity as complete when conditions are met |
| id_completionsubmit | 1 |
| completionview | 1 |
| completionsubmit | 1 |
And I press "Save and return to course"
And I follow "Test survey name"
# 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
And the "View" completion condition of "Test survey name" is displayed as "todo"
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"
And I press "Click here to continue"
And I am on "Course 1" course homepage
And the "View" completion condition of "Test survey name" is displayed as "done"
And the "Submit answers" completion condition of "Test survey name" is displayed as "done"
And I follow "Test survey name"
And the "Submit answers" completion condition of "Test survey name" is displayed as "done"
@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 |
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 log in as "student1"
And I am on "Course 1" course homepage
And I follow "Test survey name"
Then the manual completion button of "Test survey name" is displayed as "Mark as done"
And I toggle the manual completion state of "Test survey name"
And the manual completion button of "Test survey name" is displayed as "Done"