Auth with passwords + Playwright E2E tests + PostHog analytics

- bcrypt password hashing in auth (register, login, change-password)
- Login/register pages with password fields
- Profile update + OAuth placeholder endpoints
- Playwright test suite: auth, pages, API (3 test files)
- PostHog Docker analytics on :8010

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-03-29 14:26:51 +00:00
parent b4b8439f80
commit dd995d9c0f
13 changed files with 439 additions and 16 deletions

40
tests/api.spec.ts Normal file
View File

@@ -0,0 +1,40 @@
import { test, expect } from '@playwright/test';
const API = 'http://localhost:3000';
test.describe('API Endpoints', () => {
test('health check', async ({ request }) => {
const res = await request.get(`${API}/health`);
expect(res.ok()).toBeTruthy();
const data = await res.json();
expect(data.status).toBe('ok');
});
test('list tasks', async ({ request }) => {
const res = await request.get(`${API}/api/v1/tasks`);
expect(res.ok()).toBeTruthy();
});
test('list groups', async ({ request }) => {
const res = await request.get(`${API}/api/v1/groups`);
expect(res.ok()).toBeTruthy();
const data = await res.json();
expect(data.data.length).toBeGreaterThan(0);
});
test('system health', async ({ request }) => {
const res = await request.get(`${API}/api/v1/system/health`);
expect(res.ok()).toBeTruthy();
});
test('create and delete task', async ({ request }) => {
const create = await request.post(`${API}/api/v1/tasks`, {
data: { title: 'E2E Test Task', priority: 'low' }
});
expect(create.ok()).toBeTruthy();
const { data } = await create.json();
const del = await request.delete(`${API}/api/v1/tasks/${data.id}`);
expect(del.ok()).toBeTruthy();
});
});

32
tests/auth.spec.ts Normal file
View File

@@ -0,0 +1,32 @@
import { test, expect } from '@playwright/test';
test.describe('Auth Flow', () => {
const email = `test-${Date.now()}@test.cz`;
test('register page loads', async ({ page }) => {
await page.goto('/register');
await expect(page).toHaveTitle(/Task Team/);
});
test('login page loads', async ({ page }) => {
await page.goto('/login');
await expect(page.locator('input[type="email"]')).toBeVisible();
});
test('register new user', async ({ page }) => {
await page.goto('/register');
// Name is the first text input (autoFocus), email is type=email
await page.locator('input[type="text"]').first().fill('Test User');
await page.locator('input[type="email"]').fill(email);
await page.locator('button[type="submit"]').click();
await page.waitForTimeout(2000);
// Should redirect to tasks or show success
});
test('login existing user', async ({ page }) => {
await page.goto('/login');
await page.fill('input[type="email"]', email);
await page.locator('button[type="submit"]').click();
await page.waitForTimeout(2000);
});
});

34
tests/tasks.spec.ts Normal file
View File

@@ -0,0 +1,34 @@
import { test, expect } from '@playwright/test';
test.describe('Tasks', () => {
test('tasks page loads', async ({ page }) => {
await page.goto('/tasks');
await page.waitForTimeout(1000);
await expect(page.locator('body')).toBeVisible();
});
test('calendar page loads', async ({ page }) => {
await page.goto('/calendar');
await expect(page.locator('body')).toBeVisible();
});
test('chat page loads', async ({ page }) => {
await page.goto('/chat');
await expect(page.locator('body')).toBeVisible();
});
test('goals page loads', async ({ page }) => {
await page.goto('/goals');
await expect(page.locator('body')).toBeVisible();
});
test('settings page loads', async ({ page }) => {
await page.goto('/settings');
await expect(page.locator('body')).toBeVisible();
});
test('projects page loads', async ({ page }) => {
await page.goto('/projects');
await expect(page.locator('body')).toBeVisible();
});
});