This repository has been archived by the owner on May 3, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 47
[Behat] WIP Improve structure and usability of PlatformUI behat Contexts #602
Open
miguelcleverti
wants to merge
8
commits into
ezsystems:master
Choose a base branch
from
miguelcleverti:BehatStructureUpdate
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
[Behat] WIP Improve structure and usability of PlatformUI behat Contexts #602
miguelcleverti
wants to merge
8
commits into
ezsystems:master
from
miguelcleverti:BehatStructureUpdate
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
miguelcleverti
force-pushed
the
BehatStructureUpdate
branch
from
June 1, 2016 15:14
1a4407e
to
2bf44c5
Compare
{ | ||
$this->sleep(); | ||
$result = $this->getElementByText($message, '.ez-notification-text'); | ||
Assertion::AssertNotNull($result); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
instance var not really necessary, if not for consistency maybe?
miguelcleverti
force-pushed
the
BehatStructureUpdate
branch
from
June 27, 2016 14:33
f2fdad9
to
b7b16e3
Compare
This Pull Request does not respect PSR-2 Coding Standards, please, see the suggested diff below: Loaded config from "/jenkins/jenkins.std/jobs/PlatformUIBundle-Pull-Request-checker/workspace/.php_cs"
.............F.....
Legend: ?-unknown, I-invalid file syntax, file ignored, .-no changes, F-fixed, E-error
1) Features/Context/SubContext/BrowserContext.php (unused_use)
---------- begin diff ----------
--- Original
+++ New
@@ @@
-use EzSystems\BehatBundle\Helper\EzAssertion;
use EzSystems\PlatformUIBundle\Features\Context\PlatformUI;
use EzSystems\PlatformBehatBundle\Helper\Xpath;
class BrowserContext extends PlatformUI
{
/**
* @Given I clicked on/at (the) :link link
* @When I click on/at (the) :link link
*
* Click a link with text ':link'
*/
public function clickLink($link)
{
$this->clickElementByText($link, 'a');
}
/**
* @Given I clicked on/at (the) :button button
* @When I click on/at (the) :button button
*
* Clicks the button identified by ':button'
*/
public function iClickAtButton($button)
{
$this->clickElementByText($button, 'button');
}
/**
* @When I fill in :field with :value
* @When I set :field as empty
*
* Spin function make it possible to retry in case of failure
*/
public function fillFieldWithValue($field, $value = '')
{
$fieldNode = $this->spin(
function () use ($field) {
$fieldNode = $this->getSession()->getPage()->findField($field);
if ($fieldNode == null) {
throw new \Exception('Field not found');
}
return $fieldNode;
}
);
$this->spin(
function () use ($fieldNode, $field, $value) {
// make sure any autofocus elements don't mis-behave when setting value
$fieldNode->blur();
usleep(10 * 1000);
$fieldNode->focus();
usleep(10 * 1000);
// setting value on pre-filled inputs can cause issues, clearing before
$fieldNode->setValue('');
$fieldNode->setValue($value);
// verication that the field was really filled in correctly
$this->sleep();
$check = $this->getSession()->getPage()->findField($field)->getValue();
if ($check != $value) {
throw new \Exception('Failed to set the field value: ' . $check);
}
return true;
}
);
}
/**
* @Then I (should) see :title title/topic
*/
public function iSeeTitle($title)
{
$page = $this->getSession()->getPage();
$this->spin(
function () use ($title, $page) {
$titleElements = $page->findAll('css', 'h1, h2, h3');
foreach ($titleElements as $titleElement) {
$elementText = $titleElement->getText();
if ($elementText == $title) {
return $titleElement;
}
}
throw new \Exception("Title '$title' not found");
}
);
}
/**
* @Then I should see a :label input field
*/
public function seeInputField($label)
{
$field = $this->getSession()->getPage()->findField($label);
if (!$field) {
throw new \Exception("Field '$label' not found");
}
}
/**
* @Given I checked :label checkbox
* @When I check :label checkbox
*
* Toggles the value for the checkbox with name ':label'
*/
public function checkOption($option)
{
$session = $this->getSession();
$selectorsHandler = $session->getSelectorsHandler();
$literal = $selectorsHandler->xpathLiteral($option);
// To be able to work on mink 1.6 (ezplatform) & mink 1.5 (5.4+ezpublish-community) w/o deprecation exceptions
$selector = $selectorsHandler->isSelectorRegistered('named_partial') ?
$selectorsHandler->getSelector('named_partial') :
$selectorsHandler->getSelector('named');
$xpath = $selector->translateToXPath(array('field', $literal));
$fieldElement = $session->getPage()->find('xpath', $xpath);
$fieldElement->check();
}
}
---------- end diff ----------
Fixed all files in 16.341 seconds, 8.500 MB memory used |
miguelcleverti
force-pushed
the
BehatStructureUpdate
branch
from
June 27, 2016 14:40
b7b16e3
to
122e43b
Compare
miguelcleverti
force-pushed
the
BehatStructureUpdate
branch
from
June 27, 2016 14:54
122e43b
to
e36e132
Compare
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
NOT YET FOR MERGE
This PR refactors the platfomui behat contexts in order to make them more decoupled and usable.
Main objectives:
Also added a easier way to gather contexts by using annotations in the properties specifying the context needed.
There are a lot of changes here but most of it is code that has already been reviewed.
depends on: