summaryrefslogtreecommitdiffstats
path: root/tests/acceptance
diff options
context:
space:
mode:
authorDaniel Calviño Sánchez <danxuliu@gmail.com>2019-05-07 12:27:07 +0200
committerDaniel Calviño Sánchez <danxuliu@gmail.com>2019-07-19 13:19:07 +0200
commit4ff2771041038fc25c4853147879bcd141280823 (patch)
tree42c24b0dd90451a5eb13dca629e545d83c998c77 /tests/acceptance
parent8ee67f13c11746e5287352bf6e46d88b307b4d31 (diff)
Add acceptance test for joining a public room
Signed-off-by: Daniel Calviño Sánchez <danxuliu@gmail.com>
Diffstat (limited to 'tests/acceptance')
-rw-r--r--tests/acceptance/config/behat.yml1
-rw-r--r--tests/acceptance/features/bootstrap/ConversationInfoContext.php21
-rw-r--r--tests/acceptance/features/bootstrap/ConversationListContext.php23
-rw-r--r--tests/acceptance/features/bootstrap/PublicConversationContext.php69
-rw-r--r--tests/acceptance/features/conversation-public.feature11
5 files changed, 125 insertions, 0 deletions
diff --git a/tests/acceptance/config/behat.yml b/tests/acceptance/config/behat.yml
index 308ee5d45..7f663333d 100644
--- a/tests/acceptance/config/behat.yml
+++ b/tests/acceptance/config/behat.yml
@@ -27,6 +27,7 @@ default:
- FilesAppChatTabContext
- FilesAppRoomSharingContext
- ParticipantListContext
+ - PublicConversationContext
- PublicSharePasswordRequestContext
- TalkAppContext
diff --git a/tests/acceptance/features/bootstrap/ConversationInfoContext.php b/tests/acceptance/features/bootstrap/ConversationInfoContext.php
index fe8b07ef9..113d4efa9 100644
--- a/tests/acceptance/features/bootstrap/ConversationInfoContext.php
+++ b/tests/acceptance/features/bootstrap/ConversationInfoContext.php
@@ -73,6 +73,15 @@ class ConversationInfoContext implements Context, ActorAwareInterface {
}
/**
+ * @return Locator
+ */
+ public static function copyLinkButton() {
+ return Locator::forThe()->css(".clipboard-button")->
+ descendantOf(self::conversationInfoContainer())->
+ describedAs("Copy link button in conversation info");
+ }
+
+ /**
* @Given I rename the conversation to :newConversationName
*/
public function iRenameTheConversationTo($newConversationName) {
@@ -81,4 +90,16 @@ class ConversationInfoContext implements Context, ActorAwareInterface {
$this->actor->find(self::conversationNameTextInput(), 2)->setValue($newConversationName . "\r");
}
+ /**
+ * @Given I write down the public conversation link
+ */
+ public function iWriteDownThePublicConversationLink() {
+ $this->actor->find(self::copyLinkButton(), 10)->click();
+
+ // Clicking on the menu item copies the link to the clipboard, but it is
+ // not possible to access that value from the acceptance tests. Due to
+ // this the value of the attribute that holds the URL is used instead.
+ $this->actor->getSharedNotebook()["public conversation link"] = $this->actor->find(self::copyLinkButton(), 2)->getWrappedElement()->getAttribute("data-clipboard-text");
+ }
+
}
diff --git a/tests/acceptance/features/bootstrap/ConversationListContext.php b/tests/acceptance/features/bootstrap/ConversationListContext.php
index 27dcdae49..1d8e6d8d8 100644
--- a/tests/acceptance/features/bootstrap/ConversationListContext.php
+++ b/tests/acceptance/features/bootstrap/ConversationListContext.php
@@ -136,6 +136,29 @@ class ConversationListContext implements Context, ActorAwareInterface {
$this->setChatAncestorForActor(TalkAppContext::mainView(), $this->actor);
}
+ /**
+ * @Given I create a public conversation named :name
+ */
+ public function iCreateAPublicConversationNamed($name) {
+ // When the Talk app is opened and there are no conversations the
+ // dropdown is automatically shown, and when the dropdown is shown
+ // clicking on the button to open it fails because it is covered by the
+ // search field of the dropdown. Due to that first it is assumed that
+ // the dropdown is shown and the item is searched and directly clicked;
+ // if it was not shown, then it is explicitly shown and after that the
+ // item is searched and clicked.
+ try {
+ $this->setValueForSearchInputInSelect2Dropdown($name);
+ $this->actor->find(TalkAppContext::itemInSelect2DropdownFor($name . " (public)"), 2)->click();
+ } catch (NoSuchElementException $exception) {
+ $this->actor->find(self::showCreateConversationDropdownButton(), 10)->click();
+ $this->setValueForSearchInputInSelect2Dropdown($name);
+ $this->actor->find(TalkAppContext::itemInSelect2DropdownFor($name . " (public)"), 2)->click();
+ }
+
+ $this->setChatAncestorForActor(TalkAppContext::mainView(), $this->actor);
+ }
+
private function setValueForSearchInputInSelect2Dropdown($value) {
// When "setValue" is used on an element, the Selenium2 driver for Mink
// used in the acceptance tests does not send only the given value; it
diff --git a/tests/acceptance/features/bootstrap/PublicConversationContext.php b/tests/acceptance/features/bootstrap/PublicConversationContext.php
new file mode 100644
index 000000000..2c5e1054e
--- /dev/null
+++ b/tests/acceptance/features/bootstrap/PublicConversationContext.php
@@ -0,0 +1,69 @@
+<?php
+
+/**
+ *
+ * @copyright Copyright (c) 2019, Daniel Calviño Sánchez (danxuliu@gmail.com)
+ *
+ * @license GNU AGPL version 3 or any later version
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+use Behat\Behat\Context\Context;
+use Behat\Behat\Hook\Scope\BeforeScenarioScope;
+
+class PublicConversationContext implements Context, ActorAwareInterface {
+
+ use ActorAware;
+ use ChatAncestorSetter;
+
+ /**
+ * @var ChatContext
+ */
+ private $chatContext;
+
+ /**
+ * @BeforeScenario
+ */
+ public function getOtherRequiredSiblingContexts(BeforeScenarioScope $scope) {
+ $environment = $scope->getEnvironment();
+
+ $this->chatContext = $environment->getContext("ChatContext");
+ }
+
+ /**
+ * @When I visit the public conversation link I wrote down
+ */
+ public function iVisitThePublicConversationLinkIWroteDown() {
+ $this->actor->getSession()->visit($this->actor->getSharedNotebook()["public conversation link"]);
+ }
+
+ /**
+ * @Then I see that the current page is the public conversation link I wrote down
+ */
+ public function iSeeThatTheCurrentPageIsThePublicConversationLinkIWroteDown() {
+ PHPUnit_Framework_Assert::assertEquals(
+ $this->actor->getSharedNotebook()["public conversation link"],
+ $this->actor->getSession()->getCurrentUrl());
+
+ $this->setChatAncestorForActor(TalkAppContext::mainView(), $this->actor);
+
+ // The authenticate page for shared links in Files app has a special
+ // URL, but the authenticate page for public conversations does not, so
+ // it needs to be checked too that the chat view is shown.
+ $this->chatContext->iSeeThatTheChatIsShownInTheMainView();
+ }
+
+}
diff --git a/tests/acceptance/features/conversation-public.feature b/tests/acceptance/features/conversation-public.feature
new file mode 100644
index 000000000..61deadda9
--- /dev/null
+++ b/tests/acceptance/features/conversation-public.feature
@@ -0,0 +1,11 @@
+Feature: conversation
+
+ Scenario: join a public conversation
+ Given I act as John
+ And I am logged in
+ And I have opened the Talk app
+ And I create a public conversation named "Public"
+ And I write down the public conversation link
+ When I act as Jane
+ And I visit the public conversation link I wrote down
+ Then I see that the current page is the public conversation link I wrote down