Skip to content

Commit

Permalink
MDL-78530 behat: new I am adding an activity navigation step
Browse files Browse the repository at this point in the history
  • Loading branch information
ferranrecio committed Aug 14, 2023
1 parent 8740488 commit 38e939f
Show file tree
Hide file tree
Showing 2 changed files with 59 additions and 46 deletions.
86 changes: 40 additions & 46 deletions completion/tests/behat/site_default_activity_completion.feature
Original file line number Diff line number Diff line change
Expand Up @@ -10,70 +10,64 @@ Feature: Allow admins to edit the default activity completion rules at site leve
| Course 1 | C1 | 0 | 1 |
And I log in as "admin"

@javascript
Scenario: Default activity completion rules with no site or course default completion
Scenario: Default values don't affect existing activities when no site or course defaults are defined
Given the following "activity" exists:
| activity | assign |
| course | C1 |
| name | Test assignment one |
| completion | 1 |
And I am on "Course 1" course homepage with editing mode on
And I press "Add an activity or resource"
When I click on "Add a new Assignment" "link" in the "Add an activity or resource" "dialogue"
And I expand all fieldsets
# Completion tracking 0 = Do not indicate activity completion.
| activity | assign |
| course | C1 |
| name | Test assignment one |
| completion | 1 |
And I am on the "Test assignment one" Activity page
When I navigate to "Settings" in current page administration
Then the field "Completion tracking" matches value "1"

Scenario: Default activity completion rules with no site or course default completion
When I am adding an assign to section 0 of the "Course 1" course
Then the field "Completion tracking" matches value "0"
# Default values don't affect existing activities.
But I am on the "Test assignment one" Activity page
And I navigate to "Settings" in current page administration
And I expand all fieldsets
And the field "Completion tracking" matches value "1"

@javascript
Scenario: Default activity completion rules with site default completion but with no course default completion
Scenario: Default values don't affect existing activities when site default completion are defined
Given the following "activity" exists:
| activity | assign |
| course | C1 |
| name | Test assignment one |
| completion | 0 |
| activity | assign |
| course | C1 |
| name | Test assignment one |
| completion | 0 |
And the following "core_completion > Course default" exist:
| course | module | completion | completionview | completionusegrade | completionsubmit |
| Acceptance test site | assign | 2 | 0 | 1 | 1 |
And I am on "Course 1" course homepage with editing mode on
And I press "Add an activity or resource"
When I click on "Add a new Assignment" "link" in the "Add an activity or resource" "dialogue"
And I expand all fieldsets
And I am on the "Test assignment one" Activity page
When I navigate to "Settings" in current page administration
Then the field "Completion tracking" matches value "0"

Scenario: Default activity completion rules with site default completion but with no course default completion
Given the following "core_completion > Course default" exist:
| course | module | completion | completionview | completionusegrade | completionsubmit |
| Acceptance test site | assign | 2 | 0 | 1 | 1 |
When I am adding an assign to section 0 of the "Course 1" course
Then the field "Completion tracking" matches value "2"
And the field "completionview" matches value "0"
And the field "completionusegrade" matches value "1"
And the field "completionsubmit" matches value "1"
# Default values don't affect existing activities.
But I am on the "Test assignment one" Activity page
And I navigate to "Settings" in current page administration
And I expand all fieldsets
And the field "Completion tracking" matches value "0"

@javascript
Scenario: Default activity completion rules with site default completion and course default completion
Scenario: Default values don't affect existing activities when site and course defaults completion are defined
Given the following "activity" exists:
| activity | assign |
| course | C1 |
| name | Test assignment one |
| completion | 0 |
| activity | assign |
| course | C1 |
| name | Test assignment one |
| completion | 0 |
And the following "core_completion > Course defaults" exist:
| course | module | completion | completionview | completionusegrade | completionsubmit |
| Acceptance test site | assign | 2 | 0 | 1 | 1 |
| C1 | assign | 2 | 1 | 0 | 1 |
And I am on "Course 1" course homepage with editing mode on
And I press "Add an activity or resource"
When I click on "Add a new Assignment" "link" in the "Add an activity or resource" "dialogue"
And I expand all fieldsets
And I am on the "Test assignment one" Activity page
When I navigate to "Settings" in current page administration
Then the field "Completion tracking" matches value "0"

Scenario: Default activity completion rules with site default completion and course default completion
Given the following "core_completion > Course defaults" exist:
| course | module | completion | completionview | completionusegrade | completionsubmit |
| Acceptance test site | assign | 2 | 0 | 1 | 1 |
| C1 | assign | 2 | 1 | 0 | 1 |
When I am adding an assign to section 0 of the "Course 1" course
Then the field "Completion tracking" matches value "2"
And the field "completionview" matches value "1"
And the field "completionusegrade" matches value "0"
And the field "completionsubmit" matches value "1"
# Default values don't affect existing activities.
But I am on the "Test assignment one" Activity page
And I navigate to "Settings" in current page administration
And I expand all fieldsets
And the field "Completion tracking" matches value "0"
19 changes: 19 additions & 0 deletions lib/tests/behat/behat_navigation.php
Original file line number Diff line number Diff line change
Expand Up @@ -987,6 +987,25 @@ public function i_am_on_course_homepage_with_editing_mode_set_to(string $coursef
$this->execute('behat_general::i_visit', [$editmodeurl]);
}

/**
* Open a add activity form page.
*
* @Given I am adding a :activity to section :sectionnum of the :coursefullname course
* @Given I am adding an :activity to section :sectionnum of the :coursefullname course
* @throws coding_exception
* @param string $activity The activity name.
* @param int $sectionnum The section number.
* @param string $coursefullname The course full name of the course.
*/
public function i_am_adding_activity_to_section_of_the_course(string $activity, string $sectionnum, string $coursefullname): void {
$addurl = new moodle_url('/course/modedit.php', [
'add' => $activity,
'course' => $this->get_course_id($coursefullname),
'section' => intval($sectionnum),
]);
$this->execute('behat_general::i_visit', [$addurl]);
}

/**
* Opens the flat navigation drawer if it is not already open
*
Expand Down

0 comments on commit 38e939f

Please sign in to comment.