Skip to content

Commit 267ab06

Browse files
committed
fix behat tests adminapprove 2
1 parent 2091fa9 commit 267ab06

File tree

10 files changed

+158
-91
lines changed

10 files changed

+158
-91
lines changed

classes/local/manager/workflow_manager.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -223,7 +223,7 @@ public static function get_active_manual_workflow_triggers() {
223223

224224
/**
225225
* Returns tools for all active manual workflows.
226-
* You need to check the capability based on course and user before diplaying it.
226+
* You need to check the capability based on course and user before displaying it.
227227
*
228228
* @return manual_trigger_tool[] list of tools, available in the whole system.
229229
* @throws \coding_exception

classes/local/table/courses_in_step_table.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -184,8 +184,8 @@ public function col_tools($row) {
184184

185185
$element = step_manager::get_step_instance($row->stepinstanceid);
186186

187-
$rollback = settings_manager::get_settings($element->id, settings_type::STEP)['rollbackbutton'] ?? null;
188-
$proceed = settings_manager::get_settings($element->id, settings_type::STEP)['proceedbutton'] ?? null;
187+
$rollback = settings_manager::get_settings($element->id, settings_type::STEP)['rollbackbuttonlabel'] ?? null;
188+
$proceed = settings_manager::get_settings($element->id, settings_type::STEP)['proceedbuttonlabel'] ?? null;
189189

190190
$output = $OUTPUT->single_button(
191191
new \moodle_url($PAGE->url, ['action' => 'rollback', 'processid' => $row->processid,

classes/local/table/interaction_remaining_table.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ public function col_tools($row) {
132132
}
133133
$actions = [];
134134
foreach ($this->availabletools as $tool) {
135-
if (has_capability($tool->capability, \context_course::instance($row->courseid), null, false)) {
135+
if (has_capability($tool->capability, \context_course::instance($row->courseid), null, true)) {
136136
$actions[$tool->triggerid] = new \action_menu_link_secondary(
137137
new \moodle_url($PAGE->url, ['triggerid' => $tool->triggerid,
138138
'courseid' => $row->courseid, 'sesskey' => sesskey(), ]),

classes/view_controller.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ public function handle_trigger($triggerid, $courseid) {
151151

152152
// Check if user has capability.
153153
$triggersettings = settings_manager::get_settings($triggerid, settings_type::TRIGGER);
154-
require_capability($triggersettings['capability'], \context_course::instance($courseid), null, false);
154+
require_capability($triggersettings['capability'], \context_course::instance($courseid), null, true);
155155

156156
// Check if course does not have a running process.
157157
$runningprocess = process_manager::get_process_by_course_id($courseid);

lang/de/tool_lifecycle.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,7 @@
163163
$string['followedby_none'] = 'Keine';
164164
$string['force_import'] = 'Die Fehler ignorieren und den Workflow trotzdem importieren. Das kann zu unerwünschten Effekten führen.';
165165
$string['forselected'] = 'Für alle ausgewählten Prozesse';
166+
$string['forselectedcourses'] = 'Für alle ausgewählten Kurse';
166167
$string['general_config_header'] = 'Allgemein';
167168
$string['general_config_header_title'] = "Allgemeine Einstellungen & Subplugins";
168169
$string['general_settings_header'] = 'Allgemeine Einstellungen';
@@ -194,6 +195,7 @@
194195
$string['nextrun'] = 'Nächste Durchführung: {$a}';
195196
$string['noactiontools'] = 'Keine Aktionen verfügbar';
196197
$string['nocoursestodisplay'] = 'Es gibt derzeit keine Kurse, die Ihre Aufmerksamkeit erfordern!';
198+
$string['noentriesselected'] = 'Es wurden keine Tabellen-Einträge markiert.';
197199
$string['nointeractioninterface'] = 'Keine Interaktionsschnittstelle verfügbar!';
198200
$string['noprocesserrors'] = 'Es gibt keine fehlerhaften Prozesse, die behandelt werden müssen!';
199201
$string['noprocessfound'] = 'Es konnte kein Prozess mit der gegebenen Prozessid gefunden werden!';

lang/en/tool_lifecycle.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,7 @@
163163
$string['followedby_none'] = 'None';
164164
$string['force_import'] = 'Try ignoring errors and import the workflow anyway. Use this at your own risk!';
165165
$string['forselected'] = 'For all selected processes';
166+
$string['forselectedcourses'] = 'For all selected courses';
166167
$string['general_config_header'] = "General";
167168
$string['general_config_header_title'] = "General settings & subplugins";
168169
$string['general_settings_header'] = 'General settings';
@@ -195,6 +196,7 @@
195196
$string['nextrun'] = 'Next run: {$a}';
196197
$string['noactiontools'] = 'No tools available';
197198
$string['nocoursestodisplay'] = 'There are currently no courses which require your attention!';
199+
$string['noentriesselected'] = 'No table entries selected.';
198200
$string['nointeractioninterface'] = 'No interaction interface available!';
199201
$string['noprocesserrors'] = 'There are no process errors to handle!';
200202
$string['noprocessfound'] = 'A process with the given processid could not be found!';

step/adminapprove/classes/decision_table.php

Lines changed: 21 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -235,16 +235,29 @@ public function print_nothing_to_display() {
235235
public function wrap_html_start() {
236236
parent::wrap_html_start();
237237

238-
$output = \html_writer::div(
239-
$this->strings['rollbackselectedbuttonlabel'],
240-
'selectedbutton btn btn-secondary mb-1',
241-
['action' => 'rollback', 'sesskey' => sesskey(), 'stepid' => $this->stepid]
238+
$output = \html_writer::empty_tag('input',
239+
[
240+
'type' => 'button',
241+
'action' => 'rollback',
242+
'sesskey' => sesskey(),
243+
'stepid' => $this->stepid,
244+
'name' => 'button_rollback_selected',
245+
'value' => $this->strings['rollbackselectedbuttonlabel'],
246+
'class' => 'selectedbutton btn btn-secondary mb-1'
247+
]
242248
);
243-
$output .= \html_writer::div(
244-
$this->strings['proceedselectedbuttonlabel'],
245-
'selectedbutton btn btn-primary ml-1 mb-1',
246-
['action' => 'proceed', 'sesskey' => sesskey(), 'stepid' => $this->stepid]
249+
$output .= \html_writer::empty_tag('input',
250+
[
251+
'type' => 'button',
252+
'action' => 'proceed',
253+
'sesskey' => sesskey(),
254+
'stepid' => $this->stepid,
255+
'name' => 'button_proceed_selected',
256+
'value' => $this->strings['proceedselectedbuttonlabel'],
257+
'class' => 'selectedbutton btn btn-primary ml-1 mb-1'
258+
]
247259
);
260+
248261
echo $output;
249262
}
250263
}

step/adminapprove/tests/behat/custom_buttons.feature

Lines changed: 72 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
1-
@tool @tool_lifecycle @manual_trigger
2-
Feature: Add an admin approve step with 'button' customisation
1+
@tool @tool_lifecycle @lifecyclestep @lifecyclestep_adminapprove
2+
Feature: Add an admin approve step without 'button' customisation
3+
34
Background:
45
Given the following "users" exist:
56
| username | firstname | lastname | email |
@@ -16,8 +17,8 @@ Feature: Add an admin approve step with 'button' customisation
1617
And I am on workflowdrafts page
1718
And I click on "Create new workflow" "link"
1819
And I set the following fields to these values:
19-
| Title | My Workflow |
20-
| Displayed workflow title | Teachers view on workflow |
20+
| Title | My Workflow |
21+
| Displayed workflow title | Teachers view on workflow |
2122
And I press "Save changes"
2223
And I select "Manual trigger" from the "tool_lifecycle-choose-trigger" singleselect
2324
And I set the following fields to these values:
@@ -26,63 +27,77 @@ Feature: Add an admin approve step with 'button' customisation
2627
| Action name | Backup course |
2728
| Capability | moodle/course:manageactivities |
2829
And I press "Save changes"
30+
2931
And I select "Admin approve step" from the "tool_lifecycle-choose-step" singleselect
30-
And I set the field "Instance name" to "Admin approve step"
32+
And I set the field "Instance name" to "admin approve step"
3133
And I set the field "Label of the proceed button" to "Create backup"
32-
And I set the field "Label of the rollback button" to "Cancel workflow"
34+
And I set the field "Label of the rollback button" to "Call off workflow"
3335
And I set the field "Label of the proceed selected button" to "Selected create backup"
34-
And I set the field "Label of the rollback selected button" to "Selected cancel workflow"
36+
And I set the field "Label of the rollback selected button" to "Selected call off workflow"
3537
And I press "Save changes"
38+
3639
And I select "Create backup step" from the "tool_lifecycle-choose-step" singleselect
3740
And I set the field "Instance name" to "Create backup step"
3841
And I press "Save changes"
3942

40-
When I am on workflowdrafts page
43+
And I am on workflowdrafts page
4144
And I press "Activate"
4245
And I log out
46+
4347
And I log in as "teacher1"
4448
And I am on lifecycle view
49+
Then I should see the tool "Backup course" in the "Course 1" row of the "tool_lifecycle_remaining" table
4550
When I click on the tool "Backup course" in the "Course 1" row of the "tool_lifecycle_remaining" table
4651
Then I should see "Workflow started successfully."
47-
When I click on the tool "Backup course" in the "Course 2" row of the "tool_lifecycle_remaining" table
48-
Then I should see "Workflow started successfully."
49-
5052
And I log out
53+
5154
And I log in as "admin"
5255
And I run the scheduled task "tool_lifecycle\task\lifecycle_task"
56+
And I run the scheduled task "tool_lifecycle\task\lifecycle_task"
5357
And I wait "5" seconds
5458

5559
@javascript
56-
Scenario: Check button texts on approval page
60+
Scenario: Check button texts on approval page (default)
5761

5862
When I am on approvals page
59-
And I click on "Admin approve step" "link"
60-
Then I should see "Create backup"
61-
And I should see "Cancel workflow"
62-
And I should see "Selected create backup"
63-
And I should see "Selected cancel workflow"
63+
And I click on "admin approve step" "link"
64+
Then "Selected create backup" "button" should exist
65+
And "Selected call off workflow" "button" should exist
66+
And "Create backup" "button" should exist
67+
And "Call off workflow" "button" should exist
6468

6569
@javascript
66-
Scenario: Proceed on approval page (customisation)
70+
Scenario: Proceed on approval page (default)
6771

6872
When I am on approvals page
69-
And I click on "Admin approve step" "link"
70-
And I click on the tool "Create backup" in the "Course 1" row of the "lifecyclestep_adminapprove-decisiontable" table
73+
And I click on "admin approve step" "link"
74+
Then I should see "Course 1"
75+
And I click on "checkall" "checkbox"
76+
And I click on "Create backup" "button"
7177

7278
And I run the scheduled task "tool_lifecycle\task\lifecycle_task"
7379
And I run the scheduled task "tool_lifecycle\task\lifecycle_task"
74-
And I wait "5" seconds
80+
And I wait "25" seconds
7581

7682
And I am on coursebackups page
7783
Then I should see "Course 1"
78-
And I should not see "Course 2"
7984

8085
@javascript
81-
Scenario: Proceed all on approval page (customisation)
86+
Scenario: Proceed all on approval page (default)
87+
88+
When I log in as "teacher1"
89+
And I am on lifecycle view
90+
Then I should see the tool "Backup course" in the "Course 2" row of the "tool_lifecycle_remaining" table
91+
When I click on the tool "Backup course" in the "Course 2" row of the "tool_lifecycle_remaining" table
92+
Then I should see "Workflow started successfully."
93+
And I run the scheduled task "tool_lifecycle\task\lifecycle_task"
94+
And I wait "5" seconds
95+
And I log out
8296

97+
And I log in as "admin"
8398
When I am on approvals page
84-
And I click on "Admin approve step" "link"
85-
And I check "checkall"
99+
And I click on "admin approve step" "link"
100+
And I click on "checkall" "checkbox"
86101
And I click on "Selected create backup" "button"
87102

88103
And I run the scheduled task "tool_lifecycle\task\lifecycle_task"
@@ -91,71 +106,84 @@ Feature: Add an admin approve step with 'button' customisation
91106

92107
And I am on coursebackups page
93108
Then I should see "Course 1"
94-
And I should not see "Course 2"
109+
And I should see "Course 2"
95110

96111
@javascript
97-
Scenario: Rollback on approval page (customisation)
112+
Scenario: Rollback on approval page (default)
98113

99114
When I am on approvals page
100-
And I click on "Admin approve step" "link"
101-
And I click on "Cancel workflow" "button"
115+
And I click on "admin approve step" "link"
116+
Then I should see "Course 1"
117+
And I click on "checkall" "checkbox"
118+
And I click on "Call off workflow" "button"
102119

103120
And I run the scheduled task "tool_lifecycle\task\lifecycle_task"
104121
And I run the scheduled task "tool_lifecycle\task\lifecycle_task"
105-
And I wait "5" seconds
122+
And I wait "25" seconds
106123

107124
And I am on delayedworkflows page
108125
Then I should see "Course 1"
109-
And I should not see "Course 2"
110126

111127
@javascript
112-
Scenario: Rollback all on approval page (customisation)
128+
Scenario: Rollback all on approval page (default)
113129

114-
When I am on approvals page
115-
And I click on "Admin approve step" "link"
116-
And I check "checkall"
117-
And I click on "Selected cancel workflow" "button"
130+
When I log in as "teacher1"
131+
And I am on lifecycle view
132+
Then I should see the tool "Backup course" in the "Course 2" row of the "tool_lifecycle_remaining" table
133+
When I click on the tool "Backup course" in the "Course 2" row of the "tool_lifecycle_remaining" table
134+
Then I should see "Workflow started successfully."
135+
And I run the scheduled task "tool_lifecycle\task\lifecycle_task"
136+
And I wait "5" seconds
137+
And I log out
138+
139+
When I log in as "admin"
140+
And I am on approvals page
141+
And I click on "admin approve step" "link"
142+
And I click on "checkall" "checkbox"
143+
And I click on "Selected call off workflow" "button"
118144

119145
And I run the scheduled task "tool_lifecycle\task\lifecycle_task"
120146
And I run the scheduled task "tool_lifecycle\task\lifecycle_task"
121147
And I wait "5" seconds
122148

123149
And I am on delayedworkflows page
124150
Then I should see "Course 1"
125-
And I should not see "Course 2"
151+
And I should see "Course 2"
126152

127153
@javascript
128-
Scenario: Proceed on active workflows page (customisation)
154+
Scenario: Proceed on active workflows page (default)
129155

130156
When I am on activeworkflows page
131157
Then I should see the row "My Workflow" in the "tool_lifecycle_manual_workflows" table
132158
When I click on the tool "View workflow steps" in the "My Workflow" row of the "tool_lifecycle_manual_workflows" table
133159
Then I should see "Courses: 1"
134160
When I click on "Courses: 1" "link"
161+
Then I should see "Call off workflow"
135162
And I should see "Create backup"
136-
And I click on "Create backup" "button"
163+
When I click on "Create backup" "button"
137164

165+
And I run the scheduled task "tool_lifecycle\task\lifecycle_task"
138166
And I run the scheduled task "tool_lifecycle\task\lifecycle_task"
139167
And I wait "5" seconds
140168

141169
And I am on coursebackups page
142170
Then I should see "Course 1"
143-
And I should not see "Course 2"
144171

145172
@javascript
146-
Scenario: Rollback on active workflows page (customisation)
173+
Scenario: Rollback on active workflows page (default)
147174

148175
When I am on activeworkflows page
149176
Then I should see the row "My Workflow" in the "tool_lifecycle_manual_workflows" table
150177
When I click on the tool "View workflow steps" in the "My Workflow" row of the "tool_lifecycle_manual_workflows" table
151178
Then I should see "Courses: 1"
152179
When I click on "Courses: 1" "link"
153-
Then I should see "Cancel workflow"
180+
Then I should see "Call off workflow"
154181
And I should see "Create backup"
155-
And I click on "Cancel workflow" "button"
182+
When I click on "Call off workflow" "button"
156183

157184
And I run the scheduled task "tool_lifecycle\task\lifecycle_task"
158-
And I wait "5" seconds
185+
And I run the scheduled task "tool_lifecycle\task\lifecycle_task"
186+
And I wait "25" seconds
159187

160188
And I am on delayedworkflows page
161189
Then I should see "Course 1"

0 commit comments

Comments
 (0)