Skip to content

Commit

Permalink
fix nottification cleanup and retry
Browse files Browse the repository at this point in the history
  • Loading branch information
amrita-shrestha committed Feb 10, 2025
1 parent e09f0a6 commit ba12fc1
Show file tree
Hide file tree
Showing 10 changed files with 51 additions and 38 deletions.
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 inbucket emails
*
* @return void
* @throws GuzzleException
*/
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();
}
}

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

/**
* @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 (object) [];
}

/**
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 @skipOnStable3.0
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
Feature: Email notification
As a user
I want to get email notification of events related to me
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 |
| user@domain..com | 400 |

@email @issue-10059
@issue-10059 @notification
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 Down

0 comments on commit ba12fc1

Please sign in to comment.