Skip to content

Commit

Permalink
Fixing failing file upload test (experiment 4)
Browse files Browse the repository at this point in the history
  • Loading branch information
aik099 committed Feb 25, 2024
1 parent 7793ce2 commit 3158b70
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 55 deletions.
6 changes: 4 additions & 2 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -75,14 +75,16 @@ 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: |
while ! nc -z localhost 4444 </dev/null; do echo Waiting for remote driver to start...; sleep 1; done
while ! nc -z localhost 8002 </dev/null; do echo Waiting for PHP server to start...; sleep 1; done
- name: Run tests
env:
DRIVER_MACHINE_BASE_PATH: /fixtures/
run: |
vendor/bin/phpunit -v --coverage-clover=coverage.xml
Expand All @@ -95,6 +97,6 @@ jobs:
if: ${{ failure() }}
uses: actions/upload-artifact@v2
with:
name: logs_php-${{ matrix.php }}
name: logs_php-${{ matrix.php }}_selenium-${{ matrix.selenium_version }}_firefox
path: |
logs
53 changes: 0 additions & 53 deletions tests/Custom/WindowNameTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,57 +19,4 @@ public function testWindowNames()
$this->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);
}
}
10 changes: 10 additions & 0 deletions tests/Selenium2Config.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
Expand Down

0 comments on commit 3158b70

Please sign in to comment.