import { test as base, Page } from '@playwright/test'; // Define fixture types type TestFixtures = { adminPage: Page; userPage: Page; }; // Extend basic test with custom fixtures export const test = base.extend({ // Auto-login fixture for admin user adminPage: async ({ page }, use) => { await page.goto('/'); await page.fill('input[type="email"]', 'admin@localhost'); await page.fill('input[type="password"]', 'admin123!'); await page.click('button[type="submit"]'); // Wait for app to load await page.waitForSelector('h1:has-text("Medication Reminder")'); await use(page); }, // Regular user login fixture userPage: async ({ page }, use) => { await page.goto('/'); // Register a test user first if needed await page.click('text=Register'); await page.fill('input[type="email"]', 'testuser@example.com'); await page.fill('input[name="username"]', 'testuser'); await page.fill('input[type="password"]', 'TestPassword123!'); await page.click('button[type="submit"]'); // For mock database, user might be auto-verified // Wait for either verification message or app load try { await page.waitForSelector('h1:has-text("Medication Reminder")', { timeout: 5000, }); } catch { // If not auto-logged in, login manually await page.goto('/'); await page.fill('input[type="email"]', 'testuser@example.com'); await page.fill('input[type="password"]', 'TestPassword123!'); await page.click('button[type="submit"]'); await page.waitForSelector('h1:has-text("Medication Reminder")'); } await use(page); }, }); export { expect } from '@playwright/test';