elearning/frontend_management/tests/admin/dashboard.spec.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

44 lines
2 KiB
TypeScript

import { test, expect } from '@playwright/test';
import { TEST_URLS } from '../fixtures/test-data';
/**
* Admin Dashboard Tests
* ใช้ cookies จาก admin-setup project (ไม่ต้อง login ซ้ำ)
*/
test.describe('Admin Dashboard', () => {
test.beforeEach(async ({ page }) => {
await page.goto(TEST_URLS.adminDashboard);
await page.waitForLoadState('networkidle');
});
test('show display dashboard', async ({ page }) => {
await expect(page.locator('h1')).toContainText('สวัสดี');
await expect(page.locator("//p[normalize-space(text())='คอร์สรออนุมัติ']")).toBeVisible();
await expect(page.getByText('กิจกรรมวันนี้')).toBeVisible();
await expect(page.getByText('ผู้ใช้งานทั้งหมด')).toBeVisible();
});
test('navigate to pending courses and audit-log page', async ({ page }) => {
await page.locator('a[href*="pending"]', { hasText: 'ดูทั้งหมด' }).click();
await page.waitForURL('**/admin/courses/pending**');
await expect(page).toHaveURL(/\/admin\/courses\/pending/);
await page.waitForTimeout(500);
await page.goto(TEST_URLS.adminDashboard);
await page.waitForLoadState('networkidle');
await page.waitForTimeout(500);
await page.locator('a[href*="audit-log"]', { hasText: 'ดูทั้งหมด' }).click();
await page.waitForURL('**/admin/audit-log**');
await expect(page).toHaveURL(/\/admin\/audit-log/);
await page.waitForTimeout(500);
});
test('show user menu on avatar click', async ({ page }) => {
// Click the avatar / user icon area
await page.locator('.w-12.h-12.rounded-full').click();
await page.waitForTimeout(500);
// Menu should appear with profile and logout options
await expect(page.getByText('โปรไฟล์')).toBeVisible();
});
});