Some checks are pending
Bidi Control Character Guard / bidi-control-guard (push) Waiting to run
Circular Dependency Check / Check for new circular dependencies (push) Waiting to run
Citus Migration Smoke / Combined migrations on single-node Citus (push) Waiting to run
E2E Fresh Install Tests / fresh-install-e2e (push) Waiting to run
ext-v2 guardrails / Run ext-v2 guard and ESLint (push) Waiting to run
Integration Tests / Check for relevant changes (push) Waiting to run
Integration Tests / ${{ (github.event_name == 'schedule' || github.event.inputs.suite == 'full') && 'Full integration suite' || 'Tier-1 integration subset' }} (push) Blocked by required conditions
Mobile checks / Mobile lint + typecheck (push) Waiting to run
Mobile checks / Mobile unit tests (push) Waiting to run
Mobile checks / Mobile dependency audit (report) (push) Waiting to run
Mobile checks / Mobile reproducibility checks (push) Waiting to run
Secrets guard (env backups) / Ensure no tracked env backup files (push) Waiting to run
Temporal Readiness / fast-readiness (push) Waiting to run
Temporal Readiness / docker-parity (push) Waiting to run
TypeScript Type Check / Nx affected typecheck (push) Waiting to run
Unit Tests / Skipped-test budget (push) Waiting to run
Unit Tests / Nx affected unit tests (push) Waiting to run
Unit Tests / Server unit coverage (informational) (push) Waiting to run
Validate Tenant Management Schema / Check for relevant changes (push) Waiting to run
Validate Tenant Management Schema / Validate Tenant Management Schema (push) Blocked by required conditions
EE Workflows Build Guard / ee-workflows-build-guard (push) Waiting to run
Excluded: .git, node_modules, secrets/, compose.env, assemblyscript tgz Source: /opt/alga-psa on psa.joliet.tech
124 lines
4.0 KiB
JavaScript
124 lines
4.0 KiB
JavaScript
const test = require('node:test');
|
|
const assert = require('node:assert/strict');
|
|
const fs = require('node:fs');
|
|
const os = require('node:os');
|
|
const path = require('node:path');
|
|
|
|
function loadHarnessWithStubs(stubs) {
|
|
const harnessRoot = path.resolve(__dirname, '..');
|
|
const runPath = path.join(harnessRoot, 'run.cjs');
|
|
|
|
const depPaths = {
|
|
db: path.join(harnessRoot, 'lib', 'db.cjs'),
|
|
http: path.join(harnessRoot, 'lib', 'http.cjs'),
|
|
workflow: path.join(harnessRoot, 'lib', 'workflow.cjs'),
|
|
runs: path.join(harnessRoot, 'lib', 'runs.cjs'),
|
|
};
|
|
|
|
const saved = {};
|
|
for (const [key, p] of Object.entries(depPaths)) {
|
|
saved[p] = require.cache[p];
|
|
if (stubs[key]) {
|
|
require.cache[p] = { id: p, filename: p, loaded: true, exports: stubs[key] };
|
|
}
|
|
}
|
|
|
|
delete require.cache[runPath];
|
|
// eslint-disable-next-line global-require, import/no-dynamic-require
|
|
const mod = require(runPath);
|
|
|
|
return {
|
|
mod,
|
|
restore() {
|
|
delete require.cache[runPath];
|
|
for (const p of Object.values(depPaths)) {
|
|
if (saved[p]) require.cache[p] = saved[p];
|
|
else delete require.cache[p];
|
|
}
|
|
}
|
|
};
|
|
}
|
|
|
|
function readPlanTests() {
|
|
const planTestsPath = path.resolve(
|
|
process.cwd(),
|
|
'ee/docs/plans/2026-01-26-workflow-harness-fixture-suite/tests.json'
|
|
);
|
|
return JSON.parse(fs.readFileSync(planTestsPath, 'utf8'));
|
|
}
|
|
|
|
function isScaffoldedFixtureDir(fixtureDir) {
|
|
return fs.existsSync(path.join(fixtureDir, '.scaffolded'));
|
|
}
|
|
|
|
for (const item of readPlanTests()) {
|
|
if (!item.fixture || !item.eventType) continue;
|
|
|
|
const fixtureDir = path.resolve(process.cwd(), 'ee/test-data/workflow-harness', item.fixture);
|
|
if (!isScaffoldedFixtureDir(fixtureDir)) continue;
|
|
|
|
test(`${item.id}: scaffolded fixture ${item.fixture} executes via harness`, async () => {
|
|
const bundlePath = path.join(fixtureDir, 'bundle.json');
|
|
const testPath = path.join(fixtureDir, 'test.cjs');
|
|
const bundle = JSON.parse(fs.readFileSync(bundlePath, 'utf8'));
|
|
|
|
const expectedEventName = item.eventType;
|
|
const expectedSchemaRef = bundle.workflows?.[0]?.metadata?.payloadSchemaRef;
|
|
assert.ok(typeof expectedSchemaRef === 'string' && expectedSchemaRef.length > 0, 'expected payloadSchemaRef');
|
|
|
|
const requests = [];
|
|
const harness = loadHarnessWithStubs({
|
|
http: {
|
|
createHttpClient: () => ({
|
|
request: async (p, opts) => {
|
|
requests.push({ path: p, opts });
|
|
return { json: {} };
|
|
}
|
|
})
|
|
},
|
|
db: { createDbClient: async () => ({ query: async () => [], close: async () => {} }) },
|
|
workflow: {
|
|
importWorkflowBundleV1: async () => ({
|
|
createdWorkflows: [{ key: `fixture.${item.fixture}`, workflowId: `wf-${item.id}` }]
|
|
}),
|
|
exportWorkflowBundleV1: async () => ({})
|
|
},
|
|
runs: {
|
|
waitForRun: async () => ({ run_id: `run-${item.id}`, status: 'SUCCEEDED' }),
|
|
getRunSteps: async () => [],
|
|
getRunLogs: async () => [],
|
|
summarizeSteps: () => ({ counts: {}, failed: [] })
|
|
}
|
|
});
|
|
|
|
try {
|
|
const { runFixture } = harness.mod;
|
|
await runFixture({
|
|
testDir: fixtureDir,
|
|
bundlePath,
|
|
testPath,
|
|
baseUrl: 'http://localhost:3010',
|
|
tenantId: 'tenant',
|
|
cookie: 'cookie',
|
|
force: true,
|
|
timeoutMs: 1000,
|
|
debug: false,
|
|
artifactsDir: os.tmpdir(),
|
|
pgUrl: 'postgres://unused'
|
|
});
|
|
} finally {
|
|
harness.restore();
|
|
}
|
|
|
|
assert.equal(requests.length, 1, 'expected exactly one request');
|
|
assert.equal(requests[0].path, '/api/workflow/events');
|
|
assert.equal(requests[0].opts.method, 'POST');
|
|
assert.equal(requests[0].opts.json.eventName, expectedEventName);
|
|
assert.equal(requests[0].opts.json.payloadSchemaRef, expectedSchemaRef);
|
|
assert.equal(typeof requests[0].opts.json.correlationKey, 'string');
|
|
assert.ok(requests[0].opts.json.correlationKey.length > 0);
|
|
assert.equal(requests[0].opts.json.payload.fixtureName, item.fixture);
|
|
});
|
|
}
|
|
|