elearning/frontend_management/tests/instructor/dashboard.spec.ts

53 lines
2.3 KiB
TypeScript
Raw Permalink Normal View History

import { test, expect } from '@playwright/test';
import { TEST_URLS } from '../fixtures/test-data';
/**
* Instructor Dashboard Tests
* cookies instructor-setup project ( login )
*/
test.describe('Instructor Dashboard', () => {
test.beforeEach(async ({ page }) => {
await page.goto(TEST_URLS.instructorDashboard);
await page.waitForLoadState('networkidle');
});
test('check display dashboard', async ({ page }) => {
await expect(page.getByText('หลักสูตรทั้งหมด')).toBeVisible();
await expect(page.getByText('ผู้เรียนทั้งหมด')).toBeVisible();
await expect(page.getByText('เรียนจบแล้ว')).toBeVisible();
await expect(page.getByText('สถานะหลักสูตร')).toBeVisible();
await expect(page.getByRole('button', { name: 'ดูทั้งหมด' })).toBeVisible();
});
test('should navigate to courses list', async ({ page }) => {
await page.getByRole('button', { name: 'ดูทั้งหมด' }).click();
await page.waitForURL('**/instructor/courses**');
await expect(page).toHaveURL(/\/instructor\/courses/);
});
test('should show user menu on avatar click', async ({ page }) => {
await page.locator('.w-12.h-12.rounded-full').click();
await expect(page.getByText('โปรไฟล์')).toBeVisible();
});
test('should navigate to profile', async ({ page }) => {
await page.locator('.w-12.h-12.rounded-full').click();
await page.getByText('โปรไฟล์').click();
await page.waitForURL('**/instructor/profile**');
await expect(page).toHaveURL(/\/instructor\/profile/);
});
test('should logout and redirect to login', async ({ page }) => {
await page.locator('.w-12.h-12.rounded-full').click();
await page.getByRole('menu').getByText('ออกจากระบบ').click();
// Confirm logout dialog
await page.locator('.q-dialog').getByRole('button', { name: 'ออกจากระบบ' }).click();
await page.waitForURL('**/login**', { timeout: 10_000 });
await expect(page).toHaveURL(/\/login/);
});
});