1
0
mirror of https://github.com/php/web-php.git synced 2026-03-23 23:02:13 +01:00

Add visual regression tests (#994)

Co-authored-by: Roman Pronskiy <roman@pronskiy.com>
Co-authored-by: Derick Rethans <derick@php.net>
This commit is contained in:
Sergey Panteleev
2024-08-20 09:20:25 +03:00
committed by GitHub
parent 03af4d4423
commit c632d199d1
20 changed files with 339 additions and 4 deletions

View File

@@ -0,0 +1,63 @@
import {expect, test} from '@playwright/test';
export type TestPageOptions = {
path: string
options?: object
evaluate?: () => any
}
const items: TestPageOptions[] = [
{
path: 'index.php',
evaluate: () => {
const selector = document.querySelector('.elephpants');
selector.remove()
}
},
{
path: 'archive/1998.php',
evaluate: () => {
const selector = document.querySelector('.elephpants');
selector.remove()
}
},
{path: 'releases/8_3_6.php'},
{path: 'releases/8.0/index.php'},
{path: 'releases/8.1/index.php'},
{path: 'releases/8.2/index.php'},
{path: 'releases/8.3/index.php'},
{path: 'manual/index.php'},
{path: 'manual/php5.php'},
{
path: 'conferences/index.php',
options: {
fullPage: false,
}
},
]
for (const item of items) {
test(`testing with ${item.path}`, async ({page}, testInfo) => {
testInfo.snapshotSuffix = '';
const httpHost = process.env.HTTP_HOST
if (typeof httpHost !== 'string') {
throw new Error('Environment variable "HTTP_HOST" is not set.')
}
await page.goto(`${httpHost}/${item.path}`)
if (typeof item.evaluate === 'function') {
await page.evaluate(item.evaluate)
}
await expect(page).toHaveScreenshot(
`tests/screenshots/${item.path}.png`,
item.options ?? {
fullPage: true,
timeout: 10000,
}
)
})
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 202 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 168 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 382 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 99 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 604 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 730 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 565 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 50 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 818 KiB