Skip to content

Commit

Permalink
fix mail cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
amrita-shrestha committed Feb 6, 2025
1 parent 2dd40cf commit c658fc3
Show file tree
Hide file tree
Showing 5 changed files with 41 additions and 32 deletions.
68 changes: 40 additions & 28 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 de-provisioning notification
*
* @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
*
* @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 @@ -661,30 +697,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
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
@email
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,4 +1,3 @@
@email
Feature: Share Expiry Notification
As a user
I want to be notified when share expires
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
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,3 @@
@email
Feature: Notification Settings
As a user
I want to manage my notification settings
Expand Down

0 comments on commit c658fc3

Please sign in to comment.