Skip to content

Commit 654308e

Browse files
Merge pull request #10972 from owncloud/fix-notification-tests-code
[tests-only][full-ci] Fix notification cleanup and retry
2 parents 450cac7 + b4017cc commit 654308e

10 files changed

+58
-45
lines changed

tests/acceptance/bootstrap/NotificationContext.php

+42-33
Original file line numberDiff line numberDiff line change
@@ -48,9 +48,10 @@ public function getLastNotificationId(): array {
4848
}
4949

5050
/**
51-
* @AfterScenario
51+
* delete all in-app notifications
5252
*
5353
* @return void
54+
* @throws GuzzleException
5455
*/
5556
public function deleteDeprovisioningNotification(): void {
5657
$payload["ids"] = ["deprovision"];
@@ -66,6 +67,41 @@ public function deleteDeprovisioningNotification(): void {
6667
);
6768
}
6869

70+
/**
71+
* Delete all the emails
72+
*
73+
* @return void
74+
* @throws GuzzleException
75+
*/
76+
public function clearAllEmails(): void {
77+
try {
78+
$usersList = $this->featureContext->getAllCreatedUsers();
79+
foreach ($usersList as $emailRecipient) {
80+
EmailHelper::deleteAllEmailsForAMailbox(
81+
EmailHelper::getLocalEmailUrl(),
82+
$this->featureContext->getStepLineRef(),
83+
$emailRecipient['email']
84+
);
85+
}
86+
} catch (Exception $e) {
87+
echo __METHOD__ .
88+
" could not delete inbucket messages, is inbucket set up?\n" .
89+
$e->getMessage();
90+
}
91+
}
92+
93+
/**
94+
* @AfterScenario @notification
95+
*
96+
* @return void
97+
* @throws GuzzleException
98+
* @throws JsonException
99+
*/
100+
public function deleteAllNotifications(): void {
101+
$this->deleteDeprovisioningNotification();
102+
$this->clearAllEmails();
103+
}
104+
69105
/**
70106
* @var string
71107
*/
@@ -151,7 +187,7 @@ public function userListAllNotifications(string $user): void {
151187
* @throws GuzzleException
152188
* @throws JsonException
153189
*/
154-
public function deleteAllNotifications(string $user): ResponseInterface {
190+
public function deleteAllInAppNotifications(string $user): ResponseInterface {
155191
$response = $this->listAllNotifications($user);
156192
if (isset($this->featureContext->getJsonDecodedResponseBodyContent($response)->ocs->data)) {
157193
$responseBody = $this->featureContext->getJsonDecodedResponseBodyContent($response)->ocs->data;
@@ -173,7 +209,7 @@ public function deleteAllNotifications(string $user): ResponseInterface {
173209
* @throws JsonException
174210
*/
175211
public function userDeletesAllNotifications(string $user): void {
176-
$response = $this->deleteAllNotifications($user);
212+
$response = $this->deleteAllInAppNotifications($user);
177213
$this->featureContext->setResponse($response);
178214
}
179215

@@ -187,7 +223,7 @@ public function userDeletesAllNotifications(string $user): void {
187223
* @throws JsonException
188224
*/
189225
public function userHasDeletedAllNotifications(string $user): void {
190-
$response = $this->deleteAllNotifications($user);
226+
$response = $this->deleteAllInAppNotifications($user);
191227
$this->featureContext->theHTTPStatusCodeShouldBe(200, "", $response);
192228
}
193229

@@ -333,16 +369,13 @@ public function filterResponseAccordingToNotificationSubject(
333369
$responseBody = $this->featureContext->getJsonDecodedResponseBodyContent($response)->ocs->data;
334370
foreach ($responseBody as $value) {
335371
if (isset($value->subject) && $value->subject === $subject) {
336-
$responseBody = $value;
337372
// set notificationId
338373
$this->notificationIds[] = $value->notification_id;
339-
break;
374+
return $value;
340375
}
341376
}
342-
} else {
343-
$responseBody = $this->featureContext->getJsonDecodedResponseBodyContent($response);
344377
}
345-
return $responseBody;
378+
return new StdClass();
346379
}
347380

348381
/**
@@ -663,30 +696,6 @@ public function assertEmailContains(
663696
);
664697
}
665698

666-
/**
667-
* Delete all the inbucket emails
668-
*
669-
* @AfterScenario @email
670-
*
671-
* @return void
672-
*/
673-
public function clearInbucketMessages(): void {
674-
try {
675-
$usersList = $this->featureContext->getAllCreatedUsers();
676-
foreach ($usersList as $emailRecipient) {
677-
EmailHelper::deleteAllEmailsForAMailbox(
678-
EmailHelper::getLocalEmailUrl(),
679-
$this->featureContext->getStepLineRef(),
680-
$emailRecipient['email']
681-
);
682-
}
683-
} catch (Exception $e) {
684-
echo __METHOD__ .
685-
" could not delete inbucket messages, is inbucket set up?\n" .
686-
$e->getMessage();
687-
}
688-
}
689-
690699
/**
691700
*
692701
* @param string|null $user

tests/acceptance/features/apiAntivirus/antivirus.feature

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
@antivirus @skipOnReva
1+
@antivirus @skipOnReva @notification
22
Feature: antivirus
33
As a system administrator and user
44
I want to protect myself and others from known viruses

tests/acceptance/features/apiNotification/deleteNotification.feature

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
@notification
12
Feature: Delete notification
23
As a user
34
I want to delete notifications

tests/acceptance/features/apiNotification/deprovisioningNotification.feature

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
@skipOnStable3.0
1+
@notification
22
Feature: Deprovisioning notification
33
As a user admin
44
I want to inform users about shutting down and deprovisioning the instance

tests/acceptance/features/apiNotification/emailNotification.feature

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
@email
1+
@notification @email
22
Feature: Email notification
33
As a user
44
I want to get email notification of events related to me
@@ -130,7 +130,7 @@ Feature: Email notification
130130
Zum Ansehen hier klicken: %base_url%/files/shares/with-me
131131
"""
132132

133-
@skipOnStable3.0
133+
134134
Scenario: group members get an email notification in their respective languages when someone shares a space with the group
135135
Given the administrator has assigned the role "Space Admin" to user "Alice" using the Graph API
136136
And user "Carol" has been created with default attributes

tests/acceptance/features/apiNotification/notification.feature

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
@notification
12
Feature: Notification
23
As a user
34
I want to be notified of various events

tests/acceptance/features/apiNotification/serviceAvailabilityCheck.feature

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
@notification
12
Feature: service health check
23

34

tests/acceptance/features/apiNotification/spaceNotification.feature

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
@notification
12
Feature: Notification
23
As a user
34
I want to be notified of actions related to space

tests/acceptance/features/apiOcm/createInvitation.feature

+1-1
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ Feature: create invitation
7676
| @domain.com | 400 |
7777
| user@domain..com | 400 |
7878

79-
@email @issue-10059
79+
@issue-10059 @notification @email
8080
Scenario: federated user gets an email notification if their email was specified when creating the federation share invitation
8181
Given using server "REMOTE"
8282
And user "David" has been created with default attributes

tests/acceptance/features/apiSettings/notificationSetting.feature

+7-7
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
@email
1+
@notification
22
Feature: Notification Settings
33
As a user
44
I want to manage my notification settings
@@ -11,7 +11,7 @@ Feature: Notification Settings
1111
| Brian |
1212
And user "Alice" has uploaded file with content "some data" to "lorem.txt"
1313

14-
14+
@email
1515
Scenario: disable email notification
1616
When user "Brian" disables email notification using the settings API
1717
Then the HTTP status code should be "201"
@@ -64,7 +64,7 @@ Feature: Notification Settings
6464
| permissionsRole | Viewer |
6565
And user "Brian" should have "0" emails
6666

67-
67+
@email
6868
Scenario: disable mail and in-app notification for "Share Received" event
6969
When user "Brian" disables notification for the following events using the settings API:
7070
| Share Received | mail,in-app |
@@ -153,7 +153,7 @@ Feature: Notification Settings
153153
Then the HTTP status code should be "200"
154154
And the notifications should be empty
155155

156-
156+
@email
157157
Scenario: disable mail and in-app notification for "Share Removed" event
158158
Given user "Alice" has sent the following resource share invitation:
159159
| resource | lorem.txt |
@@ -244,7 +244,7 @@ Feature: Notification Settings
244244
| Alice Hansen shared lorem.txt with you |
245245
But user "Brian" should not have a notification related to resource "lorem.txt" with subject "Resource unshared"
246246

247-
247+
@email
248248
Scenario: disable mail and in-app notification for "Share Removed" event (Project space)
249249
Given using spaces DAV path
250250
And the administrator has assigned the role "Space Admin" to user "Alice" using the Graph API
@@ -654,7 +654,7 @@ Feature: Notification Settings
654654
| Alice Hansen shared lorem.txt with you |
655655
And user "Brian" should have "0" emails
656656

657-
657+
@email
658658
Scenario: disable mail and in-app notification for "Added as space member" event
659659
Given using spaces DAV path
660660
And the administrator has assigned the role "Space Admin" to user "Alice" using the Graph API
@@ -802,7 +802,7 @@ Feature: Notification Settings
802802
| Alice Hansen shared lorem.txt with you |
803803
And user "Brian" should have "0" emails
804804

805-
805+
@email
806806
Scenario: disable mail and in-app notification for "Removed as space member" event
807807
Given using spaces DAV path
808808
And the administrator has assigned the role "Space Admin" to user "Alice" using the Graph API

0 commit comments

Comments
 (0)