3ccd94f661
Test Organization: - Create tests/unit/, tests/integration/, tests/system/ directories - Move existing tests into appropriate categories - Add pytest markers (@pytest.mark.unit, @pytest.mark.integration) Shared Fixtures: - Create conftest.py with SQLite engine (for unit tests) - Add PostgreSQL session fixture with transaction rollback - Add TestClient fixture for API tests Configuration: - Update pyproject.toml with asyncio_mode=auto - Add test markers and default addopts - Add aiosqlite dependency for SQLite support E2E Testing: - Initialize Playwright in e2e/ directory - Add playwright.config.ts - Create login flow E2E test Build: - Add test-unit, test-integration, test-system, test-e2e to Makefile - Update test target to run all categories - Add testing documentation to README Note: Some tests have import issues due to missing python-jose package in dev environment. This needs to be addressed separately.
33 lines
1.0 KiB
TypeScript
33 lines
1.0 KiB
TypeScript
import { test, expect } from '@playwright/test';
|
|
|
|
test.describe('Login Flow', () => {
|
|
test('login page is accessible', async ({ page }) => {
|
|
await page.goto('/login');
|
|
|
|
// Verify login page content
|
|
await expect(page.getByText('Sign in required')).toBeVisible();
|
|
await expect(page.getByText('Continue to login')).toBeVisible();
|
|
});
|
|
|
|
test('redirects to home after login', async ({ page }) => {
|
|
await page.goto('/login');
|
|
|
|
// Click login button
|
|
await page.getByText('Continue to login').click();
|
|
|
|
// Should redirect to OAuth provider (this is a simplified check)
|
|
// In real tests, you'd mock the OAuth flow or use test credentials
|
|
await expect(page).toHaveURL(/.*authentik.*/);
|
|
});
|
|
});
|
|
|
|
test.describe('Protected Routes', () => {
|
|
test('redirects unauthenticated users to login', async ({ page }) => {
|
|
await page.goto('/projects');
|
|
|
|
// Should be redirected to login page
|
|
await expect(page).toHaveURL(/.*login.*/);
|
|
await expect(page.getByText('Sign in required')).toBeVisible();
|
|
});
|
|
});
|