Changeset 0.28.5 (#191)

This commit is contained in:
2026-03-14 22:51:50 +00:00
parent 85d5e3cc13
commit 6f0ad1355c
17 changed files with 2389 additions and 110 deletions

View File

@@ -230,6 +230,14 @@
}, 'Providers');
T.el.controls.appendChild(btnProv);
// SDK tier button — tests switchboard-sdk.js contract
var btnSdk = $('button', {
className: (typeof Switchboard !== 'undefined') ? 'btn-secondary' : 'btn-ghost',
style: { opacity: (typeof Switchboard !== 'undefined') ? '1' : '0.5' },
onClick: function () { T.runSuite('sdk'); }
}, 'SDK');
T.el.controls.appendChild(btnSdk);
T.el.controls.appendChild(btnAll);
T.el.controls.appendChild(btnClear);
@@ -342,6 +350,7 @@
var now = new Date().toISOString();
var pass = T.results.filter(function (r) { return r.status === 'pass'; }).length;
var fail = T.results.filter(function (r) { return r.status === 'fail'; }).length;
var skip = T.results.filter(function (r) { return r.status === 'skip'; }).length;
var total = T.results.length;
var totalMs = T.results.reduce(function (s, r) { return s + r.duration; }, 0);
@@ -353,7 +362,7 @@
lines.push('URL: ' + location.href);
lines.push('');
lines.push('--- Summary ---');
lines.push('Total: ' + total + ' Pass: ' + pass + ' Fail: ' + fail + ' Rate: ' + (total > 0 ? Math.round((pass / total) * 100) : 0) + '% Duration: ' + totalMs + 'ms');
lines.push('Total: ' + total + ' Pass: ' + pass + ' Fail: ' + fail + (skip > 0 ? ' Skip: ' + skip : '') + ' Rate: ' + (total > 0 ? Math.round((pass / (total - skip)) * 100) : 0) + '% Duration: ' + totalMs + 'ms');
// Critical failures callout
var criticals = T.results.filter(function (r) { return r.status === 'fail' && r.detail && r.detail.indexOf('CRITICAL') !== -1; });
@@ -391,17 +400,18 @@
var domains = {};
T.results.forEach(function (r) {
var k = r.domain;
if (!domains[k]) domains[k] = { pass: 0, fail: 0, total: 0, ms: 0 };
if (!domains[k]) domains[k] = { pass: 0, fail: 0, skip: 0, total: 0, ms: 0 };
domains[k].total++;
domains[k].ms += r.duration;
if (r.status === 'pass') domains[k].pass++;
else if (r.status === 'skip') domains[k].skip++;
else domains[k].fail++;
});
lines.push('--- By Domain ---');
Object.keys(domains).forEach(function (d) {
var s = domains[d];
var flag = s.fail > 0 ? 'FAIL' : 'OK';
var flag = s.fail > 0 ? 'FAIL' : (s.skip > 0 && s.pass === 0 ? 'SKIP' : 'OK');
lines.push(' ' + pad(d, 16) + pad(flag, 6) + pad(s.pass + '/' + s.total, 8) + s.ms + 'ms');
});
lines.push('');
@@ -417,16 +427,30 @@
lines.push('');
}
// Skipped (if any)
var skipped = T.results.filter(function (r) { return r.status === 'skip'; });
if (skipped.length > 0) {
lines.push('--- Skipped (' + skipped.length + ') ---');
skipped.forEach(function (r, i) {
lines.push(' ' + (i + 1) + '. [' + r.tier + '/' + r.domain + '] ' + r.name);
lines.push(' ' + r.detail);
});
lines.push('');
}
// Full detail table
lines.push('--- Full Results ---');
lines.push(pad('STATUS', 8) + pad('TIER', 8) + pad('DOMAIN', 16) + pad('MS', 6) + 'TEST');
lines.push(repeat('-', 90));
T.results.forEach(function (r) {
var statusStr = r.status === 'pass' ? 'PASS' : 'FAIL';
var statusStr = r.status === 'pass' ? 'PASS' : (r.status === 'skip' ? 'SKIP' : 'FAIL');
var line = pad(statusStr, 8) + pad(r.tier, 8) + pad(r.domain, 16) + pad(String(r.duration), 6) + r.name;
if (r.status === 'fail' && r.detail) {
line += '\n' + repeat(' ', 38) + '↳ ' + r.detail;
}
if (r.status === 'skip' && r.detail) {
line += '\n' + repeat(' ', 38) + '↳ SKIP: ' + r.detail;
}
lines.push(line);
});
lines.push('');
@@ -521,6 +545,7 @@
if (which === 'authz' || (which === 'all' && T.fixtures.ready)) await T.runAuthz();
if (which === 'security' || (which === 'all' && T.fixtures.ready)) await T.runSecurity();
if (which === 'provider' || (which === 'all' && T.providerSetup.configured)) await T.runProviders();
if (which === 'sdk' || which === 'all') { if (typeof T.runSdk === 'function') await T.runSdk(); }
} catch (e) {
T.results.push({ tier: '?', domain: 'runner', name: 'FATAL', status: 'fail', duration: 0, detail: String(e) });
}
@@ -546,8 +571,10 @@
if (!T.el.progress) return;
var pass = T.results.filter(function (r) { return r.status === 'pass'; }).length;
var fail = T.results.filter(function (r) { return r.status === 'fail'; }).length;
var skip = T.results.filter(function (r) { return r.status === 'skip'; }).length;
var total = T.results.length;
var pct = total > 0 ? Math.round((pass / total) * 100) : 0;
var countable = total - skip;
var pct = countable > 0 ? Math.round((pass / countable) * 100) : 0;
T.el.progress.innerHTML = '';
if (total === 0) return;
@@ -571,7 +598,7 @@
T.el.progress.appendChild(barOuter);
var label = $('div', { style: { fontSize: '12px', color: 'var(--text-2)' } },
(T.running ? 'Running... ' : '') + total + ' tests · ' + pass + ' pass · ' + fail + ' fail · ' + pct + '%');
(T.running ? 'Running... ' : '') + total + ' tests · ' + pass + ' pass · ' + fail + ' fail' + (skip > 0 ? ' · ' + skip + ' skip' : '') + ' · ' + pct + '%');
T.el.progress.appendChild(label);
}
@@ -584,10 +611,11 @@
var domains = {};
T.results.forEach(function (r) {
var k = r.domain;
if (!domains[k]) domains[k] = { pass: 0, fail: 0, total: 0, ms: 0 };
if (!domains[k]) domains[k] = { pass: 0, fail: 0, skip: 0, total: 0, ms: 0 };
domains[k].total++;
domains[k].ms += r.duration;
if (r.status === 'pass') domains[k].pass++;
else if (r.status === 'skip') domains[k].skip++;
else domains[k].fail++;
});
@@ -600,17 +628,19 @@
Object.keys(domains).forEach(function (d) {
var s = domains[d];
var allPass = s.fail === 0;
var borderColor = s.fail > 0 ? 'var(--danger)' : (s.skip > 0 ? 'var(--warning)' : 'var(--success)');
var label = s.pass + '/' + s.total + ' pass';
if (s.skip > 0) label += ' · ' + s.skip + ' skip';
label += ' · ' + s.ms + 'ms';
var card = $('div', {
style: {
background: 'var(--bg-surface)', border: '1px solid var(--border)',
borderRadius: 'var(--radius)', padding: '10px 14px',
borderLeft: '3px solid ' + (allPass ? 'var(--success)' : 'var(--danger)')
borderLeft: '3px solid ' + borderColor
}
}, [
$('div', { style: { fontSize: '13px', fontWeight: '600', color: 'var(--text)', marginBottom: '4px' } }, d),
$('div', { style: { fontSize: '12px', color: 'var(--text-2)' } },
s.pass + '/' + s.total + ' pass · ' + s.ms + 'ms')
$('div', { style: { fontSize: '12px', color: 'var(--text-2)' } }, label)
]);
grid.appendChild(card);
});
@@ -649,10 +679,14 @@
var tbody = $('tbody');
T.results.forEach(function (r) {
var isPass = r.status === 'pass';
var isSkip = r.status === 'skip';
var rowBg = isPass ? 'transparent' : (isSkip ? 'rgba(234,179,8,0.04)' : 'rgba(239,68,68,0.04)');
var dotColor = isPass ? 'var(--success)' : (isSkip ? 'var(--warning)' : 'var(--danger)');
var detailColor = isPass ? 'var(--text-3)' : (isSkip ? 'var(--warning)' : 'var(--danger)');
var tr = $('tr', {
style: {
borderBottom: '1px solid var(--border)',
background: isPass ? 'transparent' : 'rgba(239,68,68,0.04)'
background: rowBg
}
});
@@ -661,7 +695,7 @@
$('span', {
style: {
display: 'inline-block', width: '8px', height: '8px',
borderRadius: '50%', background: isPass ? 'var(--success)' : 'var(--danger)'
borderRadius: '50%', background: dotColor
}
})
]));
@@ -671,21 +705,22 @@
tr.appendChild($('td', { style: { padding: '6px 10px', color: 'var(--text)' } }, r.name));
tr.appendChild($('td', { style: { padding: '6px 10px', color: 'var(--text-3)', textAlign: 'right' } }, String(r.duration)));
var detailText = isSkip ? ('SKIP: ' + (r.detail || '')) : (r.detail || '');
var detailTd = $('td', {
style: {
padding: '6px 10px', color: isPass ? 'var(--text-3)' : 'var(--danger)',
padding: '6px 10px', color: detailColor,
maxWidth: '320px', overflow: 'hidden', textOverflow: 'ellipsis', whiteSpace: 'nowrap',
cursor: r.detail ? 'pointer' : 'default'
cursor: detailText ? 'pointer' : 'default'
},
title: r.detail || ''
}, r.detail ? r.detail.substring(0, 120) : '✓');
title: detailText || ''
}, detailText ? detailText.substring(0, 120) : '✓');
if (r.detail && r.detail.length > 120) {
if (detailText && detailText.length > 120) {
detailTd.addEventListener('click', function () {
if (detailTd.style.whiteSpace === 'nowrap') {
detailTd.style.whiteSpace = 'pre-wrap';
detailTd.style.wordBreak = 'break-all';
detailTd.textContent = r.detail;
detailTd.textContent = detailText;
} else {
detailTd.style.whiteSpace = 'nowrap';
detailTd.textContent = r.detail.substring(0, 120);