diff options
author | Arthur Schiwon <blizzz@arthur-schiwon.de> | 2017-10-28 23:57:35 +0200 |
---|---|---|
committer | Arthur Schiwon <blizzz@arthur-schiwon.de> | 2017-10-28 23:57:35 +0200 |
commit | 76c803f0afba3c6207f0b6e9d224cbd8af1783ab (patch) | |
tree | cccad510c405c3dfb1078dd3d67f1d37a8d4e48a /tests | |
parent | 20e7a0c07b4259a22231b70a1b66514be2adeed7 (diff) | |
download | nextcloud-server-76c803f0afba3c6207f0b6e9d224cbd8af1783ab.tar.gz nextcloud-server-76c803f0afba3c6207f0b6e9d224cbd8af1783ab.zip |
add acceptance tests
Signed-off-by: Arthur Schiwon <blizzz@arthur-schiwon.de>
Diffstat (limited to 'tests')
-rw-r--r-- | tests/acceptance/config/behat.yml | 1 | ||||
-rw-r--r-- | tests/acceptance/features/app-comments.feature | 8 | ||||
-rw-r--r-- | tests/acceptance/features/bootstrap/CommentsAppContext.php | 82 |
3 files changed, 91 insertions, 0 deletions
diff --git a/tests/acceptance/config/behat.yml b/tests/acceptance/config/behat.yml index 10e1d425022..3495769457d 100644 --- a/tests/acceptance/config/behat.yml +++ b/tests/acceptance/config/behat.yml @@ -10,6 +10,7 @@ default: - NextcloudTestServerContext - AppNavigationContext + - CommentsAppContext - FeatureContext - FilesAppContext - FilesSharingAppContext diff --git a/tests/acceptance/features/app-comments.feature b/tests/acceptance/features/app-comments.feature new file mode 100644 index 00000000000..81fc6f89ad1 --- /dev/null +++ b/tests/acceptance/features/app-comments.feature @@ -0,0 +1,8 @@ +Feature: app-comments + + Scenario: Writing a comment + Given I am logged in + And I open the details view for "welcome.txt" + And I open the "Comments" tab in the details view + When I create a new comment with "Hello world" as message + Then I see that a comment was added diff --git a/tests/acceptance/features/bootstrap/CommentsAppContext.php b/tests/acceptance/features/bootstrap/CommentsAppContext.php new file mode 100644 index 00000000000..64d1dc69bc4 --- /dev/null +++ b/tests/acceptance/features/bootstrap/CommentsAppContext.php @@ -0,0 +1,82 @@ +<?php +/** + * @copyright Copyright (c) 2017 Arthur Schiwon <blizzz@arthur-schiwon.de> + * + * @author Arthur Schiwon <blizzz@arthur-schiwon.de> + * + * @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; + +class CommentsAppContext implements Context, ActorAwareInterface { + use ActorAware; + + + /** + * @When /^I create a new comment with "([^"]*)" as message$/ + */ + public function iCreateANewCommentWithAsMessage($commentText) { + $this->actor->find(self::newCommentField(), 2)->setValue($commentText); + $this->actor->find(self::submitNewCommentButton(), 2)->click(); + } + + /** + * @Then /^I see that a comment was added$/ + */ + public function iSeeThatACommentWasAdded() { + $self = $this; + + $result = Utils::waitFor(function () use ($self) { + return $self->isCommentAdded(); + }, 5, 0.5); + + PHPUnit_Framework_Assert::assertTrue($result); + } + + public function isCommentAdded() { + try { + $locator = self::commentFields(); + $comments = $this->actor->getSession()->getPage()->findAll($locator->getSelector(), $locator->getLocator()); + PHPUnit_Framework_Assert::assertSame(1, count($comments)); + } catch (PHPUnit_Framework_ExpectationFailedException $e) { + return false; + } + return true; + } + + /** + * @return Locator + */ + public static function newCommentField() { + return Locator::forThe()->css("div.newCommentRow .message")->descendantOf(FilesAppContext::currentSectionDetailsView())-> + describedAs("New comment field in the details view in Files app"); + } + + public static function commentFields() { + return Locator::forThe()->css(".comments .comment .message")->descendantOf(FilesAppContext::currentSectionDetailsView())-> + describedAs("Comment fields in the details view in Files app"); + } + + /** + * @return Locator + */ + public static function submitNewCommentButton() { + return Locator::forThe()->css("div.newCommentRow .submit")->descendantOf(FilesAppContext::currentSectionDetailsView())-> + describedAs("Submit new comment button in the details view in Files app"); + } +} |