Skip to content

Commit

Permalink
Also test on Selenium 3
Browse files Browse the repository at this point in the history
  • Loading branch information
aik099 committed Feb 24, 2024
1 parent 4ca4083 commit 7793ce2
Show file tree
Hide file tree
Showing 2 changed files with 59 additions and 2 deletions.
8 changes: 6 additions & 2 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,15 @@ jobs:
- run: vendor/bin/phpstan analyze

tests:
name: Tests
name: "Tests (PHP ${{ matrix.php }}, Selenium ${{ matrix.selenium_version }})"
runs-on: ubuntu-20.04
strategy:
matrix:
selenium_version: [ '2.53.1' ]
php: [ '7.2', '7.3', '7.4', '8.0', '8.1', '8.2', '8.3' ]
include:
- selenium_version: '3.141.59'
php: '8.3'
fail-fast: false

steps:
Expand Down Expand Up @@ -71,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:2.53.1 &> ./logs/selenium.log &
docker run --net host --name selenium --volume /dev/shm:/dev/shm --shm-size 2g selenium/standalone-firefox:${{ matrix.selenium_version }} &> ./logs/selenium.log &
- name: Wait for browser & PHP to start
run: |
Expand Down
53 changes: 53 additions & 0 deletions tests/Custom/WindowNameTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,57 @@ 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);
}
}

0 comments on commit 7793ce2

Please sign in to comment.