From 83f00296fd60d8a87c255f74b976af9befc2bc9e Mon Sep 17 00:00:00 2001 From: Christian Sciberras Date: Tue, 13 Jun 2023 21:02:52 +0200 Subject: [PATCH] More test skipping fixes --- .github/workflows/ci.yml | 3 ++- tests/WebdriverClassicConfig.php | 45 +++++++++++++++++++++----------- 2 files changed, 32 insertions(+), 16 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 329ad56..ae5b39f 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -72,9 +72,10 @@ jobs: - name: Run tests env: - WEB_FIXTURES_BROWSER: ${{ matrix.browser }} + SELENIUM_VERSION: ${{ matrix.selenium }} DRIVER_URL: http://172.18.0.2:4444/wd/hub WEB_FIXTURES_HOST: http://host.docker.internal:8002 + WEB_FIXTURES_BROWSER: ${{ matrix.browser }} DRIVER_MACHINE_BASE_PATH: /fixtures/ run: | vendor/bin/phpunit -v --coverage-clover=coverage.xml --colors=always --testdox diff --git a/tests/WebdriverClassicConfig.php b/tests/WebdriverClassicConfig.php index 5493372..8d3b0fa 100644 --- a/tests/WebdriverClassicConfig.php +++ b/tests/WebdriverClassicConfig.php @@ -3,9 +3,12 @@ namespace Mink\WebdriverClassDriver\Tests; use Behat\Mink\Driver\DriverInterface; +use Behat\Mink\Exception\DriverException; use Behat\Mink\Tests\Driver\AbstractConfig; +use Behat\Mink\Tests\Driver\Basic\BasicAuthTest; use Behat\Mink\Tests\Driver\Basic\HeaderTest; use Behat\Mink\Tests\Driver\Basic\StatusCodeTest; +use Behat\Mink\Tests\Driver\Js\EventsTest; use Behat\Mink\Tests\Driver\Js\WindowTest; use Mink\WebdriverClassDriver\WebdriverClassicDriver; @@ -18,6 +21,7 @@ public static function getInstance(): self /** * {@inheritdoc} + * @throws DriverException */ public function createDriver(): DriverInterface { @@ -40,25 +44,25 @@ public function mapRemoteFilePath($file): string public function skipMessage($testCase, $test): ?string { - if ( - $testCase === WindowTest::class - && $test === 'testWindowMaximize' - && getenv('GITHUB_ACTIONS') === 'true' - ) { - return 'Maximizing the window does not work when running the browser in Xvfb.'; - } + switch (true) { + case $testCase === WindowTest::class && $test === 'testWindowMaximize' && $this->isXvfb(): + return 'Maximizing the window does not work when running the browser in Xvfb.'; - if ($testCase === HeaderTest::class) { - return 'Headers are not supported.'; - } + case $testCase === BasicAuthTest::class: + return 'Basic auth is not supported.'; - if ($testCase === StatusCodeTest::class) { - return 'Checking status code is not supported.'; - } + case $testCase === HeaderTest::class: + return 'Headers are not supported.'; - // TODO skip event tests for old chrome + case $testCase === StatusCodeTest::class: + return 'Checking status code is not supported.'; - return parent::skipMessage($testCase, $test); + case $testCase === EventsTest::class && $test === 'testKeyboardEvents' && $this->isOldChrome(): + return 'Old Chrome does not allow triggering events.'; + + default: + return parent::skipMessage($testCase, $test); + } } /** @@ -68,4 +72,15 @@ protected function supportsCss(): bool { return true; } + + private function isXvfb(): bool + { + return getenv('GITHUB_ACTIONS') === 'true'; + } + + private function isOldChrome(): bool + { + return getenv('WEB_FIXTURES_BROWSER') === 'chrome' + && version_compare(getenv('SELENIUM_VERSION'), '3', '<'); + } }