Skip to content

Commit ad12db5

Browse files
NexionisJakecanihavesomecoffee
authored andcommitted
Add real-time sample progress indicator during testing stage
This commit introduces a progress indicator that displays the number of completed samples and percentage during the 'Testing' stage of test execution, enhancing user visibility into test progress. Changes: - Modified mod_test/controllers.py to calculate and return sample progress data in the get_json_data endpoint - Updated templates/test/by_id.html to display progress information and handle real-time updates via AJAX polling Implementation details: - Calculates progress using existing test.results and test.get_customized_regressiontests() data - No database schema changes required - Updates every 20 seconds via existing AJAX mechanism - Displays format: 'X / Y samples (Z%)' - Backward compatible with existing functionality The feature provides immediate feedback to users about test execution progress without requiring any infrastructure changes.
1 parent 91443e2 commit ad12db5

File tree

2 files changed

+48
-2
lines changed

2 files changed

+48
-2
lines changed

mod_test/controllers.py

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -212,11 +212,23 @@ def get_json_data(test_id):
212212
'message': entry.message
213213
})
214214

215+
# Calculate sample progress from existing TestResult data
216+
completed_samples = len(test.results)
217+
total_samples = len(test.get_customized_regressiontests())
218+
progress_percentage = 0
219+
if total_samples > 0:
220+
progress_percentage = int((completed_samples / total_samples) * 100)
221+
215222
return jsonify({
216223
'status': 'success',
217224
'details': pr_data["progress"],
218225
'complete': test.finished,
219-
'progress_array': progress_array
226+
'progress_array': progress_array,
227+
'sample_progress': {
228+
'current': completed_samples,
229+
'total': total_samples,
230+
'percentage': progress_percentage
231+
}
220232
})
221233

222234

templates/test/by_id.html

Lines changed: 35 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,22 @@
11
{% extends "base.html" %}
22

33
{% block title %}Test progress for {{ title }} {{ super() }}{% endblock %}
4+
5+
{% block styles %}
6+
{{ super() }}
7+
<style>
8+
.sample-progress {
9+
margin-top: 5px;
10+
font-size: 12px;
11+
color: #666;
12+
}
13+
#sample-progress-text {
14+
display: block;
15+
text-align: center;
16+
}
17+
</style>
18+
{% endblock %}
19+
420
{% block body %}
521
{{ super() }}
622
<br />
@@ -48,7 +64,14 @@ <h1>Test progress for {{ title }}</h1>
4864
{% if progress.progress.state == 'error' and progress.progress.step == loop.index0 -%}
4965
{% set status = status ~ ' error' %}
5066
{%- endif %}
51-
<li class="progtrckr-{{ status }}" id="trckr-{{ stage.description }}">{{ stage.description }}</li>
67+
<li class="progtrckr-{{ status }}" id="trckr-{{ stage.description }}">
68+
{{ stage.description }}
69+
{% if stage.description == 'Testing' and status == 'running' %}
70+
<div class="sample-progress" id="sample-progress">
71+
<small id="sample-progress-text">0 / 0 samples</small>
72+
</div>
73+
{% endif %}
74+
</li>
5275
{%- endfor %}
5376
</ol>
5477
<br class="clear" />
@@ -181,6 +204,17 @@ <h6>There are no tests executed in this category.</h6>
181204
if (testprogress === 0 && val.length !== 0) {
182205
window.location.reload();
183206
}
207+
208+
// Update sample progress display
209+
if (data.sample_progress) {
210+
var progressText = document.getElementById('sample-progress-text');
211+
if (progressText) {
212+
progressText.textContent = data.sample_progress.current + ' / ' +
213+
data.sample_progress.total + ' samples (' +
214+
data.sample_progress.percentage + '%)';
215+
}
216+
}
217+
184218
{% for stage in progress.stages %}
185219
if (data.details.step >= {{ loop.index0 }}) {
186220
status = 'done';

0 commit comments

Comments
 (0)