This repository has been archived on 2026-04-03. You can view files and clone it. You cannot open issues or pull requests or push a commit.
Files
core/packages/schedules-runner/js/schedules-crud.js
Jeffrey Smith d6c7b21713
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
Feat v0.7.2 package runners ci gate (#56)
Co-authored-by: Jeffrey Smith <jasafpro@gmail.com>
Co-committed-by: Jeffrey Smith <jasafpro@gmail.com>
2026-04-02 12:10:57 +00:00

66 lines
1.9 KiB
JavaScript

/**
* Schedules Runner — schedules/crud suite
*
* Tests schedule CRUD via the kernel schedules API.
*/
(function () {
'use strict';
var API = window.SR.api;
sw.testing.suite('schedules/crud', async function (s) {
var schedId;
s.test('create schedule', async function (t) {
var r = await sw.api.post(API, {
name: 'runner-test-' + Date.now(),
cron_expr: '0 0 * * *',
script: 'print("hello from schedule runner")',
enabled: false
});
t.assert.ok(r.id, 'schedule has id');
t.assert.ok(r.name, 'schedule has name');
schedId = r.id;
s.track('schedule', schedId);
});
s.test('get schedule', async function (t) {
t.assert.ok(schedId, 'schedId from previous test');
var r = await sw.api.get(API + '/' + schedId);
t.assert.eq(r.id, schedId, 'id matches');
t.assert.ok(r.cron_expr, 'cron_expr present');
});
s.test('update schedule', async function (t) {
t.assert.ok(schedId, 'schedId from previous test');
var r = await sw.api.put(API + '/' + schedId, {
name: 'runner-test-updated',
cron_expr: '30 2 * * *'
});
t.assert.eq(r.name, 'runner-test-updated', 'name updated');
});
s.test('run schedule', async function (t) {
t.assert.ok(schedId, 'schedId from previous test');
try {
await sw.api.post(API + '/' + schedId + '/run', {});
t.assert.ok(true, 'run endpoint returned successfully');
} catch (e) {
t.warn('Schedule run failed: ' + e.message);
}
});
s.test('delete schedule', async function (t) {
t.assert.ok(schedId, 'schedId from previous test');
await sw.api.del(API + '/' + schedId);
try {
await sw.api.get(API + '/' + schedId);
t.assert.ok(false, 'expected error after delete');
} catch (e) {
t.assert.ok(true, 'schedule not found after delete');
}
schedId = null;
});
});
})();