Refactor Playwright tests to use cached authentication state for improved performance

- Removed redundant `loginViaUI` calls across E2E tests, leveraging cached storage state for faster test execution.
- Enhanced Playwright configuration to include a `setup` project for pre-caching admin and regular user authentication states.
- Added new `auth.setup.ts` to handle initial authentication and save storage states to `.auth` directory.
- Increased local worker count to 16 (CI unchanged) to optimize parallel execution.
- Updated `.gitignore` to exclude authentication state files.
This commit is contained in:
2025-11-08 20:46:59 +01:00
parent bf95aab7ec
commit a6a10855fa
11 changed files with 184 additions and 70 deletions

View File

@@ -9,7 +9,7 @@ import { setupSuperuserMocks, loginViaUI } from './helpers/auth';
test.describe('Admin Organization Management - Page Load', () => {
test.beforeEach(async ({ page }) => {
await setupSuperuserMocks(page);
await loginViaUI(page);
// Auth already cached in storage state (loginViaUI removed for performance)
await page.goto('/admin/organizations');
});
@@ -40,7 +40,7 @@ test.describe('Admin Organization Management - Page Load', () => {
test.describe('Admin Organization Management - Organization List Table', () => {
test.beforeEach(async ({ page }) => {
await setupSuperuserMocks(page);
await loginViaUI(page);
// Auth already cached in storage state (loginViaUI removed for performance)
await page.goto('/admin/organizations');
});
@@ -106,7 +106,7 @@ test.describe('Admin Organization Management - Organization List Table', () => {
test.describe('Admin Organization Management - Pagination', () => {
test.beforeEach(async ({ page }) => {
await setupSuperuserMocks(page);
await loginViaUI(page);
// Auth already cached in storage state (loginViaUI removed for performance)
await page.goto('/admin/organizations');
});
@@ -126,7 +126,7 @@ test.describe('Admin Organization Management - Pagination', () => {
test.describe('Admin Organization Management - Create Organization Button', () => {
test.beforeEach(async ({ page }) => {
await setupSuperuserMocks(page);
await loginViaUI(page);
// Auth already cached in storage state (loginViaUI removed for performance)
await page.goto('/admin/organizations');
});
@@ -139,7 +139,7 @@ test.describe('Admin Organization Management - Create Organization Button', () =
test.describe('Admin Organization Management - Action Menu', () => {
test.beforeEach(async ({ page }) => {
await setupSuperuserMocks(page);
await loginViaUI(page);
// Auth already cached in storage state (loginViaUI removed for performance)
await page.goto('/admin/organizations');
await page.waitForSelector('table tbody tr', { timeout: 10000 });
});
@@ -245,7 +245,7 @@ test.describe('Admin Organization Management - Action Menu', () => {
test.describe('Admin Organization Management - Edit Organization Dialog', () => {
test.beforeEach(async ({ page }) => {
await setupSuperuserMocks(page);
await loginViaUI(page);
// Auth already cached in storage state (loginViaUI removed for performance)
await page.goto('/admin/organizations');
await page.waitForSelector('table tbody tr', { timeout: 10000 });
});
@@ -294,7 +294,7 @@ test.describe('Admin Organization Management - Edit Organization Dialog', () =>
test.describe('Admin Organization Management - Member Count Interaction', () => {
test.beforeEach(async ({ page }) => {
await setupSuperuserMocks(page);
await loginViaUI(page);
// Auth already cached in storage state (loginViaUI removed for performance)
await page.goto('/admin/organizations');
await page.waitForSelector('table tbody tr', { timeout: 10000 });
});
@@ -318,7 +318,7 @@ test.describe('Admin Organization Management - Member Count Interaction', () =>
test.describe('Admin Organization Management - Accessibility', () => {
test.beforeEach(async ({ page }) => {
await setupSuperuserMocks(page);
await loginViaUI(page);
// Auth already cached in storage state (loginViaUI removed for performance)
await page.goto('/admin/organizations');
});