All checks were successful
Build and Deploy Frontend Management to Dev Server / Build Frontend Management Docker Image (push) Successful in 1m17s
Build and Deploy Frontend Management to Dev Server / Deploy E-learning Frontend Management to Dev Server (push) Successful in 8s
Build and Deploy Frontend Management to Dev Server / Notify Deployment Status (push) Successful in 2s
30 lines
1 KiB
TypeScript
30 lines
1 KiB
TypeScript
import { test as setup, expect } from '@playwright/test';
|
|
import { TEST_ADMIN, TEST_URLS } from './test-data';
|
|
import { fileURLToPath } from 'url';
|
|
import path from 'path';
|
|
|
|
const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
|
const ADMIN_AUTH_FILE = path.resolve(__dirname, '../.auth/admin.json');
|
|
|
|
/**
|
|
* Admin authentication setup
|
|
* Logs in as admin and saves browser state (cookies) for reuse
|
|
*/
|
|
setup('authenticate as admin', async ({ page }) => {
|
|
await page.goto(TEST_URLS.login);
|
|
await page.waitForLoadState('networkidle');
|
|
await page.waitForTimeout(500);
|
|
// Fill login form
|
|
await page.locator('input[type="email"]').fill(TEST_ADMIN.email);
|
|
await page.locator('input[type="password"]').fill(TEST_ADMIN.password);
|
|
|
|
// Submit
|
|
await page.locator('button[type="submit"]').click();
|
|
|
|
// Wait for redirect to admin dashboard
|
|
await page.waitForURL('**/admin**', { timeout: 15_000 });
|
|
await expect(page).toHaveURL(/\/admin/);
|
|
|
|
// Save auth state
|
|
await page.context().storageState({ path: ADMIN_AUTH_FILE });
|
|
});
|