MDL-70817 mod_choice: Behat tests for the activity completion info

This commit is contained in:
Jun Pataleta
2021-04-02 21:53:20 +08:00
parent 469f035a4c
commit 98f44ac00d
2 changed files with 157 additions and 0 deletions
@@ -0,0 +1,61 @@
@mod @mod_choice @core_completion
Feature: Automatic completion in the choice activity
In order for me to know what to do to complete the choice activity
As a student
I need to be able to see the completion requirements of the choice activity
Background:
Given the following "users" exist:
| username | firstname | lastname | email |
| teacher1 | Teacher | 1 | teacher1@example.com |
| student1 | Student | 1 | student1@example.com |
And the following "course" exists:
| fullname | Course 1 |
| shortname | C1 |
| category | 0 |
| enablecompletion | 1 |
And the following "activity" exists:
| activity | choice |
| name | What to drink? |
| intro | Friday drinks, anyone? |
| course | C1 |
| idnumber | choice1 |
| completion | 2 |
| completionview | 1 |
| completionsubmit | 1 |
And the following "course enrolments" exist:
| user | course | role |
| student1 | C1 | student |
| teacher1 | C1 | editingteacher |
Scenario: Viewing a choice activity with automatic completion as a student
Given I log in as "student1"
And I am on "Course 1" course homepage
When I follow "What to drink?"
Then I should see "Done: View" in the "[data-region=completionrequirements]" "css_element"
And I should see "To do: Make a choice" in the "[data-region=completionrequirements]" "css_element"
And I set the field "Beer" to "1"
And I press "Save my choice"
And I should see "Done: View" in the "[data-region=completionrequirements]" "css_element"
And I should see "Done: Make a choice" in the "[data-region=completionrequirements]" "css_element"
Scenario: Viewing a choice activity with automatic completion as a teacher
Given I log in as "teacher1"
And I am on "Course 1" course homepage
When I follow "What to drink?"
And I should see "View" in the "[data-region=completionrequirements]" "css_element"
And I should see "Make a choice" in the "[data-region=completionrequirements]" "css_element"
@javascript
Scenario: Overriding automatic choice completion for a user
Given I log in as "teacher1"
And I am on "Course 1" course homepage
And I navigate to "Reports > Activity completion" in current page administration
And I click on "Student 1, What to drink?: Not completed" "link"
And I press "Save changes"
And I log out
And I log in as "student1"
And I am on "Course 1" course homepage
When I follow "What to drink?"
Then "span[aria-label=\"Done: View (set by Teacher 1)\"]" "css_element" should exist
And "span[aria-label=\"Done: Make a choice (set by Teacher 1)\"]" "css_element" should exist
@@ -0,0 +1,96 @@
@mod @mod_choice @core_completion
Feature: Manual completion in the choice activity
To avoid navigating from the choice activity to the course homepage to mark the choice activity as complete
As a student
I need to be able to mark the choice activity as complete within the choice activity itself
Background:
Given the following "users" exist:
| username | firstname | lastname | email |
| teacher1 | Teacher | 1 | teacher1@example.com |
| student1 | Student | 1 | student1@example.com |
And the following "course" exists:
| fullname | Course 1 |
| shortname | C1 |
| category | 0 |
| enablecompletion | 1 |
And the following "activity" exists:
| activity | choice |
| name | What to drink? |
| intro | Friday drinks, anyone? |
| course | C1 |
| idnumber | choice1 |
| completion | 1 |
And the following "course enrolments" exist:
| user | course | role |
| student1 | C1 | student |
| teacher1 | C1 | editingteacher |
@javascript
Scenario: Toggle manual completion as a student
Given I log in as "student1"
And I am on "Course 1" course homepage
And I follow "What to drink?"
And "Mark as done" "button" should exist
When I press "Mark as done"
And I wait until the page is ready
Then "Done" "button" should exist
But "Mark as done" "button" should not exist
# Just make sure that the change persisted.
And I reload the page
And I wait until the page is ready
And I should not see "Mark as done"
And I should see "Done"
And I press "Done"
And I wait until the page is ready
And "Mark as done" "button" should exist
But "Done" "button" should not exist
# Just make sure that the change persisted.
And I reload the page
And I wait until the page is ready
And "Mark as done" "button" should exist
But "Done" "button" should not exist
Scenario: Viewing a choice activity with manual completion as a teacher
Given I log in as "teacher1"
And I am on "Course 1" course homepage
When I follow "What to drink?"
Then the "Mark as done" "button" should be disabled
@javascript
Scenario: Overriding a manual choice completion for a user to done
Given I log in as "teacher1"
And I am on "Course 1" course homepage
And I navigate to "Reports > Activity completion" in current page administration
And I click on "Student 1, What to drink?: Not completed" "link"
And I press "Save changes"
And I log out
And I log in as "student1"
And I am on "Course 1" course homepage
When I follow "What to drink?"
Then "button[aria-label=\"What to drink? is marked by Teacher 1 as done. Press to undo.\"]" "css_element" should exist
And I press "Done"
And I wait until the page is ready
And "button[aria-label=\"Mark What to drink? as done\"]" "css_element" should exist
@javascript
Scenario: Overriding a manual choice completion for a user to not done
Given I log in as "student1"
And I am on "Course 1" course homepage
And I follow "What to drink?"
And I press "Mark as done"
And I wait until the page is ready
And I log out
And I log in as "teacher1"
And I am on "Course 1" course homepage
And I navigate to "Reports > Activity completion" in current page administration
And I click on "Student 1, What to drink?: Completed" "link"
And I press "Save changes"
And I log out
And I log in as "student1"
And I am on "Course 1" course homepage
When I follow "What to drink?"
Then "button[aria-label=\"What to drink? is marked by Teacher 1 as not done. Press to mark as done.\"]" "css_element" should exist
And I press "Mark as done"
And I wait until the page is ready
And "button[aria-label=\"What to drink? is marked as done. Press to undo.\"]" "css_element" should exist