Hub 2.4.0: demo sites, and demo data loaded from the Hub

Mark a Cross Events install as a demo site, then load a demo set (small,
events, ministry, multicampus) with a seed-demo job (agent 1.2.0+,
crosscode demo: backup, demo data, restart). Typing the short name for both.
Deployment.isDemo (migration), contracts 1.7.0 vendored.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-11-19 10:41:03 +02:00
co-authored by Claude Opus 5.5
parent 36987a9b69
commit dbfa4116c4
15 changed files with 149 additions and 14 deletions
+38
View File
@@ -455,3 +455,41 @@ describe('adopting an existing install', () => {
expect(job.args.address).toBe('hope.co.za');
});
});
describe('demo sites (2.4.0)', () => {
async function liveDemo({ agentVersion = '1.2.0', isDemo = true, adminEmail = 'Jane@Hope.test' } = {}) {
const { server } = await joinServer();
await db.server.update({ where: { id: server.id }, data: { agentVersion } });
const d = await db.deployment.create({ data: { id: 'dep-demo', serverId: server.id, customerId: 'cust-1', product: 'events', shortName: 'demo2', domain: 'events.demo2.test', webPort: 20000, apiPort: 20001, status: 'live', isDemo, adminEmail } });
return { server, d };
}
test('marking a site as demo asks for its short name; unmarking doesn\'t', async () => {
const { d } = await liveDemo({ isDemo: false });
await expect(jobs.setDemo(d.id, { isDemo: true, confirm: 'nope' })).rejects.toMatchObject({ code: 'CONFIRM' });
expect(await jobs.setDemo(d.id, { isDemo: true, confirm: 'demo2' })).toMatchObject({ isDemo: true });
expect(await jobs.setDemo(d.id, { isDemo: false })).toMatchObject({ isDemo: false });
});
test('a seed-demo job for a demo site: the profile, and its admin kept', async () => {
const { server, d } = await liveDemo();
const job = await jobs.seedDemo({ deploymentId: d.id, profile: 'ministry', confirm: 'demo2' }, admin, NOW);
expect(job).toMatchObject({ type: 'seed-demo', deploymentId: d.id, args: { church: 'demo2', profile: 'ministry', adminEmail: 'jane@hope.test' } });
const polled = await jobs.poll(server, { agentApiVersion: 1, agentVersion: '1.2.0', mode: 'church', runningJobId: null }, NOW);
expect(agent.agentJobSchema.safeParse(polled.jobs[0]).success).toBe(true);
expect(polled.jobs[0].config).toBeNull();
});
test('refused: not a demo site, wrong short name, unknown profile, an agent before 1.2.0', async () => {
let { d } = await liveDemo({ isDemo: false });
await expect(jobs.seedDemo({ deploymentId: d.id, profile: 'small', confirm: 'demo2' }, admin, NOW)).rejects.toMatchObject({ code: 'NOT_DEMO' });
await db.deployment.update({ where: { id: d.id }, data: { isDemo: true } });
await expect(jobs.seedDemo({ deploymentId: d.id, profile: 'small', confirm: 'demo' }, admin, NOW)).rejects.toMatchObject({ code: 'CONFIRM' });
await expect(jobs.seedDemo({ deploymentId: d.id, profile: 'everything', confirm: 'demo2' }, admin, NOW)).rejects.toMatchObject({ code: 'BAD_REQUEST' });
await seed();
({ d } = await liveDemo({ agentVersion: '1.1.1' }));
await expect(jobs.seedDemo({ deploymentId: d.id, profile: 'small', confirm: 'demo2' }, admin, NOW)).rejects.toMatchObject({ code: 'AGENT_TOO_OLD', message: expect.stringContaining('1.2.0') });
expect(await db.job.findMany({})).toEqual([]);
});
});