diff options
author | Daniel Calviño Sánchez <danxuliu@gmail.com> | 2019-07-23 19:23:10 +0200 |
---|---|---|
committer | Daniel Calviño Sánchez <danxuliu@gmail.com> | 2019-08-28 00:49:54 +0200 |
commit | 482c86a30ddbe73868d74e029b23e41c63f38dd9 (patch) | |
tree | d6aa35db9f6a68ef2f6d1aea46eefe9979ec5084 /tests/acceptance | |
parent | b2b506aa82966de6f5d10de78e8aa801535a6d3a (diff) |
Check mention of current user in acceptance tests
Signed-off-by: Daniel Calviño Sánchez <danxuliu@gmail.com>
Diffstat (limited to 'tests/acceptance')
-rw-r--r-- | tests/acceptance/features/bootstrap/ChatContext.php | 16 | ||||
-rw-r--r-- | tests/acceptance/features/chat.feature | 16 |
2 files changed, 29 insertions, 3 deletions
diff --git a/tests/acceptance/features/bootstrap/ChatContext.php b/tests/acceptance/features/bootstrap/ChatContext.php index 02fb25729..fa8acb1c4 100644 --- a/tests/acceptance/features/bootstrap/ChatContext.php +++ b/tests/acceptance/features/bootstrap/ChatContext.php @@ -162,6 +162,15 @@ class ChatContext implements Context, ActorAwareInterface { /** * @return Locator */ + public static function formattedMentionInChatMessageOfAsCurrentUser($chatAncestor, $number, $user) { + return Locator::forThe()->xpath("span/span[contains(concat(' ', normalize-space(@class), ' '), ' mention-user ') and contains(concat(' ', normalize-space(@class), ' '), ' currentUser ') and normalize-space() = '$user']")-> + descendantOf(self::textOfChatMessage($chatAncestor, $number))-> + describedAs("Formatted mention of $user as current user in chat message $number in the list of received messages"); + } + + /** + * @return Locator + */ public static function formattedLinkInChatMessageTo($chatAncestor, $number, $url) { return Locator::forThe()->xpath("a[normalize-space(@href) = '$url']")-> descendantOf(self::textOfChatMessage($chatAncestor, $number))-> @@ -289,6 +298,13 @@ class ChatContext implements Context, ActorAwareInterface { } /** + * @Then I see that the message :number contains a formatted mention of :user as current user + */ + public function iSeeThatTheMessageContainsAFormattedMentionOfAsCurrentUser($number, $user) { + PHPUnit_Framework_Assert::assertNotNull($this->actor->find(self::formattedMentionInChatMessageOfAsCurrentUser($this->chatAncestor, $number, $user), 10)); + } + + /** * @Then I see that the message :number contains a formatted link to :user */ public function iSeeThatTheMessageContainsAFormattedLinkTo($number, $url) { diff --git a/tests/acceptance/features/chat.feature b/tests/acceptance/features/chat.feature index 3579d0f2e..dad834f04 100644 --- a/tests/acceptance/features/chat.feature +++ b/tests/acceptance/features/chat.feature @@ -129,13 +129,23 @@ Feature: chat And I see that the message 6 was sent by "admin" with the text "Fine too!" Scenario: mention another user - Given I am logged in + Given I act as John + And I am logged in And I have opened the Talk app - And I create a group conversation named "Group" + And I create a one-to-one conversation with "admin" + And I see that the chat is shown in the main view + And I act as Jane + And I am logged in as the admin + And I have opened the Talk app + And I open the "user0" conversation And I see that the chat is shown in the main view - When I send a new chat message with the text "Hello @admin" + When I act as John + And I send a new chat message with the text "Hello @admin" Then I see that the message 1 was sent by "user0" with the text "Hello admin" And I see that the message 1 contains a formatted mention of "admin" + And I act as Jane + And I see that the message 1 was sent by "user0" with the text "Hello admin" + And I see that the message 1 contains a formatted mention of "admin" as current user Scenario: mention another user and a URL Given I am logged in |