| 38 | |
| 39 | // Update the entire dashboard and components |
| 40 | function updateUI() { |
| 41 | if (!$pageBody) return; |
| 42 | |
| 43 | // 1. Update stats |
| 44 | if ($statsTotal) $statsTotal.textContent = currentRunnerState.stats.total; |
| 45 | if ($statsPassed) $statsPassed.textContent = currentRunnerState.stats.passed; |
| 46 | if ($statsFailed) $statsFailed.textContent = currentRunnerState.stats.failed; |
| 47 | if ($statsSkipped) |
| 48 | $statsSkipped.textContent = currentRunnerState.stats.skipped; |
| 49 | |
| 50 | const effectiveTotal = |
| 51 | currentRunnerState.stats.total - currentRunnerState.stats.skipped; |
| 52 | const rate = |
| 53 | effectiveTotal > 0 |
| 54 | ? ((currentRunnerState.stats.passed / effectiveTotal) * 100).toFixed(1) |
| 55 | : "0.0"; |
| 56 | if ($statsSuccessRate) $statsSuccessRate.textContent = rate + "%"; |
| 57 | |
| 58 | // 2. Update progress bar |
| 59 | if ($progressBar) { |
| 60 | const total = currentRunnerState.stats.total; |
| 61 | const completed = |
| 62 | currentRunnerState.stats.passed + |
| 63 | currentRunnerState.stats.failed + |
| 64 | currentRunnerState.stats.skipped; |
| 65 | const pct = total > 0 ? (completed / total) * 100 : 0; |
| 66 | $progressBar.style.width = pct + "%"; |
| 67 | } |
| 68 | |
| 69 | // 3. Update Run button status |
| 70 | if ($runBtn) { |
| 71 | if (currentRunnerState.status === "running") { |
| 72 | $runBtn.classList.add("running"); |
| 73 | $runBtn.disabled = true; |
| 74 | $runBtn.innerHTML = '<span class="icon loader"></span> Running...'; |
| 75 | } else { |
| 76 | $runBtn.classList.remove("running"); |
| 77 | $runBtn.disabled = false; |
| 78 | $runBtn.innerHTML = |
| 79 | '<span class="icon play_circle_filled"></span> Run Tests'; |
| 80 | } |
| 81 | } |
| 82 | |
| 83 | // 4. Render/Update each suite card |
| 84 | currentRunnerState.suites.forEach((suite) => { |
| 85 | updateSuiteElement(suite); |
| 86 | }); |
| 87 | } |
| 88 | |
| 89 | function getOrCreateSuiteElement(suite) { |
| 90 | if (suiteElementsMap.has(suite.name)) { |