- Replace 'any' types with proper TypeScript interfaces in auth setup/teardown - Remove conflicting custom Playwright type declarations that were overriding official types - Fix ES module compatibility by replacing require() with proper import paths - Add proper generic typing to Playwright test fixtures - Fix test discovery in auth debug configuration - Add comprehensive auth debug setup documentation Fixes: - 3 lint warnings about explicit 'any' usage - 45+ TypeScript compilation errors from type conflicts - ES module import errors in auth configuration - Test fixture typing issues All e2e tests now pass lint and type checking with zero warnings.
55 lines
1.7 KiB
TypeScript
55 lines
1.7 KiB
TypeScript
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<TestFixtures>({
|
|
// 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';
|