Add acceptance tests for showing the input field for tags

Signed-off-by: Daniel Calviño Sánchez <danxuliu@gmail.com>
This commit is contained in:
Daniel Calviño Sánchez 2017-06-09 03:02:33 +02:00
parent 3678be045e
commit be02b3df28
2 changed files with 123 additions and 0 deletions

View file

@ -52,3 +52,19 @@ Feature: app-files
And I authenticate with password "fedcba"
Then I see that the current page is the Authenticate page for the shared link I wrote down
And I see that a wrong password for the shared file message is shown
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
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 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
Then I see that the input field for tags in the details view is shown

View file

@ -102,6 +102,69 @@ class FilesAppContext implements Context, ActorAwareInterface {
describedAs("Current section details view in Files app");
}
/**
* @return Locator
*/
public static function fileDetailsInCurrentSectionDetailsViewWithText($fileDetailsText) {
return Locator::forThe()->xpath("//span[normalize-space() = '$fileDetailsText']")->
descendantOf(self::fileDetailsInCurrentSectionDetailsView())->
describedAs("File details with text \"$fileDetailsText\" in current section details view in Files app");
}
/**
* @return Locator
*/
private static function fileDetailsInCurrentSectionDetailsView() {
return Locator::forThe()->css(".file-details")->
descendantOf(self::currentSectionDetailsView())->
describedAs("File details in current section details view in Files app");
}
/**
* @return Locator
*/
public static function inputFieldForTagsInCurrentSectionDetails() {
return Locator::forThe()->css(".systemTagsInfoView")->
descendantOf(self::currentSectionDetailsView())->
describedAs("Input field for tags in current section details view in Files app");
}
/**
* @return Locator
*/
public static function tabHeaderInCurrentSectionDetailsViewNamed($tabHeaderName) {
return Locator::forThe()->xpath("//li[normalize-space() = '$tabHeaderName']")->
descendantOf(self::tabHeadersInCurrentSectionDetailsView())->
describedAs("Tab header named $tabHeaderName in current section details view in Files app");
}
/**
* @return Locator
*/
private static function tabHeadersInCurrentSectionDetailsView() {
return Locator::forThe()->css(".tabHeaders")->
descendantOf(self::currentSectionDetailsView())->
describedAs("Tab headers in current section details view in Files app");
}
/**
* @return Locator
*/
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())->
describedAs("Tab named $tabName in current section details view in Files app");
}
/**
* @return Locator
*/
public static function loadingIconForTabInCurrentSectionDetailsViewNamed($tabName) {
return Locator::forThe()->css(".loading")->
descendantOf(self::tabInCurrentSectionDetailsViewNamed($tabName))->
describedAs("Loading icon for tab named $tabName in current section details view in Files app");
}
/**
* @return Locator
*/
@ -246,6 +309,20 @@ class FilesAppContext implements Context, ActorAwareInterface {
$this->actor->find(self::detailsMenuItem(), 2)->click();
}
/**
* @Given I open the input field for tags in the details view
*/
public function iOpenTheInputFieldForTagsInTheDetailsView() {
$this->actor->find(self::fileDetailsInCurrentSectionDetailsViewWithText("Tags"), 10)->click();
}
/**
* @Given I open the :tabName tab in the details view
*/
public function iOpenTheTabInTheDetailsView($tabName) {
$this->actor->find(self::tabHeaderInCurrentSectionDetailsViewNamed($tabName), 10)->click();
}
/**
* @Given I mark :fileName as favorite
*/
@ -343,6 +420,36 @@ class FilesAppContext implements Context, ActorAwareInterface {
PHPUnit_Framework_Assert::assertNotNull($this->actor->find(self::favoritedStateIconForFile($fileName), 10));
}
/**
* @Then I see that the input field for tags in the details view is shown
*/
public function iSeeThatTheInputFieldForTagsInTheDetailsViewIsShown() {
PHPUnit_Framework_Assert::assertTrue(
$this->actor->find(self::inputFieldForTagsInCurrentSectionDetails(), 10)->isVisible());
}
/**
* @When I see that the :tabName tab in the details view is eventually loaded
*/
public function iSeeThatTheTabInTheDetailsViewIsEventuallyLoaded($tabName) {
$timeout = 10;
$timeoutStep = 1;
$actor = $this->actor;
$loadingIcon = self::loadingIconForTabInCurrentSectionDetailsViewNamed($tabName);
$loadingIconNotFoundCallback = function() use ($actor, $loadingIcon) {
try {
return !$actor->find($loadingIcon)->isVisible();
} catch (NoSuchElementException $exception) {
return true;
}
};
if (!Utils::waitFor($loadingIconNotFoundCallback, $timeout, $timeoutStep)) {
PHPUnit_Framework_Assert::fail("The $tabName tab in the details view has not been loaded after $timeout seconds");
}
}
/**
* @Then I see that the working icon for password protect is shown
*/