Skip to content

Commit fac5037

Browse files
test: setup playwright e2e tests
1 parent 49f13cf commit fac5037

File tree

4 files changed

+64
-1
lines changed

4 files changed

+64
-1
lines changed

package-lock.json

Lines changed: 19 additions & 0 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
@@ -53,7 +53,9 @@
5353
"eject": "react-scripts eject",
5454
"prepublishOnly": "npm run package",
5555
"typecheck": "tsc --noEmit",
56-
"prepare": "husky install"
56+
"prepare": "husky install",
57+
"test:e2e:install": "npx playwright install --with-deps chromium",
58+
"test:e2e": "npx playwright test --config=playwright.config.ts"
5759
},
5860
"lint-staged": {
5961
"*.{scss}": [
@@ -104,6 +106,7 @@
104106
"@gravity-ui/stylelint-config": "^1.0.1",
105107
"@gravity-ui/tsconfig": "^1.0.0",
106108
"@gravity-ui/uikit": "^3.20.2",
109+
"@playwright/test": "^1.31.1",
107110
"@testing-library/jest-dom": "^5.15.0",
108111
"@testing-library/react": "^11.2.7",
109112
"@testing-library/user-event": "^12.8.3",

playwright.config.ts

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
import {PlaywrightTestConfig, devices} from '@playwright/test';
2+
3+
const baseUrl = process.env.PLAYWRIGHT_BASE_URL;
4+
5+
const config: PlaywrightTestConfig = {
6+
testDir: 'tests',
7+
timeout: 2 * 60 * 1000,
8+
// If there is no url provided, playwright starts webServer with the app in dev mode
9+
webServer: baseUrl
10+
? undefined
11+
: {
12+
command: 'npm run dev',
13+
port: 3000,
14+
},
15+
use: {
16+
baseURL: baseUrl || 'http://localhost:3000',
17+
},
18+
projects: [
19+
{
20+
name: 'chromium',
21+
use: {...devices['Desktop Chrome']},
22+
},
23+
],
24+
};
25+
26+
export default config;

tests/tenant.test.ts

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
import {test, expect} from '@playwright/test';
2+
3+
test.describe('Test Tenants page', async () => {
4+
test('Tenants page is OK', async ({page}) => {
5+
const response = await page.goto('/tenants');
6+
expect(response?.ok()).toBe(true);
7+
});
8+
test('Tenants page has tenants table', async ({page}) => {
9+
await page.goto('/tenants');
10+
11+
// react-data-table has 2 table elements - for header and for the content
12+
// so we select content table that is wrapped with .data-table__box
13+
await expect(page.locator('.data-table__box').getByRole('table')).toBeVisible();
14+
});
15+
});

0 commit comments

Comments
 (0)