Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nextcloud/server.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorDaniel Calviño Sánchez <danxuliu@gmail.com>2018-02-15 19:30:51 +0300
committerDaniel Calviño Sánchez <danxuliu@gmail.com>2018-02-16 14:24:35 +0300
commit5fd7de527553ae892b80ca63afe60f14d85a5f6d (patch)
treef01d2518805c6c8bf6955d9a4d54a818acec953a /tests
parentd9e66b211499b611d08c7e7a914c050fdfa31597 (diff)
Take into account the comment message when looking for it
Instead of checking that the list contains one comment it is now checked that a comment with certain message is visible. This makes the step (and the locator) more reusable in future tests and also simplifies the code. Signed-off-by: Daniel Calviño Sánchez <danxuliu@gmail.com>
Diffstat (limited to 'tests')
-rw-r--r--tests/acceptance/features/app-comments.feature2
-rw-r--r--tests/acceptance/features/bootstrap/CommentsAppContext.php39
2 files changed, 17 insertions, 24 deletions
diff --git a/tests/acceptance/features/app-comments.feature b/tests/acceptance/features/app-comments.feature
index 81fc6f89ad1..a5bdb0aa745 100644
--- a/tests/acceptance/features/app-comments.feature
+++ b/tests/acceptance/features/app-comments.feature
@@ -5,4 +5,4 @@ Feature: app-comments
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
+ Then I see a comment with "Hello world" as message
diff --git a/tests/acceptance/features/bootstrap/CommentsAppContext.php b/tests/acceptance/features/bootstrap/CommentsAppContext.php
index 8bc0f28ca34..7e804cfac23 100644
--- a/tests/acceptance/features/bootstrap/CommentsAppContext.php
+++ b/tests/acceptance/features/bootstrap/CommentsAppContext.php
@@ -47,10 +47,19 @@ class CommentsAppContext implements Context, ActorAwareInterface {
/**
* @return Locator
*/
- public static function commentFields() {
- return Locator::forThe()->css(".comments .comment .message")->
+ public static function commentList() {
+ return Locator::forThe()->css("ul.comments")->
descendantOf(FilesAppContext::currentSectionDetailsView())->
- describedAs("Comment fields in current section details view in Files app");
+ describedAs("Comment list in current section details view in Files app");
+ }
+
+ /**
+ * @return Locator
+ */
+ public static function commentWithText($text) {
+ return Locator::forThe()->xpath("//div[normalize-space() = '$text']/ancestor::li")->
+ descendantOf(self::commentList())->
+ describedAs("Comment with text \"$text\" in current section details view in Files app");
}
/**
@@ -62,26 +71,10 @@ class CommentsAppContext implements Context, ActorAwareInterface {
}
/**
- * @Then /^I see that a comment was added$/
+ * @Then /^I see a comment with "([^"]*)" as message$/
*/
- 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;
+ public function iSeeACommentWithAsMessage($commentText) {
+ PHPUnit_Framework_Assert::assertTrue(
+ $this->actor->find(self::commentWithText($commentText), 10)->isVisible());
}
}