Files
moyosapp_beta.0.0.3.3_beta/e2e/admin-dashboard-flow.spec.ts
2026-01-16 19:04:48 +02:00

61 lines
2.3 KiB
TypeScript

/**
* E2E Test: Admin Dashboard Flow
* Priority: CRITICAL - Admin functionality
*
* Tests the complete admin journey:
* 1. Admin login
* 2. View dashboard statistics
* 3. Manage guests
* 4. Export data
* 5. View analytics
*/
import { test, expect, type Page } from '@playwright/test';
test.describe('Admin Dashboard Flow', () => {
test.beforeEach(async ({ page }: { page: Page }) => {
await page.goto('http://localhost:3000/admin');
});
test('complete admin dashboard journey', async ({ page }: { page: Page }) => {
// Step 1: Admin login
await page.fill('input[name="email"]', 'admin@example.com');
await page.fill('input[name="password"]', 'admin-password');
await page.click('button[type="submit"]');
await page.waitForURL(/.*admin.*dashboard.*/, { timeout: 5000 });
// Step 2: View dashboard statistics
await expect(page.locator('text=Total Guests')).toBeVisible({ timeout: 3000 });
await expect(page.locator('text=Confirmed')).toBeVisible({ timeout: 3000 });
await expect(page.locator('text=Pending')).toBeVisible({ timeout: 3000 });
// Step 3: Navigate to guest management
await page.click('text=Guests');
await expect(page).toHaveURL(/.*guests.*/);
await expect(page.locator('text=Guest List')).toBeVisible({ timeout: 3000 });
// Step 4: Export data
await page.click('text=Export');
await page.click('text=Export All');
await expect(page.locator('text=Exporting')).toBeVisible({ timeout: 3000 });
// Step 5: View analytics
await page.click('text=Analytics');
await expect(page.locator('text=Engagement')).toBeVisible({ timeout: 3000 });
await expect(page.locator('text=RSVP Trends')).toBeVisible({ timeout: 3000 });
});
test('handles invalid admin credentials', async ({ page }: { page: Page }) => {
await page.fill('input[name="email"]', 'invalid@example.com');
await page.fill('input[name="password"]', 'wrong-password');
await page.click('button[type="submit"]');
await expect(page.locator('text=Invalid credentials')).toBeVisible({ timeout: 3000 });
});
test('requires authentication for admin routes', async ({ page }: { page: Page }) => {
await page.goto('http://localhost:3000/admin/dashboard');
await expect(page).toHaveURL(/.*login.*/, { timeout: 3000 });
});
});