Merge #20172 - Fix Selenium tests

Pull-request: #20172
Signed-off-by: William Desportes <williamdes@wdes.fr>
This commit is contained in:
William Desportes 2026-02-24 11:02:57 +01:00
commit 18913e8efe
No known key found for this signature in database
GPG Key ID: 70684F4717D49A31
24 changed files with 65 additions and 73 deletions

View File

@ -1,4 +1,4 @@
name: Run Selenium tests
name: "End-to-End tests"
on:
push:
@ -11,14 +11,34 @@ on:
permissions:
contents: read
env:
php-version: "7.2"
node-version: "12"
jobs:
test-selenium:
name: Selenium tests on PHP ${{ matrix.php-version }} and ${{ matrix.os }}
generate-matrix:
name: Generate the matrix of Selenium tests
if: "!contains(github.event.head_commit.message, '[ci selenium skip]')"
runs-on: ${{ matrix.os }}
runs-on: ubuntu-latest
outputs:
tests: ${{ steps.tests-list.outputs.tests }}
steps:
- name: Checkout code
uses: actions/checkout@v6
- id: tests-list
name: Send test names to outputs
run: |
set -euo pipefail
TEST_NAMES="[$(find $PWD/test/selenium/ -type f -name '*Test.php' -print |sed -E "s,$PWD/test/selenium/(.*)Test.php,{\"test-name\": \"\1\"}," | paste -sd ",")]"
echo "tests=$(printf "$TEST_NAMES")" >> $GITHUB_OUTPUT
selenium:
name: "Selenium"
if: "!contains(github.event.head_commit.message, '[ci selenium skip]')"
needs: generate-matrix
runs-on: "ubuntu-latest"
services:
database-server:
image: ${{ matrix.db-server }}
image: "mysql:5.7"
env:
MYSQL_ROOT_PASSWORD: testbench
ports:
@ -53,10 +73,9 @@ jobs:
--cap-add=NET_RAW
--restart on-failure
strategy:
fail-fast: false
matrix:
php-version: ["7.2"]
os: [ubuntu-latest]
db-server: ["mysql:5.7"]
include: ${{ fromJSON(needs.generate-matrix.outputs.tests) }}
steps:
- name: Checkout code
uses: actions/checkout@v6
@ -67,21 +86,20 @@ jobs:
- name: Generate mo files
run: ./scripts/generate-mo --quiet
- name: Set up PHP ${{ matrix.php-version }}
- name: Set up PHP ${{ env.php-version }}
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php-version }}
extensions: mbstring, iconv, mysqli, zip, gd, bz2
coverage: "none"
php-version: ${{ env.php-version }}
extensions: :opcache, mbstring, iconv, mysqli, zip, gd, bz2
- name: Install Composer dependencies
uses: ramsey/composer-install@v3
with:
dependency-versions: highest
- name: Set up Node
uses: actions/setup-node@v6
with:
node-version: 12
node-version: '${{ env.node-version }}'
cache: 'yarn'
- name: Install modules
@ -93,9 +111,11 @@ jobs:
- name: Start server
env:
CI_MODE: selenium
FPM_PATH: php-fpm7.2
FPM_PATH: php-fpm${{ env.php-version }}
SKIP_STANDALONE: 1
run: |
sudo chown -R runner:docker /var/lib/nginx/
sudo chown -R runner:docker /var/log/nginx/
./test/start-local-server
echo "SELENIUM_TEMPDIR=$(cat /tmp/last_temp_dir_phpMyAdminTests)" >> $GITHUB_OUTPUT
id: start-local-server
@ -111,7 +131,7 @@ jobs:
TESTSUITE_DATABASE_PREFIX: "selenium"
TESTSUITE_SELENIUM_HOST: "127.0.0.1"
TESTSUITE_SELENIUM_PORT: "4444"
run: ./vendor/bin/phpunit --testsuite selenium --verbose --debug --no-coverage --stop-on-skipped
run: ./vendor/bin/phpunit --testsuite selenium --no-logging --no-coverage --stop-on-skipped --testdox test/selenium/${{ matrix.test-name }}Test.php
- name: Output logs and stop server
env:
@ -127,6 +147,6 @@ jobs:
uses: actions/upload-artifact@v6
if: ${{ failure() }}
with:
name: selenium-screenshots
name: selenium-screenshots-${{ strategy.job-index }}
path: ${{ github.workspace }}/build/selenium/**/*
retention-days: 3

View File

@ -19,7 +19,7 @@ class ChangePasswordTest extends TestBase
*
* @var bool
*/
protected static $createDatabase = false;
protected $createDatabase = false;
/**
* Array of AssertionFailedError->toString
@ -35,8 +35,6 @@ class ChangePasswordTest extends TestBase
*/
public function testChangePassword(): void
{
$this->login();
$e = $this->waitForElement('id', 'change_password_anchor');
$e->click();

View File

@ -17,7 +17,6 @@ class CreateDropDatabaseTest extends TestBase
parent::setUp();
/* TODO: For now this tests needs superuser for deleting database */
$this->skipIfNotSuperUser();
$this->login();
}
/**

View File

@ -14,7 +14,7 @@ class CreateRemoveUserTest extends TestBase
*
* @var bool
*/
protected static $createDatabase = false;
protected $createDatabase = false;
/**
* Username for the user
@ -39,7 +39,6 @@ class CreateRemoveUserTest extends TestBase
$this->skipIfNotSuperUser();
$this->txtUsername = 'pma_user';
$this->txtPassword = 'abc_123';
$this->login();
}
/**

View File

@ -31,7 +31,7 @@ class EventsTest extends TestBase
. 'INSERT INTO `test_table` (val) VALUES (2);'
. 'SET GLOBAL event_scheduler="ON";'
);
$this->login();
$this->navigateDatabase($this->databaseName);
// Let the Database page load

View File

@ -11,15 +11,6 @@ use PhpMyAdmin\Tests\Selenium\TestBase;
*/
class OperationsTest extends TestBase
{
/**
* setUp function
*/
protected function setUp(): void
{
parent::setUp();
$this->login();
}
private function getToDBOperations(): void
{
$this->gotoHomepage();

View File

@ -49,8 +49,6 @@ class ProceduresTest extends TestBase
. ');'
);
$this->login();
$this->navigateDatabase($this->databaseName);
$this->expandMore();
}

View File

@ -29,8 +29,6 @@ class QueryByExampleTest extends TestBase
. ');'
. 'INSERT INTO `test_table` (val) VALUES (2), (6), (5), (3), (4), (4), (5);'
);
$this->login();
}
/**

View File

@ -32,7 +32,6 @@ class StructureTest extends TestBase
. 'INSERT INTO `test_table` (val) VALUES (2);'
);
$this->login();
$this->navigateDatabase($this->databaseName);
// Let the Database page load

View File

@ -32,8 +32,6 @@ class TriggersTest extends TestBase
. 'INSERT INTO `test_table2` (val) VALUES (2);'
);
$this->login();
$this->navigateDatabase($this->databaseName);
}

View File

@ -24,8 +24,6 @@ class ExportTest extends TestBase
. ');'
. 'INSERT INTO `test_table` (val) VALUES (2);'
);
$this->login();
}
/**

View File

@ -9,15 +9,6 @@ namespace PhpMyAdmin\Tests\Selenium;
*/
class ImportTest extends TestBase
{
/**
* setUp function
*/
protected function setUp(): void
{
parent::setUp();
$this->login();
}
/**
* Test for server level import
*

View File

@ -14,7 +14,14 @@ class LoginTest extends TestBase
*
* @var bool
*/
protected static $createDatabase = false;
protected $createDatabase = false;
/**
* Login before starting this test
*
* @var bool
*/
protected $login = false;
protected function setUp(): void
{

View File

@ -25,7 +25,6 @@ class NormalizationTest extends TestBase
. ');'
);
$this->login();
$this->navigateTable('test_table');
$this->waitForElement('xpath', "(//a[contains(., 'Structure')])")->click();

View File

@ -16,7 +16,7 @@ class ServerSettingsTest extends TestBase
*
* @var bool
*/
protected static $createDatabase = false;
protected $createDatabase = false;
/**
* setUp function

View File

@ -25,7 +25,6 @@ class SqlQueryTest extends TestBase
. ');'
. 'INSERT INTO `test_table` (val) VALUES (2), (3), (4), (5);'
);
$this->login();
}
/**

View File

@ -32,7 +32,6 @@ class BrowseTest extends TestBase
. " (3, 'Abcd', '2012-01-20 02:00:02');"
);
$this->login();
$this->navigateTable('test_table');
$this->waitAjax();

View File

@ -16,8 +16,6 @@ class CreateTest extends TestBase
protected function setUp(): void
{
parent::setUp();
$this->login();
$this->navigateDatabase($this->databaseName);
}

View File

@ -28,7 +28,6 @@ class InsertTest extends TestBase
. ');'
);
$this->login();
$this->navigateTable('test_table');
}

View File

@ -32,7 +32,6 @@ class OperationsTest extends TestBase
. 'INSERT INTO test_table (val, val2) VALUES (33, 44);'
);
$this->login();
$this->navigateTable('test_table');
$this->waitAjax();

View File

@ -27,7 +27,6 @@ class StructureTest extends TestBase
. ');'
);
$this->login();
$this->navigateTable('test_table');
$this->waitForElement('xpath', "(//a[contains(., 'Structure')])")->click();

View File

@ -95,7 +95,14 @@ abstract class TestBase extends TestCase
*
* @var bool
*/
protected static $createDatabase = true;
protected $createDatabase = true;
/**
* Login before starting this test
*
* @var bool
*/
protected $login = true;
/**
* Did the test create the phpMyAdmin storage database ?
@ -148,7 +155,11 @@ abstract class TestBase extends TestCase
$this->navigateTo('');
$this->webDriver->manage()->window()->maximize();
if (! static::$createDatabase) {
if ($this->login) {
$this->login();
}
if (! $this->createDatabase) {
// Stop here, we where not asked to create a database
return;
}
@ -165,7 +176,7 @@ abstract class TestBase extends TestCase
$this->dbQuery(
'CREATE DATABASE IF NOT EXISTS `' . $this->databaseName . '`; USE `' . $this->databaseName . '`;'
);
static::$createDatabase = true;
$this->createDatabase = true;
}
public function getDbPrefix(): string
@ -1097,7 +1108,7 @@ JS;
*/
protected function tearDown(): void
{
if (static::$createDatabase) {
if ($this->createDatabase) {
$this->dbQuery('DROP DATABASE IF EXISTS `' . $this->databaseName . '`;');
}

View File

@ -30,7 +30,6 @@ class TrackingTest extends TestBase
. 'INSERT INTO `test_table` (val) VALUES (2), (3);'
);
$this->login();
$this->skipIfNotPMADB();
$this->navigateDatabase($this->databaseName);

View File

@ -14,13 +14,7 @@ class XssTest extends TestBase
*
* @var bool
*/
protected static $createDatabase = false;
protected function setUp(): void
{
parent::setUp();
$this->login();
}
protected $createDatabase = false;
/**
* Tests the SQL query tab with a null query