Events 3.4.0, Accounts 1.4.0, contracts 1.12.0, agent 1.3.0: jobs from the dashboard, styled Accounts emails, .env from the Hub
- Events and Accounts: Background jobs are switched on or off and rescheduled from the admin; the choice is kept in the database (job_overrides), wins over the .env and applies at once. Accounts gets an Admin -> Background jobs page and per-job env flags, as Events. - Accounts: every email styled as Cross Events' (church colour, logo, button, footer), same plain text (src/lib/emails.ts). - Contracts 1.12.0: env-read / env-set agent jobs, envReadResultSchema, isSecretEnvName. - crosscode script: `crosscode env <church> <product>` reads the .env (secrets hidden) and, with --set/--unset/--restart, changes one file, rebuilds the frontend when its file changed, reloads, and puts the file back if the site doesn't answer (lib/envedit.cjs, tests/envedit.bats). - Agent 1.3.0: runs env-read and env-set. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -36,6 +36,41 @@ describe('job registry', () => {
|
||||
warn.mockRestore();
|
||||
});
|
||||
|
||||
test('3.4.0: an admin choice wins over the env flag and schedule; JOBS_ENABLED=false still wins over everything', () => {
|
||||
const { setOverridesForTest, envEnabled } = require('../src/jobs');
|
||||
try {
|
||||
delete process.env.JOBS_ENABLED;
|
||||
process.env.WAITLIST_JOB_ENABLED = 'false';
|
||||
process.env.JOB_SCHEDULE_WAITLIST = '*/5 * * * *';
|
||||
setOverridesForTest({ waitlist: { enabled: true, cron: '*/20 * * * *' }, backup: { enabled: false } });
|
||||
expect(envEnabled(job('waitlist'))).toBe(false);
|
||||
expect(isEnabled(job('waitlist'))).toBe(true);
|
||||
expect(cronFor(job('waitlist'))).toBe('*/20 * * * *');
|
||||
expect(isEnabled(job('backup'))).toBe(false);
|
||||
expect(isEnabled(job('temp-cleanup'))).toBe(true); // no env flag, no choice
|
||||
process.env.JOBS_ENABLED = 'false';
|
||||
expect(isEnabled(job('waitlist'))).toBe(false);
|
||||
// A broken saved schedule falls back to the env's.
|
||||
delete process.env.JOBS_ENABLED;
|
||||
setOverridesForTest({ waitlist: { cron: 'nonsense' } });
|
||||
expect(cronFor(job('waitlist'))).toBe('*/5 * * * *');
|
||||
expect(isEnabled(job('waitlist'))).toBe(false); // the env flag again
|
||||
} finally {
|
||||
setOverridesForTest({});
|
||||
}
|
||||
});
|
||||
|
||||
test('3.4.0: setOverride checks its input before saving', async () => {
|
||||
const { setOverride, isCron } = require('../src/jobs');
|
||||
expect(isCron('*/10 * * * *')).toBe(true);
|
||||
expect(isCron('0 7 * * *')).toBe(true);
|
||||
expect(isCron('every day')).toBe(false);
|
||||
expect(isCron('* * * * * *')).toBe(false); // seconds aren't offered
|
||||
await expect(setOverride('nope', { enabled: true })).rejects.toMatchObject({ statusCode: 404 });
|
||||
await expect(setOverride('waitlist', { enabled: 'yes' })).rejects.toMatchObject({ statusCode: 400 });
|
||||
await expect(setOverride('waitlist', { cron: 'every day' })).rejects.toMatchObject({ statusCode: 400 });
|
||||
});
|
||||
|
||||
test('daily jobs fire at local (Johannesburg) time', () => {
|
||||
// 07:00 SAST = 05:00 UTC
|
||||
const next = nextRun('0 7 * * *', new Date('2026-11-04T06:00:00Z'));
|
||||
|
||||
Reference in New Issue
Block a user