This repository has been archived on 2026-04-03. You can view files and clone it. You cannot open issues or pull requests or push a commit.
Files
Jeffrey Smith 829caa3b20
All checks were successful
CI/CD / detect-changes (push) Successful in 3s
CI/CD / test-frontend (push) Successful in 6s
CI/CD / test-go-pg (push) Successful in 2m51s
CI/CD / test-sqlite (push) Successful in 3m2s
CI/CD / build-and-deploy (push) Successful in 1m26s
Feat v0.7.1 surface runner framework (#55)
Co-authored-by: Jeffrey Smith <jasafpro@gmail.com>
Co-committed-by: Jeffrey Smith <jasafpro@gmail.com>
2026-04-01 23:01:38 +00:00

89 lines
2.8 KiB
JavaScript

/**
* SDK Test Runner — Entry Point
*
* Boot SDK, set up SDKR namespace, load modules via script tags,
* then redirect to the test-runners registry surface.
*
* Load order:
* 1. framework.js — dual-path utilities, assertions, raw fetch
* 2. shapes.js — ICD response shapes
* 3. fixtures.js — provision/teardown helpers
* 4. domains/*.js — per-domain suites (register via sw.testing.suite())
*/
(async function () {
'use strict';
try {
var base = window.__BASE__ || '';
var ver = window.__VERSION__ || '0';
if (!window.preact) {
var { h, render } = await import(base + '/js/sw/vendor/preact.module.js');
var hooksModule = await import(base + '/js/sw/vendor/hooks.module.js');
var htmModule = await import(base + '/js/sw/vendor/htm.module.js');
window.preact = { h, render };
window.hooks = hooksModule;
window.html = htmModule.default.bind(h);
}
var sdk = await import(base + '/js/sw/sdk/index.js?v=' + ver);
await sdk.boot();
} catch (e) {
console.warn('[SDKR] SDK boot failed:', e.message);
}
window.SDKR = {
manifest: window.__MANIFEST__ || {},
user: window.sw?.auth?.user || {},
base: window.__BASE__ || '',
S: {},
fixtures: { ready: false, users: [], team: null, group: null }
};
// Always use own package ID — when loaded by the registry,
// __MANIFEST__ belongs to the registry surface, not this runner.
var surfaceId = 'sdk-test-runner';
var assetBase = '/surfaces/' + surfaceId + '/js/';
if (window.SDKR.base) assetBase = window.SDKR.base + assetBase;
var modules = [
'framework.js',
'shapes.js',
'fixtures.js',
// Domain test files — each registers sw.testing.suite()
'domains/misc.js',
'domains/workflows.js',
'domains/admin.js',
'domains/packages.js',
'domains/connections.js',
'domains/dependencies.js',
'domains/composition.js'
];
var loaded = 0;
function loadNext() {
if (loaded >= modules.length) {
onReady();
return;
}
var script = document.createElement('script');
script.src = assetBase + modules[loaded] + '?v=' + (window.__VERSION__ || '0') + '.' + Date.now();
script.onload = function () { loaded++; loadNext(); };
script.onerror = function () {
console.error('[SDKR] Failed to load: ' + modules[loaded]);
loaded++; loadNext();
};
document.body.appendChild(script);
}
function onReady() {
console.log('[SDKR] All modules loaded — ' + sw.testing.suites().length + ' suites registered');
// If loaded as standalone surface (not via registry), redirect to registry
var manifest = window.__MANIFEST__ || {};
if (manifest.id === 'sdk-test-runner') {
var base = window.__BASE__ || '';
window.location.href = base + '/s/test-runners';
}
}
loadNext();
})();