- Migrated from Python pre-commit to NodeJS-native solution - Reorganized documentation structure - Set up Husky + lint-staged for efficient pre-commit hooks - Fixed Dockerfile healthcheck issue - Added comprehensive documentation index
59 lines
2.0 KiB
TypeScript
59 lines
2.0 KiB
TypeScript
import { test, expect } from '@playwright/test';
|
|
|
|
test.describe('Authentication Flow', () => {
|
|
test.beforeEach(async ({ page }) => {
|
|
await page.goto('/');
|
|
});
|
|
|
|
test('should display login page for unauthenticated users', async ({
|
|
page,
|
|
}) => {
|
|
await expect(page.locator('h2')).toContainText(['Sign In', 'Login']);
|
|
await expect(page.locator('input[type="email"]')).toBeVisible();
|
|
await expect(page.locator('input[type="password"]')).toBeVisible();
|
|
});
|
|
|
|
test('should allow user registration', async ({ page }) => {
|
|
// Click register tab/link
|
|
await page.click('text=Register');
|
|
|
|
// Fill registration form
|
|
await page.fill('input[type="email"]', 'test@example.com');
|
|
await page.fill('input[name="username"]', 'testuser');
|
|
await page.fill('input[type="password"]', 'TestPassword123!');
|
|
|
|
// Submit registration
|
|
await page.click('button[type="submit"]');
|
|
|
|
// Should show verification message or redirect
|
|
await expect(page.locator('text=verification')).toBeVisible();
|
|
});
|
|
|
|
test('should login with admin credentials', async ({ page }) => {
|
|
// Fill login form with admin credentials
|
|
await page.fill('input[type="email"]', 'admin@localhost');
|
|
await page.fill('input[type="password"]', 'admin123!');
|
|
|
|
// Submit login
|
|
await page.click('button[type="submit"]');
|
|
|
|
// Should redirect to main app
|
|
await expect(page.locator('h1')).toContainText('Medication Reminder');
|
|
await expect(page.locator('text=Admin')).toBeVisible();
|
|
});
|
|
|
|
test('should show error for invalid credentials', async ({ page }) => {
|
|
await page.fill('input[type="email"]', 'invalid@example.com');
|
|
await page.fill('input[type="password"]', 'wrongpassword');
|
|
|
|
await page.click('button[type="submit"]');
|
|
|
|
await expect(page.locator('text=Invalid')).toBeVisible();
|
|
});
|
|
|
|
test('should handle OAuth login buttons', async ({ page }) => {
|
|
await expect(page.locator('button:has-text("Google")')).toBeVisible();
|
|
await expect(page.locator('button:has-text("GitHub")')).toBeVisible();
|
|
});
|
|
});
|