elearning/frontend_management/tests/fixtures/admin.setup.ts
Missez 9bc24fbe8a
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
feat: Establish Playwright testing infrastructure with initial tests for authentication, admin, and instructor modules, and fix instructor video and quiz lesson management pages.
2026-03-02 15:48:47 +07:00

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 });
});