Signed-off-by: John Molakvoæ (skjnldsv) <skjnldsv@protonmail.com>
This commit is contained in:
John Molakvoæ (skjnldsv) 2018-05-10 16:00:48 +02:00
parent 07a592bd27
commit a434077251
No known key found for this signature in database
GPG key ID: 60C25B8C072916CF
2 changed files with 76 additions and 72 deletions

View file

@ -25,77 +25,77 @@ use Behat\Behat\Context\Context;
class AppSettingsContext implements Context, ActorAwareInterface {
use ActorAware;
use ActorAware;
/**
* @return Locator
*/
public static function appSettings() {
return Locator::forThe()->id("app-settings")->
describedAs("App settings");
}
/**
* @return Locator
*/
public static function appSettingsContent() {
return Locator::forThe()->id("app-settings-content")->
descendantOf(self::appSettings())->
describedAs("App settings");
}
/**
* @return Locator
*/
public static function appSettings() {
return Locator::forThe()->id("app-settings")->
describedAs("App settings");
}
/**
* @return Locator
*/
public static function appSettingsContent() {
return Locator::forThe()->id("app-settings-content")->
descendantOf(self::appSettings())->
describedAs("App settings");
}
/**
* @return Locator
*/
public static function appSettingsOpenButton() {
return Locator::forThe()->xpath("//div[@id = 'app-settings-header']/button")->
descendantOf(self::appSettings())->
describedAs("The button to open the app settings");
}
/**
* @return Locator
*/
public static function appSettingsOpenButton() {
return Locator::forThe()->xpath("//div[@id = 'app-settings-header']/button")->
descendantOf(self::appSettings())->
describedAs("The button to open the app settings");
}
/**
* @return Locator
*/
public static function checkboxInTheSettings($id) {
return Locator::forThe()->xpath("//input[@id = '$id']")->
descendantOf(self::appSettingsContent())->
describedAs("The $id checkbox in the settings");
}
/**
* @return Locator
*/
public static function checkboxInTheSettings($id) {
return Locator::forThe()->xpath("//input[@id = '$id']")->
descendantOf(self::appSettingsContent())->
describedAs("The $id checkbox in the settings");
}
/**
* @return Locator
*/
public static function checkboxLabelInTheSettings($id) {
return Locator::forThe()->xpath("//label[@for = '$id']")->
descendantOf(self::appSettingsContent())->
describedAs("The label for the $id checkbox in the settings");
}
/**
* @return Locator
*/
public static function checkboxLabelInTheSettings($id) {
return Locator::forThe()->xpath("//label[@for = '$id']")->
descendantOf(self::appSettingsContent())->
describedAs("The label for the $id checkbox in the settings");
}
/**
* @Given I open the settings
*/
public function iOpenTheSettings() {
$this->actor->find(self::appSettingsOpenButton())->click();
}
/**
* @Given I open the settings
*/
public function iOpenTheSettings() {
$this->actor->find(self::appSettingsOpenButton())->click();
}
/**
* @Given I toggle the :id checkbox in the settings
*/
public function iToggleTheCheckboxInTheSettingsTo($id) {
$locator = self::CheckboxInTheSettings($id);
/**
* @Given I toggle the :id checkbox in the settings
*/
public function iToggleTheCheckboxInTheSettingsTo($id) {
$locator = self::CheckboxInTheSettings($id);
// If locator is not visible, fallback to label
if (!$this->actor->find(self::CheckboxInTheSettings($id))->isVisible()) {
$locator = self::checkboxLabelInTheSettings($id);
}
// If locator is not visible, fallback to label
if (!$this->actor->find(self::CheckboxInTheSettings($id))->isVisible()) {
$locator = self::checkboxLabelInTheSettings($id);
}
$this->actor->find($locator)->click();
}
$this->actor->find($locator)->click();
}
/**
* @Then I see that the settings are opened
*/
public function iSeeThatTheSettingsAreOpened() {
WaitFor::elementToBeEventuallyShown($this->actor, self::appSettingsContent());
}
/**
* @Then I see that the settings are opened
*/
public function iSeeThatTheSettingsAreOpened() {
WaitFor::elementToBeEventuallyShown($this->actor, self::appSettingsContent());
}
}

View file

@ -36,21 +36,25 @@ Feature: users
And I am logged in as the admin
And I open the User settings
And I see that the list of users contains the user user0
When I assign the user user0 to the group admin
Then I see that the section Admins is shown
And I see that the section Admins has a count of 2
# disabled because we need the TAB patch:
# https://github.com/minkphp/MinkSelenium2Driver/pull/244
# When I assign the user user0 to the group admin
# Then I see that the section Admins is shown
# And I see that the section Admins has a count of 2
Scenario: create and delete a group
Given I act as Jane
And I am logged in as the admin
And I open the User settings
And I see that the list of users contains the user user0
And I assign the user user0 to the group Group1
And I see that the section Group1 is shown
And I click the "icon-delete" button on the Group1 section
And I see that the confirmation dialog is shown
When I click the "Yes" button of the confirmation dialog
Then I see that the section Group1 is not shown
# disabled because we need the TAB patch:
# https://github.com/minkphp/MinkSelenium2Driver/pull/244
# And I assign the user user0 to the group Group1
# And I see that the section Group1 is shown
# And I click the "icon-delete" button on the Group1 section
# And I see that the confirmation dialog is shown
# When I click the "Yes" button of the confirmation dialog
# Then I see that the section Group1 is not shown
Scenario: change columns visibility
Given I act as Jane