feat: run tests in background with progress polling

Improve the testing dashboard to run pytest in the background:

- Add background task execution using FastAPI's BackgroundTasks
- Create test_runner_tasks.py following existing background task pattern
- API now returns immediately after starting the test run
- Frontend polls for status every 2 seconds until completion
- Show running indicator with elapsed time counter
- Resume polling if user navigates away and returns while tests running
- Tests continue running even if user closes the page

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
2025-12-12 23:20:26 +01:00
parent 6e3ae4bebb
commit 0e6c9e3eea
5 changed files with 228 additions and 41 deletions

View File

@@ -23,6 +23,33 @@
{{ alert_dynamic(type='success', message_var='successMessage', show_condition='successMessage') }}
<!-- Running Indicator -->
<div x-show="running" x-cloak class="mb-6">
<div class="p-4 bg-purple-100 dark:bg-purple-900 rounded-lg shadow-xs">
<div class="flex items-center justify-between">
<div class="flex items-center">
<svg class="animate-spin h-5 w-5 text-purple-600 dark:text-purple-400 mr-3" xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24">
<circle class="opacity-25" cx="12" cy="12" r="10" stroke="currentColor" stroke-width="4"></circle>
<path class="opacity-75" fill="currentColor" d="M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"></path>
</svg>
<div>
<p class="font-semibold text-purple-800 dark:text-purple-200">Running tests...</p>
<p class="text-sm text-purple-600 dark:text-purple-300">Tests are executing in the background. You can leave this page and come back.</p>
</div>
</div>
<div class="text-right">
<p class="text-2xl font-bold text-purple-700 dark:text-purple-300" x-text="formatDuration(elapsedTime)">0s</p>
<p class="text-xs text-purple-600 dark:text-purple-400">elapsed</p>
</div>
</div>
<div class="mt-3">
<div class="w-full bg-purple-200 dark:bg-purple-800 rounded-full h-1.5 overflow-hidden">
<div class="bg-purple-600 dark:bg-purple-400 h-1.5 rounded-full animate-pulse" style="width: 100%"></div>
</div>
</div>
</div>
</div>
<!-- Dashboard Content -->
<div x-show="!loading && !error">
<!-- Stats Cards Row 1 - Main Metrics -->