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
This commit is contained in:
commit
964b511b39
|
@ -615,6 +615,13 @@ pipeline:
|
||||||
when:
|
when:
|
||||||
matrix:
|
matrix:
|
||||||
TESTS-ACCEPTANCE: access-levels
|
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:
|
acceptance-app-files:
|
||||||
image: nextcloudci/integration-php7.0:integration-php7.0-6
|
image: nextcloudci/integration-php7.0:integration-php7.0-6
|
||||||
commands:
|
commands:
|
||||||
|
@ -813,6 +820,8 @@ matrix:
|
||||||
- TESTS: integration-remote-api
|
- TESTS: integration-remote-api
|
||||||
- TESTS: acceptance
|
- TESTS: acceptance
|
||||||
TESTS-ACCEPTANCE: access-levels
|
TESTS-ACCEPTANCE: access-levels
|
||||||
|
- TESTS: acceptance
|
||||||
|
TESTS-ACCEPTANCE: app-comments
|
||||||
- TESTS: acceptance
|
- TESTS: acceptance
|
||||||
TESTS-ACCEPTANCE: app-files
|
TESTS-ACCEPTANCE: app-files
|
||||||
- TESTS: acceptance
|
- TESTS: acceptance
|
||||||
|
|
|
@ -5,4 +5,4 @@ Feature: app-comments
|
||||||
And I open the details view for "welcome.txt"
|
And I open the details view for "welcome.txt"
|
||||||
And I open the "Comments" tab in the details view
|
And I open the "Comments" tab in the details view
|
||||||
When I create a new comment with "Hello world" as message
|
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
|
||||||
|
|
|
@ -26,57 +26,55 @@ use Behat\Behat\Context\Context;
|
||||||
class CommentsAppContext implements Context, ActorAwareInterface {
|
class CommentsAppContext implements Context, ActorAwareInterface {
|
||||||
use ActorAware;
|
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
|
* @return Locator
|
||||||
*/
|
*/
|
||||||
public static function newCommentField() {
|
public static function newCommentField() {
|
||||||
return Locator::forThe()->css("div.newCommentRow .message")->descendantOf(FilesAppContext::currentSectionDetailsView())->
|
return Locator::forThe()->css("div.newCommentRow .message")->
|
||||||
describedAs("New comment field in the details view in Files app");
|
descendantOf(FilesAppContext::currentSectionDetailsView())->
|
||||||
}
|
describedAs("New comment field 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");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return Locator
|
* @return Locator
|
||||||
*/
|
*/
|
||||||
public static function submitNewCommentButton() {
|
public static function submitNewCommentButton() {
|
||||||
return Locator::forThe()->css("div.newCommentRow .submit")->descendantOf(FilesAppContext::currentSectionDetailsView())->
|
return Locator::forThe()->css("div.newCommentRow .submit")->
|
||||||
describedAs("Submit new comment button in the details view in Files app");
|
descendantOf(FilesAppContext::currentSectionDetailsView())->
|
||||||
|
describedAs("Submit new comment button in current section details view in Files app");
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @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 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");
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @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();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Then /^I see a comment with "([^"]*)" as message$/
|
||||||
|
*/
|
||||||
|
public function iSeeACommentWithAsMessage($commentText) {
|
||||||
|
PHPUnit_Framework_Assert::assertTrue(
|
||||||
|
$this->actor->find(self::commentWithText($commentText), 10)->isVisible());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue