feat: restructure test infrastructure with unit/integration/system separation

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.
This commit is contained in:
Fusion
2026-05-18 15:00:33 +02:00
parent a441ea2fac
commit 3ccd94f661
26 changed files with 627 additions and 11 deletions
+13
View File
@@ -0,0 +1,13 @@
{
"name": "headquarter-e2e",
"version": "0.1.0",
"private": true,
"scripts": {
"test": "playwright test",
"test:ui": "playwright test --ui",
"test:debug": "playwright test --debug"
},
"devDependencies": {
"@playwright/test": "^1.40.0"
}
}
+25
View File
@@ -0,0 +1,25 @@
import { defineConfig, devices } from '@playwright/test';
export default defineConfig({
testDir: './tests',
fullyParallel: true,
forbidOnly: !!process.env.CI,
retries: process.env.CI ? 2 : 0,
workers: process.env.CI ? 1 : undefined,
reporter: 'list',
use: {
baseURL: process.env.WEB_URL || 'http://localhost:3000',
trace: 'on-first-retry',
screenshot: 'only-on-failure',
},
projects: [
{
name: 'chromium',
use: { ...devices['Desktop Chrome'] },
},
{
name: 'firefox',
use: { ...devices['Desktop Firefox'] },
},
],
});
+32
View File
@@ -0,0 +1,32 @@
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();
});
});