Skip to content

Commit 964b511

Browse files
authored
Merge pull request #8395 from nextcloud/stable13-8382-make-acceptance-tests-for-comments-more-consistent-with-the-others
[stable13] Make acceptance tests for comments more consistent with the others
2 parents de9865b + 5fd7de5 commit 964b511

3 files changed

Lines changed: 41 additions & 34 deletions

File tree

.drone.yml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -615,6 +615,13 @@ pipeline:
615615
when:
616616
matrix:
617617
TESTS-ACCEPTANCE: access-levels
618+
acceptance-app-comments:
619+
image: nextcloudci/integration-php7.0:integration-php7.0-6
620+
commands:
621+
- tests/acceptance/run-local.sh --timeout-multiplier 10 --nextcloud-server-domain acceptance-app-comments --selenium-server selenium:4444 allow-git-repository-modifications features/app-comments.feature
622+
when:
623+
matrix:
624+
TESTS-ACCEPTANCE: app-comments
618625
acceptance-app-files:
619626
image: nextcloudci/integration-php7.0:integration-php7.0-6
620627
commands:
@@ -813,6 +820,8 @@ matrix:
813820
- TESTS: integration-remote-api
814821
- TESTS: acceptance
815822
TESTS-ACCEPTANCE: access-levels
823+
- TESTS: acceptance
824+
TESTS-ACCEPTANCE: app-comments
816825
- TESTS: acceptance
817826
TESTS-ACCEPTANCE: app-files
818827
- TESTS: acceptance

tests/acceptance/features/app-comments.feature

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,4 @@ Feature: app-comments
55
And I open the details view for "welcome.txt"
66
And I open the "Comments" tab in the details view
77
When I create a new comment with "Hello world" as message
8-
Then I see that a comment was added
8+
Then I see a comment with "Hello world" as message

tests/acceptance/features/bootstrap/CommentsAppContext.php

Lines changed: 31 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -26,57 +26,55 @@
2626
class CommentsAppContext implements Context, ActorAwareInterface {
2727
use ActorAware;
2828

29-
3029
/**
31-
* @When /^I create a new comment with "([^"]*)" as message$/
30+
* @return Locator
3231
*/
33-
public function iCreateANewCommentWithAsMessage($commentText) {
34-
$this->actor->find(self::newCommentField(), 2)->setValue($commentText);
35-
$this->actor->find(self::submitNewCommentButton(), 2)->click();
32+
public static function newCommentField() {
33+
return Locator::forThe()->css("div.newCommentRow .message")->
34+
descendantOf(FilesAppContext::currentSectionDetailsView())->
35+
describedAs("New comment field in current section details view in Files app");
3636
}
3737

3838
/**
39-
* @Then /^I see that a comment was added$/
39+
* @return Locator
4040
*/
41-
public function iSeeThatACommentWasAdded() {
42-
$self = $this;
43-
44-
$result = Utils::waitFor(function () use ($self) {
45-
return $self->isCommentAdded();
46-
}, 5, 0.5);
47-
48-
PHPUnit_Framework_Assert::assertTrue($result);
41+
public static function submitNewCommentButton() {
42+
return Locator::forThe()->css("div.newCommentRow .submit")->
43+
descendantOf(FilesAppContext::currentSectionDetailsView())->
44+
describedAs("Submit new comment button in current section details view in Files app");
4945
}
5046

51-
public function isCommentAdded() {
52-
try {
53-
$locator = self::commentFields();
54-
$comments = $this->actor->getSession()->getPage()->findAll($locator->getSelector(), $locator->getLocator());
55-
PHPUnit_Framework_Assert::assertSame(1, count($comments));
56-
} catch (PHPUnit_Framework_ExpectationFailedException $e) {
57-
return false;
58-
}
59-
return true;
47+
/**
48+
* @return Locator
49+
*/
50+
public static function commentList() {
51+
return Locator::forThe()->css("ul.comments")->
52+
descendantOf(FilesAppContext::currentSectionDetailsView())->
53+
describedAs("Comment list in current section details view in Files app");
6054
}
6155

6256
/**
6357
* @return Locator
6458
*/
65-
public static function newCommentField() {
66-
return Locator::forThe()->css("div.newCommentRow .message")->descendantOf(FilesAppContext::currentSectionDetailsView())->
67-
describedAs("New comment field in the details view in Files app");
59+
public static function commentWithText($text) {
60+
return Locator::forThe()->xpath("//div[normalize-space() = '$text']/ancestor::li")->
61+
descendantOf(self::commentList())->
62+
describedAs("Comment with text \"$text\" in current section details view in Files app");
6863
}
6964

70-
public static function commentFields() {
71-
return Locator::forThe()->css(".comments .comment .message")->descendantOf(FilesAppContext::currentSectionDetailsView())->
72-
describedAs("Comment fields in the details view in Files app");
65+
/**
66+
* @When /^I create a new comment with "([^"]*)" as message$/
67+
*/
68+
public function iCreateANewCommentWithAsMessage($commentText) {
69+
$this->actor->find(self::newCommentField(), 10)->setValue($commentText);
70+
$this->actor->find(self::submitNewCommentButton())->click();
7371
}
7472

7573
/**
76-
* @return Locator
74+
* @Then /^I see a comment with "([^"]*)" as message$/
7775
*/
78-
public static function submitNewCommentButton() {
79-
return Locator::forThe()->css("div.newCommentRow .submit")->descendantOf(FilesAppContext::currentSectionDetailsView())->
80-
describedAs("Submit new comment button in the details view in Files app");
76+
public function iSeeACommentWithAsMessage($commentText) {
77+
PHPUnit_Framework_Assert::assertTrue(
78+
$this->actor->find(self::commentWithText($commentText), 10)->isVisible());
8179
}
8280
}

0 commit comments

Comments
 (0)