Skip to content

Commit

Permalink
Acceptance fixes
Browse files Browse the repository at this point in the history
Signed-off-by: John Molakvoæ (skjnldsv) <skjnldsv@protonmail.com>
  • Loading branch information
skjnldsv committed Jun 28, 2018
1 parent 57ac7f2 commit 252734c
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 50 deletions.
10 changes: 5 additions & 5 deletions tests/acceptance/features/app-files.feature
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ Feature: app-files
And I see that "welcome.txt" is marked as favorite
And I open the "Favorites" section
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
Then I see that the current section is "All files"
And I see that the details view is closed
Expand All @@ -17,11 +17,11 @@ Feature: app-files
And I see that "welcome.txt" is marked as favorite
And I open the "Favorites" section
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 see that the current section is "All files"
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
Given I am logged in
Expand Down Expand Up @@ -151,14 +151,14 @@ Feature: app-files
Scenario: show the input field for tags in the details view
Given I am logged in
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
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
Given I am logged in
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 see that the "Sharing" tab in the details view is eventually loaded
When I open the input field for tags in the details view
Expand Down
64 changes: 19 additions & 45 deletions tests/acceptance/features/bootstrap/FilesAppContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -63,18 +63,8 @@ public static function currentSectionMainView() {
/**
* @return Locator
*/
public static function detailsViewForSection($section) {
return Locator::forThe()->xpath("/preceding-sibling::*[position() = 1 and @id = 'app-sidebar']")->
descendantOf(self::mainViewForSection($section))->
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())->
public static function currentDetailsView() {
return Locator::forThe()->id("app-sidebar")->
describedAs("Current section details view in Files app");
}

Expand All @@ -83,7 +73,7 @@ public static function currentSectionDetailsView() {
*/
public static function closeDetailsViewButton() {
return Locator::forThe()->css(".icon-close")->
descendantOf(self::currentSectionDetailsView())->
descendantOf(self::currentDetailsView())->
describedAs("Close current section details view in Files app");
}

Expand All @@ -92,7 +82,7 @@ public static function closeDetailsViewButton() {
*/
public static function fileNameInCurrentSectionDetailsView() {
return Locator::forThe()->css(".fileName")->
descendantOf(self::currentSectionDetailsView())->
descendantOf(self::currentDetailsView())->
describedAs("File name in current section details view in Files app");
}

Expand All @@ -110,7 +100,7 @@ public static function fileDetailsInCurrentSectionDetailsViewWithText($fileDetai
*/
private static function fileDetailsInCurrentSectionDetailsView() {
return Locator::forThe()->css(".file-details")->
descendantOf(self::currentSectionDetailsView())->
descendantOf(self::currentDetailsView())->
describedAs("File details in current section details view in Files app");
}

Expand All @@ -119,7 +109,7 @@ private static function fileDetailsInCurrentSectionDetailsView() {
*/
public static function inputFieldForTagsInCurrentSectionDetailsView() {
return Locator::forThe()->css(".systemTagsInfoView")->
descendantOf(self::currentSectionDetailsView())->
descendantOf(self::currentDetailsView())->
describedAs("Input field for tags in current section details view in Files app");
}

Expand Down Expand Up @@ -172,7 +162,7 @@ public static function tabHeaderInCurrentSectionDetailsViewNamed($tabHeaderName)
*/
private static function tabHeadersInCurrentSectionDetailsView() {
return Locator::forThe()->css(".tabHeaders")->
descendantOf(self::currentSectionDetailsView())->
descendantOf(self::currentDetailsView())->
describedAs("Tab headers in current section details view in Files app");
}

Expand All @@ -181,7 +171,7 @@ private static function tabHeadersInCurrentSectionDetailsView() {
*/
public static function tabInCurrentSectionDetailsViewNamed($tabName) {
return Locator::forThe()->xpath("//div[@id=//*[contains(concat(' ', normalize-space(@class), ' '), ' tabHeader ') and normalize-space() = '$tabName']/@data-tabid]")->
descendantOf(self::currentSectionDetailsView())->
descendantOf(self::currentDetailsView())->
describedAs("Tab named $tabName in current section details view in Files app");
}

Expand All @@ -202,15 +192,15 @@ public static function shareLinkCheckbox() {
// return the checkbox itself, but the element that the user interacts
// with is the label.
return Locator::forThe()->xpath("//label[normalize-space() = 'Share link']")->
descendantOf(self::currentSectionDetailsView())->
descendantOf(self::currentDetailsView())->
describedAs("Share link checkbox in the details view in Files app");
}

/**
* @return Locator
*/
public static function shareLinkField() {
return Locator::forThe()->css(".linkText")->descendantOf(self::currentSectionDetailsView())->
return Locator::forThe()->css(".linkText")->descendantOf(self::currentDetailsView())->
describedAs("Share link field in the details view in Files app");
}

Expand All @@ -222,7 +212,7 @@ public static function allowUploadAndEditingRadioButton() {
// that would return the radio button itself, but the element that the
// user interacts with is the label.
return Locator::forThe()->xpath("//label[normalize-space() = 'Allow upload and editing']")->
descendantOf(self::currentSectionDetailsView())->
descendantOf(self::currentDetailsView())->
describedAs("Allow upload and editing radio button in the details view in Files app");
}

Expand All @@ -234,23 +224,23 @@ public static function passwordProtectCheckbox() {
// would return the checkbox itself, but the element that the user
// interacts with is the label.
return Locator::forThe()->xpath("//label[normalize-space() = 'Password protect']")->
descendantOf(self::currentSectionDetailsView())->
descendantOf(self::currentDetailsView())->
describedAs("Password protect checkbox in the details view in Files app");
}

/**
* @return Locator
*/
public static function passwordProtectField() {
return Locator::forThe()->css(".linkPassText")->descendantOf(self::currentSectionDetailsView())->
return Locator::forThe()->css(".linkPassText")->descendantOf(self::currentDetailsView())->
describedAs("Password protect field in the details view in Files app");
}

/**
* @return Locator
*/
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::currentDetailsView())->
describedAs("Password protect working icon in the details view in Files app");
}

Expand Down Expand Up @@ -347,36 +337,20 @@ public function iSeeThatTheCurrentPageIsTheFilesApp() {
}

/**
* @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(
$this->actor->find(self::detailsViewForSection($section), 10)->isVisible());

$otherSections = self::sections();
unset($otherSections[$section]);

$this->assertDetailsViewForSectionsAreClosed($otherSections);
$this->actor->find(self::currentDetailsView(), 10)->isVisible());
}

/**
* @Then I see that the details view is closed
*/
public function iSeeThatTheDetailsViewIsClosed() {
PHPUnit_Framework_Assert::assertNotNull($this->actor->find(self::currentSectionMainView(), 10));

$this->assertDetailsViewForSectionsAreClosed(self::sections());
}
PHPUnit_Framework_Assert::assertFalse(
$this->actor->find(self::currentDetailsView(), 10)->isVisible());

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) {
}
}
}

/**
Expand Down

0 comments on commit 252734c

Please sign in to comment.