Skip to content

Commit 1b25ad6

Browse files
committed
fix: Update summary chart to reflect test results
1 parent 961d593 commit 1b25ad6

3 files changed

Lines changed: 62 additions & 6 deletions

File tree

src/main/resources/scripts.js

Lines changed: 28 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ function initializeChart() {
4848
data: {
4949
labels: ['Success', 'Warnings', 'Errors'],
5050
datasets: [{
51-
data: [266, 8, 2],
51+
data: [totalScs, totalWrn, totalErr],
5252
backgroundColor: ['#10b981', '#f59e0b', '#ef4444'],
5353
borderWidth: 0,
5454
cutout: '70%'
@@ -250,6 +250,29 @@ function copyReplayCommand(event) {
250250
});
251251
}
252252

253+
// ==========================================
254+
// SUCCESS RATE STYLING
255+
// ==========================================
256+
257+
/**
258+
* Update success rate styling based on percentage value
259+
*/
260+
function updateSuccessRateStyles() {
261+
document.querySelectorAll('.success-rate-compact').forEach(element => {
262+
const percentage = parseFloat(element.getAttribute('data-percentage'));
263+
264+
// Remove all existing state classes
265+
element.classList.remove('warning', 'error');
266+
267+
// Add appropriate class based on percentage
268+
if (percentage < 50) {
269+
element.classList.add('error');
270+
} else if (percentage < 95) {
271+
element.classList.add('warning');
272+
}
273+
});
274+
}
275+
253276
// ==========================================
254277
// INITIALIZATION
255278
// ==========================================
@@ -258,8 +281,11 @@ function copyReplayCommand(event) {
258281
* Initialize all functionality when DOM is loaded
259282
*/
260283
document.addEventListener('DOMContentLoaded', function() {
261-
// Initialize theme
284+
// Initialize theme on page load
262285
initializeTheme();
286+
287+
// Initialize success rate styling
288+
updateSuccessRateStyles();
263289

264290
// Initialize chart (landing page only)
265291
initializeChart();

src/main/resources/styles.css

Lines changed: 33 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -245,23 +245,53 @@ body.dark-theme .stat-item.primary .stat-value { color: #BC8CFF; }
245245
align-items: center;
246246
text-align: center;
247247
padding: 0.5rem 1rem;
248-
background: rgba(16, 185, 129, 0.1);
249248
border-radius: 0.5rem;
249+
transition: all 0.3s ease;
250+
}
251+
252+
/* Success state (green) - above 75% */
253+
.success-rate-compact {
254+
background: rgba(16, 185, 129, 0.1);
250255
border: 1px solid rgba(16, 185, 129, 0.2);
251256
}
252257

258+
.success-rate-compact .rate-value,
259+
.success-rate-compact .rate-label {
260+
color: var(--success);
261+
}
262+
263+
/* Warning state (orange) - between 50% and 75% */
264+
.success-rate-compact.warning {
265+
background: rgba(245, 158, 11, 0.1);
266+
border: 1px solid rgba(245, 158, 11, 0.2);
267+
}
268+
269+
.success-rate-compact.warning .rate-value,
270+
.success-rate-compact.warning .rate-label {
271+
color: #f59e0b;
272+
}
273+
274+
/* Error state (red) - below 50% */
275+
.success-rate-compact.error {
276+
background: rgba(239, 68, 68, 0.1);
277+
border: 1px solid rgba(239, 68, 68, 0.2);
278+
}
279+
280+
.success-rate-compact.error .rate-value,
281+
.success-rate-compact.error .rate-label {
282+
color: #ef4444;
283+
}
284+
253285
.success-rate-compact .rate-value {
254286
font-size: 1.25rem;
255287
font-weight: 700;
256-
color: var(--success);
257288
font-family: 'JetBrains Mono', monospace;
258289
line-height: 1;
259290
}
260291

261292
.success-rate-compact .rate-label {
262293
font-size: 0.75rem;
263294
font-weight: 500;
264-
color: var(--success);
265295
margin-top: 0.25rem;
266296
}
267297

src/main/resources/summary.mustache

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@
5959
<span class="stat-label">Failed</span>
6060
</div>
6161
<div class="stat-divider"></div>
62-
<div class="success-rate-compact">
62+
<div class="success-rate-compact" data-success="{{SUCCESS_PERCENTAGE}}" data-percentage="{{SUCCESS_PERCENTAGE}}">
6363
<span class="rate-value">{{SUCCESS_PERCENTAGE}}%</span>
6464
<span class="rate-label">Success</span>
6565
</div>

0 commit comments

Comments
 (0)