Skip to content

Commit e4a893a

Browse files
committed
Added first Playwright test.
1 parent 41afe77 commit e4a893a

10 files changed

Lines changed: 242 additions & 28 deletions

File tree

.github/workflows/playwright.yml

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
name: Playwright Tests
2+
on:
3+
push:
4+
branches: [ main ]
5+
pull_request:
6+
branches: [ main ]
7+
jobs:
8+
test:
9+
timeout-minutes: 60
10+
runs-on: ubuntu-latest
11+
steps:
12+
- uses: actions/checkout@v4
13+
- uses: actions/setup-node@v4
14+
with:
15+
node-version: lts/*
16+
- name: Install dependencies
17+
run: npm ci
18+
- name: Install Playwright Browsers
19+
run: npx playwright install --with-deps
20+
- name: Run Playwright tests
21+
run: npx playwright test
22+
- uses: actions/upload-artifact@v4
23+
if: ${{ !cancelled() }}
24+
with:
25+
name: playwright-report
26+
path: playwright-report/
27+
retention-days: 30

.gitignore

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,11 @@ vendor/
88
.env
99

1010
sbom.xml
11-
*-sbom.xml
11+
*-sbom.xml
12+
13+
# Playwright
14+
/test-results/
15+
/playwright-report/
16+
/blob-report/
17+
/playwright/.cache/
18+
/playwright/.auth/

all_db_export.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
<?php
22

3+
declare(strict_types=1);
4+
35
use PhpPgAdmin\Website\AllDbExport;
46

57
require_once __DIR__ . DIRECTORY_SEPARATOR . 'autoload.php';

composer.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,12 +63,12 @@
6363
"@dev:lint:phpcs"
6464
],
6565
"dev:lint:php": "parallel-lint --exclude vendor .",
66-
"dev:lint:phpcs": "phpcs -d memory_limit=256M src/ autoload.php all_db.php alter_db.php alter_role.php browser.php create_db.php create_role.php drop_db.php drop_role.php history.php history_clear.php history_delete.php history_download.php index.php intro.php login.php logout.php roles.php server-logout.php servers.php servers-tree.php sqledit.php",
66+
"dev:lint:phpcs": "phpcs -d memory_limit=256M src/ autoload.php all_db.php all_db_export.php alter_db.php alter_role.php browser.php create_db.php create_role.php drop_db.php drop_role.php history.php history_clear.php history_delete.php history_download.php index.php intro.php login.php logout.php roles.php server-logout.php servers.php servers-tree.php sqledit.php",
6767
"dev:test": [
6868
"@dev:test:acceptance"
6969
],
7070
"dev:test:unit": "php -d register_argc_argv=On vendor/bin/codecept run Unit",
71-
"dev:test:acceptance": "codecept run Acceptance",
71+
"dev:test:acceptance": "php -d register_argc_argv=On vendor/bin/codecept run Acceptance",
7272
"dev:test:coverage:ci": "codecept run Unit,Acceptance --coverage --coverage-xml",
7373
"dev:test:coverage:html": "codecept run Unit,Acceptance --coverage --coverage-html",
7474
"build-locales": [

composer.lock

Lines changed: 18 additions & 17 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

e2e/index.spec.ts

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
import { test, expect } from '@playwright/test';
2+
3+
test('Landing Page > Introduction Tab (default)', async ({ page }) => {
4+
await page.goto('http://localhost:9876/');
5+
6+
await expect(page).toHaveTitle(/phpPgAdmin/);
7+
8+
await expect(page.getAttribute('html', 'lang')).resolves.toBe('en-US');
9+
10+
const browserIFrame = page.locator('iframe#browser');
11+
await expect(browserIFrame).toHaveAttribute('src', 'browser.php');
12+
await expect(browserIFrame).toHaveAttribute('name', 'browser');
13+
14+
const detailIFrame = page.locator('iframe#detail');
15+
await expect(detailIFrame).toHaveAttribute('src', 'intro.php');
16+
await expect(detailIFrame).toHaveAttribute('name', 'detail');
17+
18+
const detailContentFrame = detailIFrame.contentFrame();
19+
20+
await expect(detailContentFrame.locator('table.tabs tr:first-child td:first-child.active span.label')).toHaveText('Introduction');
21+
22+
const languageOptions = detailContentFrame.locator('select[name="language"] option');
23+
await expect(languageOptions).toHaveCount(29);
24+
const themeOptions = detailContentFrame.locator('select[name="theme"] option');
25+
await expect(themeOptions).toHaveCount(5);
26+
27+
await expect(detailContentFrame.locator('select[name="language"] option[value="english"]')).toHaveText('English');
28+
await expect(detailContentFrame.locator('select[name="language"] option[value="german"]')).toHaveText('Deutsch');
29+
});

package-lock.json

Lines changed: 72 additions & 7 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
{
22
"devDependencies": {
3+
"@playwright/test": "^1.57.0",
4+
"@types/node": "^25.0.8",
35
"selenium-standalone": "^10.0.1"
4-
}
6+
},
7+
"scripts": {}
58
}

phpstan.neon.dist

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ parameters:
55
- Tests/Architecture/
66
- autoload.php
77
- all_db.php
8+
- all_db_export.php
89
- alter_db.php
910
- alter_role.php
1011
- browser.php

0 commit comments

Comments
 (0)