Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[tests-only][full-ci] Fix notification cleanup and retry #10972

Merged
merged 1 commit into from
Feb 10, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
75 changes: 42 additions & 33 deletions tests/acceptance/bootstrap/NotificationContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,10 @@ public function getLastNotificationId(): array {
}

/**
* @AfterScenario
* delete all in-app notifications
*
* @return void
* @throws GuzzleException
*/
public function deleteDeprovisioningNotification(): void {
$payload["ids"] = ["deprovision"];
Expand All @@ -66,6 +67,41 @@ public function deleteDeprovisioningNotification(): void {
);
}

/**
* Delete all the emails
*
* @return void
* @throws GuzzleException
*/
public function clearAllEmails(): void {
try {
$usersList = $this->featureContext->getAllCreatedUsers();
foreach ($usersList as $emailRecipient) {
EmailHelper::deleteAllEmailsForAMailbox(
EmailHelper::getLocalEmailUrl(),
$this->featureContext->getStepLineRef(),
$emailRecipient['email']
);
}
} catch (Exception $e) {
echo __METHOD__ .
" could not delete inbucket messages, is inbucket set up?\n" .
$e->getMessage();
}
}

/**
* @AfterScenario @notification
*
* @return void
* @throws GuzzleException
* @throws JsonException
*/
public function deleteAllNotifications(): void {
$this->deleteDeprovisioningNotification();
$this->clearAllEmails();
}

/**
* @var string
*/
Expand Down Expand Up @@ -151,7 +187,7 @@ public function userListAllNotifications(string $user): void {
* @throws GuzzleException
* @throws JsonException
*/
public function deleteAllNotifications(string $user): ResponseInterface {
public function deleteAllInAppNotifications(string $user): ResponseInterface {
$response = $this->listAllNotifications($user);
if (isset($this->featureContext->getJsonDecodedResponseBodyContent($response)->ocs->data)) {
$responseBody = $this->featureContext->getJsonDecodedResponseBodyContent($response)->ocs->data;
Expand All @@ -173,7 +209,7 @@ public function deleteAllNotifications(string $user): ResponseInterface {
* @throws JsonException
*/
public function userDeletesAllNotifications(string $user): void {
$response = $this->deleteAllNotifications($user);
$response = $this->deleteAllInAppNotifications($user);
$this->featureContext->setResponse($response);
}

Expand All @@ -187,7 +223,7 @@ public function userDeletesAllNotifications(string $user): void {
* @throws JsonException
*/
public function userHasDeletedAllNotifications(string $user): void {
$response = $this->deleteAllNotifications($user);
$response = $this->deleteAllInAppNotifications($user);
$this->featureContext->theHTTPStatusCodeShouldBe(200, "", $response);
}

Expand Down Expand Up @@ -333,16 +369,13 @@ public function filterResponseAccordingToNotificationSubject(
$responseBody = $this->featureContext->getJsonDecodedResponseBodyContent($response)->ocs->data;
foreach ($responseBody as $value) {
if (isset($value->subject) && $value->subject === $subject) {
$responseBody = $value;
// set notificationId
$this->notificationIds[] = $value->notification_id;
break;
return $value;
}
}
} else {
$responseBody = $this->featureContext->getJsonDecodedResponseBodyContent($response);
}
return $responseBody;
return new StdClass();
}

/**
Expand Down Expand Up @@ -663,30 +696,6 @@ public function assertEmailContains(
);
}

/**
* Delete all the inbucket emails
*
* @AfterScenario @email
*
* @return void
*/
public function clearInbucketMessages(): void {
try {
$usersList = $this->featureContext->getAllCreatedUsers();
foreach ($usersList as $emailRecipient) {
EmailHelper::deleteAllEmailsForAMailbox(
EmailHelper::getLocalEmailUrl(),
$this->featureContext->getStepLineRef(),
$emailRecipient['email']
);
}
} catch (Exception $e) {
echo __METHOD__ .
" could not delete inbucket messages, is inbucket set up?\n" .
$e->getMessage();
}
}

/**
*
* @param string|null $user
Expand Down
2 changes: 1 addition & 1 deletion tests/acceptance/features/apiAntivirus/antivirus.feature
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
@antivirus @skipOnReva
@antivirus @skipOnReva @notification
Feature: antivirus
As a system administrator and user
I want to protect myself and others from known viruses
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
@notification
Feature: Delete notification
As a user
I want to delete notifications
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
@skipOnStable3.0
@notification
Feature: Deprovisioning notification
As a user admin
I want to inform users about shutting down and deprovisioning the instance
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
@email
@notification @email
Feature: Email notification
As a user
I want to get email notification of events related to me
Expand Down Expand Up @@ -130,7 +130,7 @@ Feature: Email notification
Zum Ansehen hier klicken: %base_url%/files/shares/with-me
"""

@skipOnStable3.0

Scenario: group members get an email notification in their respective languages when someone shares a space with the group
Given the administrator has assigned the role "Space Admin" to user "Alice" using the Graph API
And user "Carol" has been created with default attributes
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
@notification
Feature: Notification
As a user
I want to be notified of various events
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
@notification
Feature: service health check


Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
@notification
Feature: Notification
As a user
I want to be notified of actions related to space
Expand Down
2 changes: 1 addition & 1 deletion tests/acceptance/features/apiOcm/createInvitation.feature
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ Feature: create invitation
| @domain.com | 400 |
| [email protected] | 400 |

@email @issue-10059
@issue-10059 @notification @email
Scenario: federated user gets an email notification if their email was specified when creating the federation share invitation
Given using server "REMOTE"
And user "David" has been created with default attributes
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
@email
@notification
Feature: Notification Settings
As a user
I want to manage my notification settings
Expand All @@ -11,7 +11,7 @@ Feature: Notification Settings
| Brian |
And user "Alice" has uploaded file with content "some data" to "lorem.txt"


@email
Scenario: disable email notification
When user "Brian" disables email notification using the settings API
Then the HTTP status code should be "201"
Expand Down Expand Up @@ -64,7 +64,7 @@ Feature: Notification Settings
| permissionsRole | Viewer |
And user "Brian" should have "0" emails


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


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


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


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


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