61baf3ac5d
- Update next.config.ts - Add netlify.toml, Docker configs, e2e tests - Add env templates, docs (README, ROADMAP, TODO) - Add vitest/playwright test configs - Add component and lib tests - Add install script, portainer env template - Update .gitignore (tsbuildinfo, deno.lock, dev.db)
39 lines
1.5 KiB
TypeScript
39 lines
1.5 KiB
TypeScript
import { test, expect } from '@playwright/test';
|
|
|
|
test.describe('Authentication Flow', () => {
|
|
test('should handle login, registration, and logout', async ({ page }) => {
|
|
// Visit site → home page loads → see navbar
|
|
await page.goto('/');
|
|
await expect(page.locator('nav')).toBeVisible();
|
|
|
|
// Click Login → see login form
|
|
await page.click('text=Login');
|
|
await expect(page.locator('form')).toBeVisible();
|
|
|
|
// Try invalid login → see error message
|
|
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 credentials')).toBeVisible();
|
|
|
|
// Navigate to registration (assuming a link exists on login page)
|
|
await page.click('text=Register');
|
|
|
|
// Fill registration form → submit → redirect to home
|
|
await page.fill('input[name="name"]', 'Test User');
|
|
await page.fill('input[name="email"]', 'newuser@example.com');
|
|
await page.fill('input[name="password"]', 'securepassword123');
|
|
await page.click('button[type="submit"]');
|
|
|
|
// Check redirect and authentication state
|
|
await expect(page).toHaveURL('/');
|
|
// See user menu or similar in navbar when authenticated
|
|
await expect(page.locator('nav')).toContainText('Logout');
|
|
|
|
// Click logout → redirect to home → see login button
|
|
await page.click('text=Logout');
|
|
await expect(page).toHaveURL('/');
|
|
await expect(page.locator('text=Login')).toBeVisible();
|
|
});
|
|
});
|