Initial commit: Complete NodeJS-native setup
- 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
This commit is contained in:
58
tests/e2e/auth.spec.ts
Normal file
58
tests/e2e/auth.spec.ts
Normal file
@@ -0,0 +1,58 @@
|
||||
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();
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user