Adjust acceptance tests to sidebar changes in Files app

Before, each section of the Files app ("All files", "Favorites"...) had
its own sidebar element. Now there is a single sidebar element for all
the sections in the Files app.

Signed-off-by: John Molakvoæ (skjnldsv) <skjnldsv@protonmail.com>
This commit is contained in:
John Molakvoæ (skjnldsv) 2018-06-26 16:47:16 +02:00 committed by Morris Jobke
parent fe6f444928
commit 562e2aa30b
No known key found for this signature in database
GPG Key ID: FE03C3A163FEDE68
3 changed files with 73 additions and 89 deletions

View File

@ -6,7 +6,7 @@ Feature: app-files
And I see that "welcome.txt" is marked as favorite And I see that "welcome.txt" is marked as favorite
And I open the "Favorites" section And I open the "Favorites" section
And I open the details view for "welcome.txt" And I open the details view for "welcome.txt"
And I see that the details view for "Favorites" section is open And I see that the details view is open
When I view "welcome.txt" in folder When I view "welcome.txt" in folder
Then I see that the current section is "All files" Then I see that the current section is "All files"
And I see that the details view is closed And I see that the details view is closed
@ -17,11 +17,11 @@ Feature: app-files
And I see that "welcome.txt" is marked as favorite And I see that "welcome.txt" is marked as favorite
And I open the "Favorites" section And I open the "Favorites" section
And I open the details view for "welcome.txt" And I open the details view for "welcome.txt"
And I see that the details view for "Favorites" section is open And I see that the details view is open
And I view "welcome.txt" in folder And I view "welcome.txt" in folder
And I see that the current section is "All files" And I see that the current section is "All files"
When I open the details view for "welcome.txt" When I open the details view for "welcome.txt"
Then I see that the details view for "All files" section is open Then I see that the details view is open
Scenario: rename a file with the details view open Scenario: rename a file with the details view open
Given I am logged in Given I am logged in
@ -151,14 +151,14 @@ Feature: app-files
Scenario: show the input field for tags in the details view Scenario: show the input field for tags in the details view
Given I am logged in Given I am logged in
And I open the details view for "welcome.txt" And I open the details view for "welcome.txt"
And I see that the details view for "All files" section is open And I see that the details view is open
When I open the input field for tags in the details view When I open the input field for tags in the details view
Then I see that the input field for tags in the details view is shown Then I see that the input field for tags in the details view is shown
Scenario: show the input field for tags in the details view after the sharing tab has loaded Scenario: show the input field for tags in the details view after the sharing tab has loaded
Given I am logged in Given I am logged in
And I open the details view for "welcome.txt" And I open the details view for "welcome.txt"
And I see that the details view for "All files" section is open And I see that the details view is open
And I open the "Sharing" tab in the details view And I open the "Sharing" tab in the details view
And I see that the "Sharing" tab in the details view is eventually loaded And I see that the "Sharing" tab in the details view is eventually loaded
When I open the input field for tags in the details view When I open the input field for tags in the details view

View File

@ -31,8 +31,8 @@ class CommentsAppContext implements Context, ActorAwareInterface {
*/ */
public static function newCommentField() { public static function newCommentField() {
return Locator::forThe()->css("div.newCommentRow .message")-> return Locator::forThe()->css("div.newCommentRow .message")->
descendantOf(FilesAppContext::currentSectionDetailsView())-> descendantOf(FilesAppContext::detailsView())->
describedAs("New comment field in current section details view in Files app"); describedAs("New comment field in details view in Files app");
} }
/** /**
@ -40,8 +40,8 @@ class CommentsAppContext implements Context, ActorAwareInterface {
*/ */
public static function submitNewCommentButton() { public static function submitNewCommentButton() {
return Locator::forThe()->css("div.newCommentRow .submit")-> return Locator::forThe()->css("div.newCommentRow .submit")->
descendantOf(FilesAppContext::currentSectionDetailsView())-> descendantOf(FilesAppContext::detailsView())->
describedAs("Submit new comment button in current section details view in Files app"); describedAs("Submit new comment button in details view in Files app");
} }
/** /**
@ -49,8 +49,8 @@ class CommentsAppContext implements Context, ActorAwareInterface {
*/ */
public static function commentList() { public static function commentList() {
return Locator::forThe()->css("ul.comments")-> return Locator::forThe()->css("ul.comments")->
descendantOf(FilesAppContext::currentSectionDetailsView())-> descendantOf(FilesAppContext::detailsView())->
describedAs("Comment list in current section details view in Files app"); describedAs("Comment list in details view in Files app");
} }
/** /**
@ -59,7 +59,7 @@ class CommentsAppContext implements Context, ActorAwareInterface {
public static function commentWithText($text) { public static function commentWithText($text) {
return Locator::forThe()->xpath("//div[normalize-space() = '$text']/ancestor::li")-> return Locator::forThe()->xpath("//div[normalize-space() = '$text']/ancestor::li")->
descendantOf(self::commentList())-> descendantOf(self::commentList())->
describedAs("Comment with text \"$text\" in current section details view in Files app"); describedAs("Comment with text \"$text\" in details view in Files app");
} }
/** /**

View File

@ -63,19 +63,9 @@ class FilesAppContext implements Context, ActorAwareInterface {
/** /**
* @return Locator * @return Locator
*/ */
public static function detailsViewForSection($section) { public static function detailsView() {
return Locator::forThe()->xpath("/preceding-sibling::*[position() = 1 and @id = 'app-sidebar']")-> return Locator::forThe()->id("app-sidebar")->
descendantOf(self::mainViewForSection($section))-> describedAs("Details view in Files app");
describedAs("Details view for section $section in Files app");
}
/**
* @return Locator
*/
public static function currentSectionDetailsView() {
return Locator::forThe()->xpath("/preceding-sibling::*[position() = 1 and @id = 'app-sidebar']")->
descendantOf(self::currentSectionMainView())->
describedAs("Current section details view in Files app");
} }
/** /**
@ -83,53 +73,53 @@ class FilesAppContext implements Context, ActorAwareInterface {
*/ */
public static function closeDetailsViewButton() { public static function closeDetailsViewButton() {
return Locator::forThe()->css(".icon-close")-> return Locator::forThe()->css(".icon-close")->
descendantOf(self::currentSectionDetailsView())-> descendantOf(self::detailsView())->
describedAs("Close current section details view in Files app"); describedAs("Close details view in Files app");
} }
/** /**
* @return Locator * @return Locator
*/ */
public static function fileNameInCurrentSectionDetailsView() { public static function fileNameInDetailsView() {
return Locator::forThe()->css(".fileName")-> return Locator::forThe()->css(".fileName")->
descendantOf(self::currentSectionDetailsView())-> descendantOf(self::detailsView())->
describedAs("File name in current section details view in Files app"); describedAs("File name in details view in Files app");
} }
/** /**
* @return Locator * @return Locator
*/ */
public static function fileDetailsInCurrentSectionDetailsViewWithText($fileDetailsText) { public static function fileDetailsInDetailsViewWithText($fileDetailsText) {
return Locator::forThe()->xpath("//span[normalize-space() = '$fileDetailsText']")-> return Locator::forThe()->xpath("//span[normalize-space() = '$fileDetailsText']")->
descendantOf(self::fileDetailsInCurrentSectionDetailsView())-> descendantOf(self::fileDetailsInDetailsView())->
describedAs("File details with text \"$fileDetailsText\" in current section details view in Files app"); describedAs("File details with text \"$fileDetailsText\" in details view in Files app");
} }
/** /**
* @return Locator * @return Locator
*/ */
private static function fileDetailsInCurrentSectionDetailsView() { private static function fileDetailsInDetailsView() {
return Locator::forThe()->css(".file-details")-> return Locator::forThe()->css(".file-details")->
descendantOf(self::currentSectionDetailsView())-> descendantOf(self::detailsView())->
describedAs("File details in current section details view in Files app"); describedAs("File details in details view in Files app");
} }
/** /**
* @return Locator * @return Locator
*/ */
public static function inputFieldForTagsInCurrentSectionDetailsView() { public static function inputFieldForTagsInDetailsView() {
return Locator::forThe()->css(".systemTagsInfoView")-> return Locator::forThe()->css(".systemTagsInfoView")->
descendantOf(self::currentSectionDetailsView())-> descendantOf(self::detailsView())->
describedAs("Input field for tags in current section details view in Files app"); describedAs("Input field for tags in details view in Files app");
} }
/** /**
* @return Locator * @return Locator
*/ */
public static function itemInInputFieldForTagsInCurrentSectionDetailsViewForTag($tag) { public static function itemInInputFieldForTagsInDetailsViewForTag($tag) {
return Locator::forThe()->xpath("//span[normalize-space() = '$tag']")-> return Locator::forThe()->xpath("//span[normalize-space() = '$tag']")->
descendantOf(self::inputFieldForTagsInCurrentSectionDetailsView())-> descendantOf(self::inputFieldForTagsInDetailsView())->
describedAs("Item in input field for tags in current section details view for tag $tag in Files app"); describedAs("Item in input field for tags in details view for tag $tag in Files app");
} }
/** /**
@ -161,37 +151,37 @@ class FilesAppContext implements Context, ActorAwareInterface {
/** /**
* @return Locator * @return Locator
*/ */
public static function tabHeaderInCurrentSectionDetailsViewNamed($tabHeaderName) { public static function tabHeaderInDetailsViewNamed($tabHeaderName) {
return Locator::forThe()->xpath("//li[normalize-space() = '$tabHeaderName']")-> return Locator::forThe()->xpath("//li[normalize-space() = '$tabHeaderName']")->
descendantOf(self::tabHeadersInCurrentSectionDetailsView())-> descendantOf(self::tabHeadersInDetailsView())->
describedAs("Tab header named $tabHeaderName in current section details view in Files app"); describedAs("Tab header named $tabHeaderName in details view in Files app");
} }
/** /**
* @return Locator * @return Locator
*/ */
private static function tabHeadersInCurrentSectionDetailsView() { private static function tabHeadersInDetailsView() {
return Locator::forThe()->css(".tabHeaders")-> return Locator::forThe()->css(".tabHeaders")->
descendantOf(self::currentSectionDetailsView())-> descendantOf(self::detailsView())->
describedAs("Tab headers in current section details view in Files app"); describedAs("Tab headers in details view in Files app");
} }
/** /**
* @return Locator * @return Locator
*/ */
public static function tabInCurrentSectionDetailsViewNamed($tabName) { public static function tabInDetailsViewNamed($tabName) {
return Locator::forThe()->xpath("//div[@id=//*[contains(concat(' ', normalize-space(@class), ' '), ' tabHeader ') and normalize-space() = '$tabName']/@data-tabid]")-> return Locator::forThe()->xpath("//div[@id=//*[contains(concat(' ', normalize-space(@class), ' '), ' tabHeader ') and normalize-space() = '$tabName']/@data-tabid]")->
descendantOf(self::currentSectionDetailsView())-> descendantOf(self::detailsView())->
describedAs("Tab named $tabName in current section details view in Files app"); describedAs("Tab named $tabName in details view in Files app");
} }
/** /**
* @return Locator * @return Locator
*/ */
public static function loadingIconForTabInCurrentSectionDetailsViewNamed($tabName) { public static function loadingIconForTabInDetailsViewNamed($tabName) {
return Locator::forThe()->css(".loading")-> return Locator::forThe()->css(".loading")->
descendantOf(self::tabInCurrentSectionDetailsViewNamed($tabName))-> descendantOf(self::tabInDetailsViewNamed($tabName))->
describedAs("Loading icon for tab named $tabName in current section details view in Files app"); describedAs("Loading icon for tab named $tabName in details view in Files app");
} }
/** /**
@ -202,7 +192,7 @@ class FilesAppContext implements Context, ActorAwareInterface {
// return the checkbox itself, but the element that the user interacts // return the checkbox itself, but the element that the user interacts
// with is the label. // with is the label.
return Locator::forThe()->xpath("//label[normalize-space() = 'Share link']")-> return Locator::forThe()->xpath("//label[normalize-space() = 'Share link']")->
descendantOf(self::currentSectionDetailsView())-> descendantOf(self::detailsView())->
describedAs("Share link checkbox in the details view in Files app"); describedAs("Share link checkbox in the details view in Files app");
} }
@ -210,7 +200,7 @@ class FilesAppContext implements Context, ActorAwareInterface {
* @return Locator * @return Locator
*/ */
public static function shareLinkField() { public static function shareLinkField() {
return Locator::forThe()->css(".linkText")->descendantOf(self::currentSectionDetailsView())-> return Locator::forThe()->css(".linkText")->descendantOf(self::detailsView())->
describedAs("Share link field in the details view in Files app"); describedAs("Share link field in the details view in Files app");
} }
@ -222,7 +212,7 @@ class FilesAppContext implements Context, ActorAwareInterface {
// that would return the radio button itself, but the element that the // that would return the radio button itself, but the element that the
// user interacts with is the label. // user interacts with is the label.
return Locator::forThe()->xpath("//label[normalize-space() = 'Allow upload and editing']")-> return Locator::forThe()->xpath("//label[normalize-space() = 'Allow upload and editing']")->
descendantOf(self::currentSectionDetailsView())-> descendantOf(self::detailsView())->
describedAs("Allow upload and editing radio button in the details view in Files app"); describedAs("Allow upload and editing radio button in the details view in Files app");
} }
@ -234,7 +224,7 @@ class FilesAppContext implements Context, ActorAwareInterface {
// would return the checkbox itself, but the element that the user // would return the checkbox itself, but the element that the user
// interacts with is the label. // interacts with is the label.
return Locator::forThe()->xpath("//label[normalize-space() = 'Password protect']")-> return Locator::forThe()->xpath("//label[normalize-space() = 'Password protect']")->
descendantOf(self::currentSectionDetailsView())-> descendantOf(self::detailsView())->
describedAs("Password protect checkbox in the details view in Files app"); describedAs("Password protect checkbox in the details view in Files app");
} }
@ -242,7 +232,7 @@ class FilesAppContext implements Context, ActorAwareInterface {
* @return Locator * @return Locator
*/ */
public static function passwordProtectField() { public static function passwordProtectField() {
return Locator::forThe()->css(".linkPassText")->descendantOf(self::currentSectionDetailsView())-> return Locator::forThe()->css(".linkPassText")->descendantOf(self::detailsView())->
describedAs("Password protect field in the details view in Files app"); describedAs("Password protect field in the details view in Files app");
} }
@ -250,7 +240,7 @@ class FilesAppContext implements Context, ActorAwareInterface {
* @return Locator * @return Locator
*/ */
public static function passwordProtectWorkingIcon() { public static function passwordProtectWorkingIcon() {
return Locator::forThe()->css(".linkPass .icon-loading-small")->descendantOf(self::currentSectionDetailsView())-> return Locator::forThe()->css(".linkPass .icon-loading-small")->descendantOf(self::detailsView())->
describedAs("Password protect working icon in the details view in Files app"); describedAs("Password protect working icon in the details view in Files app");
} }
@ -265,14 +255,14 @@ class FilesAppContext implements Context, ActorAwareInterface {
* @Given I open the input field for tags in the details view * @Given I open the input field for tags in the details view
*/ */
public function iOpenTheInputFieldForTagsInTheDetailsView() { public function iOpenTheInputFieldForTagsInTheDetailsView() {
$this->actor->find(self::fileDetailsInCurrentSectionDetailsViewWithText("Tags"), 10)->click(); $this->actor->find(self::fileDetailsInDetailsViewWithText("Tags"), 10)->click();
} }
/** /**
* @Given I open the :tabName tab in the details view * @Given I open the :tabName tab in the details view
*/ */
public function iOpenTheTabInTheDetailsView($tabName) { public function iOpenTheTabInTheDetailsView($tabName) {
$this->actor->find(self::tabHeaderInCurrentSectionDetailsViewNamed($tabName), 10)->click(); $this->actor->find(self::tabHeaderInDetailsViewNamed($tabName), 10)->click();
} }
/** /**
@ -347,35 +337,29 @@ class FilesAppContext implements Context, ActorAwareInterface {
} }
/** /**
* @Then I see that the details view for :section section is open * @Then I see that the details view is open
*/ */
public function iSeeThatTheDetailsViewForSectionIsOpen($section) { public function iSeeThatTheDetailsViewIsOpen() {
PHPUnit_Framework_Assert::assertTrue( // The sidebar always exists in the DOM, so it has to be explicitly
$this->actor->find(self::detailsViewForSection($section), 10)->isVisible()); // waited for it to be visible instead of relying on the implicit wait
// made to find the element.
$otherSections = self::sections(); if (!WaitFor::elementToBeEventuallyShown(
unset($otherSections[$section]); $this->actor,
self::detailsView(),
$this->assertDetailsViewForSectionsAreClosed($otherSections); $timeout = 10 * $this->actor->getFindTimeoutMultiplier())) {
PHPUnit_Framework_Assert::fail("The details view is not open yet after $timeout seconds");
}
} }
/** /**
* @Then I see that the details view is closed * @Then I see that the details view is closed
*/ */
public function iSeeThatTheDetailsViewIsClosed() { public function iSeeThatTheDetailsViewIsClosed() {
PHPUnit_Framework_Assert::assertNotNull($this->actor->find(self::currentSectionMainView(), 10)); if (!WaitFor::elementToBeEventuallyNotShown(
$this->actor,
$this->assertDetailsViewForSectionsAreClosed(self::sections()); self::detailsView(),
} $timeout = 10 * $this->actor->getFindTimeoutMultiplier())) {
PHPUnit_Framework_Assert::fail("The details view is not closed yet after $timeout seconds");
private function assertDetailsViewForSectionsAreClosed($sections) {
foreach ($sections as $section => $id) {
try {
PHPUnit_Framework_Assert::assertFalse(
$this->actor->find(self::detailsViewForSection($section))->isVisible(),
"Details view for section $section is open but it should be closed");
} catch (NoSuchElementException $exception) {
}
} }
} }
@ -384,7 +368,7 @@ class FilesAppContext implements Context, ActorAwareInterface {
*/ */
public function iSeeThatTheFileNameShownInTheDetailsViewIs($fileName) { public function iSeeThatTheFileNameShownInTheDetailsViewIs($fileName) {
PHPUnit_Framework_Assert::assertEquals( PHPUnit_Framework_Assert::assertEquals(
$this->actor->find(self::fileNameInCurrentSectionDetailsView(), 10)->getText(), $fileName); $this->actor->find(self::fileNameInDetailsView(), 10)->getText(), $fileName);
} }
/** /**
@ -392,7 +376,7 @@ class FilesAppContext implements Context, ActorAwareInterface {
*/ */
public function iSeeThatTheInputFieldForTagsInTheDetailsViewIsShown() { public function iSeeThatTheInputFieldForTagsInTheDetailsViewIsShown() {
PHPUnit_Framework_Assert::assertTrue( PHPUnit_Framework_Assert::assertTrue(
$this->actor->find(self::inputFieldForTagsInCurrentSectionDetailsView(), 10)->isVisible()); $this->actor->find(self::inputFieldForTagsInDetailsView(), 10)->isVisible());
} }
/** /**
@ -400,7 +384,7 @@ class FilesAppContext implements Context, ActorAwareInterface {
*/ */
public function iSeeThatTheInputFieldForTagsInTheDetailsViewContainsTheTag($tag) { public function iSeeThatTheInputFieldForTagsInTheDetailsViewContainsTheTag($tag) {
PHPUnit_Framework_Assert::assertTrue( PHPUnit_Framework_Assert::assertTrue(
$this->actor->find(self::itemInInputFieldForTagsInCurrentSectionDetailsViewForTag($tag), 10)->isVisible()); $this->actor->find(self::itemInInputFieldForTagsInDetailsViewForTag($tag), 10)->isVisible());
} }
/** /**
@ -411,7 +395,7 @@ class FilesAppContext implements Context, ActorAwareInterface {
try { try {
PHPUnit_Framework_Assert::assertFalse( PHPUnit_Framework_Assert::assertFalse(
$this->actor->find(self::itemInInputFieldForTagsInCurrentSectionDetailsViewForTag($tag))->isVisible()); $this->actor->find(self::itemInInputFieldForTagsInDetailsViewForTag($tag))->isVisible());
} catch (NoSuchElementException $exception) { } catch (NoSuchElementException $exception) {
} }
} }
@ -441,7 +425,7 @@ class FilesAppContext implements Context, ActorAwareInterface {
public function iSeeThatTheTabInTheDetailsViewIsEventuallyLoaded($tabName) { public function iSeeThatTheTabInTheDetailsViewIsEventuallyLoaded($tabName) {
if (!WaitFor::elementToBeEventuallyNotShown( if (!WaitFor::elementToBeEventuallyNotShown(
$this->actor, $this->actor,
self::loadingIconForTabInCurrentSectionDetailsViewNamed($tabName), self::loadingIconForTabInDetailsViewNamed($tabName),
$timeout = 10 * $this->actor->getFindTimeoutMultiplier())) { $timeout = 10 * $this->actor->getFindTimeoutMultiplier())) {
PHPUnit_Framework_Assert::fail("The $tabName tab in the details view has not been loaded after $timeout seconds"); PHPUnit_Framework_Assert::fail("The $tabName tab in the details view has not been loaded after $timeout seconds");
} }