Add Playwright E2E test infrastructure to argocd-plugin
- Add @playwright/test and playwright as devDependencies - Add e2e and e2e:headed scripts - Add playwright.config.ts - Add basic e2e test and auth.setup.ts This fixes the E2E workflow which was failing at the Playwright install step because the project lacked Playwright dependencies. Co-Authored-By: Paperclip <noreply@paperclip.ing>
This commit is contained in:
@@ -0,0 +1,16 @@
|
||||
import { test as setup } from '@playwright/test';
|
||||
import { request } from '@playwright/test';
|
||||
|
||||
setup('authenticate', async ({ page }) => {
|
||||
const token = process.env.HEADLAMP_TOKEN;
|
||||
const url = process.env.HEADLAMP_URL;
|
||||
|
||||
if (!token || !url) {
|
||||
throw new Error('HEADLAMP_TOKEN and HEADLAMP_URL must be set');
|
||||
}
|
||||
|
||||
await page.goto(url);
|
||||
await page.evaluate((t) => {
|
||||
localStorage.setItem('token', t);
|
||||
}, token);
|
||||
});
|
||||
@@ -0,0 +1,16 @@
|
||||
import { test, expect } from '@playwright/test';
|
||||
|
||||
test.describe('ArgoCD Plugin E2E', () => {
|
||||
test('plugin page loads', async ({ page }) => {
|
||||
const url = process.env.HEADLAMP_URL;
|
||||
if (!url) {
|
||||
throw new Error('HEADLAMP_URL must be set');
|
||||
}
|
||||
|
||||
await page.goto(url);
|
||||
await page.waitForLoadState('networkidle');
|
||||
|
||||
const title = await page.title();
|
||||
expect(title).toBeTruthy();
|
||||
});
|
||||
});
|
||||
+5
-1
@@ -23,7 +23,9 @@
|
||||
"format": "prettier --write src/",
|
||||
"format:check": "prettier --check src/",
|
||||
"test": "vitest run",
|
||||
"test:watch": "vitest"
|
||||
"test:watch": "vitest",
|
||||
"e2e": "playwright test",
|
||||
"e2e:headed": "playwright test --headed"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"react": "^18.0.0",
|
||||
@@ -39,6 +41,7 @@
|
||||
"devDependencies": {
|
||||
"@kinvolk/headlamp-plugin": "^0.13.0",
|
||||
"@mui/material": "^5.15.14",
|
||||
"@playwright/test": "^1.58.2",
|
||||
"@testing-library/jest-dom": "^6.4.8",
|
||||
"@testing-library/react": "^16.0.0",
|
||||
"@testing-library/user-event": "^14.5.2",
|
||||
@@ -48,6 +51,7 @@
|
||||
"@headlamp-k8s/eslint-config": "^0.6.0",
|
||||
"eslint": "^8.57.0",
|
||||
"jsdom": "^24.0.0",
|
||||
"playwright": "^1.58.2",
|
||||
"prettier": "^2.8.8",
|
||||
"react": "^18.3.1",
|
||||
"react-dom": "^18.3.1",
|
||||
|
||||
@@ -0,0 +1,27 @@
|
||||
import { defineConfig, devices } from '@playwright/test';
|
||||
|
||||
export default defineConfig({
|
||||
testDir: './e2e',
|
||||
timeout: 30_000,
|
||||
expect: { timeout: 10_000 },
|
||||
fullyParallel: false,
|
||||
forbidOnly: !!process.env.CI,
|
||||
retries: process.env.CI ? 1 : 0,
|
||||
reporter: 'list',
|
||||
use: {
|
||||
baseURL: process.env.HEADLAMP_URL || (() => { throw new Error('HEADLAMP_URL is required — run scripts/deploy-e2e-headlamp.sh first'); })(),
|
||||
trace: 'on-first-retry',
|
||||
screenshot: 'only-on-failure',
|
||||
},
|
||||
projects: [
|
||||
{ name: 'setup', testMatch: /auth\.setup\.ts/, timeout: 60_000 },
|
||||
{
|
||||
name: 'chromium',
|
||||
use: {
|
||||
...devices['Desktop Chrome'],
|
||||
storageState: 'e2e/.auth/state.json',
|
||||
},
|
||||
dependencies: ['setup'],
|
||||
},
|
||||
],
|
||||
});
|
||||
Reference in New Issue
Block a user