diff --git a/tests/acceptance/bootstrap/NotificationContext.php b/tests/acceptance/bootstrap/NotificationContext.php index 7fefc8570..bd9fea738 100644 --- a/tests/acceptance/bootstrap/NotificationContext.php +++ b/tests/acceptance/bootstrap/NotificationContext.php @@ -513,17 +513,41 @@ class NotificationContext implements Context { $this->assertEmailContains($user, $expectedEmailBodyContent); } + /** + * @Then user :user should have received the following email from user :sender ignoring whitespaces + * + * @param string $user + * @param string $sender + * @param PyStringNode $content + * + * @return void + * @throws Exception + */ + public function userShouldHaveReceivedTheFollowingEmailFromUserIgnoringWhitespaces(string $user, string $sender, PyStringNode $content):void { + $rawExpectedEmailBodyContent = \str_replace("\r\n", "\n", $content->getRaw()); + $expectedEmailBodyContent = $this->featureContext->substituteInLineCodes( + $rawExpectedEmailBodyContent, + $sender + ); + $this->assertEmailContains($user, $expectedEmailBodyContent, true); + } + /*** * @param string $user * @param string $expectedEmailBodyContent + * @param bool $ignoreWhiteSpace * * @return void * @throws GuzzleException */ - public function assertEmailContains(string $user, string $expectedEmailBodyContent):void { + public function assertEmailContains(string $user, string $expectedEmailBodyContent, $ignoreWhiteSpace = false):void { $address = $this->featureContext->getEmailAddressForUser($user); $this->featureContext->pushEmailRecipientAsMailBox($address); $actualEmailBodyContent = EmailHelper::getBodyOfLastEmail($address, $this->featureContext->getStepLineRef()); + if ($ignoreWhiteSpace) { + $expectedEmailBodyContent = preg_replace('/\s+/', '', $expectedEmailBodyContent); + $actualEmailBodyContent = preg_replace('/\s+/', '', $actualEmailBodyContent); + } Assert::assertStringContainsString( $expectedEmailBodyContent, $actualEmailBodyContent, diff --git a/tests/acceptance/bootstrap/OcmContext.php b/tests/acceptance/bootstrap/OcmContext.php index bf41e1b54..7c3532629 100644 --- a/tests/acceptance/bootstrap/OcmContext.php +++ b/tests/acceptance/bootstrap/OcmContext.php @@ -32,6 +32,7 @@ use TestHelpers\WebDavHelper; */ class OcmContext implements Context { private FeatureContext $featureContext; + private NotificationContext $notificationContext; private string $invitationToken; /** @@ -52,6 +53,18 @@ class OcmContext implements Context { $environment = $scope->getEnvironment(); // Get all the contexts you need in this context from here $this->featureContext = $environment->getContext('FeatureContext'); + $this->notificationContext = $environment->getContext('NotificationContext'); + } + + /** + * Delete all the inbucket emails + * + * @AfterScenario @email + * + * @return void + */ + public function clearInbucketMessages():void { + $this->notificationContext->clearInbucketMessages(); } /** diff --git a/tests/acceptance/config/behat.yml b/tests/acceptance/config/behat.yml index d80a79446..80426135c 100644 --- a/tests/acceptance/config/behat.yml +++ b/tests/acceptance/config/behat.yml @@ -200,6 +200,7 @@ default: - SettingsContext: - OcisConfigContext: - SharingNgContext: + - OcmContext: apiAntivirus: paths: diff --git a/tests/acceptance/features/apiOcm/createInvitation.feature b/tests/acceptance/features/apiOcm/createInvitation.feature index 64cae31ad..ac53913e5 100755 --- a/tests/acceptance/features/apiOcm/createInvitation.feature +++ b/tests/acceptance/features/apiOcm/createInvitation.feature @@ -134,17 +134,17 @@ Feature: create invitation | @domain.com | 400 | | user@domain..com | 400 | - @email @skip + @email @issue-10059 Scenario: federated user gets an email notification if their email was specified when creating the federation share invitation Given using server "LOCAL" When "Alice" has created the federation share invitation with email "brian@example.com" and description "a share invitation from Alice" - And user "Brian" should have received the following email from user "Alice" + And user "Brian" should have received the following email from user "Alice" ignoring whitespaces """ Hi, Alice Hansen (alice@example.org) wants to start sharing collaboration resources with you. - Please visit your federation provider and use the following details: + Please visit your federation settings and use the following details: Token: %fed_invitation_token% ProviderDomain: https://ocis-server:9200 """