diff options
author | Daniel Calviño Sánchez <danxuliu@gmail.com> | 2018-12-23 17:14:40 +0100 |
---|---|---|
committer | Daniel Calviño Sánchez <danxuliu@gmail.com> | 2019-02-01 16:46:36 +0100 |
commit | 7faf1dcd90765d8a0044349af50e46fa953e91aa (patch) | |
tree | f5c21afd5917965d4e4c6eee20e4461961aff98f /tests/acceptance | |
parent | f7bb94d37945037b65075c3784f7fa68339ff3b2 (diff) |
Add acceptance tests for opening the chat tab in the Files app
Signed-off-by: Daniel Calviño Sánchez <danxuliu@gmail.com>
Diffstat (limited to 'tests/acceptance')
-rw-r--r-- | tests/acceptance/config/behat.yml | 1 | ||||
-rw-r--r-- | tests/acceptance/features/app-files.feature | 58 | ||||
-rw-r--r-- | tests/acceptance/features/bootstrap/FilesAppChatTabContext.php | 101 |
3 files changed, 160 insertions, 0 deletions
diff --git a/tests/acceptance/config/behat.yml b/tests/acceptance/config/behat.yml index 1b8eade41..4c554ff2d 100644 --- a/tests/acceptance/config/behat.yml +++ b/tests/acceptance/config/behat.yml @@ -22,6 +22,7 @@ default: - ChatContext - ConversationInfoContext - ConversationListContext + - FilesAppChatTabContext - FilesAppRoomSharingContext - ParticipantListContext - TalkAppContext diff --git a/tests/acceptance/features/app-files.feature b/tests/acceptance/features/app-files.feature new file mode 100644 index 000000000..0ac4e0d78 --- /dev/null +++ b/tests/acceptance/features/app-files.feature @@ -0,0 +1,58 @@ +Feature: app-files + + Scenario: open chat tab in a file not shared + Given I am logged in as the admin + When I open the details view for "welcome.txt" + And I open the Chat tab in the details view of the Files app + Then I see that the "Start a conversation Share this file with others to discuss Share" empty content message is shown in the chat tab + + Scenario: open chat tab in a file again after sharing it with a user + Given I am logged in as the admin + And I open the details view for "welcome.txt" + And I open the Chat tab in the details view of the Files app + And I see that the "Start a conversation Share this file with others to discuss Share" empty content message is shown in the chat tab + When I share "welcome.txt" with "user0" + And I see that the file is shared with "user0" + And I open the Chat tab in the details view of the Files app + Then I see that the chat is shown in the Chat tab + + Scenario: open chat tab in a received shared file + Given I act as John + And I am logged in as the admin + And I act as Jane + And I am logged in + And I act as John + And I share "welcome.txt" with "user0" + And I see that the file is shared with "user0" + When I act as Jane + # The Files app is open again to reload the file list + And I open the Files app + And I open the details view for "welcome (2).txt" + And I open the Chat tab in the details view of the Files app + Then I see that the chat is shown in the Chat tab + + Scenario: open chat tab in a file shared by link + Given I am logged in as the admin + When I share the link for "welcome.txt" + # The shared link is not used for anything, but this ensures that the link + # share is ready before continuing. + And I write down the shared link + And I open the Chat tab in the details view of the Files app + Then I see that the "Start a conversation Share this file with others to discuss Share" empty content message is shown in the chat tab + + Scenario: chat tab header is not shown in a folder even if shared + Given I am logged in as the admin + # Open the details view for a file, which has the "Chat" tab header, to + # ensure that opening the details view for a folder actually hides the + # header. + And I open the details view for "welcome.txt" + And I see that the details view is open + When I create a new folder named "Folder" + Then I see that the Chat tab header is not shown in the details view + And I share "Folder" with "user0" + And I see that the file is shared with "user0" + # Close and open the details view again to trigger an update of the tab + # headers. + And I close the details view + And I open the details view for "Folder" + And I see that the Chat tab header is not shown in the details view diff --git a/tests/acceptance/features/bootstrap/FilesAppChatTabContext.php b/tests/acceptance/features/bootstrap/FilesAppChatTabContext.php new file mode 100644 index 000000000..caa638924 --- /dev/null +++ b/tests/acceptance/features/bootstrap/FilesAppChatTabContext.php @@ -0,0 +1,101 @@ +<?php + +/** + * + * @copyright Copyright (c) 2018, 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 FilesAppChatTabContext implements Context, ActorAwareInterface { + + use ActorAware; + use ChatAncestorSetter; + + /** + * @var FilesAppContext + */ + private $filesAppContext; + + /** + * @return Locator + */ + public static function emptyContent() { + return Locator::forThe()->css(".emptycontent")-> + descendantOf(FilesAppContext::tabInDetailsViewNamed("Chat"))-> + describedAs("Empty content in tab named Chat in details view in Files app"); + } + + /** + * @BeforeScenario + */ + public function getOtherRequiredSiblingContexts(BeforeScenarioScope $scope) { + $environment = $scope->getEnvironment(); + + $this->filesAppContext = $environment->getContext("FilesAppContext"); + } + + // "of the Files app" is needed to resolve the ambiguity between this step + // and the one defined in FilesAppContext. + /** + * @Given I open the Chat tab in the details view of the Files app + */ + public function iOpenTheChatTabInTheDetailsViewOfTheFilesApp() { + $this->filesAppContext->iOpenTheTabInTheDetailsView("Chat"); + + $this->setChatAncestorForActor(FilesAppContext::tabInDetailsViewNamed("Chat"), $this->actor); + } + + /** + * @Then I see that the Chat tab header is not shown in the details view + */ + public function iSeeThatTheChatTabHeaderIsNotShownInTheDetailsView() { + if (!WaitFor::elementToBeEventuallyNotShown( + $this->actor, + FilesAppContext::tabHeaderInDetailsViewNamed("Chat"), + $timeout = 10 * $this->actor->getFindTimeoutMultiplier())) { + PHPUnit_Framework_Assert::fail("The tab header named Chat is still shown in the details view after $timeout seconds"); + } + } + + /** + * @Then I see that the :text empty content message is shown in the chat tab + */ + public function iSeeThatTheEmptyContentMessageIsShownInTheChatTab($text) { + PHPUnit_Framework_Assert::assertEquals($text, $this->actor->find(self::emptyContent(), 10)->getText()); + } + + /** + * @Then I see that the chat is shown in the Chat tab + */ + public function iSeeThatTheChatIsShownInTheChatTab() { + // The chat may be present in the DOM but hidden behind a loading icon + // while the messages are being loaded, so it has to be explicitly + // waited for it to be visible instead of relying on the implicit wait + // made to find the element. + if (!WaitFor::elementToBeEventuallyShown( + $this->actor, + ChatContext::chatView(FilesAppContext::tabInDetailsViewNamed("Chat")), + $timeout = 10 * $this->actor->getFindTimeoutMultiplier())) { + PHPUnit_Framework_Assert::fail("The chat was not shown yet in the chat tab after $timeout seconds"); + } + } + +} |