Press n or j to go to the next uncovered block, b, p or k for the previous block.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 | // Helper function to get coverage color class based on percentage function getCoverageClass(percentage) { const pct = parseFloat(percentage); if (pct >= 95) return 'coverage-excellent'; if (pct >= 80) return 'coverage-good'; if (pct >= 60) return 'coverage-fair'; return 'coverage-poor'; } // Simple browser-compatible renderToString function function renderToString(component) { if (!component || typeof component !== 'object') return ''; function renderElement(element) { if (typeof element === 'string') return element; if (typeof element === 'number') return String(element); if (!element || typeof element !== 'object') return ''; for (const tag in element) { const props = element[tag]; if (typeof props === 'string') return `<${tag}>${props}</${tag}>`; if (typeof props === 'number') return `<${tag}>${props}</${tag}>`; let html = `<${tag}`; if (props.className) html += ` class="${props.className}"`; if (props.id) html += ` id="${props.id}"`; if (props.style) html += ` style="${props.style}"`; html += '>'; if (props.text) html += props.text; if (props.html) html += props.html; if (props.children) { html += props.children.map(renderElement).join(''); } html += `</${tag}>`; return html; } return ''; } return renderElement(component); } async function loadCoverageData() { try { const response = await fetch('/coverage-summary.json'); const data = await response.json(); // Create coverage summary component using Coherent.js const summaryEl = document.getElementById('coverage-data'); if (summaryEl && data.total) { const summaryComponent = { div: { className: 'coverage-stats', children: [ { div: { className: 'stat', children: [ { div: { className: `stat-value ${getCoverageClass(data.total.lines.pct)}`, text: `${data.total.lines.pct}%` } }, { div: { className: 'stat-label', text: `Lines (${data.total.lines.covered}/${data.total.lines.total})` } } ] } }, { div: { className: 'stat', children: [ { div: { className: `stat-value ${getCoverageClass(data.total.functions.pct)}`, text: `${data.total.functions.pct}%` } }, { div: { className: 'stat-label', text: `Functions (${data.total.functions.covered}/${data.total.functions.total})` } } ] } }, { div: { className: 'stat', children: [ { div: { className: `stat-value ${getCoverageClass(data.total.branches.pct)}`, text: `${data.total.branches.pct}%` } }, { div: { className: 'stat-label', text: `Branches (${data.total.branches.covered}/${data.total.branches.total})` } } ] } } ] } }; summaryEl.innerHTML = renderToString(summaryComponent); } // Update package coverage table using Coherent.js const tableEl = document.getElementById('package-coverage-table'); if (tableEl && data.packages) { // Check if we have meaningful package data (more than one package or different from total) const hasMultiplePackages = data.packages.length > 1; const hasUniquePackageData = data.packages.some(pkg => pkg.lines.pct !== data.total.lines.pct || pkg.functions.pct !== data.total.functions.pct || pkg.branches.pct !== data.total.branches.pct ); if (hasMultiplePackages || hasUniquePackageData) { const packageComponent = { div: { className: 'coverage-grid', children: data.packages.map(pkg => ({ div: { className: 'coverage-item', children: [ { div: { className: 'package-name', children: [{ strong: { text: pkg.name } }] } }, { div: { className: 'coverage-metrics', children: [ { div: { className: 'metric', children: [ { div: { className: 'metric-label', text: 'Lines' } }, { div: { className: `coverage-cell ${getCoverageClass(pkg.lines.pct)}`, text: `${pkg.lines.pct}%` } }, { div: { className: 'coverage-detail', text: `(${pkg.lines.covered}/${pkg.lines.total})` } } ] } }, { div: { className: 'metric', children: [ { div: { className: 'metric-label', text: 'Functions' } }, { div: { className: `coverage-cell ${getCoverageClass(pkg.functions.pct)}`, text: `${pkg.functions.pct}%` } }, { div: { className: 'coverage-detail', text: `(${pkg.functions.covered}/${pkg.functions.total})` } } ] } }, { div: { className: 'metric', children: [ { div: { className: 'metric-label', text: 'Branches' } }, { div: { className: `coverage-cell ${getCoverageClass(pkg.branches.pct)}`, text: `${pkg.branches.pct}%` } }, { div: { className: 'coverage-detail', text: `(${pkg.branches.covered}/${pkg.branches.total})` } } ] } } ] } } ] } })) } }; tableEl.innerHTML = renderToString(packageComponent); } else { // Hide the package section if it's just duplicating the global data const noteComponent = { p: { className: 'coverage-note', text: 'Package-level coverage data is the same as the overall project coverage shown above.' } }; tableEl.innerHTML = renderToString(noteComponent); } } } catch (error) { console.error('Failed to load coverage data:', error); const summaryEl = document.getElementById('coverage-data'); if (summaryEl) { const errorComponent = { p: { className: 'error', text: 'Failed to load coverage data. Please try again later.' } }; summaryEl.innerHTML = renderToString(errorComponent); } } } // Load coverage data when page loads if (typeof window !== 'undefined') { loadCoverageData(); } |