Changeset 0.37.14 (#226)

Co-authored-by: gobha <jasafpro@gmail.com>
Co-committed-by: gobha <jasafpro@gmail.com>
This commit is contained in:
2026-03-23 16:47:48 +00:00
committed by xcaliber
parent fcb998bff9
commit b7746c3004
164 changed files with 6972 additions and 3527 deletions

View File

@@ -97,13 +97,13 @@
style: { alignSelf: 'flex-end', whiteSpace: 'nowrap' },
onClick: function () {
if (!T.providerSetup.apiKey) {
if (typeof UI !== 'undefined') UI.toast('Paste an API key first', 'warning');
if (window.sw && sw.toast) sw.toast('Paste an API key first', 'warning');
return;
}
T.providerSetup.configured = true;
T.renderProviderSetup();
T.renderControls();
if (typeof UI !== 'undefined') UI.toast(T.providerSetup.provider + ' configured — run Provider tier', 'success');
if (window.sw && sw.toast) sw.toast(T.providerSetup.provider + ' configured — run Provider tier', 'success');
}
}, T.providerSetup.configured ? 'Reconfigure' : 'Configure');
inputRow.appendChild(cfgBtn);
@@ -140,12 +140,18 @@
T.mount.style.maxWidth = '1000px';
T.mount.style.margin = '0 auto';
// Top bar with user menu
var topbar = $('div', { style: { display: 'flex', justifyContent: 'flex-end', marginBottom: '8px' } });
T.mount.appendChild(topbar);
if (window.sw?.userMenu) window.sw.userMenu(topbar, { flyout: 'down' });
// Header
var user = window.sw?.auth?.user || T.user || {};
var hdr = $('div', { style: { marginBottom: '24px' } }, [
$('h1', { style: { fontSize: '22px', fontWeight: '700', color: 'var(--text)', margin: '0 0 4px 0' } },
'ICD Test Runner'),
$('div', { style: { fontSize: '13px', color: 'var(--text-3)' } },
'v' + (T.manifest.version || '0.28.0') + ' · ' + esc(T.user.username) + (T.user.role === 'admin' ? ' (admin)' : ' (user)'))
'v' + (T.manifest.version || '0.28.0') + ' · ' + esc(user.username || 'unknown') + (user.role === 'admin' ? ' (admin)' : ' (user)'))
]);
T.mount.appendChild(hdr);
@@ -232,8 +238,8 @@
// 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' },
className: (typeof window.sw !== 'undefined') ? 'btn-secondary' : 'btn-ghost',
style: { opacity: (typeof window.sw !== 'undefined') ? '1' : '0.5' },
onClick: function () { T.runSuite('sdk'); }
}, 'SDK');
T.el.controls.appendChild(btnSdk);
@@ -321,7 +327,7 @@
var pwSpan = $('span', { style: { color: 'var(--warning)', cursor: 'pointer' }, title: 'Click to copy' }, u.password);
pwSpan.addEventListener('click', function () {
navigator.clipboard.writeText(u.password);
if (typeof UI !== 'undefined') UI.toast('Password copied', 'info');
if (window.sw && sw.toast) sw.toast('Password copied', 'info');
});
pwTd.appendChild(pwSpan);
tr.appendChild(pwTd);
@@ -480,7 +486,7 @@
T.exportReport = function (mode) {
if (T.results.length === 0) {
if (typeof UI !== 'undefined') UI.toast('No T.results to export — run a suite first', 'warning');
if (window.sw && sw.toast) sw.toast('No T.results to export — run a suite first', 'warning');
return;
}
@@ -488,7 +494,7 @@
if (mode === 'clipboard') {
navigator.clipboard.writeText(text).then(function () {
if (typeof UI !== 'undefined') UI.toast('Report copied to clipboard', 'success');
if (window.sw && sw.toast) sw.toast('Report copied to clipboard', 'success');
}).catch(function () {
// Fallback: select-all textarea
clipboardFallback(text);
@@ -505,7 +511,7 @@
a.click();
document.body.removeChild(a);
URL.revokeObjectURL(url);
if (typeof UI !== 'undefined') UI.toast('Downloaded ' + filename, 'success');
if (window.sw && sw.toast) sw.toast('Downloaded ' + filename, 'success');
}
}
@@ -517,7 +523,7 @@
ta.select();
try { document.execCommand('copy'); } catch (e) { /* give up */ }
document.body.removeChild(ta);
if (typeof UI !== 'undefined') UI.toast('Report copied (fallback)', 'info');
if (window.sw && sw.toast) sw.toast('Report copied (fallback)', 'info');
}
@@ -525,15 +531,15 @@
T.runSuite = async function (which) {
if (T.running) return;
if (which === 'authz' && !T.fixtures.ready) {
if (typeof UI !== 'undefined') UI.toast('Provision test fixtures first (button on the right)', 'warning');
if (window.sw && sw.toast) sw.toast('Provision test fixtures first (button on the right)', 'warning');
return;
}
if (which === 'security' && !T.fixtures.ready) {
if (typeof UI !== 'undefined') UI.toast('Provision test fixtures first (button on the right)', 'warning');
if (window.sw && sw.toast) sw.toast('Provision test fixtures first (button on the right)', 'warning');
return;
}
if (which === 'provider' && !T.providerSetup.configured) {
if (typeof UI !== 'undefined') UI.toast('Configure a provider (type + API key) in the panel above', 'warning');
if (window.sw && sw.toast) sw.toast('Configure a provider (type + API key) in the panel above', 'warning');
return;
}
T.running = true;
@@ -571,7 +577,7 @@
var critical = T.results.filter(function (r) { return r.status === 'fail' && r.detail && r.detail.indexOf('CRITICAL') !== -1; }).length;
var msg = pass + ' passed, ' + fail + ' failed';
if (critical > 0) msg += ' (' + critical + ' CRITICAL)';
UI.toast(msg, critical > 0 ? 'error' : fail > 0 ? 'warning' : 'success');
if (window.sw && sw.toast) sw.toast(msg, critical > 0 ? 'error' : fail > 0 ? 'warning' : 'success');
}
}