All checks were successful
CI/CD / detect-changes (pull_request) Successful in 23s
CI/CD / test-frontend (pull_request) Successful in 26s
CI/CD / test-go-pg (pull_request) Successful in 2m35s
CI/CD / test-sqlite (pull_request) Successful in 3m19s
CI/CD / build-and-deploy (pull_request) Successful in 1m46s
sw.testing SDK module — structured test framework for surface runners: - suite/test registration, lifecycle hooks (beforeAll/afterAll/beforeEach/afterEach) - Assertion library (ok/eq/neq/gt/match/throws/status/shape/arrayOf) - Auto-cleanup via track(type, id) with LIFO deletion - Three result statuses: passed/failed/warned - Structured JSON results with timing, warnings, cleanup stats test-runner manifest type: - ValidateManifest accepts "test-runner" packages - Excluded from sidebar nav (extensionNavItems filters surface/full only) - DB migrations: SQLite 013, Postgres 014 (CHECK constraint) ICD runner migration (kernel-only): - Migrated from T.test()/T.assert() to sw.testing.suite() - Stripped extension-dependent tests (channels, notes, personas, etc.) - Kernel suites: smoke, crud, authz, security, providers, packaging, sdk - Deleted ui.js + css (rendering delegated to registry surface) SDK runner migration (kernel-only): - Migrated from T.dualTest()/T.domains to sw.testing.suite() - Stripped extension domains (belong in v0.7.2 package runners) - Kernel suites: misc, workflows, admin, packages, connections, deps, composition Runner registry surface (/s/test-runners): - Admin-only dashboard discovering test-runner packages - Run All / per-runner Run buttons, real-time results - Export Failures / Export Full Results (JSON download) - Dark mode styling using kernel CSS variables - Suite count polling for async runner script loading 141 passed, 0 failed on fresh minimal install. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
128 lines
5.0 KiB
JavaScript
128 lines
5.0 KiB
JavaScript
/**
|
|
* SDK Test Runner — Domain: workflows
|
|
*
|
|
* Tests: list, create, get, update, delete, stages.
|
|
*/
|
|
(function () {
|
|
'use strict';
|
|
var T = window.SDKR;
|
|
if (!T) return;
|
|
|
|
sw.testing.suite('sdk/workflows', async function (s) {
|
|
var tag = 'sdkr-' + Date.now();
|
|
var wfId = null;
|
|
|
|
// ── List ──
|
|
|
|
s.test('list: sw.api.workflows.list() returns array', async function (t) {
|
|
var result = await T.dualTest(
|
|
function () { return sw.api.workflows.list(); },
|
|
{ method: 'GET', path: '/workflows' },
|
|
function (r) { var arr = T.unwrapList(r); T.assert(arr.length >= 0, 'expected list'); }
|
|
);
|
|
if (result.verdict === 'PASS') return;
|
|
if (result.verdict === 'SDK_BUG') t.assert.ok(false, 'SDK_BUG: ' + result.sdkErr);
|
|
if (result.verdict === 'ICD_BUG') t.assert.ok(false, 'ICD_BUG: ' + result.rawErr);
|
|
if (result.verdict === 'SHAPE_BUG') t.warn('SHAPE_BUG: ' + result.sdkErr);
|
|
});
|
|
|
|
// ── Create ──
|
|
|
|
s.test('crud: sw.api.workflows.create()', async function (t) {
|
|
var result = await T.dualTest(
|
|
function () {
|
|
return sw.api.workflows.create({
|
|
name: tag + '-wf', slug: tag + '-wf',
|
|
entry_mode: 'team_only', scope: 'personal'
|
|
});
|
|
},
|
|
{ method: 'POST', path: '/workflows', body: {
|
|
name: tag + '-wf', slug: tag + '-wf',
|
|
entry_mode: 'team_only', scope: 'personal'
|
|
}},
|
|
function (r) {
|
|
T.assertShape(r, T.S.workflow, 'workflow');
|
|
wfId = r.id;
|
|
T.registerCleanup(function () { if (wfId) return T.safeDelete('/workflows/' + wfId); });
|
|
}
|
|
);
|
|
if (result.verdict === 'PASS') return;
|
|
if (result.verdict === 'SDK_BUG') t.assert.ok(false, 'SDK_BUG: ' + result.sdkErr);
|
|
if (result.verdict === 'ICD_BUG') t.assert.ok(false, 'ICD_BUG: ' + result.rawErr);
|
|
if (result.verdict === 'SHAPE_BUG') t.warn('SHAPE_BUG: ' + result.sdkErr);
|
|
});
|
|
|
|
if (!wfId) return;
|
|
|
|
// ── Get ──
|
|
|
|
s.test('crud: sw.api.workflows.get(id)', async function (t) {
|
|
var result = await T.dualTest(
|
|
function () { return sw.api.workflows.get(wfId); },
|
|
{ method: 'GET', path: '/workflows/' + wfId },
|
|
function (r) {
|
|
T.assertShape(r, T.S.workflow, 'workflow');
|
|
T.assert(r.id === wfId, 'id mismatch');
|
|
}
|
|
);
|
|
if (result.verdict === 'PASS') return;
|
|
if (result.verdict === 'SDK_BUG') t.assert.ok(false, 'SDK_BUG: ' + result.sdkErr);
|
|
if (result.verdict === 'ICD_BUG') t.assert.ok(false, 'ICD_BUG: ' + result.rawErr);
|
|
if (result.verdict === 'SHAPE_BUG') t.warn('SHAPE_BUG: ' + result.sdkErr);
|
|
});
|
|
|
|
// ── Update (KNOWN BUG: SDK uses PUT, backend expects PATCH) ──
|
|
|
|
s.test('crud: sw.api.workflows.update(id, data)', async function (t) {
|
|
var result = await T.dualTest(
|
|
function () {
|
|
return sw.api.workflows.update(wfId, { name: tag + '-wf-updated' });
|
|
},
|
|
{ method: 'PATCH', path: '/workflows/' + wfId,
|
|
body: { name: tag + '-wf-updated' } },
|
|
function (r) {
|
|
T.assertShape(r, T.S.workflow, 'workflow');
|
|
T.assert(r.name === tag + '-wf-updated', 'name not updated');
|
|
}
|
|
);
|
|
if (result.verdict === 'PASS') return;
|
|
if (result.verdict === 'SDK_BUG') t.assert.ok(false, 'SDK_BUG: ' + result.sdkErr);
|
|
if (result.verdict === 'ICD_BUG') t.assert.ok(false, 'ICD_BUG: ' + result.rawErr);
|
|
if (result.verdict === 'SHAPE_BUG') t.warn('SHAPE_BUG: ' + result.sdkErr);
|
|
});
|
|
|
|
// ── Stages ──
|
|
|
|
// stages.list via SDK (if wired) vs raw
|
|
s.test('stages: GET /workflows/:id/stages (raw — SDK may not have this)', async function (t) {
|
|
var result = await T.dualTest(
|
|
function () {
|
|
// SDK may or may not expose stages — test raw path
|
|
if (sw.api.workflows.stages) return sw.api.workflows.stages(wfId);
|
|
throw new Error('sw.api.workflows.stages not defined');
|
|
},
|
|
{ method: 'GET', path: '/workflows/' + wfId + '/stages' },
|
|
function (r) { var arr = T.unwrapList(r); T.assert(arr.length >= 0, 'expected list'); }
|
|
);
|
|
if (result.verdict === 'PASS') return;
|
|
if (result.verdict === 'SDK_BUG') t.assert.ok(false, 'SDK_BUG: ' + result.sdkErr);
|
|
if (result.verdict === 'ICD_BUG') t.assert.ok(false, 'ICD_BUG: ' + result.rawErr);
|
|
if (result.verdict === 'SHAPE_BUG') t.warn('SHAPE_BUG: ' + result.sdkErr);
|
|
});
|
|
|
|
// ── Delete ──
|
|
|
|
s.test('crud: sw.api.workflows.del(id)', async function (t) {
|
|
var result = await T.dualTest(
|
|
function () { return sw.api.workflows.del(wfId); },
|
|
{ method: 'DELETE', path: '/workflows/' + wfId },
|
|
function () { wfId = null; }
|
|
);
|
|
if (result.verdict === 'PASS') return;
|
|
if (result.verdict === 'SDK_BUG') t.assert.ok(false, 'SDK_BUG: ' + result.sdkErr);
|
|
if (result.verdict === 'ICD_BUG') t.assert.ok(false, 'ICD_BUG: ' + result.rawErr);
|
|
if (result.verdict === 'SHAPE_BUG') t.warn('SHAPE_BUG: ' + result.sdkErr);
|
|
});
|
|
});
|
|
})();
|