Feat v0.7.2 package runners ci gate (#56)
All checks were successful
CI/CD / detect-changes (push) Successful in 4s
CI/CD / test-runners (push) Has been skipped
CI/CD / test-frontend (push) Successful in 6s
CI/CD / test-go-pg (push) Successful in 2m39s
CI/CD / test-sqlite (push) Successful in 2m55s
CI/CD / build-and-deploy (push) Successful in 29s
All checks were successful
CI/CD / detect-changes (push) Successful in 4s
CI/CD / test-runners (push) Has been skipped
CI/CD / test-frontend (push) Successful in 6s
CI/CD / test-go-pg (push) Successful in 2m39s
CI/CD / test-sqlite (push) Successful in 2m55s
CI/CD / build-and-deploy (push) Successful in 29s
Co-authored-by: Jeffrey Smith <jasafpro@gmail.com> Co-committed-by: Jeffrey Smith <jasafpro@gmail.com>
This commit was merged in pull request #56.
This commit is contained in:
62
packages/workflow-runner/js/main.js
Normal file
62
packages/workflow-runner/js/main.js
Normal file
@@ -0,0 +1,62 @@
|
||||
/**
|
||||
* Workflow Runner — Entry Point
|
||||
*
|
||||
* Boot SDK, load test modules.
|
||||
* Each module is an IIFE that registers suites 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('[WfRunner] SDK boot failed:', e.message);
|
||||
}
|
||||
|
||||
window.WR = {
|
||||
base: window.__BASE__ || '',
|
||||
api: '/api/v1/workflows'
|
||||
};
|
||||
|
||||
var surfaceId = 'workflow-runner';
|
||||
var assetBase = '/surfaces/' + surfaceId + '/js/';
|
||||
if (window.WR.base) assetBase = window.WR.base + assetBase;
|
||||
|
||||
var modules = [
|
||||
'workflow-lifecycle.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('[WfRunner] Failed to load: ' + modules[loaded]);
|
||||
loaded++; loadNext();
|
||||
};
|
||||
document.body.appendChild(script);
|
||||
}
|
||||
|
||||
function onReady() {
|
||||
console.log('[WfRunner] All modules loaded — ' + sw.testing.suites().length + ' suites registered');
|
||||
var manifest = window.__MANIFEST__ || {};
|
||||
if (manifest.id === surfaceId) {
|
||||
window.location.href = (window.__BASE__ || '') + '/s/test-runners';
|
||||
}
|
||||
}
|
||||
|
||||
loadNext();
|
||||
})();
|
||||
87
packages/workflow-runner/js/workflow-lifecycle.js
Normal file
87
packages/workflow-runner/js/workflow-lifecycle.js
Normal file
@@ -0,0 +1,87 @@
|
||||
/**
|
||||
* Workflow Runner — workflow/lifecycle suite
|
||||
*
|
||||
* Tests workflow definitions, instance creation, and stage progression.
|
||||
* Requires the content-approval workflow package to be installed.
|
||||
*/
|
||||
(function () {
|
||||
'use strict';
|
||||
|
||||
var API = window.WR.api;
|
||||
|
||||
sw.testing.suite('workflow/lifecycle', async function (s) {
|
||||
var defId, instanceId;
|
||||
|
||||
s.test('list workflow definitions', async function (t) {
|
||||
var r = await sw.api.get(API);
|
||||
var list = Array.isArray(r) ? r : (r.data || []);
|
||||
t.assert.ok(Array.isArray(list), 'definitions is array');
|
||||
// Find content-approval definition
|
||||
var def = list.find(function (d) {
|
||||
return d.slug === 'content-approval' || d.name === 'Content Approval';
|
||||
});
|
||||
if (!def) {
|
||||
t.warn('content-approval definition not found — package may need activation');
|
||||
// Try to find any definition
|
||||
if (list.length > 0) {
|
||||
def = list[0];
|
||||
t.warn('Using first available definition: ' + (def.name || def.slug));
|
||||
} else {
|
||||
t.skip('No workflow definitions available');
|
||||
return;
|
||||
}
|
||||
}
|
||||
t.assert.ok(def.id, 'definition has id');
|
||||
defId = def.id;
|
||||
});
|
||||
|
||||
s.test('create workflow instance', async function (t) {
|
||||
if (!defId) { t.skip('No definition from previous test'); return; }
|
||||
var r = await sw.api.post(API + '/' + defId + '/instances', {
|
||||
data: {
|
||||
title: 'Runner test submission',
|
||||
body: 'Test content from workflow-runner',
|
||||
category: 'blog'
|
||||
}
|
||||
});
|
||||
t.assert.ok(r.id, 'instance has id');
|
||||
t.assert.ok(r.status || r.current_stage !== undefined, 'instance has status/stage');
|
||||
instanceId = r.id;
|
||||
s.track('workflow', instanceId);
|
||||
});
|
||||
|
||||
s.test('get workflow instance', async function (t) {
|
||||
if (!defId || !instanceId) { t.skip('No instance from previous test'); return; }
|
||||
var r = await sw.api.get(API + '/' + defId + '/instances/' + instanceId);
|
||||
t.assert.eq(r.id, instanceId, 'instance id matches');
|
||||
});
|
||||
|
||||
s.test('advance stage', async function (t) {
|
||||
if (!defId || !instanceId) { t.skip('No instance from previous test'); return; }
|
||||
try {
|
||||
var r = await sw.api.post(API + '/' + defId + '/instances/' + instanceId + '/advance', {
|
||||
data: {
|
||||
title: 'Runner test submission',
|
||||
body: 'Test content from workflow-runner',
|
||||
category: 'blog'
|
||||
}
|
||||
});
|
||||
t.assert.ok(true, 'advance succeeded');
|
||||
} catch (e) {
|
||||
// Stage advance may fail if form validation requires specific fields
|
||||
t.warn('Stage advance failed: ' + e.message);
|
||||
}
|
||||
});
|
||||
|
||||
s.test('list instances', async function (t) {
|
||||
if (!defId) { t.skip('No definition from previous test'); return; }
|
||||
var r = await sw.api.get(API + '/' + defId + '/instances');
|
||||
var list = Array.isArray(r) ? r : (r.data || []);
|
||||
t.assert.ok(Array.isArray(list), 'instances is array');
|
||||
if (instanceId) {
|
||||
var found = list.some(function (i) { return i.id === instanceId; });
|
||||
t.assert.ok(found, 'created instance appears in list');
|
||||
}
|
||||
});
|
||||
});
|
||||
})();
|
||||
9
packages/workflow-runner/manifest.json
Normal file
9
packages/workflow-runner/manifest.json
Normal file
@@ -0,0 +1,9 @@
|
||||
{
|
||||
"id": "workflow-runner",
|
||||
"icon": "🔄",
|
||||
"type": "test-runner",
|
||||
"title": "Workflow Runner",
|
||||
"auth": "admin",
|
||||
"version": "0.1.0",
|
||||
"description": "Integration tests for Workflow package — definitions, instances, stage progression."
|
||||
}
|
||||
Reference in New Issue
Block a user