Skip to content

Commit 9b05647

Browse files
committed
test(integration): cover workflow webhook email and talk flows
Signed-off-by: Vitor Mattos <1079143+vitormattos@users.noreply.github.com>
1 parent 12d2933 commit 9b05647

1 file changed

Lines changed: 204 additions & 0 deletions

File tree

tests/integration/features/workflow/profile_fields_workflow.feature

Lines changed: 204 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
Feature: profile field workflows
22
Background:
33
Given user "workflow_subject" exists
4+
And run the command "app:enable --force profile_fields" with result code 0
5+
And run the command "profile_fields:developer:reset --all" with result code 0
46

57
Scenario: matching field updates notify configured admin targets through workflow and notifications OCS
68
Given as user "admin"
@@ -123,3 +125,205 @@ Feature: profile field workflows
123125
"""
124126
operations
125127
"""
128+
129+
Scenario: matching field updates send workflow webhook payloads
130+
Given as user "admin"
131+
And the mock web server "webhook-capture" is started
132+
And save the mock web server "webhook-capture" root URL as "WEBHOOK_CAPTURE_URL"
133+
When sending "post" to ocs "/apps/profile_fields/api/v1/definitions"
134+
| fieldKey | workflow_webhook_department |
135+
| label | Workflow Webhook Department |
136+
| type | text |
137+
| adminOnly | false |
138+
| userEditable | true |
139+
| userVisible | true |
140+
| initialVisibility | users |
141+
| sortOrder | 30 |
142+
| active | true |
143+
Then the response should have a status code 201
144+
And fetch field "(WORKFLOW_WEBHOOK_FIELD_ID)(jq).ocs.data.id" from previous JSON response
145+
When sending "post" to ocs "/apps/workflowengine/api/v1/workflows/global"
146+
"""
147+
{
148+
"class": "OCA\\ProfileFields\\Workflow\\SendWebhookProfileFieldChangeOperation",
149+
"name": "workflow send webhook",
150+
"checks": [
151+
{
152+
"class": "OCA\\ProfileFields\\Workflow\\UserProfileFieldCheck",
153+
"operator": "is",
154+
"value": "{\"field_key\":\"workflow_webhook_department\",\"value\":\"security\"}"
155+
}
156+
],
157+
"operation": "{\"url\":\"<WEBHOOK_CAPTURE_URL>/profile-fields\",\"secret\":\"shared-secret\",\"timeout\":10,\"retries\":0,\"headers\":{\"X-Test-Suite\":\"profile_fields\"}}",
158+
"entity": "OCA\\ProfileFields\\Workflow\\ProfileFieldValueEntity",
159+
"events": [
160+
"OCA\\ProfileFields\\Workflow\\Event\\ProfileFieldValueUpdatedEvent"
161+
]
162+
}
163+
"""
164+
Then the response should have a status code 200
165+
Given as user "workflow_subject"
166+
When sending "put" to ocs "/apps/profile_fields/api/v1/me/values/<WORKFLOW_WEBHOOK_FIELD_ID>"
167+
| value | finance |
168+
| currentVisibility | users |
169+
Then the response should have a status code 200
170+
When sending "put" to ocs "/apps/profile_fields/api/v1/me/values/<WORKFLOW_WEBHOOK_FIELD_ID>"
171+
| value | security |
172+
| currentVisibility | users |
173+
Then the response should have a status code 200
174+
When read the last request from mock web server "webhook-capture"
175+
Then the output of the last command should contain the following text:
176+
"""
177+
"METHOD": "POST"
178+
"""
179+
And the output of the last command should contain the following text:
180+
"""
181+
"REQUEST_URI": "/profile-fields"
182+
"""
183+
And the output of the last command should contain the following text:
184+
"""
185+
"X-Test-Suite": "profile_fields"
186+
"""
187+
And the output of the last command should contain the following text:
188+
"""
189+
"X-Profile-Fields-Signature": "sha256=
190+
"""
191+
When read the last request body from mock web server "webhook-capture"
192+
And the output of the last command should contain the following text:
193+
"""
194+
"name": "workflow send webhook"
195+
"""
196+
And the output of the last command should contain the following text:
197+
"""
198+
"key": "workflow_webhook_department"
199+
"""
200+
And the output of the last command should contain the following text:
201+
"""
202+
"previousValue": "finance"
203+
"""
204+
And the output of the last command should contain the following text:
205+
"""
206+
"currentValue": "security"
207+
"""
208+
209+
Scenario: matching field updates email the affected user
210+
Given as user "admin"
211+
And run the command "config:system:set mail_smtpmode --value smtp" with result code 0
212+
And run the command "config:system:set mail_smtphost --value mailpit" with result code 0
213+
And run the command "config:system:set mail_smtpport --value 1025 --type integer" with result code 0
214+
And run the command "config:system:set mail_smtpauth --value false --type boolean" with result code 0
215+
And run the command "config:system:set mail_smtpsecure --value \"\"" with result code 0
216+
And run the command "config:system:set mail_from_address --value profile-fields" with result code 0
217+
And run the command "config:system:set mail_domain --value example.test" with result code 0
218+
And set the email of user "workflow_subject" to "workflow_subject@example.test"
219+
And my inbox is empty
220+
When sending "post" to ocs "/apps/profile_fields/api/v1/definitions"
221+
| fieldKey | workflow_email_department |
222+
| label | Workflow Email Department |
223+
| type | text |
224+
| adminOnly | false |
225+
| userEditable | true |
226+
| userVisible | true |
227+
| initialVisibility | users |
228+
| sortOrder | 40 |
229+
| active | true |
230+
Then the response should have a status code 201
231+
And fetch field "(WORKFLOW_EMAIL_FIELD_ID)(jq).ocs.data.id" from previous JSON response
232+
When sending "post" to ocs "/apps/workflowengine/api/v1/workflows/global"
233+
"""
234+
{
235+
"class": "OCA\\ProfileFields\\Workflow\\EmailUserProfileFieldChangeOperation",
236+
"name": "workflow email user",
237+
"checks": [
238+
{
239+
"class": "OCA\\ProfileFields\\Workflow\\UserProfileFieldCheck",
240+
"operator": "is",
241+
"value": "{\"field_key\":\"workflow_email_department\",\"value\":\"compliance\"}"
242+
}
243+
],
244+
"operation": "{\"subjectTemplate\":\"Profile update: {{fieldLabel}}\",\"bodyTemplate\":\"Field {{fieldLabel}} changed from {{previousValue}} to {{currentValue}} by {{actorUid}}.\"}",
245+
"entity": "OCA\\ProfileFields\\Workflow\\ProfileFieldValueEntity",
246+
"events": [
247+
"OCA\\ProfileFields\\Workflow\\Event\\ProfileFieldValueUpdatedEvent"
248+
]
249+
}
250+
"""
251+
Then the response should have a status code 200
252+
Given as user "workflow_subject"
253+
When sending "put" to ocs "/apps/profile_fields/api/v1/me/values/<WORKFLOW_EMAIL_FIELD_ID>"
254+
| value | finance |
255+
| currentVisibility | users |
256+
Then the response should have a status code 200
257+
When sending "put" to ocs "/apps/profile_fields/api/v1/me/values/<WORKFLOW_EMAIL_FIELD_ID>"
258+
| value | compliance |
259+
| currentVisibility | users |
260+
Then the response should have a status code 200
261+
And there should be 1 email in my inbox
262+
When I open the latest email to "workflow_subject@example.test" with subject "Profile update: Workflow Email Department"
263+
Then I should see "Field Workflow Email Department changed from finance to compliance by workflow_subject." in the opened email
264+
265+
Scenario: matching field updates create Talk conversations for admins and affected users
266+
Given as user "admin"
267+
When sending "post" to ocs "/apps/profile_fields/api/v1/definitions"
268+
| fieldKey | workflow_talk_department |
269+
| label | Workflow Talk Department |
270+
| type | text |
271+
| adminOnly | false |
272+
| userEditable | true |
273+
| userVisible | true |
274+
| initialVisibility | users |
275+
| sortOrder | 50 |
276+
| active | true |
277+
Then the response should have a status code 201
278+
And fetch field "(WORKFLOW_TALK_FIELD_ID)(jq).ocs.data.id" from previous JSON response
279+
When sending "put" to ocs "/apps/profile_fields/api/v1/definitions/<WORKFLOW_TALK_FIELD_ID>"
280+
| label | Workflow Talk Department <WORKFLOW_TALK_FIELD_ID> |
281+
| type | text |
282+
| adminOnly | false |
283+
| userEditable | true |
284+
| userVisible | true |
285+
| initialVisibility | users |
286+
| sortOrder | 50 |
287+
| active | true |
288+
Then the response should have a status code 200
289+
When sending "post" to ocs "/apps/workflowengine/api/v1/workflows/global"
290+
"""
291+
{
292+
"class": "OCA\\ProfileFields\\Workflow\\CreateTalkConversationProfileFieldChangeOperation",
293+
"name": "workflow create talk conversation",
294+
"checks": [
295+
{
296+
"class": "OCA\\ProfileFields\\Workflow\\UserProfileFieldCheck",
297+
"operator": "is",
298+
"value": "{\"field_key\":\"workflow_talk_department\",\"value\":\"support\"}"
299+
}
300+
],
301+
"operation": "",
302+
"entity": "OCA\\ProfileFields\\Workflow\\ProfileFieldValueEntity",
303+
"events": [
304+
"OCA\\ProfileFields\\Workflow\\Event\\ProfileFieldValueUpdatedEvent"
305+
]
306+
}
307+
"""
308+
Then the response should have a status code 200
309+
Given as user "workflow_subject"
310+
When sending "put" to ocs "/apps/profile_fields/api/v1/me/values/<WORKFLOW_TALK_FIELD_ID>"
311+
| value | finance |
312+
| currentVisibility | users |
313+
Then the response should have a status code 200
314+
When sending "put" to ocs "/apps/profile_fields/api/v1/me/values/<WORKFLOW_TALK_FIELD_ID>"
315+
| value | support |
316+
| currentVisibility | users |
317+
Then the response should have a status code 200
318+
Given as user "admin"
319+
When sending "get" to ocs "/apps/spreed/api/v4/room"
320+
Then the response should have a status code 200
321+
And the response should be a JSON array with the following mandatory values
322+
| key | value |
323+
| (jq).ocs.data[] \| select(.displayName == "Profile field change: Workflow Talk Department <WORKFLOW_TALK_FIELD_ID> for workflow_subject") \| .displayName | Profile field change: Workflow Talk Department <WORKFLOW_TALK_FIELD_ID> for workflow_subject |
324+
Given as user "workflow_subject"
325+
When sending "get" to ocs "/apps/spreed/api/v4/room"
326+
Then the response should have a status code 200
327+
And the response should be a JSON array with the following mandatory values
328+
| key | value |
329+
| (jq).ocs.data[] \| select(.displayName == "Profile field change: Workflow Talk Department <WORKFLOW_TALK_FIELD_ID> for workflow_subject") \| .displayName | Profile field change: Workflow Talk Department <WORKFLOW_TALK_FIELD_ID> for workflow_subject |

0 commit comments

Comments
 (0)