|
| 1 | +@tool @tool_lifecycle @manual_trigger |
| 2 | +Feature: Combine triggers with 'and' operation and test view and actions |
| 3 | + |
| 4 | + Background: |
| 5 | + Given the following "users" exist: |
| 6 | + | username | firstname | lastname | email | |
| 7 | + | teacher1 | Teacher | 1 | teacher1@example.com | |
| 8 | + | teacher2 | Teacher | 2 | teacher2@example.com | |
| 9 | + And the following "categories" exist: |
| 10 | + | name | category | idnumber | |
| 11 | + | cata | 0 | cata | |
| 12 | + | catba | cata | catba | |
| 13 | + | catc | 0 | catc | |
| 14 | + | archive | 0 | archive | |
| 15 | + And the following "courses" exist: |
| 16 | + | fullname | shortname | category | |
| 17 | + | Course A | CA | cata | |
| 18 | + | Course BA | CBA | catba | |
| 19 | + | Course C | CC | catc | |
| 20 | + | ArchCourse | CArch | archive | |
| 21 | + And the following "course enrolments" exist: |
| 22 | + | user | course | role | |
| 23 | + | teacher1 | CA | editingteacher | |
| 24 | + | teacher1 | CBA | editingteacher | |
| 25 | + | teacher1 | CC | editingteacher | |
| 26 | + | teacher1 | CArch | editingteacher | |
| 27 | + | teacher2 | CA | editingteacher | |
| 28 | + | teacher2 | CBA | student | |
| 29 | + | teacher2 | CC | student | |
| 30 | + | teacher2 | CArch | editingteacher | |
| 31 | + |
| 32 | + @javascript |
| 33 | + Scenario: Combine manual trigger with automatic categories trigger (backup and course deletion) |
| 34 | + # => category archive is excluded, so course ArchCourse shall not be deleted |
| 35 | + Given I log in as "admin" |
| 36 | + And I am on workflowdrafts page |
| 37 | + And I click on "Create new workflow" "link" |
| 38 | + And I set the following fields to these values: |
| 39 | + | Title | My Workflow | |
| 40 | + | Displayed workflow title | Teachers view on workflow | |
| 41 | + And I press "Save changes" |
| 42 | + And I select "Manual trigger" from the "tool_lifecycle-choose-trigger" singleselect |
| 43 | + And I set the following fields to these values: |
| 44 | + | Instance name | My Trigger | |
| 45 | + | Icon | t/delete | |
| 46 | + | Action name | Delete course | |
| 47 | + | Capability | moodle/course:manageactivities | |
| 48 | + And I press "Save changes" |
| 49 | + |
| 50 | + And I select "Categories trigger" from the "tool_lifecycle-choose-trigger" singleselect |
| 51 | + And I set the following fields to these values: |
| 52 | + | Instance name | Categories | |
| 53 | + And I set the following fields to these values: |
| 54 | + | Categories, for which the workflow should be triggered | cata, catc | |
| 55 | + And I press "Save changes" |
| 56 | + |
| 57 | + And I select "Create backup step" from the "tool_lifecycle-choose-step" singleselect |
| 58 | + And I set the field "Instance name" to "Create backup step" |
| 59 | + And I press "Save changes" |
| 60 | + And I select "Delete course step" from the "tool_lifecycle-choose-step" singleselect |
| 61 | + And I set the field "Instance name" to "Delete Course 2" |
| 62 | + And I press "Save changes" |
| 63 | + |
| 64 | + And I am on workflowdrafts page |
| 65 | + And I press "Activate" |
| 66 | + And I log out |
| 67 | + And I log in as "teacher1" |
| 68 | + |
| 69 | + And I am on lifecycle view |
| 70 | + Then I should see the tool "Delete course" in the "Course A" row of the "tool_lifecycle_remaining" table |
| 71 | + And I should see the tool "Delete course" in the "Course BA" row of the "tool_lifecycle_remaining" table |
| 72 | + And I should see the tool "Delete course" in the "Course C" row of the "tool_lifecycle_remaining" table |
| 73 | + And I should not see "Action" in the "ArchCourse" "table_row" |
| 74 | + |
| 75 | + When I click on the tool "Delete course" in the "Course C" row of the "tool_lifecycle_remaining" table |
| 76 | + And I should not see the tool "Delete course" in the "Course C" row of the "tool_lifecycle_remaining" table |
| 77 | + And I should see the tool "Delete course" in the "Course BA" row of the "tool_lifecycle_remaining" table |
| 78 | + And I should see the tool "Delete course" in the "Course A" row of the "tool_lifecycle_remaining" table |
| 79 | + When I log out |
| 80 | + And I log in as "admin" |
| 81 | + And I run the scheduled task "tool_lifecycle\task\lifecycle_task" |
| 82 | + And I wait "5" seconds |
| 83 | + And I run the scheduled task "tool_lifecycle\task\lifecycle_task" |
| 84 | + And I wait "5" seconds |
| 85 | + And I run the scheduled task "tool_lifecycle\task\lifecycle_task" |
| 86 | + And I wait "5" seconds |
| 87 | + And I log out |
| 88 | + And I log in as "teacher1" |
| 89 | + And I am on lifecycle view |
| 90 | + Then I should not see "Course C" |
| 91 | + And I should see "Course BA" |
| 92 | + And I should see "Course A" |
| 93 | + And I should see "ArchCourse" |
| 94 | + When I log out |
| 95 | + And I log in as "admin" |
| 96 | + And I am on coursebackups page |
| 97 | + Then I should see "Course C" |
| 98 | + And I should not see "Course BA" |
| 99 | + And I should not see "Course A" |
| 100 | + And I should not see "ArchCourse" |
| 101 | + |
| 102 | + @javascript |
| 103 | + Scenario: Combine automatic triggers (backup and course deletion) |
| 104 | + Given I log in as "admin" |
| 105 | + And I am on workflowdrafts page |
| 106 | + And I click on "Create new workflow" "link" |
| 107 | + And I set the following fields to these values: |
| 108 | + | Title | My Workflow | |
| 109 | + | Displayed workflow title | Teachers view on workflow | |
| 110 | + And I press "Save changes" |
| 111 | + |
| 112 | + And I select "Trigger courses by roles missing" from the "tool_lifecycle-choose-trigger" singleselect |
| 113 | + And I set the following fields to these values: |
| 114 | + | Instance name | Roles | |
| 115 | + | Responsible Roles in courses | student | |
| 116 | + And I press "Save changes" |
| 117 | + |
| 118 | + And I select "Categories trigger" from the "tool_lifecycle-choose-trigger" singleselect |
| 119 | + And I set the following fields to these values: |
| 120 | + | Instance name | Categories | |
| 121 | + And I set the following fields to these values: |
| 122 | + | Categories, for which the workflow should be triggered | cata, catc | |
| 123 | + And I press "Save changes" |
| 124 | + |
| 125 | + And I select "Create backup step" from the "tool_lifecycle-choose-step" singleselect |
| 126 | + And I set the field "Instance name" to "Create backup step" |
| 127 | + And I press "Save changes" |
| 128 | + And I select "Delete course step" from the "tool_lifecycle-choose-step" singleselect |
| 129 | + And I set the field "Instance name" to "Delete Course 2" |
| 130 | + And I press "Save changes" |
| 131 | + |
| 132 | + And I am on workflowdrafts page |
| 133 | + And I press "Activate" |
| 134 | + |
| 135 | + And I run the scheduled task "tool_lifecycle\task\lifecycle_task" |
| 136 | + And I wait "2" seconds |
| 137 | + And I run the scheduled task "tool_lifecycle\task\lifecycle_task" |
| 138 | + And I wait "2" seconds |
| 139 | + And I run the scheduled task "tool_lifecycle\task\lifecycle_task" |
| 140 | + And I wait "2" seconds |
| 141 | + |
| 142 | + And I log out |
| 143 | + And I log in as "teacher1" |
| 144 | + And I am on lifecycle view |
| 145 | + Then I should not see "Course A" |
| 146 | + And I should see "Course BA" |
| 147 | + And I should see "Course C" |
| 148 | + And I should see "ArchCourse" |
| 149 | + When I log out |
| 150 | + And I log in as "admin" |
| 151 | + And I am on coursebackups page |
| 152 | + Then I should see "Course A" |
| 153 | + And I should not see "Course BA" |
| 154 | + And I should not see "Course CS" |
| 155 | + And I should not see "ArchCourse" |
0 commit comments