Files
wehub-resource-sync d48cda4081
CI / Test (ubuntu-latest, Node 18.x, bun) (push) Failing after 15m1s
CI / Test (ubuntu-latest, Node 18.x, npm) (push) Failing after 15m1s
CI / Test (ubuntu-latest, Node 18.x, pnpm) (push) Failing after 15m1s
CI / Test (ubuntu-latest, Node 18.x, yarn) (push) Failing after 15m1s
CI / Test (ubuntu-latest, Node 20.x, bun) (push) Failing after 17m13s
CI / Test (ubuntu-latest, Node 20.x, npm) (push) Failing after 18m42s
CI / Test (ubuntu-latest, Node 20.x, pnpm) (push) Failing after 15m0s
CI / Test (ubuntu-latest, Node 20.x, yarn) (push) Failing after 49m44s
CI / Test (ubuntu-latest, Node 22.x, bun) (push) Failing after 51m55s
CI / Test (ubuntu-latest, Node 22.x, pnpm) (push) Failing after 21m57s
CI / Test (ubuntu-latest, Node 22.x, npm) (push) Failing after 37m39s
CI / Test (ubuntu-latest, Node 22.x, yarn) (push) Failing after 34m7s
CI / Validate Components (push) Failing after 37m15s
CI / Python Tests (push) Failing after 10m1s
CI / Security Scan (push) Failing after 10m1s
CI / Lint (push) Failing after 17m12s
CI / Coverage (push) Failing after 20m19s
CI / Test (macos-latest, Node 18.x, bun) (push) Has been cancelled
CI / Test (macos-latest, Node 18.x, npm) (push) Has been cancelled
CI / Test (macos-latest, Node 18.x, pnpm) (push) Has been cancelled
CI / Test (macos-latest, Node 18.x, yarn) (push) Has been cancelled
CI / Test (windows-latest, Node 18.x, npm) (push) Has been cancelled
CI / Test (windows-latest, Node 18.x, pnpm) (push) Has been cancelled
CI / Test (windows-latest, Node 18.x, yarn) (push) Has been cancelled
CI / Test (macos-latest, Node 20.x, bun) (push) Has been cancelled
CI / Test (macos-latest, Node 20.x, npm) (push) Has been cancelled
CI / Test (macos-latest, Node 20.x, pnpm) (push) Has been cancelled
CI / Test (macos-latest, Node 20.x, yarn) (push) Has been cancelled
CI / Test (windows-latest, Node 20.x, npm) (push) Has been cancelled
CI / Test (windows-latest, Node 20.x, pnpm) (push) Has been cancelled
CI / Test (windows-latest, Node 20.x, yarn) (push) Has been cancelled
CI / Test (macos-latest, Node 22.x, bun) (push) Has been cancelled
CI / Test (macos-latest, Node 22.x, npm) (push) Has been cancelled
CI / Test (macos-latest, Node 22.x, pnpm) (push) Has been cancelled
CI / Test (macos-latest, Node 22.x, yarn) (push) Has been cancelled
CI / Test (windows-latest, Node 22.x, npm) (push) Has been cancelled
CI / Test (windows-latest, Node 22.x, pnpm) (push) Has been cancelled
CI / Test (windows-latest, Node 22.x, yarn) (push) Has been cancelled
chore: import upstream snapshot with attribution
2026-07-13 11:55:55 +08:00

101 lines
2.7 KiB
JavaScript

/**
* Tests for allowlisted ECC2 control-pane actions.
*/
const assert = require('assert');
const path = require('path');
const {
buildControlPaneActions,
buildControlPaneAction,
shellQuote,
} = require('../../scripts/lib/control-pane/actions');
function test(name, fn) {
try {
fn();
console.log(` PASS ${name}`);
return true;
} catch (error) {
console.log(` FAIL ${name}`);
console.log(` Error: ${error.message}`);
return false;
}
}
function runTests() {
console.log('\n=== Testing control-pane actions ===\n');
let passed = 0;
let failed = 0;
if (test('builds copyable and executable allowlisted ECC2 actions', () => {
const repoRoot = path.join(__dirname, '..', '..');
const actions = buildControlPaneActions({
repoRoot,
query: 'Hermes Desktop Zellij',
limit: 25,
});
assert.ok(actions.some(action => action.id === 'sync-knowledge'));
assert.ok(actions.some(action => action.id === 'recall-knowledge'));
assert.ok(actions.some(action => action.id === 'open-dashboard'));
const sync = actions.find(action => action.id === 'sync-knowledge');
assert.strictEqual(sync.executable, true);
assert.strictEqual(sync.command, 'cargo');
assert.deepStrictEqual(sync.args, [
'run',
'--quiet',
'--',
'graph',
'connector-sync',
'--all',
'--json',
'--limit',
'25',
]);
assert.strictEqual(sync.cwd, path.join(repoRoot, 'ecc2'));
assert.ok(sync.commandLine.includes('connector-sync'));
})) passed++; else failed++;
if (test('preserves recall query as a single argument instead of shell text', () => {
const action = buildControlPaneAction('recall-knowledge', {
repoRoot: '/repo/ecc',
query: 'Hermes "Desktop"; rm -rf ~',
limit: 7,
});
assert.deepStrictEqual(action.args, [
'run',
'--quiet',
'--',
'graph',
'recall',
'Hermes "Desktop"; rm -rf ~',
'--json',
'--limit',
'7',
]);
assert.ok(action.commandLine.includes("'Hermes \"Desktop\"; rm -rf ~'"));
})) passed++; else failed++;
if (test('rejects unknown action identifiers', () => {
assert.throws(
() => buildControlPaneAction('rm -rf', { repoRoot: '/repo/ecc' }),
/Unknown control-pane action/
);
})) passed++; else failed++;
if (test('shellQuote handles empty strings and single quotes', () => {
assert.strictEqual(shellQuote(''), "''");
assert.strictEqual(shellQuote("can't"), "'can'\\''t'");
assert.strictEqual(shellQuote('simple'), 'simple');
})) passed++; else failed++;
console.log(`\nResults: Passed: ${passed}, Failed: ${failed}`);
process.exit(failed > 0 ? 1 : 0);
}
runTests();