Skip to content
Snippets Groups Projects
Commit 2ed987dd authored by Adam G-H's avatar Adam G-H
Browse files

Only use Chromedriver/WebDriver for functional JavaScript tests.

parent 98fddb13
Branches
Tags
No related merge requests found
...@@ -28,11 +28,12 @@ before_install: ...@@ -28,11 +28,12 @@ before_install:
install: install:
# Add Composer's local bin directory to the PATH so that we will be running # Add Composer's local bin directory to the PATH so that we will be running
# our installed versions of Drush, PHPCS, Behat, PhantomJS, etc. # our installed versions of Drush, Behat, etc.
- export PATH="$HOME/.composer/vendor/bin:$TRAVIS_BUILD_DIR/vendor/bin:$PATH" - export PATH="$HOME/.composer/vendor/bin:$TRAVIS_BUILD_DIR/vendor/bin:$PATH"
# composer install should fail on bad patches. # composer install should fail on bad patches.
- export COMPOSER_EXIT_ON_PATCH_FAILURE=1 - export COMPOSER_EXIT_ON_PATCH_FAILURE=1
# Require Prestissimo to speed up Composer.
- composer global require hirak/prestissimo
# Install the PECL YAML extension for strict parsing. yes is used to # Install the PECL YAML extension for strict parsing. yes is used to
# acknowledge all prompts. # acknowledge all prompts.
...@@ -54,17 +55,17 @@ install: ...@@ -54,17 +55,17 @@ install:
- cp -f phpunit.xml docroot/core - cp -f phpunit.xml docroot/core
before_script: before_script:
- drush config:set system.date timezone.default $TZ --yes # Remove any time zone stored in config by the update path.
- drush config:set system.date timezone.default '' --yes
- drush runserver --default-server=builtin 8080 &>/dev/null & - drush runserver --default-server=builtin 8080 &>/dev/null &
- google-chrome-stable --headless --disable-gpu --no-sandbox --remote-debugging-port=9222 http://localhost &
- drush pm-enable lightning_roles toolbar --yes - drush pm-enable lightning_roles toolbar --yes
- chromedriver --port=4444 & - chromedriver --port=4444 &
script: script:
- composer validate composer.json --no-check-all --ansi --no-interaction - composer validate composer.json --no-check-all --ansi --no-interaction
- phpunit --configuration ./docroot/core --group lightning_workflow - phpunit --debug --configuration ./docroot/core --group lightning_workflow
- phpunit --configuration ./docroot/core tests/src/ExistingSite - phpunit --debug --configuration ./docroot/core tests/src/ExistingSite
- behat --suite lightning_workflow - behat
after_failure: after_failure:
- cd docroot - cd docroot
......
imports:
- 'docroot/modules/contrib/acquia/lightning_core/behat.yml'
default: default:
suites: suites:
lightning_workflow: lightning_workflow:
...@@ -12,3 +9,34 @@ default: ...@@ -12,3 +9,34 @@ default:
paths: paths:
- 'modules/lightning_scheduler/tests/features' - 'modules/lightning_scheduler/tests/features'
- 'tests/features' - 'tests/features'
extensions:
Behat\MinkExtension:
base_url: 'http://127.0.0.1:8080'
goutte: ~
selenium2:
wd_host: 'http://127.0.0.1:4444'
capabilities:
chrome:
switches:
- headless
- disable-gpu
- no-sandbox
- disable-dev-shm-usage
- disable-extensions
browser: chrome
browser_name: chrome
Drupal\DrupalExtension:
api_driver: drupal
blackbox: ~
drupal:
drupal_root: 'docroot'
drush:
alias: self
selectors:
error_message_selector: '.messages [role="alert"]'
warning_message_selector: .messages--warning
login_form_selector: '#user-login-form'
subcontexts:
# These paths are relative to the Drupal root.
paths:
- 'modules/contrib'
...@@ -10,11 +10,6 @@ react: ...@@ -10,11 +10,6 @@ react:
attributes: attributes:
integrity: 'sha384-9HNXemlU8cB7vTVvdlZbsut+fnt78jK2amX1CCxkLlamx+yD4gde8D6DJe+QkHm3' integrity: 'sha384-9HNXemlU8cB7vTVvdlZbsut+fnt78jK2amX1CCxkLlamx+yD4gde8D6DJe+QkHm3'
crossorigin: anonymous crossorigin: anonymous
'https://unpkg.com/react-dom@16.3.2/umd/react-dom-test-utils.production.min.js':
external: true
attributes:
integrity: 'sha384-7jjA9Du+a2tQZfn0Rzzz4xsYIwnft+l09jw6BUpA21gsQNj+0x2yLq77a7mvqwWl'
crossorigin: anonymous
widget: widget:
js: js:
......
...@@ -15,7 +15,6 @@ final class SchedulerContext extends DrupalSubContextBase { ...@@ -15,7 +15,6 @@ final class SchedulerContext extends DrupalSubContextBase {
*/ */
public function setUp() { public function setUp() {
ini_set('date.timezone', drupal_get_user_timezone()); ini_set('date.timezone', drupal_get_user_timezone());
\Drupal::state()->set('lightning_scheduler.is_testing', TRUE);
} }
/** /**
...@@ -41,35 +40,9 @@ final class SchedulerContext extends DrupalSubContextBase { ...@@ -41,35 +40,9 @@ final class SchedulerContext extends DrupalSubContextBase {
} }
$assert->fieldExists('Scheduled moderation state')->selectOption($state); $assert->fieldExists('Scheduled moderation state')->selectOption($state);
$this->setValue('Scheduled transition date', date('Y-m-d', strtotime($date))); // These date and time formats will only work Chrome via WebDriver.
$this->setValue('Scheduled transition time', date('H:i:s', strtotime($time))); $assert->fieldExists('Scheduled transition date')->setValue(date('m-d-Y', strtotime($date)));
} $assert->fieldExists('Scheduled transition time')->setValue(date('g:i:sA', strtotime($time)));
/**
* Sets the value of a field and tries to trigger a React event on it.
*
* @param string $field
* The field locator.
* @param mixed $value
* The value to set.
* @param string $event
* (optional) The event to trigger. Defaults to 'change'.
*/
private function setValue($field, $value, $event = 'change') {
$field = $this->assertSession()->fieldExists($field);
$field->setValue($value);
$field = $field->getXpath();
// If React's testing utilities are present, simulate the event so that all
// values will be updated successfully.
$js = <<<END
if (ReactTestUtils) {
let element = document.evaluate('$field', document, null).iterateNext();
ReactTestUtils.Simulate.$event(element);
}
END;
$this->getSession()->executeScript($js);
} }
/** /**
......
...@@ -57,7 +57,9 @@ class TransitionTest extends WebDriverTestBase { ...@@ -57,7 +57,9 @@ class TransitionTest extends WebDriverTestBase {
// to catch time zone-related edge cases and bugs. However, the scheduler UI // to catch time zone-related edge cases and bugs. However, the scheduler UI
// is very sensitive to time zones, so it's best to set it, for the purposes // is very sensitive to time zones, so it's best to set it, for the purposes
// of this test, to the time zone configured in php.ini. // of this test, to the time zone configured in php.ini.
date_default_timezone_set(ini_get('date.timezone')); $this->config('system.date')
->set('timezone.default', ini_get('date.timezone'))
->save();
$this->today = date('mdY'); $this->today = date('mdY');
} }
......
...@@ -32,7 +32,9 @@ class UiTest extends WebDriverTestBase { ...@@ -32,7 +32,9 @@ class UiTest extends WebDriverTestBase {
// to catch time zone-related edge cases and bugs. However, the scheduler UI // to catch time zone-related edge cases and bugs. However, the scheduler UI
// is very sensitive to time zones, so it's best to set it, for the purposes // is very sensitive to time zones, so it's best to set it, for the purposes
// of this test, to the time zone configured in php.ini. // of this test, to the time zone configured in php.ini.
date_default_timezone_set(ini_get('date.timezone')); $this->config('system.date')
->set('timezone.default', ini_get('date.timezone'))
->save();
} }
public function testUiNotPresentWithoutModeration() { public function testUiNotPresentWithoutModeration() {
...@@ -62,7 +64,7 @@ class UiTest extends WebDriverTestBase { ...@@ -62,7 +64,7 @@ class UiTest extends WebDriverTestBase {
$this->assertSession()->elementExists('named', ['link', 'Schedule a status change'])->click(); $this->assertSession()->elementExists('named', ['link', 'Schedule a status change'])->click();
$this->assertSession()->fieldExists('Scheduled moderation state')->selectOption('Published'); $this->assertSession()->fieldExists('Scheduled moderation state')->selectOption('Published');
$this->assertSession()->fieldExists('Scheduled transition date')->setValue('5-4-2038'); $this->assertSession()->fieldExists('Scheduled transition date')->setValue('5-4-2038');
$this->assertSession()->fieldExists('Scheduled transition time')->setValue('6:00PM'); $this->assertSession()->fieldExists('Scheduled transition time')->setValue('6:00:00PM');
$this->assertSession()->buttonExists('Save transition')->press(); $this->assertSession()->buttonExists('Save transition')->press();
$this->assertSession()->pageTextContains("Change to Published on May 4, 2038 at 6:00 PM"); $this->assertSession()->pageTextContains("Change to Published on May 4, 2038 at 6:00 PM");
......
...@@ -2,6 +2,7 @@ ...@@ -2,6 +2,7 @@
namespace Acquia\LightningExtension\Context; namespace Acquia\LightningExtension\Context;
use Behat\Mink\Exception\UnsupportedDriverActionException;
use Drupal\Component\Utility\Random; use Drupal\Component\Utility\Random;
use Drupal\DrupalExtension\Context\DrupalSubContextBase; use Drupal\DrupalExtension\Context\DrupalSubContextBase;
use Drupal\workflows\StateInterface; use Drupal\workflows\StateInterface;
...@@ -110,7 +111,12 @@ final class ModerationContext extends DrupalSubContextBase { ...@@ -110,7 +111,12 @@ final class ModerationContext extends DrupalSubContextBase {
$this->visitPath($this->node->toUrl()->toString()); $this->visitPath($this->node->toUrl()->toString());
$assert = $this->assertSession(); $assert = $this->assertSession();
$assert->statusCodeEquals(200); try {
$assert->statusCodeEquals(200);
}
catch (UnsupportedDriverActionException $e) {
// This isn't an important assertion, so just swallow the exception.
}
$assert->pageTextContains($this->node->getTitle()); $assert->pageTextContains($this->node->getTitle());
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment