MDL-78280 completion: Fix behat for new completion UI

- The following behat step definitions were modified to work correctly both for course page conditions dialog and activity page
condition badges: 'activity_completion_condition_displayed_as', 'overridden_activity_completion_condition_displayed_as'
and 'activity_should_have_the_completion_condition'.
- Because now "Mark as done" manual completion button is not displayed for teachers in course homepage,
some behat steps were also modified.
This commit is contained in:
Mikel Martín 2023-07-03 15:21:37 +02:00
parent e5908a1ce4
commit 530691b1ca
14 changed files with 56 additions and 54 deletions

View File

@ -157,7 +157,7 @@ class behat_completion extends behat_base {
/**
* Checks if the activity with specified name is maked as complete.
*
* @Given /^the "(?P<conditionname>(?:[^"]|\\")*)" completion condition of "(?P<activityname>(?:[^"]|\\")*)" is displayed as "(?P<completionstatus>(?:[^"]|\\")*)"$/
* @When the :conditionname completion condition of :activityname is displayed as :completionstatus
* @param string $conditionname The completion condition text.
* @param string $activityname The activity name.
* @param string $completionstatus The completion status. Must be either of the following: 'todo', 'done', 'failed'.
@ -169,7 +169,7 @@ class behat_completion extends behat_base {
throw new coding_exception('Invalid completion status. It must be of type "todo", "done", or "failed".');
}
$text = get_string("completion_automatic:$completionstatus", 'core_course') . ' ' . $conditionname;
$text = get_string("completion_automatic:$completionstatus", 'core_course');
$conditionslistlabel = get_string('completionrequirements', 'core_course', $activityname);
$selector = "div[aria-label='$conditionslistlabel']";
@ -178,20 +178,21 @@ class behat_completion extends behat_base {
// If there is a dropdown, open it.
$dropdownnode = $this->find('css', $selector . ' .dropdown-menu');
if (!$dropdownnode->hasClass('show')) {
$params = [get_string('completionmenuitem', 'completion'), "button", $selector, "css_element"];
$params = ["button.dropdown-toggle", "css_element", $selector, "css_element"];
$this->execute("behat_general::i_click_on_in_the", $params);
}
} catch (ElementNotFoundException $e) {
// If the dropdown does not exist, we are in the activity page, all good.
}
$this->execute("behat_general::assert_element_contains_text", [$text, $selector, "css_element"]);
$xpath = "//div[@aria-label='$conditionslistlabel']//span[text()='$conditionname']/..";
$this->execute("behat_general::assert_element_contains_text", [$text, $xpath, "xpath_element"]);
}
/**
* Checks if the activity with specified name is maked as complete.
*
* @Given /^the "(?P<conditionname>(?:[^"]|\\")*)" completion condition of "(?P<activityname>(?:[^"]|\\")*)" overridden by "(?P<username>(?:[^"]|\\")*)" is displayed as "(?P<completionstatus>(?:[^"]|\\")*)"$/
* @When the :conditionname completion condition of :activityname overridden by :username is displayed as :completionstatus
* @param string $conditionname The completion condition text.
* @param string $activityname The activity name.
* @param string $username The full name of the user overriding the student's activity completion.
@ -207,7 +208,7 @@ class behat_completion extends behat_base {
'condition' => $conditionname,
'setby' => $username,
]);
$conditionbadge = "span[aria-label='$conditionlabel']";
$conditionbadge = "div[aria-label='$conditionlabel']";
$conditionslistlabel = get_string('completionrequirements', 'core_course', $activityname);
$completionconditions = "div[aria-label='$conditionslistlabel']";
@ -336,13 +337,24 @@ class behat_completion extends behat_base {
/**
* Check that the activity has the given automatic completion condition.
*
* @Given /^"(?P<activityname>(?:[^"]|\\")*)" should have the "(?P<conditionname>(?:[^"]|\\")*)" completion condition$/
* @When :activityname should have the :conditionname completion condition
* @param string $activityname The activity name.
* @param string $conditionname The automatic condition name.
*/
public function activity_should_have_the_completion_condition(string $activityname, string $conditionname): void {
$containerselector = "div[data-region=activity-information][data-activityname='$activityname']";
try {
// If there is a dropdown, open it.
$dropdownnode = $this->find('css', $containerselector . ' .dropdown-menu');
if (!$dropdownnode->hasClass('show')) {
$params = ["button.dropdown-toggle", "css_element", $containerselector, "css_element"];
$this->execute("behat_general::i_click_on_in_the", $params);
}
} catch (ElementNotFoundException $e) {
// If the dropdown does not exist, we are in the activity page, all good.
}
$params = [$conditionname, $containerselector, 'css_element'];
$this->execute("behat_general::assert_element_contains_text", $params);
}

View File

@ -1,4 +1,4 @@
@core @core_completion
@core @core_completion @javascript
Feature: Show activity completion status or activity completion configuration on the course page
In order to understand the configuration or status of an activity's completion
As a user
@ -38,16 +38,16 @@ Feature: Show activity completion status or activity completion configuration on
Scenario: Show completion configuration to editing teachers
Given I am on the "Course 1" course page logged in as teacher1
And the manual completion button for "Test forum name" should be disabled
And "Test forum name" should have the "Mark as done" completion condition
And "Test assignment name" should have the "View" completion condition
And there should be no completion information shown for "Test quiz name"
And I am on "Course 1" course homepage with editing mode on
And the manual completion button for "Test forum name" should be disabled
And "Test forum name" should have the "Mark as done" completion condition
And "Test assignment name" should have the "View" completion condition
And there should be no completion information shown for "Test quiz name"
Scenario: Show completion configuration to non-editing teachers
Given I am on the "Course 1" course page logged in as teacher2
And the manual completion button for "Test forum name" should be disabled
And "Test forum name" should have the "Mark as done" completion condition
And "Test assignment name" should have the "View" completion condition
And there should be no completion information shown for "Test quiz name"

View File

@ -18,13 +18,14 @@ Feature: Allow teachers to edit the visibility of completion conditions in a cou
| activity | course | idnumber | name | completion | completionsubmit |
| choice | C1 | c1m | Test choice manual| 1 | 0 |
| choice | C1 | c1a | Test choice auto | 2 | 1 |
@javascript
Scenario: Completion condition displaying for manual and auto completion
Given I log in as "teacher1"
When I am on "Course 1" course homepage
# The manual completion toggle button should be always displayed in both course homepage and activity view.
Then the manual completion button for "Test choice manual" should be disabled
# The manual completion "Mark as done" criteria should displayed in the dropdown in the course homepage.
Then "Test choice manual" should have the "Mark as done" completion condition
And I follow "Test choice manual"
# The manual completion toggle button should be displayed in activity view.
And the manual completion button for "Test choice manual" should be disabled
# Automatic completion conditions should be displayed on both activity view page and course homepage if show completion conditions is enabled.
And I am on "Course 1" course homepage

View File

@ -43,8 +43,7 @@ Feature: View activity completion in the assignment activity
Scenario: The manual completion button will be shown on the course page if the Show activity completion conditions is set to Yes
Given I am on the "Course 1" course page logged in as teacher1
# Teacher view.
And the manual completion button for "Music history" should exist
And the manual completion button for "Music history" should be disabled
And "Music history" should have the "Mark as done" completion condition
And I log out
# Student view.
When I log in as "student1"
@ -62,10 +61,7 @@ Feature: View activity completion in the assignment activity
And I set the field "Show activity completion conditions" to "No"
And I press "Save and display"
# Teacher view.
And the manual completion button for "Music history" should not exist
And I am on the "Music history" "assign activity" page
And the manual completion button for "Music history" should exist
And the manual completion button for "Music history" should be disabled
And "Completion" "button" should not exist in the "Music history" "activity"
And I log out
# Student view.
When I am on the "Course 1" course page logged in as "student1"

View File

@ -55,7 +55,7 @@ Feature: View activity completion information in the chat activity
| completion | 1 |
And I am on "Course 1" course homepage
# Teacher view.
And the manual completion button for "Music history" should be disabled
And "Music history" should have the "Mark as done" completion condition
And I log out
# Student view.
And I am on the "Music history" Activity page logged in as student1

View File

@ -35,8 +35,7 @@ Feature: View activity completion information for the label
Scenario: The manual completion button will be shown on the course page if the Show activity completion conditions is set to No
Given I am on "Course 1" course homepage
# Teacher view.
And the manual completion button for "Test label 1" should exist
And the manual completion button for "Test label 1" should be disabled
And "Test label 1" should have the "Mark as done" completion condition
And I log out
# Student view.
When I log in as "student1"
@ -54,8 +53,7 @@ Feature: View activity completion information for the label
And I set the field "Show activity completion conditions" to "Yes"
And I press "Save and display"
# Teacher view.
And the manual completion button for "Test label 1" should exist
And the manual completion button for "Test label 1" should be disabled
And "Test label 1" should have the "Mark as done" completion condition
And I log out
# Student view.
When I log in as "student1"

View File

@ -1,4 +1,4 @@
@mod @mod_lesson
@mod @mod_lesson @javascript
Feature: Set end of lesson reached as a completion condition for a lesson
In order to ensure students really see all lesson pages
As a teacher

View File

@ -1,4 +1,4 @@
@mod @mod_lesson
@mod @mod_lesson @javascript
Feature: Set time spent as a completion condition for a lesson
In order to ensure students spend the needed time to study lessons
As a teacher

View File

@ -1,4 +1,4 @@
@mod @mod_quiz @core_completion
@mod @mod_quiz @core_completion @javascript
Feature: Set a quiz to be marked complete when the student uses all attempts allowed
In order to ensure a student has learned the material before being marked complete
As a teacher
@ -35,8 +35,7 @@ Feature: Set a quiz to be marked complete when the student uses all attempts all
| 1 | False |
Scenario Outline: Student attempts the quiz - pass and fails
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 "Receive a grade" completion condition of "Test quiz name" is displayed as "done"
And the "Receive a passing grade" completion condition of "Test quiz name" is displayed as "failed"
And the "Receive a pass grade or complete all available attempts" completion condition of "Test quiz name" is displayed as "todo"
@ -45,18 +44,17 @@ Feature: Set a quiz to be marked complete when the student uses all attempts all
And I set the field "<answer>" to "1"
And I press "Finish attempt ..."
And I press "Submit all and finish"
And I click on "Submit all and finish" "button" in the "Submit all your answers and finish?" "dialogue"
And I am on "Course 1" course homepage
Then the "Receive a grade" completion condition of "Test quiz name" is displayed as "done"
And the "Receive a passing grade" completion condition of "Test quiz name" is displayed as "<passcompletionexpected>"
And the "Receive a pass grade or complete all available attempts" completion condition of "Test quiz name" is displayed as "done"
And I follow "Test quiz name"
And I click on "Test quiz name" "link" in the "region-main" "region"
And the "Receive a grade" completion condition of "Test quiz name" is displayed as "done"
And the "Receive a passing grade" completion condition of "Test quiz name" is displayed as "<passcompletionexpected>"
And the "Receive a pass grade or complete all available attempts" completion condition of "Test quiz name" is displayed as "done"
And I log out
And I log in as "teacher1"
And I am on "Course 1" course homepage
And I follow "Test quiz name"
And I am on the "Test quiz name" "quiz activity" page logged in as teacher1
And "Test quiz name" should have the "Receive a pass grade or complete all available attempts" completion condition
And I am on "Course 1" course homepage
And I navigate to "Reports" in current page administration

View File

@ -1,4 +1,4 @@
@mod @mod_quiz @core_completion
@mod @mod_quiz @core_completion @javascript
Feature: Set a quiz to be marked complete when the student completes a minimum amount of attempts
In order to ensure a student has completed the quiz before being marked complete
As a teacher
@ -35,26 +35,24 @@ Feature: Set a quiz to be marked complete when the student completes a minimum a
| 1 | False |
Scenario: student1 uses up both attempts without passing
When I log in as "teacher1"
And I am on "Course 1" course homepage
When I am on the "Course 1" course page logged in as teacher1
And "Completed: Test quiz name" "icon" should not exist in the "Test quiz name" "list_item"
And I log out
And I log in as "student1"
And I am on "Course 1" course homepage
And I am on the "Course 1" course page logged in as student1
And the "Make attempts: 2" completion condition of "Test quiz name" is displayed as "todo"
And I follow "Test quiz name"
And I click on "Test quiz name" "link" in the "region-main" "region"
And I press "Re-attempt quiz"
And I set the field "False" to "1"
And I press "Finish attempt ..."
And I press "Submit all and finish"
And I click on "Submit all and finish" "button" in the "Submit all your answers and finish?" "dialogue"
And I am on "Course 1" course homepage
Then the "Make attempts: 2" completion condition of "Test quiz name" is displayed as "done"
And I follow "Test quiz name"
And I click on "Test quiz name" "link" in the "region-main" "region"
And the "Make attempts: 2" completion condition of "Test quiz name" is displayed as "done"
And I log out
And I log in as "teacher1"
And I am on "Course 1" course homepage
And I follow "Test quiz name"
And I am on the "Course 1" course page logged in as teacher1
And I click on "Test quiz name" "link" in the "region-main" "region"
And "Test quiz name" should have the "Make attempts: 2" completion condition
And I am on "Course 1" course homepage
And I navigate to "Reports" in current page administration

View File

@ -31,6 +31,7 @@ Feature: Set a quiz to be marked complete when the student passes
| question | page |
| First question | 1 |
@javascript
Scenario: student1 passes on the first try
When I log in as "student1"
And I am on "Course 1" course homepage

View File

@ -33,8 +33,7 @@ Feature: View activity completion information for file resources
| resource | C1 | Myfile | <display> | 0 | 0 | 0 | 1 | mod/resource/tests/fixtures/samplefile.txt | 620 | 450 | 1 |
And I am on "Course 1" course homepage with editing mode on
# Teacher view.
And the manual completion button for "Myfile" should exist
And the manual completion button for "Myfile" should be disabled
And "Myfile" should have the "Mark as done" completion condition
# Student view.
When I am on the "Course 1" course page logged in as student1
Then the manual completion button for "Myfile" should exist
@ -64,8 +63,7 @@ Feature: View activity completion information for file resources
| Completion tracking | Students can manually mark the activity as completed |
And I click on "Save and return to course" "button"
# Teacher view.
And the manual completion button for "Myfile" should exist
And the manual completion button for "Myfile" should be disabled
And "Myfile" should have the "Mark as done" completion condition
And I am on the "Myfile" "resource activity" page
And the manual completion button for "Myfile" should exist
And the manual completion button for "Myfile" should be disabled

View File

@ -1,4 +1,4 @@
@mod @mod_survey @core_completion
@mod @mod_survey @core_completion @javascript
Feature: A teacher can use activity completion to track a student progress
In order to use activity completion
As a teacher
@ -50,14 +50,13 @@ Feature: A teacher can use activity completion to track a student progress
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 | 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 "Test survey name" should have the "Mark as done" completion condition
# 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

@ -77,6 +77,7 @@ Feature: View activity completion information in the URL resource
When I am on the "Music history" "url activity" page logged in as student1
Then the "View" completion condition of "Music history" is displayed as "done"
@javascript
Scenario: View automatic completion items in open display mode as teacher
Given the following "activity" exists:
| activity | url |
@ -92,6 +93,7 @@ Feature: View activity completion information in the URL resource
And I am on the "Course 1" course page
Then "Music history" should have the "View" completion condition
@javascript
Scenario: View automatic completion items in open display mode as student
Given the following "activity" exists:
| activity | url |
@ -172,7 +174,7 @@ Feature: View activity completion information in the URL resource
And the manual completion button of "Music history" is displayed as "Done"
@javascript
Scenario Outline: The manual completion button will be shown on the course page for Open, In pop-up and New window display mode if the Show activity completion conditions is set to No as teacher
Scenario Outline: The Mark as done completion condition will be shown on the course page for Open, In pop-up and New window display mode if the Show activity completion conditions is set to No as teacher
Given the following "activity" exists:
| activity | url |
| course | C1 |
@ -186,8 +188,7 @@ Feature: View activity completion information in the URL resource
| popupwidth | 620 |
| popupheight | 450 |
When I am on the "Course 1" course page logged in as teacher1
Then the manual completion button for "Music history" should exist
And the manual completion button for "Music history" should be disabled
Then "Music history" should have the "Mark as done" completion condition
Examples:
| display | description |