Changeset 0.28.6 (#192)

This commit is contained in:
2026-03-15 01:33:38 +00:00
parent 6f0ad1355c
commit bffda043db
59 changed files with 3022 additions and 77 deletions

View File

@@ -249,5 +249,66 @@
}
}
// ── System functions (v0.28.6) ──
await T.test('crud', 'tasks', 'GET /admin/system-functions', async function () {
var d = await T.apiGet('/admin/system-functions');
T.assertHasKey(d, 'data', 'system-functions');
T.assert(Array.isArray(d.data), 'data should be array');
T.assert(d.data.length >= 4, 'should have at least 4 built-in functions, got ' + d.data.length);
var names = d.data.map(function(f) { return f.name; });
T.assert(names.indexOf('session_cleanup') >= 0, 'should include session_cleanup');
T.assert(names.indexOf('staleness_check') >= 0, 'should include staleness_check');
T.assert(names.indexOf('retention_sweep') >= 0, 'should include retention_sweep');
T.assert(names.indexOf('health_prune') >= 0, 'should include health_prune');
// Verify shape
T.assert(typeof d.data[0].name === 'string', 'name should be string');
T.assert(typeof d.data[0].description === 'string', 'description should be string');
});
var sysTaskId = null;
await T.test('crud', 'tasks', 'POST /tasks (create system task)', async function () {
var d = await T.apiPost('/tasks', {
name: testTag + '-system-task',
task_type: 'system',
system_function: 'health_prune',
schedule: '0 3 * * *',
scope: 'global',
});
T.assert(d.id, 'should return id');
T.assert(d.task_type === 'system', 'task_type should be system');
T.assert(d.system_function === 'health_prune', 'system_function should be health_prune');
sysTaskId = d.id;
T.registerCleanup(function () { if (sysTaskId) return T.safeDelete('/tasks/' + sysTaskId); });
});
if (sysTaskId) {
await T.test('crud', 'tasks', 'DELETE /tasks/:id (cleanup system task)', async function () {
await T.safeDelete('/tasks/' + sysTaskId);
sysTaskId = null;
});
}
await T.test('crud', 'tasks', 'POST /tasks (system task — invalid function → 400)', async function () {
var token = await T.getAuthToken();
var d = await T.authFetch(token, 'POST', '/tasks', {
name: 'bad-func',
task_type: 'system',
system_function: 'nonexistent_func',
schedule: '0 3 * * *',
});
T.assertStatus(d, 400, 'invalid system function');
});
await T.test('crud', 'tasks', 'POST /tasks (system task — missing function → 400)', async function () {
var token = await T.getAuthToken();
var d = await T.authFetch(token, 'POST', '/tasks', {
name: 'no-func',
task_type: 'system',
schedule: '0 3 * * *',
});
T.assertStatus(d, 400, 'missing system_function');
});
};
})();