feat(tests): add E2E test for Dashboard API budget and update documentation
Deploy Development / deploy (push) Successful in 40s
Test Suite / pytest-backend (push) Successful in 35s
Test Suite / lint-backend (push) Successful in 0s
Test Suite / build-frontend (push) Successful in 11s
Test Suite / playwright-tests (push) Successful in 57s

- Introduced a new E2E test to validate API call counts for `/api/profiles/me` and `/api/training-units` after reloading the Dashboard, ensuring compliance with refactor phase requirements.
- Updated architecture documentation to include details about the new test and its execution within the CI pipeline.
This commit is contained in:
Lars committed 2026-05-14 06:49:15 +02:00
1 parent 7043addd15
commit 255fa45e90
2 files changed
+50 -1

No files matched your search

+46 -1
View File
@@ -143,6 +143,51 @@ test('7. Session-Persistenz nach Reload', async ({ page }) => {
console.log('✓ Session bleibt nach Reload erhalten');
});
/**
* Refaktor Phase 1 (Dashboard): kein zweites GET /api/profiles/me; genau drei GET /api/training-units.
* Production-ähnlicher Build empfohlen (kein React StrictMode-Doppel-Mount im lokalen Vite-Dev).
*/
test('8. Dashboard API-Budget nach Reload (profiles/me, training-units)', async ({ page }) => {
await login(page);
let profilesMe = 0;
let trainingUnits = 0;
const onRequest = (request) => {
if (request.method() !== 'GET') return;
let pathname = '';
try {
pathname = new URL(request.url()).pathname;
} catch {
return;
}
if (pathname === '/api/profiles/me') profilesMe += 1;
if (pathname === '/api/training-units') trainingUnits += 1;
};
page.on('request', onRequest);
try {
await page.reload({ waitUntil: 'networkidle' });
const main = page.locator('.app-main');
await expect(main.getByRole('heading', { level: 1, name: 'Dashboard' })).toBeVisible({
timeout: 15000,
});
await expect(page.locator('.spinner')).toHaveCount(0, { timeout: 10000 });
await expect(page.getByRole('heading', { name: 'Nächste Termine' })).toBeVisible({
timeout: 20000,
});
expect(profilesMe).toBe(1);
expect(trainingUnits).toBe(3);
} finally {
page.off('request', onRequest);
}
console.log('✓ Dashboard API-Budget: 1× profiles/me, 3× training-units');
});
test('P-12: sessionStorage wird bei Logout bereinigt (sj_coach_* Schlüssel)', async ({ page }) => {
await page.setViewportSize({ width: 1280, height: 800 });
await login(page);
@@ -457,7 +502,7 @@ test('P-06e: API-Endpoint /api/admin/media-rights/legacy-summary erreichbar (Sup
}
});
test('8. Keine kritischen Console-Fehler', async ({ page }) => {
test('9. Keine kritischen Console-Fehler', async ({ page }) => {
const errors = [];
page.on('console', msg => {
if (msg.type() === 'error') errors.push(msg.text());