Skip to content

Commit

Permalink
Merge pull request #8395 from nextcloud/stable13-8382-make-acceptance…
Browse files Browse the repository at this point in the history
…-tests-for-comments-more-consistent-with-the-others

[stable13] Make acceptance tests for comments more consistent with the others
  • Loading branch information
MorrisJobke authored Feb 16, 2018
2 parents de9865b + 5fd7de5 commit 964b511
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 34 deletions.
9 changes: 9 additions & 0 deletions .drone.yml
Original file line number Diff line number Diff line change
Expand Up @@ -615,6 +615,13 @@ pipeline:
when:
matrix:
TESTS-ACCEPTANCE: access-levels
acceptance-app-comments:
image: nextcloudci/integration-php7.0:integration-php7.0-6
commands:
- 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
when:
matrix:
TESTS-ACCEPTANCE: app-comments
acceptance-app-files:
image: nextcloudci/integration-php7.0:integration-php7.0-6
commands:
Expand Down Expand Up @@ -813,6 +820,8 @@ matrix:
- TESTS: integration-remote-api
- TESTS: acceptance
TESTS-ACCEPTANCE: access-levels
- TESTS: acceptance
TESTS-ACCEPTANCE: app-comments
- TESTS: acceptance
TESTS-ACCEPTANCE: app-files
- TESTS: acceptance
Expand Down
2 changes: 1 addition & 1 deletion tests/acceptance/features/app-comments.feature
Original file line number Diff line number Diff line change
Expand Up @@ -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
64 changes: 31 additions & 33 deletions tests/acceptance/features/bootstrap/CommentsAppContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,57 +26,55 @@
class CommentsAppContext implements Context, ActorAwareInterface {
use ActorAware;


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

/**
* @Then /^I see that a comment was added$/
* @return Locator
*/
public function iSeeThatACommentWasAdded() {
$self = $this;

$result = Utils::waitFor(function () use ($self) {
return $self->isCommentAdded();
}, 5, 0.5);

PHPUnit_Framework_Assert::assertTrue($result);
public static function submitNewCommentButton() {
return Locator::forThe()->css("div.newCommentRow .submit")->
descendantOf(FilesAppContext::currentSectionDetailsView())->
describedAs("Submit new comment button in current section details view in Files app");
}

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 commentList() {
return Locator::forThe()->css("ul.comments")->
descendantOf(FilesAppContext::currentSectionDetailsView())->
describedAs("Comment list in current section details view in Files app");
}

/**
* @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 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");
}

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

/**
* @return Locator
* @Then /^I see a comment with "([^"]*)" as message$/
*/
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");
public function iSeeACommentWithAsMessage($commentText) {
PHPUnit_Framework_Assert::assertTrue(
$this->actor->find(self::commentWithText($commentText), 10)->isVisible());
}
}

0 comments on commit 964b511

Please sign in to comment.