@jesdi/skills 0.0.84 → 0.0.86
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/skills/implement-spec/ARCHITECTURE.md +9 -2
- package/skills/implement-spec/README.md +2 -2
- package/skills/implement-spec/driver.py +34 -8
- package/skills/implement-spec/driver_agents.py +41 -13
- package/skills/implement-spec/driver_final.py +21 -2
- package/skills/implement-spec/driver_fixloop.py +4 -3
- package/skills/implement-spec/prompts/pr-body.md +1 -0
- package/skills/implement-spec/tests/test_agents.py +20 -3
- package/skills/implement-spec/tests/test_driver.py +17 -10
- package/skills/implement-spec/tests/test_landing.py +2 -2
- package/skills/implement-spec/tests/test_lenses.py +31 -0
- package/skills/implement-spec/tests/test_tidy.py +2 -0
- package/skills/implement-spec/tests/test_walk.py +2 -2
- package/skills/test-weigh-in/dashboard.html +185 -27
- package/skills/test-weigh-in/rules.toml +18 -0
- package/skills/test-weigh-in/tests/browser_driver.py +161 -0
- package/skills/test-weigh-in/tests/conftest.py +8 -1
- package/skills/test-weigh-in/tests/latency_probe.py +96 -0
- package/skills/test-weigh-in/tests/layout_page.py +37 -0
- package/skills/test-weigh-in/tests/metric_page.py +56 -0
- package/skills/test-weigh-in/tests/overlap_page.py +60 -0
- package/skills/test-weigh-in/tests/rules_fixture.py +3 -1
- package/skills/test-weigh-in/tests/sorted_map_page.py +35 -0
- package/skills/test-weigh-in/tests/test_brittleness.py +5 -0
- package/skills/test-weigh-in/tests/test_dashboard_layout.py +103 -0
- package/skills/test-weigh-in/tests/test_scoring.py +10 -0
- package/skills/test-weigh-in/weigh.py +25 -15
- package/skills/test-weigh-in/weigh_dashboard.py +9 -1
- package/skills/test-weigh-in/weigh_rules.py +3 -0
- package/skills-manifest.json +5 -5
|
@@ -1,18 +1,54 @@
|
|
|
1
1
|
<!doctype html>
|
|
2
2
|
<html lang="en"><head><meta charset="utf-8"><title>test-weigh-in</title>
|
|
3
3
|
<style>
|
|
4
|
-
body{font:14px system-ui,sans-serif;margin:24px;color:#222}
|
|
5
|
-
#gauges{display:
|
|
6
|
-
.gauge{
|
|
4
|
+
body{font:14px system-ui,sans-serif;margin:24px;color:#222;overflow-wrap:break-word}
|
|
5
|
+
#gauges{display:grid;grid-template-columns:repeat(auto-fit,minmax(150px,1fr));gap:0 12px;margin:16px 0}
|
|
6
|
+
.gauge{grid-row:span 3;display:grid;grid-template-rows:subgrid;row-gap:4px;align-content:start;margin-bottom:12px;border:2px solid #ccc;border-radius:8px;padding:12px;background:#fff;text-align:center;cursor:pointer;font:inherit}
|
|
7
|
+
.gauge>*{align-self:start}
|
|
8
|
+
.gauge-status{font-size:12px;line-height:1.3}
|
|
9
|
+
/* one row of tabs on a rule; it scrolls sideways when the row is wider than the screen */
|
|
10
|
+
.tabs{display:flex;gap:4px;overflow-x:auto;border-bottom:1px solid #ccc;scrollbar-width:thin}
|
|
11
|
+
.tabs>button{flex:none;font:inherit;padding:4px 12px;border:1px solid #ccc;border-bottom:3px solid transparent;border-radius:6px 6px 0 0;background:#f3f4f6;color:#222;cursor:pointer;white-space:nowrap}
|
|
12
|
+
.tabs>button[aria-pressed=true]{background:#2563eb;color:#fff;border-bottom-color:#1e40af;font-weight:600}
|
|
13
|
+
@media (max-width:600px){.tabs{gap:2px}.tabs>button{padding:4px 7px}}
|
|
14
|
+
button:focus-visible{outline:3px solid #f59e0b;outline-offset:2px}
|
|
15
|
+
#details table{width:100%}
|
|
16
|
+
#details tr+tr{border-top:1px solid #e5e7eb}
|
|
7
17
|
.gauge[aria-pressed=true]{border-color:#2563eb}
|
|
8
18
|
.score{display:block;font-size:32px;font-weight:600}
|
|
9
|
-
#banner{background:#fef2f2;color:#991b1b;padding:8px 12px;border-radius:6px}
|
|
19
|
+
#banner{background:#fef2f2;color:#991b1b;padding:8px 12px;border-radius:6px;margin-bottom:0}
|
|
20
|
+
#failing{border:1px solid #fecaca;border-top:0;border-radius:0 0 6px 6px;padding:4px 12px;margin-bottom:16px}
|
|
21
|
+
#failing p{margin:4px 0}
|
|
22
|
+
#failing:empty{display:none}
|
|
23
|
+
#banner:has(+#failing:not(:empty)){border-radius:6px 6px 0 0}
|
|
10
24
|
.flag{display:block;color:#92400e}
|
|
11
25
|
table{border-collapse:collapse}td,th{padding:4px 12px;text-align:left}
|
|
26
|
+
/* a test identity: breaks after / :: . _ (see ident), anywhere only when one part is wider than the line */
|
|
27
|
+
.id{font:13px ui-monospace,SFMono-Regular,Menlo,monospace;overflow-wrap:anywhere}
|
|
28
|
+
/* the anchors column takes the spare width, so a metric and its value stay side by side */
|
|
29
|
+
@media (min-width:601px){#details th:nth-child(-n+3),#details td:nth-child(-n+3):not([colspan]){width:1%;white-space:nowrap}}
|
|
30
|
+
td:first-child,th:first-child{padding-left:0}
|
|
31
|
+
@media (max-width:600px){td,th{padding:4px 6px}td:last-child,th:last-child{padding-right:0}#details td:first-child{min-width:7em}}
|
|
32
|
+
input[type=search]{font:inherit;padding:6px 10px;border:1px solid #ccc;border-radius:6px;width:100%;max-width:24rem;box-sizing:border-box}
|
|
33
|
+
.pair{display:grid;grid-template-columns:8em minmax(0,1fr);gap:4px 12px;padding:8px 0;border-bottom:1px solid #e5e7eb}
|
|
34
|
+
.pair>strong{grid-row:span 3}
|
|
35
|
+
.pair hr{width:100%;border:0;border-top:1px dashed #d1d5db;margin:0}
|
|
36
|
+
@media (max-width:600px){.pair{grid-template-columns:minmax(0,1fr)}.pair>strong{grid-row:auto}}
|
|
37
|
+
.map{display:grid;gap:16px;align-items:start}
|
|
38
|
+
.map svg{display:block;width:100%;height:auto}
|
|
39
|
+
.map-side p{margin:0 0 8px}
|
|
40
|
+
.similar{display:grid;grid-template-columns:minmax(0,1fr) auto;gap:4px 12px}
|
|
41
|
+
.similar>div{display:grid;grid-template-columns:subgrid;grid-column:1/-1}
|
|
42
|
+
.similar>.head{font-weight:600}
|
|
43
|
+
.similar>div+div+div{border-top:1px solid #f3f4f6;padding-top:4px}
|
|
44
|
+
.similar .num{text-align:right;font-variant-numeric:tabular-nums}
|
|
45
|
+
/* wide screens: the selection sits beside the map and stays in view while the map scrolls */
|
|
46
|
+
@media (min-width:900px){.map{grid-template-columns:minmax(0,1fr) 22rem}.map-side{position:sticky;top:0;max-height:100vh;overflow-y:auto}}
|
|
12
47
|
</style></head><body>
|
|
13
48
|
<h1>test-weigh-in</h1>
|
|
14
49
|
<p data-testid="inventory" id="inventory"></p>
|
|
15
50
|
<p data-testid="banner" id="banner"></p>
|
|
51
|
+
<div data-testid="failing" id="failing"></div>
|
|
16
52
|
<div id="gauges"></div>
|
|
17
53
|
<section data-testid="details" id="details"></section>
|
|
18
54
|
<script>
|
|
@@ -20,15 +56,46 @@ const data = __DATA__;
|
|
|
20
56
|
const shown = (s) => Math.min(99, Math.max(1, Math.round(s)));
|
|
21
57
|
const el = (tag, text, parent) => { const e = document.createElement(tag); e.textContent = text; parent.appendChild(e); return e; };
|
|
22
58
|
const fmt = (n) => String(Math.round(n * 100) / 100);
|
|
59
|
+
// words that belong together stay on one line: "71.3 %", "target ≤ 60 s"
|
|
60
|
+
const nb = (...parts) => parts.filter((x) => x !== '').join('\u00a0');
|
|
61
|
+
// ident marks an element whose text is a test identity. It gets break opportunities after / :: . or _ (not inside
|
|
62
|
+
// "name.py"), at least 12 characters apart, so it wraps between its parts; overflow-wrap breaks a part only when it is
|
|
63
|
+
// wider than the line. The breaks are added just before the next paint, to the identities still on the page then:
|
|
64
|
+
// paging through thousands of pairs in one go never builds the breaks of pages nobody saw.
|
|
65
|
+
let unbroken = [];
|
|
66
|
+
const addBreaks = () => {
|
|
67
|
+
const ids = unbroken; unbroken = [];
|
|
68
|
+
ids.forEach((s) => {
|
|
69
|
+
if (!s.isConnected) return;
|
|
70
|
+
const parts = [];
|
|
71
|
+
let chunk = '';
|
|
72
|
+
for (const part of s.textContent.split(/(?<=\/|::|\.(?!py\b)|_)/)) if ((chunk += part).length >= 12) { parts.push(chunk); chunk = ''; }
|
|
73
|
+
if (chunk) parts.push(chunk);
|
|
74
|
+
s.replaceChildren();
|
|
75
|
+
parts.forEach((part, i) => { if (i) s.appendChild(document.createElement('wbr')); s.appendChild(document.createTextNode(part)); });
|
|
76
|
+
});
|
|
77
|
+
};
|
|
78
|
+
const ident = (e) => {
|
|
79
|
+
e.className = 'id';
|
|
80
|
+
if (!unbroken.length) (window.requestAnimationFrame || setTimeout)(addBreaks);
|
|
81
|
+
unbroken.push(e);
|
|
82
|
+
return e;
|
|
83
|
+
};
|
|
84
|
+
// a block naming one test, optionally followed by a note such as "(skipped)" or "(Real sleep, 1.02 s)", whose numbers keep their units
|
|
85
|
+
const testLine = (tag, test, parent, note) => {
|
|
86
|
+
if (!note) return ident(el(tag, test, parent));
|
|
87
|
+
const e = el(tag, '', parent); ident(el('span', test, e));
|
|
88
|
+
e.append(' ' + note.replace(/(\d) (?=s\b|%)/g, '$1\u00a0'));
|
|
89
|
+
return e;
|
|
90
|
+
};
|
|
23
91
|
let selected = 0, tab = 'Metrics', picked = null;
|
|
24
92
|
const NS = 'http://www.w3.org/2000/svg';
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
// ponytail: all pairs per pass, quadratic; a spatial grid if maps of thousands of dots get slow
|
|
93
|
+
// tests with the same or nearly the same coverage land on or near one place: push apart each pair of dots that
|
|
94
|
+
// overlaps until none does, so every dot stays clickable; same data, same pushes, same map on every load.
|
|
95
|
+
// Computed once, on first opening: selecting a dot never moves one.
|
|
96
|
+
// ponytail: all pairs per pass, quadratic; a spatial grid if maps of thousands of dots get slow
|
|
97
|
+
let placed = null;
|
|
98
|
+
function place() {
|
|
32
99
|
const dots = data.map.map((d) => ({ d, cx: 20 + d.x * 360, cy: 20 + d.y * 260, r: 4 + Math.min(10, d.runtime * 4) }));
|
|
33
100
|
for (let pass = 0, moved = true; moved && pass < 200; pass++) {
|
|
34
101
|
moved = false;
|
|
@@ -42,70 +109,161 @@ function drawMap(parent) {
|
|
|
42
109
|
moved = true;
|
|
43
110
|
}));
|
|
44
111
|
}
|
|
45
|
-
// the view grows to hold every ring
|
|
112
|
+
// the view grows to hold every ring; the drawing then scales to the width it gets, dots and gaps alike
|
|
46
113
|
const x0 = Math.min(0, ...dots.map((o) => o.cx - o.r - 2)), y0 = Math.min(0, ...dots.map((o) => o.cy - o.r - 2));
|
|
47
114
|
const w = Math.max(400, ...dots.map((o) => o.cx + o.r + 2)) - x0, h = Math.max(300, ...dots.map((o) => o.cy + o.r + 2)) - y0;
|
|
48
|
-
|
|
115
|
+
return { dots, x0, y0, w, h };
|
|
116
|
+
}
|
|
117
|
+
function drawMap(parent) {
|
|
118
|
+
const { dots, x0, y0, w, h } = placed || (placed = place());
|
|
119
|
+
const legend = el('p', 'Colour shows unique lines: grey 0, amber 1–3, green 4+. Dot size shows runtime: slower tests are larger. Hover a dot for its test; click it to select.', parent);
|
|
120
|
+
legend.setAttribute('data-testid', 'map-legend');
|
|
121
|
+
const box = el('div', '', parent); box.className = 'map';
|
|
122
|
+
const svg = document.createElementNS(NS, 'svg');
|
|
123
|
+
box.appendChild(svg);
|
|
124
|
+
svg.setAttribute('viewBox', `${x0} ${y0} ${w} ${h}`);
|
|
125
|
+
const circles = new Map();
|
|
49
126
|
dots.forEach(({ d, cx, cy, r }) => {
|
|
50
127
|
const c = document.createElementNS(NS, 'circle');
|
|
51
128
|
c.setAttribute('cx', cx); c.setAttribute('cy', cy);
|
|
52
129
|
c.setAttribute('r', r);
|
|
53
130
|
c.setAttribute('fill', d.unique === 0 ? '#9ca3af' : d.unique < 4 ? '#f59e0b' : '#16a34a');
|
|
54
|
-
c.setAttribute('stroke', picked && (picked === d || near.has(d.test)) ? '#2563eb' : 'none');
|
|
55
131
|
c.setAttribute('stroke-width', '3');
|
|
56
132
|
c.setAttribute('data-testid', 'map-dot'); c.dataset.test = d.test;
|
|
57
|
-
|
|
58
|
-
|
|
133
|
+
el('title', d.test, c);
|
|
134
|
+
circles.set(d.test, c);
|
|
135
|
+
c.onclick = () => pick(d);
|
|
59
136
|
svg.appendChild(c);
|
|
60
137
|
});
|
|
61
|
-
const
|
|
62
|
-
|
|
138
|
+
const side = el('div', '', box); side.className = 'map-side';
|
|
139
|
+
const hint = el('p', 'Click a dot to see its test and the tests that cover nearly the same lines.', side);
|
|
140
|
+
const pickedName = el('p', '', side); pickedName.setAttribute('data-testid', 'map-picked');
|
|
141
|
+
const list = el('div', '', side); list.setAttribute('data-testid', 'map-similar');
|
|
142
|
+
let lit = [];
|
|
143
|
+
// selection touches only the previous and the new highlights and the neighbour list, never the placement
|
|
144
|
+
const pick = (d) => {
|
|
145
|
+
picked = d;
|
|
146
|
+
lit.forEach((c) => { c.setAttribute('stroke', 'none'); delete c.dataset.highlighted; });
|
|
147
|
+
const sims = d.similar.slice().sort((a, b) => b[1] - a[1] || (a[0] < b[0] ? -1 : a[0] > b[0] ? 1 : 0));
|
|
148
|
+
lit = [d.test, ...sims.map(([n]) => n)].map((n) => circles.get(n)).filter(Boolean);
|
|
149
|
+
lit.forEach((c) => { c.setAttribute('stroke', '#2563eb'); c.dataset.highlighted = 'true'; });
|
|
150
|
+
hint.hidden = true;
|
|
151
|
+
pickedName.replaceChildren();
|
|
152
|
+
el('strong', 'Selected', pickedName); el('br', '', pickedName); ident(el('span', d.test, pickedName));
|
|
153
|
+
list.replaceChildren();
|
|
154
|
+
if (!sims.length) { el('p', 'No test covers similar lines.', list); return; }
|
|
155
|
+
el('p', sims.length + (sims.length === 1 ? ' similar test' : ' similar tests') + ', highest Jaccard similarity first; 1.00 means identical coverage', list);
|
|
156
|
+
// built off the page and attached once: one insertion instead of hundreds keeps a 148-neighbour selection fast
|
|
157
|
+
const table = document.createElement('div'); table.className = 'similar';
|
|
158
|
+
const head = el('div', '', table); head.className = 'head';
|
|
159
|
+
el('span', 'Test', head); el('span', 'Jaccard', head).className = 'num';
|
|
160
|
+
sims.forEach(([n, s]) => {
|
|
161
|
+
const row = el('div', '', table); row.setAttribute('data-testid', 'map-similar-item');
|
|
162
|
+
ident(el('span', n, row)); row.append(' '); el('span', s.toFixed(2), row).className = 'num';
|
|
163
|
+
});
|
|
164
|
+
list.appendChild(table);
|
|
165
|
+
};
|
|
166
|
+
if (picked) pick(picked);
|
|
167
|
+
}
|
|
168
|
+
const PAGE = 100;
|
|
169
|
+
// highest similarity first; ties by identities, so the order does not depend on how the pairs arrive
|
|
170
|
+
const byIdentity = (o) => o.tests.slice().sort().join('\n');
|
|
171
|
+
const ranked = data.overlaps.slice().sort((a, b) => b.jaccard - a.jaccard || (byIdentity(a) < byIdentity(b) ? -1 : byIdentity(a) > byIdentity(b) ? 1 : 0));
|
|
172
|
+
let ovQuery = '', ovPage = 0;
|
|
173
|
+
function drawOverlaps(parent) {
|
|
174
|
+
const box = el('div', '', parent);
|
|
175
|
+
const input = document.createElement('input');
|
|
176
|
+
input.type = 'search'; input.placeholder = 'Search test identities'; input.value = ovQuery; input.setAttribute('aria-label', 'Search overlapping tests');
|
|
177
|
+
input.setAttribute('data-testid', 'overlap-search');
|
|
178
|
+
box.appendChild(input);
|
|
179
|
+
const out = el('div', '', box);
|
|
180
|
+
const draw = () => {
|
|
181
|
+
out.replaceChildren();
|
|
182
|
+
const q = ovQuery.toLowerCase();
|
|
183
|
+
const hits = q ? ranked.filter((o) => o.tests.some((t) => t.toLowerCase().includes(q))) : ranked;
|
|
184
|
+
const pages = Math.max(1, Math.ceil(hits.length / PAGE));
|
|
185
|
+
ovPage = Math.min(ovPage, pages - 1);
|
|
186
|
+
el('p', hits.length.toLocaleString('en-US') + (hits.length === 1 ? ' pair' : ' pairs'), out).setAttribute('data-testid', 'overlap-count');
|
|
187
|
+
if (!hits.length) el('p', 'No pair matches this search.', out).setAttribute('data-testid', 'overlap-empty');
|
|
188
|
+
// a page is built off the page and attached once: one insertion instead of hundreds
|
|
189
|
+
const rows = document.createDocumentFragment();
|
|
190
|
+
hits.slice(ovPage * PAGE, (ovPage + 1) * PAGE).forEach((o) => {
|
|
191
|
+
const row = el('div', '', rows);
|
|
192
|
+
row.setAttribute('data-testid', 'overlap-pair'); row.className = 'pair';
|
|
193
|
+
el('strong', 'Jaccard ' + o.jaccard.toFixed(2), row);
|
|
194
|
+
// the two tests on their own lines, a dashed rule between them
|
|
195
|
+
o.tests.forEach((t, k) => { if (k) el('hr', '', row); testLine('div', t, row).setAttribute('data-testid', 'overlap-test'); });
|
|
196
|
+
});
|
|
197
|
+
out.appendChild(rows);
|
|
198
|
+
const nav = el('p', '', out);
|
|
199
|
+
const step = (text, d, id) => { const b = el('button', text, nav); b.setAttribute('data-testid', id); b.disabled = ovPage + d < 0 || ovPage + d >= pages; b.onclick = () => { ovPage += d; draw(); }; };
|
|
200
|
+
step('Previous', -1, 'overlap-prev');
|
|
201
|
+
el('span', ' Page ' + (ovPage + 1) + ' of ' + pages + ' ', nav);
|
|
202
|
+
step('Next', 1, 'overlap-next');
|
|
203
|
+
};
|
|
204
|
+
input.oninput = () => { ovQuery = input.value; ovPage = 0; draw(); };
|
|
205
|
+
draw();
|
|
63
206
|
}
|
|
64
207
|
function render() {
|
|
65
208
|
document.getElementById('inventory').textContent = data.inventory;
|
|
66
209
|
const banner = document.getElementById('banner');
|
|
67
210
|
if (banner) { if (data.banner) banner.textContent = data.banner; else banner.remove(); }
|
|
211
|
+
const failing = document.getElementById('failing'); failing.replaceChildren();
|
|
212
|
+
data.failing.forEach((n) => testLine('p', n, failing).setAttribute('data-testid', 'failing-test'));
|
|
68
213
|
const gauges = document.getElementById('gauges'), details = document.getElementById('details');
|
|
69
214
|
gauges.replaceChildren(); details.replaceChildren();
|
|
70
215
|
data.pillars.forEach((p, i) => {
|
|
71
216
|
const g = el('button', '', gauges);
|
|
72
217
|
g.className = 'gauge'; g.dataset.testid = 'gauge'; g.setAttribute('data-testid', 'gauge');
|
|
73
218
|
g.setAttribute('aria-pressed', i === selected);
|
|
74
|
-
el('span', p.name, g);
|
|
219
|
+
el('span', p.name, g).setAttribute('data-testid', 'gauge-title');
|
|
75
220
|
el('span', p.score === null ? '–' : shown(p.score), g).className = 'score';
|
|
76
|
-
|
|
221
|
+
const status = el('span', p.partial ? 'partial: ' + p.metrics.length + ' of ' + p.total + ' metrics measured' : 'all ' + p.total + ' metrics measured', g);
|
|
222
|
+
status.className = 'gauge-status' + (p.partial ? ' flag' : ''); status.setAttribute('data-testid', 'gauge-status');
|
|
77
223
|
g.onclick = () => { selected = i; tab = 'Metrics'; picked = null; render(); };
|
|
78
224
|
});
|
|
79
225
|
const p = data.pillars[selected];
|
|
80
226
|
el('h2', p.name, details);
|
|
81
227
|
const names = ['Metrics', 'Worst tests', 'Smells', ...(p.key === 'economy' ? ['Overlaps', 'Map'] : [])];
|
|
82
|
-
|
|
228
|
+
const tabs = el('div', '', details); tabs.className = 'tabs';
|
|
229
|
+
names.forEach((n) => { const b = el('button', n, tabs); b.setAttribute('aria-pressed', n === tab); b.onclick = () => { tab = n; picked = null; render(); }; });
|
|
83
230
|
el('h3', tab, details);
|
|
84
231
|
if (tab === 'Metrics') {
|
|
232
|
+
if (!p.metrics.length) el('p', 'No metrics were measured for this pillar.', details);
|
|
85
233
|
const t = el('table', '', details);
|
|
234
|
+
const head = el('tr', '', t);
|
|
235
|
+
['Metric', 'Value', 'Score', 'Anchors'].forEach((h) => el('th', h, head));
|
|
86
236
|
p.metrics.forEach((m) => {
|
|
237
|
+
const u = m.unit || '', up = m.target < m.bad;
|
|
238
|
+
const r = el('tr', '', t);
|
|
239
|
+
el('td', m.name, r); el('td', nb(fmt(m.value), u), r); el('td', String(shown(m.score)), r);
|
|
240
|
+
el('td', nb('target', up ? '≤' : '≥', fmt(m.target), u) + ', ' + nb('bad', up ? '≥' : '≤', fmt(m.bad), u), r);
|
|
241
|
+
});
|
|
242
|
+
p.missing.forEach((m) => {
|
|
87
243
|
const r = el('tr', '', t);
|
|
88
|
-
|
|
244
|
+
// no value, so no score or anchors: the reason takes their place
|
|
245
|
+
el('td', m.name, r); el('td', 'unmeasured: ' + (m.reason || 'unavailable (cause not recorded)'), r).colSpan = 3;
|
|
89
246
|
});
|
|
247
|
+
el('p', 'Scores are rounded and shown as 1 to 99, not 100 or 0. A metric at its target scores 90 and at its bad anchor 10; the logistic curve between them never reaches 0 or 100.', details);
|
|
90
248
|
if (data.skipped.length) {
|
|
91
249
|
el('h3', 'Skipped tests', details);
|
|
92
|
-
data.skipped.forEach((n) =>
|
|
250
|
+
data.skipped.forEach((n) => testLine('p', n, details, '(skipped)'));
|
|
93
251
|
}
|
|
94
252
|
if (p.key === 'economy' && data.insufficient.length) {
|
|
95
253
|
el('h3', 'Insufficient evidence (fewer than 2 sampled mutants on their lines)', details);
|
|
96
|
-
data.insufficient.forEach((n) =>
|
|
254
|
+
data.insufficient.forEach((n) => testLine('p', n, details));
|
|
97
255
|
}
|
|
98
256
|
} else if (tab === 'Worst tests') {
|
|
99
|
-
p.worst.forEach((w) =>
|
|
257
|
+
p.worst.forEach((w) => testLine('p', w.test, details, '(' + w.reason + ')').setAttribute('data-testid', 'worst-test'));
|
|
100
258
|
} else if (tab === 'Smells') {
|
|
101
259
|
const smells = Object.entries(p.smells);
|
|
102
260
|
if (!smells.length) el('p', 'No test has a smell of this pillar.', details);
|
|
103
261
|
smells.forEach(([smell, tests]) => {
|
|
104
262
|
el('h4', smell + ' (' + tests.length + (tests.length === 1 ? ' test)' : ' tests)'), details).setAttribute('data-testid', 'smell');
|
|
105
|
-
tests.forEach((n) =>
|
|
263
|
+
tests.forEach((n) => testLine('p', n, details).setAttribute('data-testid', 'smell-test'));
|
|
106
264
|
});
|
|
107
265
|
} else if (tab === 'Overlaps') {
|
|
108
|
-
|
|
266
|
+
drawOverlaps(details);
|
|
109
267
|
} else if (tab === 'Map') drawMap(details);
|
|
110
268
|
}
|
|
111
269
|
render();
|
|
@@ -9,12 +9,14 @@ name = "Protection against regressions"
|
|
|
9
9
|
|
|
10
10
|
[pillars.regression.metrics.mutation_score]
|
|
11
11
|
name = "Mutation score"
|
|
12
|
+
unit = "%"
|
|
12
13
|
weight = 0.45
|
|
13
14
|
target = 80
|
|
14
15
|
bad = 40
|
|
15
16
|
|
|
16
17
|
[pillars.regression.metrics.branch_coverage]
|
|
17
18
|
name = "Branch coverage"
|
|
19
|
+
unit = "%"
|
|
18
20
|
weight = 0.25
|
|
19
21
|
target = 90
|
|
20
22
|
bad = 50
|
|
@@ -22,6 +24,7 @@ partial_weight = 0.6
|
|
|
22
24
|
|
|
23
25
|
[pillars.regression.metrics.hollow_tests]
|
|
24
26
|
name = "Hollow tests"
|
|
27
|
+
unit = "%"
|
|
25
28
|
weight = 0.2
|
|
26
29
|
target = 0
|
|
27
30
|
bad = 10
|
|
@@ -29,6 +32,7 @@ partial_weight = 0.4
|
|
|
29
32
|
|
|
30
33
|
[pillars.regression.metrics.pseudo_tested_functions]
|
|
31
34
|
name = "Pseudo-tested functions"
|
|
35
|
+
unit = "%"
|
|
32
36
|
weight = 0.1
|
|
33
37
|
target = 0
|
|
34
38
|
bad = 15
|
|
@@ -38,24 +42,28 @@ name = "Resistance to refactoring"
|
|
|
38
42
|
|
|
39
43
|
[pillars.refactoring.metrics.brittle_test_files]
|
|
40
44
|
name = "Brittle test files"
|
|
45
|
+
unit = "%"
|
|
41
46
|
weight = 0.4
|
|
42
47
|
target = 15
|
|
43
48
|
bad = 60
|
|
44
49
|
|
|
45
50
|
[pillars.refactoring.metrics.private_access]
|
|
46
51
|
name = "Tests with private access"
|
|
52
|
+
unit = "%"
|
|
47
53
|
weight = 0.25
|
|
48
54
|
target = 2
|
|
49
55
|
bad = 30
|
|
50
56
|
|
|
51
57
|
[pillars.refactoring.metrics.mock_heavy]
|
|
52
58
|
name = "Mock-heavy tests"
|
|
59
|
+
unit = "%"
|
|
53
60
|
weight = 0.2
|
|
54
61
|
target = 5
|
|
55
62
|
bad = 30
|
|
56
63
|
|
|
57
64
|
[pillars.refactoring.metrics.interaction_only]
|
|
58
65
|
name = "Interaction-only tests"
|
|
66
|
+
unit = "%"
|
|
59
67
|
weight = 0.15
|
|
60
68
|
target = 5
|
|
61
69
|
bad = 30
|
|
@@ -65,6 +73,7 @@ name = "Fast feedback"
|
|
|
65
73
|
|
|
66
74
|
[pillars.feedback.metrics.total_runtime]
|
|
67
75
|
name = "Total runtime"
|
|
76
|
+
unit = "s"
|
|
68
77
|
weight = 0.4
|
|
69
78
|
target = 60
|
|
70
79
|
bad = 600
|
|
@@ -72,6 +81,7 @@ log = true
|
|
|
72
81
|
|
|
73
82
|
[pillars.feedback.metrics.p95_duration]
|
|
74
83
|
name = "p95 test duration"
|
|
84
|
+
unit = "s"
|
|
75
85
|
weight = 0.3
|
|
76
86
|
target = 0.1
|
|
77
87
|
bad = 2
|
|
@@ -79,12 +89,14 @@ log = true
|
|
|
79
89
|
|
|
80
90
|
[pillars.feedback.metrics.slowest_decile_share]
|
|
81
91
|
name = "Runtime share of slowest 10% of tests"
|
|
92
|
+
unit = "%"
|
|
82
93
|
weight = 0.15
|
|
83
94
|
target = 40
|
|
84
95
|
bad = 90
|
|
85
96
|
|
|
86
97
|
[pillars.feedback.metrics.tests_over_10s]
|
|
87
98
|
name = "Tests over 10 s"
|
|
99
|
+
unit = "%"
|
|
88
100
|
weight = 0.15
|
|
89
101
|
target = 0
|
|
90
102
|
bad = 2
|
|
@@ -94,18 +106,21 @@ name = "Maintainability"
|
|
|
94
106
|
|
|
95
107
|
[pillars.maintainability.metrics.smelly_tests]
|
|
96
108
|
name = "Tests with a maintainability smell"
|
|
109
|
+
unit = "%"
|
|
97
110
|
weight = 0.5
|
|
98
111
|
target = 5
|
|
99
112
|
bad = 40
|
|
100
113
|
|
|
101
114
|
[pillars.maintainability.metrics.long_tests]
|
|
102
115
|
name = "Tests longer than 50 lines"
|
|
116
|
+
unit = "%"
|
|
103
117
|
weight = 0.2
|
|
104
118
|
target = 2
|
|
105
119
|
bad = 20
|
|
106
120
|
|
|
107
121
|
[pillars.maintainability.metrics.test_source_ratio]
|
|
108
122
|
name = "Test : source lines-of-code ratio"
|
|
123
|
+
unit = ""
|
|
109
124
|
weight = 0.3
|
|
110
125
|
target = 1.5
|
|
111
126
|
bad = 4.0
|
|
@@ -115,6 +130,7 @@ name = "Economy"
|
|
|
115
130
|
|
|
116
131
|
[pillars.economy.metrics.no_unique_coverage]
|
|
117
132
|
name = "Tests with no unique coverage"
|
|
133
|
+
unit = "%"
|
|
118
134
|
weight = 0.35
|
|
119
135
|
target = 10
|
|
120
136
|
bad = 50
|
|
@@ -122,12 +138,14 @@ partial_weight = 0.6
|
|
|
122
138
|
|
|
123
139
|
[pillars.economy.metrics.subsumed_in_kill_matrix]
|
|
124
140
|
name = "Tests subsumed in the kill matrix"
|
|
141
|
+
unit = "%"
|
|
125
142
|
weight = 0.4
|
|
126
143
|
target = 5
|
|
127
144
|
bad = 35
|
|
128
145
|
|
|
129
146
|
[pillars.economy.metrics.duplicate_clusters]
|
|
130
147
|
name = "Tests in a duplicate-body cluster"
|
|
148
|
+
unit = "%"
|
|
131
149
|
weight = 0.25
|
|
132
150
|
target = 2
|
|
133
151
|
bad = 20
|
|
@@ -0,0 +1,161 @@
|
|
|
1
|
+
"""Ticket 04 browser driver: `uv run --with playwright python browser_driver.py <dashboard.html>` opens the standalone
|
|
2
|
+
report from disk in Chrome with the network switched off, drives the visible controls and prints one JSON document of
|
|
3
|
+
measurements on stdout. It asserts nothing: test_dashboard_layout.py reads the measurements.
|
|
4
|
+
|
|
5
|
+
Page interface the acceptance tests pin, on top of the earlier tickets' markup (metric/overlap/map tabs):
|
|
6
|
+
[data-testid=gauge-title] inside every [data-testid=gauge]: the pillar title
|
|
7
|
+
[data-testid=gauge-status] inside every gauge, also a fully measured one: the measurement status text
|
|
8
|
+
[data-testid=gauge] .score the displayed score (existing)
|
|
9
|
+
the tabs are the <button>s inside [data-testid=details]; the selected one must look different from the others.
|
|
10
|
+
"""
|
|
11
|
+
import json
|
|
12
|
+
import sys
|
|
13
|
+
from pathlib import Path
|
|
14
|
+
from urllib.parse import quote
|
|
15
|
+
|
|
16
|
+
from playwright.sync_api import sync_playwright
|
|
17
|
+
|
|
18
|
+
URL = "file://" + quote(str(Path(sys.argv[1]).resolve()))
|
|
19
|
+
UNIQUE = "test_only_left_xylophone"
|
|
20
|
+
GAUGE = "[data-testid=gauge]"
|
|
21
|
+
TABS = "[data-testid=details] button"
|
|
22
|
+
|
|
23
|
+
GAUGES = """() => [...document.querySelectorAll('[data-testid=gauge]')].map((g) => {
|
|
24
|
+
const box = (e) => { if (!e) return null; const r = e.getBoundingClientRect(), s = getComputedStyle(e);
|
|
25
|
+
return {top: Math.round(r.top), left: Math.round(r.left), width: Math.round(r.width), height: Math.round(r.height),
|
|
26
|
+
lines: Math.round(r.height / (parseFloat(s.lineHeight) || 1.2 * parseFloat(s.fontSize))), font: parseFloat(s.fontSize),
|
|
27
|
+
clipped: e.scrollWidth > e.clientWidth + 1 || e.scrollHeight > e.clientHeight + 1, text: e.textContent.trim()}; };
|
|
28
|
+
return {card: box(g), title: box(g.querySelector('[data-testid=gauge-title]')), score: box(g.querySelector('.score')),
|
|
29
|
+
status: box(g.querySelector('[data-testid=gauge-status]'))};
|
|
30
|
+
})"""
|
|
31
|
+
|
|
32
|
+
SIG = """(el) => { const s = getComputedStyle(el);
|
|
33
|
+
return [s.backgroundColor, s.color, s.fontWeight, s.borderTopColor, s.borderBottomColor, s.borderBottomWidth, s.textDecorationLine,
|
|
34
|
+
s.boxShadow].join('|'); }"""
|
|
35
|
+
FOCUS = """() => { const el = document.activeElement, s = getComputedStyle(el);
|
|
36
|
+
return {text: el.textContent.trim(), outline: s.outlineStyle + ' ' + s.outlineWidth + ' ' + s.outlineColor, shadow: s.boxShadow}; }"""
|
|
37
|
+
TAB_STATE = """() => { const tabs = [...document.querySelectorAll('[data-testid=details] button')];
|
|
38
|
+
return tabs.filter((b) => ['Metrics', 'Worst tests', 'Smells', 'Overlaps', 'Map'].includes(b.textContent.trim())).map((b) => ({text: b.textContent.trim(), sig: window.sigOf(b)})); }"""
|
|
39
|
+
OVERFLOW = """() => ({viewport: document.documentElement.clientWidth, scroll_width: document.documentElement.scrollWidth,
|
|
40
|
+
details_right: Math.round(Math.max(...[...document.querySelectorAll('[data-testid=details] > *')].map((e) => e.getBoundingClientRect().right))),
|
|
41
|
+
details_width: Math.round(document.querySelector('[data-testid=details]').getBoundingClientRect().width)})"""
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
def click_gauge(page, label):
|
|
45
|
+
page.locator(GAUGE).filter(has_text=label).first.click()
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
def click_tab(page, label):
|
|
49
|
+
page.locator(TABS).filter(has_text=label).first.click()
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
def tabs(page):
|
|
53
|
+
return page.evaluate(TAB_STATE)
|
|
54
|
+
|
|
55
|
+
|
|
56
|
+
def table_share(page):
|
|
57
|
+
return page.evaluate("""() => { const t = document.querySelector('[data-testid=details] table'), d = document.querySelector('[data-testid=details]');
|
|
58
|
+
return t ? t.getBoundingClientRect().width / d.getBoundingClientRect().width : null; }""")
|
|
59
|
+
|
|
60
|
+
|
|
61
|
+
def layout(browser, width, height):
|
|
62
|
+
page = browser.new_page(viewport={"width": width, "height": height})
|
|
63
|
+
page.goto(URL)
|
|
64
|
+
page.wait_for_selector(GAUGE)
|
|
65
|
+
out = {"gauges": page.evaluate(GAUGES), "overview": page.evaluate(OVERFLOW)}
|
|
66
|
+
click_gauge(page, "Fast feedback")
|
|
67
|
+
out["feedback_table_share"] = table_share(page)
|
|
68
|
+
out["feedback_details"] = page.evaluate(OVERFLOW)
|
|
69
|
+
click_gauge(page, "Resistance to refactoring")
|
|
70
|
+
out["refactoring_details"] = page.evaluate(OVERFLOW)
|
|
71
|
+
click_gauge(page, "Economy")
|
|
72
|
+
click_tab(page, "Overlaps")
|
|
73
|
+
out["overlaps"] = page.evaluate(OVERFLOW)
|
|
74
|
+
out["overlap_ids"] = page.evaluate("""() => [...document.querySelectorAll('[data-testid=overlap-test]')].map((e) => {
|
|
75
|
+
const r = e.getBoundingClientRect(), s = getComputedStyle(e);
|
|
76
|
+
return {text: e.textContent, right: Math.round(r.right), clipped: e.scrollWidth > e.clientWidth + 1 && s.overflowX !== 'visible',
|
|
77
|
+
ellipsis: s.textOverflow === 'ellipsis', title: e.getAttribute('title')}; })""")
|
|
78
|
+
click_tab(page, "Map")
|
|
79
|
+
out["map"] = page.evaluate(OVERFLOW)
|
|
80
|
+
page.close()
|
|
81
|
+
return out
|
|
82
|
+
|
|
83
|
+
|
|
84
|
+
def tab_styles(browser):
|
|
85
|
+
page = browser.new_page(viewport={"width": 1440, "height": 900})
|
|
86
|
+
page.goto(URL)
|
|
87
|
+
page.wait_for_selector(GAUGE)
|
|
88
|
+
page.evaluate("() => { window.sigOf = " + SIG + "; }")
|
|
89
|
+
click_gauge(page, "Economy")
|
|
90
|
+
steps = {}
|
|
91
|
+
for label in ("Metrics", "Overlaps", "Map"):
|
|
92
|
+
click_tab(page, label)
|
|
93
|
+
steps[label] = tabs(page)
|
|
94
|
+
# keyboard focus: from the active Map tab, Shift+Tab lands on a neighbouring tab
|
|
95
|
+
before = {t["text"]: t["sig"] for t in tabs(page)}
|
|
96
|
+
page.keyboard.press("Shift+Tab")
|
|
97
|
+
focus = page.evaluate(FOCUS)
|
|
98
|
+
focus["sig_unfocused"] = before.get(focus["text"])
|
|
99
|
+
focus["sig_focused"] = page.evaluate("() => window.sigOf(document.activeElement)")
|
|
100
|
+
page.close()
|
|
101
|
+
return {"steps": steps, "focus": focus}
|
|
102
|
+
|
|
103
|
+
|
|
104
|
+
def journey(browser):
|
|
105
|
+
context = browser.new_context(viewport={"width": 1440, "height": 900}, offline=True)
|
|
106
|
+
requests = []
|
|
107
|
+
context.on("request", lambda r: requests.append(r.url))
|
|
108
|
+
failures = []
|
|
109
|
+
context.on("requestfailed", lambda r: failures.append(r.url))
|
|
110
|
+
page = context.new_page()
|
|
111
|
+
errors = []
|
|
112
|
+
page.on("pageerror", lambda e: errors.append(str(e)))
|
|
113
|
+
page.goto(URL)
|
|
114
|
+
page.wait_for_selector(GAUGE)
|
|
115
|
+
page.evaluate("() => { window.sigOf = " + SIG + "; }")
|
|
116
|
+
log = {}
|
|
117
|
+
count = lambda: (page.locator("[data-testid=overlap-count]").first.text_content() or "")
|
|
118
|
+
click_gauge(page, "Fast feedback")
|
|
119
|
+
log["feedback_text"] = page.inner_text("[data-testid=details]")
|
|
120
|
+
click_gauge(page, "Resistance to refactoring")
|
|
121
|
+
log["refactoring_text"] = page.inner_text("[data-testid=details]")
|
|
122
|
+
click_gauge(page, "Economy")
|
|
123
|
+
click_tab(page, "Overlaps")
|
|
124
|
+
log["active_overlaps"] = tabs(page)
|
|
125
|
+
log["count_all"] = count()
|
|
126
|
+
log["first_row_page_1"] = page.locator("[data-testid=overlap-pair]").first.text_content()
|
|
127
|
+
page.locator("[data-testid=overlap-next]").click()
|
|
128
|
+
log["first_row_page_2"] = page.locator("[data-testid=overlap-pair]").first.text_content()
|
|
129
|
+
page.locator("[data-testid=overlap-search]").fill(UNIQUE)
|
|
130
|
+
page.wait_for_timeout(300)
|
|
131
|
+
log["count_search"] = count()
|
|
132
|
+
log["rows_search"] = page.locator("[data-testid=overlap-pair]").count()
|
|
133
|
+
page.locator("[data-testid=overlap-search]").fill("")
|
|
134
|
+
page.wait_for_timeout(300)
|
|
135
|
+
log["count_cleared"] = count()
|
|
136
|
+
click_tab(page, "Map")
|
|
137
|
+
log["active_map"] = tabs(page)
|
|
138
|
+
dot = page.locator("[data-testid=map-dot]").nth(10)
|
|
139
|
+
log["dots"] = page.locator("[data-testid=map-dot]").count()
|
|
140
|
+
dot.dispatch_event("click")
|
|
141
|
+
page.wait_for_timeout(300)
|
|
142
|
+
log["picked"] = (page.locator("[data-testid=map-picked]").first.text_content() or "")
|
|
143
|
+
log["similar_items"] = page.locator("[data-testid=map-similar-item]").count()
|
|
144
|
+
click_tab(page, "Metrics")
|
|
145
|
+
log["active_metrics"] = tabs(page)
|
|
146
|
+
log["metrics_text"] = page.inner_text("[data-testid=details]")
|
|
147
|
+
log["requests"] = [u for u in requests if not u.startswith("file:")]
|
|
148
|
+
log["failed_requests"] = failures
|
|
149
|
+
log["page_errors"] = errors
|
|
150
|
+
context.close()
|
|
151
|
+
return log
|
|
152
|
+
|
|
153
|
+
|
|
154
|
+
with sync_playwright() as p:
|
|
155
|
+
try:
|
|
156
|
+
browser = p.chromium.launch(channel="chrome")
|
|
157
|
+
except Exception:
|
|
158
|
+
browser = p.chromium.launch()
|
|
159
|
+
result = {"desktop": layout(browser, 1440, 900), "narrow": layout(browser, 390, 844), "tabs": tab_styles(browser), "journey": journey(browser)}
|
|
160
|
+
browser.close()
|
|
161
|
+
print(json.dumps(result))
|
|
@@ -1,6 +1,13 @@
|
|
|
1
|
+
import sys
|
|
2
|
+
from pathlib import Path
|
|
3
|
+
|
|
4
|
+
# The engine's modules sit one folder up. Set the path here, before any test module is collected, so a test file
|
|
5
|
+
# needs no sys.path line of its own and collection order cannot hide a missing one.
|
|
6
|
+
sys.path.insert(0, str(Path(__file__).resolve().parents[1]))
|
|
7
|
+
|
|
1
8
|
collect_ignore_glob = ["testdata/*"]
|
|
2
9
|
|
|
3
|
-
import pytest
|
|
10
|
+
import pytest # noqa: E402
|
|
4
11
|
|
|
5
12
|
from fixture_repo import build_repo, weigh
|
|
6
13
|
|