test: end to end testing (#2793) · api-platform/api-platform@aa21bb1 · GitHub
Skip to content

Commit aa21bb1

Browse files
authored
test: end to end testing (#2793)
1 parent 7d7f181 commit aa21bb1

8 files changed

Lines changed: 227 additions & 6 deletions

File tree

‎.github/workflows/e2e.yml‎

Lines changed: 46 additions & 0 deletions

‎e2e/.gitignore‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
node_modules/
2+
/test-results/
3+
/playwright-report/
4+
/blob-report/
5+
/playwright/.cache/

‎e2e/package-lock.json‎

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

‎e2e/package.json‎

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
{
2+
"name": "e2e",
3+
"version": "1.0.0",
4+
"main": "index.js",
5+
"scripts": {},
6+
"keywords": [],
7+
"author": "",
8+
"license": "ISC",
9+
"description": "",
10+
"devDependencies": {
11+
"@playwright/test": "^1.48.2",
12+
"@types/node": "^22.9.0"
13+
}
14+
}

‎e2e/playwright.config.js‎

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
// @ts-check
2+
const { defineConfig, devices } = require('@playwright/test');
3+
4+
module.exports = defineConfig({
5+
testDir: './tests',
6+
fullyParallel: true,
7+
forbidOnly: !!process.env.CI,
8+
retries: 0,
9+
workers: 1,
10+
reporter: 'html',
11+
use: {
12+
ignoreHTTPSErrors: true,
13+
trace: 'on-first-retry',
14+
},
15+
16+
projects: [
17+
{
18+
name: 'chromium',
19+
use: { ...devices['Desktop Chrome'], },
20+
},
21+
{
22+
name: 'firefox',
23+
use: { ...devices['Desktop Firefox'] },
24+
},
25+
{
26+
name: 'webkit',
27+
use: { ...devices['Desktop Safari'] },
28+
},
29+
],
30+
});
31+

‎e2e/tests/example.spec.js‎

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
// @ts-check
2+
const { test, expect } = require('@playwright/test');
3+
4+
test('homepage', async ({ page }) => {
5+
await page.goto('https://localhost/');
6+
await expect(page).toHaveTitle('Welcome to API Platform!');
7+
});
8+
9+
test('swagger', async ({ page }) => {
10+
await page.goto('https://localhost/docs');
11+
await expect(page).toHaveTitle('Hello API Platform - API Platform');
12+
await expect(page.locator('.operation-tag-content > span')).toHaveCount(5);
13+
});
14+
15+
test('admin', async ({ page, browserName }) => {
16+
await page.goto('https://localhost/admin');
17+
await page.getByLabel('Create').click();
18+
await page.getByLabel('Name').fill('foo' + browserName);
19+
await page.getByLabel('Save').click();
20+
await expect(page).toHaveURL(/admin#\/greetings$/);
21+
await page.getByText('foo' + browserName).first().click();
22+
await expect(page).toHaveURL(/show$/);
23+
await page.getByLabel('Edit').click();
24+
await page.getByLabel('Name').fill('bar' + browserName);
25+
await page.getByLabel('Save').click();
26+
await expect(page).toHaveURL(/admin#\/greetings$/);
27+
await page.getByText('bar' + browserName).first().click();
28+
});

‎pwa/package.json‎

Lines changed: 1 addition & 1 deletion

‎pwa/pnpm-lock.yaml‎

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

0 commit comments

Comments
 (0)