From 3158b703fe52facfbae83b8229a2419177066f23 Mon Sep 17 00:00:00 2001 From: Alex Date: Sun, 25 Feb 2024 14:46:39 +0200 Subject: [PATCH] Fixing failing file upload test (experiment 4) --- .github/workflows/tests.yml | 6 ++-- tests/Custom/WindowNameTest.php | 53 --------------------------------- tests/Selenium2Config.php | 10 +++++++ 3 files changed, 14 insertions(+), 55 deletions(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 0a2ff2e8..7d0bb6d3 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -75,7 +75,7 @@ jobs: - name: Start Selenium run: | - docker run --net host --name selenium --volume /dev/shm:/dev/shm --shm-size 2g selenium/standalone-firefox:${{ matrix.selenium_version }} &> ./logs/selenium.log & + docker run --net host --name selenium --volume /dev/shm:/dev/shm --volume ./vendor/mink/driver-testsuite/web-fixtures:/fixtures --shm-size 2g selenium/standalone-firefox:${{ matrix.selenium_version }} &> ./logs/selenium.log & - name: Wait for browser & PHP to start run: | @@ -83,6 +83,8 @@ jobs: while ! nc -z localhost 8002 assertIsString($windowName); $this->assertContains($windowName, $windowNames, 'The current window name is one of the available window names.'); } - - /** - * @dataProvider setValueChangeEventCopyDataProvider - * @group change-event-detector - */ - public function testSetValueChangeEventCopy(string $elementId, string $valueForEmpty, string $valueForFilled = ''): void - { - if ($elementId === 'the-file') { - $valueForEmpty = $this->mapRemoteFilePath($valueForEmpty); - $valueForFilled = $this->mapRemoteFilePath($valueForFilled); - } - - $this->getSession()->visit($this->pathTo('/element_change_detector.html')); - $page = $this->getSession()->getPage(); - - $input = $this->findById($elementId); - $this->assertNull($page->findById($elementId . '-result')); - - // Verify setting value, when control is initially empty. - $input->setValue($valueForEmpty); - $this->assertElementChangeCount($elementId, 'initial value setting triggers change event'); - - if ($valueForFilled) { - // Verify setting value, when control already has a value. - $this->findById('results')->click(); - $input->setValue($valueForFilled); - $this->assertElementChangeCount($elementId, 'value change triggers change event'); - } - } - - public static function setValueChangeEventCopyDataProvider(): iterable - { - $file1 = __DIR__ . '/../../vendor/mink/driver-testsuite/web-fixtures/file1.txt'; - $file2 = __DIR__ . '/../../vendor/mink/driver-testsuite/web-fixtures/file2.txt'; - - return [ - 'input default' => ['the-input-default', 'from empty', 'from existing'], - 'input text' => ['the-input-text', 'from empty', 'from existing'], - 'input email' => ['the-email', 'from empty', 'from existing'], - 'textarea' => ['the-textarea', 'from empty', 'from existing'], - 'file' => ['the-file', $file1, $file2], - 'select' => ['the-select', '30'], - 'radio' => ['the-radio-m', 'm'], - ]; - } - - private function assertElementChangeCount(string $elementId, string $message = ''): void - { - $counterElement = $this->getSession()->getPage()->findById($elementId . '-result'); - $actualCount = null === $counterElement ? 0 : $counterElement->getText(); - - $this->assertEquals('1', $actualCount, $message); - } } diff --git a/tests/Selenium2Config.php b/tests/Selenium2Config.php index faa6cf96..7affa8dc 100644 --- a/tests/Selenium2Config.php +++ b/tests/Selenium2Config.php @@ -23,6 +23,16 @@ public function createDriver(): DriverInterface return new Selenium2Driver($browser, null, $seleniumHost); } + public function mapRemoteFilePath($file): string + { + if (!isset($_SERVER['TEST_MACHINE_BASE_PATH'])) { + $webFixturesPath = dirname(__DIR__) . '/vendor/mink/driver-testsuite/web-fixtures'; + $_SERVER['TEST_MACHINE_BASE_PATH'] = realpath($webFixturesPath) . DIRECTORY_SEPARATOR; + } + + return parent::mapRemoteFilePath($file); + } + public function skipMessage($testCase, $test): ?string { if (