mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 14:05:37 +02:00
API Update to use new chromedriver + behat-extension + facebook/webdriver
This commit is contained in:
parent
b6c6bd6af2
commit
c54b07a952
13
.travis.yml
13
.travis.yml
@ -2,6 +2,10 @@ language: php
|
|||||||
|
|
||||||
dist: trusty
|
dist: trusty
|
||||||
|
|
||||||
|
before_install:
|
||||||
|
- sudo apt-get update
|
||||||
|
- sudo apt-get install chromium-chromedriver
|
||||||
|
|
||||||
cache:
|
cache:
|
||||||
directories:
|
directories:
|
||||||
- $HOME/.composer/cache/files
|
- $HOME/.composer/cache/files
|
||||||
@ -67,6 +71,10 @@ matrix:
|
|||||||
- PHPUNIT_TEST=framework
|
- PHPUNIT_TEST=framework
|
||||||
|
|
||||||
before_script:
|
before_script:
|
||||||
|
# Extra $PATH
|
||||||
|
- export PATH=~/.composer/vendor/bin:$PATH
|
||||||
|
- export PATH=/usr/lib/chromium-browser/:$PATH
|
||||||
|
|
||||||
# Init PHP
|
# Init PHP
|
||||||
- pecl channel-update pecl.php.net
|
- pecl channel-update pecl.php.net
|
||||||
- phpenv rehash
|
- phpenv rehash
|
||||||
@ -74,11 +82,10 @@ before_script:
|
|||||||
- echo 'memory_limit = 2048M' >> ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/travis.ini
|
- echo 'memory_limit = 2048M' >> ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/travis.ini
|
||||||
|
|
||||||
# Install composer dependencies
|
# Install composer dependencies
|
||||||
- export PATH=~/.composer/vendor/bin:$PATH
|
|
||||||
- composer validate
|
- composer validate
|
||||||
- if [[ $DB == PGSQL ]]; then composer require silverstripe/postgresql:2.0.x-dev --no-update; fi
|
- if [[ $DB == PGSQL ]]; then composer require silverstripe/postgresql:2.0.x-dev --no-update; fi
|
||||||
- if [[ $DB == SQLITE ]]; then composer require silverstripe/sqlite3:2.0.x-dev --no-update; fi
|
- if [[ $DB == SQLITE ]]; then composer require silverstripe/sqlite3:2.0.x-dev --no-update; fi
|
||||||
- composer require silverstripe/recipe-core:1.0.x-dev silverstripe/admin:1.0.x-dev silverstripe/versioned:1.0.x-dev --no-update
|
- composer require silverstripe/recipe-testing:^1 silverstripe/recipe-core:1.0.x-dev silverstripe/admin:1.0.x-dev silverstripe/versioned:1.0.x-dev --no-update
|
||||||
- if [[ $PHPUNIT_TEST == cms ]] || [[ $BEHAT_TEST == cms ]]; then composer require silverstripe/recipe-cms:1.0.x-dev --no-update; fi
|
- if [[ $PHPUNIT_TEST == cms ]] || [[ $BEHAT_TEST == cms ]]; then composer require silverstripe/recipe-cms:1.0.x-dev --no-update; fi
|
||||||
- if [[ $PHPCS_TEST ]]; then composer global require squizlabs/php_codesniffer:^3 --prefer-dist --no-interaction --no-progress --no-suggest -o; fi
|
- if [[ $PHPCS_TEST ]]; then composer global require squizlabs/php_codesniffer:^3 --prefer-dist --no-interaction --no-progress --no-suggest -o; fi
|
||||||
- composer install --prefer-dist --no-interaction --no-progress --no-suggest --optimize-autoloader --verbose --profile
|
- composer install --prefer-dist --no-interaction --no-progress --no-suggest --optimize-autoloader --verbose --profile
|
||||||
@ -90,7 +97,7 @@ before_script:
|
|||||||
- if [[ $BEHAT_TEST ]]; then mkdir artifacts; fi
|
- if [[ $BEHAT_TEST ]]; then mkdir artifacts; fi
|
||||||
- if [[ $BEHAT_TEST ]]; then cp composer.lock artifacts/; fi
|
- if [[ $BEHAT_TEST ]]; then cp composer.lock artifacts/; fi
|
||||||
- if [[ $BEHAT_TEST ]]; then sh -e /etc/init.d/xvfb start; sleep 3; fi
|
- if [[ $BEHAT_TEST ]]; then sh -e /etc/init.d/xvfb start; sleep 3; fi
|
||||||
- if [[ $BEHAT_TEST ]]; then (vendor/bin/selenium-server-standalone > artifacts/selenium.log 2>&1 &); fi
|
- if [[ $BEHAT_TEST ]]; then (chromedriver > artifacts/chromedriver.log 2>&1 &); fi
|
||||||
- if [[ $BEHAT_TEST == framework ]]; then (vendor/bin/serve --bootstrap-file tests/behat/serve-bootstrap.php &> artifacts/serve.log &); fi
|
- if [[ $BEHAT_TEST == framework ]]; then (vendor/bin/serve --bootstrap-file tests/behat/serve-bootstrap.php &> artifacts/serve.log &); fi
|
||||||
- if [[ $BEHAT_TEST == cms ]]; then (vendor/bin/serve --bootstrap-file vendor/silverstripe/cms/tests/behat/serve-bootstrap.php &> artifacts/serve.log &); fi
|
- if [[ $BEHAT_TEST == cms ]]; then (vendor/bin/serve --bootstrap-file vendor/silverstripe/cms/tests/behat/serve-bootstrap.php &> artifacts/serve.log &); fi
|
||||||
|
|
||||||
|
@ -23,10 +23,11 @@ default:
|
|||||||
|
|
||||||
extensions:
|
extensions:
|
||||||
SilverStripe\BehatExtension\MinkExtension:
|
SilverStripe\BehatExtension\MinkExtension:
|
||||||
default_session: selenium2
|
default_session: facebook_web_driver
|
||||||
javascript_session: selenium2
|
javascript_session: facebook_web_driver
|
||||||
selenium2:
|
facebook_web_driver:
|
||||||
browser: firefox
|
browser: chrome
|
||||||
|
wd_host: "http://127.0.0.1:9515" #chromedriver port
|
||||||
|
|
||||||
SilverStripe\BehatExtension\Extension:
|
SilverStripe\BehatExtension\Extension:
|
||||||
screenshot_path: %paths.base%/artifacts/screenshots
|
screenshot_path: %paths.base%/artifacts/screenshots
|
||||||
|
@ -52,10 +52,7 @@
|
|||||||
},
|
},
|
||||||
"require-dev": {
|
"require-dev": {
|
||||||
"phpunit/phpunit": "^5.7",
|
"phpunit/phpunit": "^5.7",
|
||||||
"silverstripe/versioned": "^1.0",
|
"silverstripe/versioned": "^1.0"
|
||||||
"silverstripe/behat-extension": "^3",
|
|
||||||
"silverstripe/serve": "^2",
|
|
||||||
"se/selenium-server-standalone": "2.41.0"
|
|
||||||
},
|
},
|
||||||
"provide": {
|
"provide": {
|
||||||
"psr/container-implementation": "1.0.0"
|
"psr/container-implementation": "1.0.0"
|
||||||
|
@ -18,8 +18,9 @@ Feature: Reauthenticate
|
|||||||
When I fill in "Password" with "Secret!123"
|
When I fill in "Password" with "Secret!123"
|
||||||
And I press the "Let me back in" button
|
And I press the "Let me back in" button
|
||||||
And I am not in an iframe
|
And I am not in an iframe
|
||||||
And I click "ADMIN" in the "#Root_Users" element
|
And I go to "/admin/security"
|
||||||
Then I should see "Save" in the "#Form_ItemEditForm_action_doSave" element
|
When I press the "Add Member" button
|
||||||
|
Then I should see "Create" in the "#Form_ItemEditForm_action_doSave" element
|
||||||
|
|
||||||
Scenario: Reauthenticate with wrong login
|
Scenario: Reauthenticate with wrong login
|
||||||
When I press the "Add Member" button
|
When I press the "Add Member" button
|
||||||
@ -31,5 +32,6 @@ Feature: Reauthenticate
|
|||||||
When I fill in "Password" with "Secret!123"
|
When I fill in "Password" with "Secret!123"
|
||||||
And I press the "Let me back in" button
|
And I press the "Let me back in" button
|
||||||
And I am not in an iframe
|
And I am not in an iframe
|
||||||
And I click "ADMIN" in the "#Root_Users" element
|
And I go to "/admin/security"
|
||||||
Then I should see "Save" in the "#Form_ItemEditForm_action_doSave" element
|
When I press the "Add Member" button
|
||||||
|
Then I should see "Create" in the "#Form_ItemEditForm_action_doSave" element
|
||||||
|
@ -6,6 +6,7 @@ use BadMethodCallException;
|
|||||||
use Behat\Behat\Context\Context;
|
use Behat\Behat\Context\Context;
|
||||||
use Behat\Mink\Exception\ElementHtmlException;
|
use Behat\Mink\Exception\ElementHtmlException;
|
||||||
use Behat\Gherkin\Node\TableNode;
|
use Behat\Gherkin\Node\TableNode;
|
||||||
|
use Behat\Mink\Session;
|
||||||
use SilverStripe\BehatExtension\Context\MainContextAwareTrait;
|
use SilverStripe\BehatExtension\Context\MainContextAwareTrait;
|
||||||
use SilverStripe\BehatExtension\Utility\StepHelper;
|
use SilverStripe\BehatExtension\Utility\StepHelper;
|
||||||
use Symfony\Component\DomCrawler\Crawler;
|
use Symfony\Component\DomCrawler\Crawler;
|
||||||
@ -24,6 +25,9 @@ class CmsFormsContext implements Context
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Get Mink session from MinkContext
|
* Get Mink session from MinkContext
|
||||||
|
*
|
||||||
|
* @param string $name
|
||||||
|
* @return Session
|
||||||
*/
|
*/
|
||||||
public function getSession($name = null)
|
public function getSession($name = null)
|
||||||
{
|
{
|
||||||
@ -210,6 +214,7 @@ JS;
|
|||||||
$page = $this->getSession()->getPage();
|
$page = $this->getSession()->getPage();
|
||||||
$els = $page->findAll('named', array('field', "'$text'"));
|
$els = $page->findAll('named', array('field', "'$text'"));
|
||||||
$matchedEl = null;
|
$matchedEl = null;
|
||||||
|
/** @var NodeElement $el */
|
||||||
foreach ($els as $el) {
|
foreach ($els as $el) {
|
||||||
if ($el->isVisible()) {
|
if ($el->isVisible()) {
|
||||||
$matchedEl = $el;
|
$matchedEl = $el;
|
||||||
@ -267,6 +272,7 @@ JS;
|
|||||||
public function iSelectValueInTreeDropdown($text, $selector)
|
public function iSelectValueInTreeDropdown($text, $selector)
|
||||||
{
|
{
|
||||||
$page = $this->getSession()->getPage();
|
$page = $this->getSession()->getPage();
|
||||||
|
/** @var NodeElement $parentElement */
|
||||||
$parentElement = null;
|
$parentElement = null;
|
||||||
$this->retryThrowable(function () use (&$parentElement, &$page, $selector) {
|
$this->retryThrowable(function () use (&$parentElement, &$page, $selector) {
|
||||||
$parentElement = $page->find('css', $selector);
|
$parentElement = $page->find('css', $selector);
|
||||||
|
@ -2,13 +2,13 @@
|
|||||||
|
|
||||||
namespace SilverStripe\Framework\Tests\Behaviour;
|
namespace SilverStripe\Framework\Tests\Behaviour;
|
||||||
|
|
||||||
use Behat\Behat\Hook\Call\AfterStep;
|
|
||||||
use Behat\Behat\Hook\Scope\AfterStepScope;
|
|
||||||
use Behat\Mink\Element\NodeElement;
|
|
||||||
use Behat\Mink\Session;
|
|
||||||
use Behat\Behat\Context\Context;
|
use Behat\Behat\Context\Context;
|
||||||
|
use Behat\Behat\Hook\Scope\AfterStepScope;
|
||||||
|
use Behat\Mink\Element\Element;
|
||||||
|
use Behat\Mink\Element\NodeElement;
|
||||||
|
use Behat\Mink\Selector\Xpath\Escaper;
|
||||||
|
use Behat\Mink\Session;
|
||||||
use SilverStripe\BehatExtension\Context\MainContextAwareTrait;
|
use SilverStripe\BehatExtension\Context\MainContextAwareTrait;
|
||||||
use SilverStripe\BehatExtension\Context\RetryableContextTrait;
|
|
||||||
use SilverStripe\BehatExtension\Utility\StepHelper;
|
use SilverStripe\BehatExtension\Utility\StepHelper;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -24,6 +24,7 @@ class CmsUiContext implements Context
|
|||||||
/**
|
/**
|
||||||
* Get Mink session from MinkContext
|
* Get Mink session from MinkContext
|
||||||
*
|
*
|
||||||
|
* @param string $name
|
||||||
* @return Session
|
* @return Session
|
||||||
*/
|
*/
|
||||||
public function getSession($name = null)
|
public function getSession($name = null)
|
||||||
@ -306,6 +307,7 @@ class CmsUiContext implements Context
|
|||||||
$page = $this->getSession()->getPage();
|
$page = $this->getSession()->getPage();
|
||||||
$toggle_elements = $page->findAll('css', '.toggle-expand');
|
$toggle_elements = $page->findAll('css', '.toggle-expand');
|
||||||
assertNotNull($toggle_elements, 'Panel toggle not found');
|
assertNotNull($toggle_elements, 'Panel toggle not found');
|
||||||
|
/** @var NodeElement $toggle */
|
||||||
foreach ($toggle_elements as $toggle) {
|
foreach ($toggle_elements as $toggle) {
|
||||||
if ($toggle->isVisible()) {
|
if ($toggle->isVisible()) {
|
||||||
$toggle->click();
|
$toggle->click();
|
||||||
@ -354,7 +356,6 @@ SCRIPT
|
|||||||
public function iExpandInTheTree($action, $nodeText)
|
public function iExpandInTheTree($action, $nodeText)
|
||||||
{
|
{
|
||||||
//Tries to find the first visiable matched Node in the page
|
//Tries to find the first visiable matched Node in the page
|
||||||
$page = $this->getSession()->getPage();
|
|
||||||
$treeEl = $this->getCmsTreeElement();
|
$treeEl = $this->getCmsTreeElement();
|
||||||
$treeNode = $treeEl->findLink($nodeText);
|
$treeNode = $treeEl->findLink($nodeText);
|
||||||
assertNotNull($treeNode, sprintf('%s link not found', $nodeText));
|
assertNotNull($treeNode, sprintf('%s link not found', $nodeText));
|
||||||
@ -391,6 +392,7 @@ SCRIPT
|
|||||||
assertNotNull($tabsets, 'CMS tabs not found');
|
assertNotNull($tabsets, 'CMS tabs not found');
|
||||||
|
|
||||||
$tab_element = null;
|
$tab_element = null;
|
||||||
|
/** @var NodeElement $tabset */
|
||||||
foreach ($tabsets as $tabset) {
|
foreach ($tabsets as $tabset) {
|
||||||
$tab_element = $tabset->find('named', array('link_or_button', "'$tab'"));
|
$tab_element = $tabset->find('named', array('link_or_button', "'$tab'"));
|
||||||
if ($tab_element) {
|
if ($tab_element) {
|
||||||
@ -419,6 +421,7 @@ SCRIPT
|
|||||||
assertNotNull($tabsets, 'CMS tabs not found');
|
assertNotNull($tabsets, 'CMS tabs not found');
|
||||||
|
|
||||||
$tab_element = null;
|
$tab_element = null;
|
||||||
|
/** @var NodeElement $tabset */
|
||||||
foreach ($tabsets as $tabset) {
|
foreach ($tabsets as $tabset) {
|
||||||
if ($tab_element) {
|
if ($tab_element) {
|
||||||
continue;
|
continue;
|
||||||
@ -443,14 +446,10 @@ SCRIPT
|
|||||||
*/
|
*/
|
||||||
public function thePreviewContains($content)
|
public function thePreviewContains($content)
|
||||||
{
|
{
|
||||||
$driver = $this->getSession()->getDriver();
|
|
||||||
// TODO Remove once we have native support in Mink and php-webdriver,
|
|
||||||
// see https://groups.google.com/forum/#!topic/behat/QNhOuGHKEWI
|
// see https://groups.google.com/forum/#!topic/behat/QNhOuGHKEWI
|
||||||
$origWindowName = $driver->getWebDriverSession()->window_handle();
|
$this->getSession()->switchToIFrame('cms-preview-iframe');
|
||||||
|
|
||||||
$driver->switchToIFrame('cms-preview-iframe');
|
|
||||||
$this->getMainContext()->assertPageContainsText($content);
|
$this->getMainContext()->assertPageContainsText($content);
|
||||||
$driver->switchToWindow($origWindowName);
|
$this->getSession()->switchToWindow();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -467,17 +466,13 @@ SCRIPT
|
|||||||
*/
|
*/
|
||||||
public function iWaitForThePreviewToLoad()
|
public function iWaitForThePreviewToLoad()
|
||||||
{
|
{
|
||||||
$driver = $this->getSession()->getDriver();
|
|
||||||
// TODO Remove once we have native support in Mink and php-webdriver,
|
|
||||||
// see https://groups.google.com/forum/#!topic/behat/QNhOuGHKEWI
|
// see https://groups.google.com/forum/#!topic/behat/QNhOuGHKEWI
|
||||||
$origWindowName = $driver->getWebDriverSession()->window_handle();
|
$this->getSession()->switchToIFrame('cms-preview-iframe');
|
||||||
|
|
||||||
$driver->switchToIFrame('cms-preview-iframe');
|
|
||||||
$this->getSession()->wait(
|
$this->getSession()->wait(
|
||||||
5000,
|
5000,
|
||||||
"window.jQuery && !window.jQuery('iframe[name=cms-preview-iframe]').hasClass('loading')"
|
"window.jQuery && !window.jQuery('iframe[name=cms-preview-iframe]').hasClass('loading')"
|
||||||
);
|
);
|
||||||
$driver->switchToWindow($origWindowName);
|
$this->getSession()->switchToWindow();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -504,14 +499,10 @@ SCRIPT
|
|||||||
*/
|
*/
|
||||||
public function thePreviewDoesNotContain($content)
|
public function thePreviewDoesNotContain($content)
|
||||||
{
|
{
|
||||||
$driver = $this->getSession()->getDriver();
|
|
||||||
// TODO Remove once we have native support in Mink and php-webdriver,
|
|
||||||
// see https://groups.google.com/forum/#!topic/behat/QNhOuGHKEWI
|
// see https://groups.google.com/forum/#!topic/behat/QNhOuGHKEWI
|
||||||
$origWindowName = $driver->getWebDriverSession()->window_handle();
|
$this->getSession()->switchToIFrame('cms-preview-iframe');
|
||||||
|
|
||||||
$driver->switchToIFrame('cms-preview-iframe');
|
|
||||||
$this->getMainContext()->assertPageNotContainsText($content);
|
$this->getMainContext()->assertPageNotContainsText($content);
|
||||||
$driver->switchToWindow($origWindowName);
|
$this->getSession()->switchToWindow();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -521,16 +512,12 @@ SCRIPT
|
|||||||
*/
|
*/
|
||||||
public function clickLinkInPreview($link)
|
public function clickLinkInPreview($link)
|
||||||
{
|
{
|
||||||
$driver = $this->getSession()->getDriver();
|
|
||||||
// TODO Remove once we have native support in Mink and php-webdriver,
|
// TODO Remove once we have native support in Mink and php-webdriver,
|
||||||
// see https://groups.google.com/forum/#!topic/behat/QNhOuGHKEWI
|
// see https://groups.google.com/forum/#!topic/behat/QNhOuGHKEWI
|
||||||
$origWindowName = $driver->getWebDriverSession()->window_handle();
|
$this->getSession()->switchToIFrame('cms-preview-iframe');
|
||||||
$driver->switchToIFrame('cms-preview-iframe');
|
|
||||||
|
|
||||||
$link = $this->fixStepArgument($link);
|
$link = $this->fixStepArgument($link);
|
||||||
$this->getSession()->getPage()->clickLink($link);
|
$this->getSession()->getPage()->clickLink($link);
|
||||||
|
$this->getSession()->switchToWindow();
|
||||||
$driver->switchToWindow($origWindowName);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -540,16 +527,11 @@ SCRIPT
|
|||||||
*/
|
*/
|
||||||
public function pressButtonInPreview($button)
|
public function pressButtonInPreview($button)
|
||||||
{
|
{
|
||||||
$driver = $this->getSession()->getDriver();
|
|
||||||
// TODO Remove once we have native support in Mink and php-webdriver,
|
|
||||||
// see https://groups.google.com/forum/#!topic/behat/QNhOuGHKEWI
|
// see https://groups.google.com/forum/#!topic/behat/QNhOuGHKEWI
|
||||||
$origWindowName = $driver->getWebDriverSession()->window_handle();
|
$this->getSession()->switchToIFrame('cms-preview-iframe');
|
||||||
$driver->switchToIFrame('cms-preview-iframe');
|
|
||||||
|
|
||||||
$button = $this->fixStepArgument($button);
|
$button = $this->fixStepArgument($button);
|
||||||
$this->getSession()->getPage()->pressButton($button);
|
$this->getSession()->getPage()->pressButton($button);
|
||||||
|
$this->getSession()->switchToWindow();
|
||||||
$driver->switchToWindow($origWindowName);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -563,9 +545,10 @@ SCRIPT
|
|||||||
$field = $this->fixStepArgument($field);
|
$field = $this->fixStepArgument($field);
|
||||||
$value = $this->fixStepArgument($value);
|
$value = $this->fixStepArgument($value);
|
||||||
|
|
||||||
|
$escaper = new Escaper();
|
||||||
$nativeField = $this->getSession()->getPage()->find(
|
$nativeField = $this->getSession()->getPage()->find(
|
||||||
'named',
|
'named',
|
||||||
array('select', $this->getSession()->getSelectorsHandler()->xpathLiteral($field))
|
array('select', $escaper->escapeLiteral($field))
|
||||||
);
|
);
|
||||||
if ($nativeField && $nativeField->isVisible()) {
|
if ($nativeField && $nativeField->isVisible()) {
|
||||||
$nativeField->selectOption($value);
|
$nativeField->selectOption($value);
|
||||||
@ -614,6 +597,7 @@ SCRIPT
|
|||||||
));
|
));
|
||||||
|
|
||||||
// Traverse up to field holder
|
// Traverse up to field holder
|
||||||
|
/** @var NodeElement $container */
|
||||||
$container = null;
|
$container = null;
|
||||||
foreach ($formFields as $formField) {
|
foreach ($formFields as $formField) {
|
||||||
$container = $this->findParentByClass($formField, 'field');
|
$container = $this->findParentByClass($formField, 'field');
|
||||||
|
Loading…
Reference in New Issue
Block a user