From d0ea4ad8b84998d9eecd41d0f518530615cb0fce Mon Sep 17 00:00:00 2001 From: =?utf8?q?Daniel=20Calvi=C3=B1o=20S=C3=A1nchez?= Date: Thu, 22 Nov 2018 05:20:26 +0100 Subject: [PATCH] Add acceptance tests for switching to the comments of another file MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Signed-off-by: Daniel Calviño Sánchez --- .../acceptance/features/app-comments.feature | 23 +++++++++++++++ .../features/bootstrap/CommentsAppContext.php | 28 +++++++++++++++++++ 2 files changed, 51 insertions(+) diff --git a/tests/acceptance/features/app-comments.feature b/tests/acceptance/features/app-comments.feature index a5bdb0aa745..1ee113d0aac 100644 --- a/tests/acceptance/features/app-comments.feature +++ b/tests/acceptance/features/app-comments.feature @@ -6,3 +6,26 @@ Feature: app-comments And I open the "Comments" tab in the details view When I create a new comment with "Hello world" as message Then I see a comment with "Hello world" as message + + Scenario: open the comments for a different file + Given I am logged in + And I create a new folder named "Folder" + And I open the details view for "welcome.txt" + And I open the "Comments" tab in the details view + And I create a new comment with "Hello world" as message + And I see a comment with "Hello world" as message + When I open the details view for "Folder" + # The "Comments" tab should already be opened + Then I see that there are no comments + + Scenario: write a comment in a file right after writing a comment in another file + Given I am logged in + And I create a new folder named "Folder" + And I open the details view for "Folder" + And I open the "Comments" tab in the details view + And I create a new comment with "Comment in Folder" as message + And I open the details view for "welcome.txt" + # The "Comments" tab should already be opened + When I create a new comment with "Comment in welcome.txt" as message + Then I see a comment with "Comment in welcome.txt" as message + And I see that there is no comment with "Comment in Folder" as message diff --git a/tests/acceptance/features/bootstrap/CommentsAppContext.php b/tests/acceptance/features/bootstrap/CommentsAppContext.php index 13d8af4e60e..5d19412c30e 100644 --- a/tests/acceptance/features/bootstrap/CommentsAppContext.php +++ b/tests/acceptance/features/bootstrap/CommentsAppContext.php @@ -62,6 +62,15 @@ class CommentsAppContext implements Context, ActorAwareInterface { describedAs("Comment with text \"$text\" in details view in Files app"); } + /** + * @return Locator + */ + public static function emptyContent() { + return Locator::forThe()->css(".emptycontent")-> + descendantOf(FilesAppContext::detailsView())-> + describedAs("Empty content in details view in Files app"); + } + /** * @When /^I create a new comment with "([^"]*)" as message$/ */ @@ -70,6 +79,14 @@ class CommentsAppContext implements Context, ActorAwareInterface { $this->actor->find(self::submitNewCommentButton())->click(); } + /** + * @Then /^I see that there are no comments$/ + */ + public function iSeeThatThereAreNoComments() { + PHPUnit_Framework_Assert::assertTrue( + $this->actor->find(self::emptyContent(), 10)->isVisible()); + } + /** * @Then /^I see a comment with "([^"]*)" as message$/ */ @@ -77,4 +94,15 @@ class CommentsAppContext implements Context, ActorAwareInterface { PHPUnit_Framework_Assert::assertTrue( $this->actor->find(self::commentWithText($commentText), 10)->isVisible()); } + + /** + * @Then /^I see that there is no comment with "([^"]*)" as message$/ + */ + public function iSeeThatThereIsNoCommentWithAsMessage($commentText) { + try { + PHPUnit_Framework_Assert::assertFalse( + $this->actor->find(self::commentWithText($commentText))->isVisible()); + } catch (NoSuchElementException $exception) { + } + } } -- 2.39.5