Hub 2.25.0: demo clients, and demo data for the Church Website
- A customer can be a demo client: every install a demo site (Accounts included, and any later install), never billed (billing off, no invoice drafted, sent or made by hand). Migration: Customer.isDemo, demoSince. - Any install can be marked as a demo site; Events and the Website have demo data. The Website's eight demo churches need agent 1.6.0. - Contracts 1.19.0 vendored. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -706,6 +706,54 @@ describe('demo sites (2.4.0)', () => {
|
||||
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([]);
|
||||
});
|
||||
|
||||
test('2.25.0: a Website demo site gets a Website profile, on an agent of 1.6.0 or later', async () => {
|
||||
const { server, d } = await liveDemo({ agentVersion: '1.6.0' });
|
||||
await db.deployment.update({ where: { id: d.id }, data: { product: 'website' } });
|
||||
await expect(jobs.seedDemo({ deploymentId: d.id, profile: 'small', confirm: 'demo2' }, admin, NOW)).rejects.toMatchObject({ code: 'BAD_REQUEST', message: expect.stringContaining('heritage-parish') });
|
||||
const job = await jobs.seedDemo({ deploymentId: d.id, profile: 'community-town', confirm: 'demo2' }, admin, NOW);
|
||||
expect(job.args).toEqual({ church: 'demo2', product: 'website', profile: 'community-town' });
|
||||
const polled = await jobs.poll(server, { agentApiVersion: 1, agentVersion: '1.6.0', mode: 'church', runningJobId: null }, NOW);
|
||||
expect(agent.agentJobSchema.safeParse(polled.jobs[0]).success).toBe(true);
|
||||
|
||||
await db.server.update({ where: { id: server.id }, data: { agentVersion: '1.5.0' } });
|
||||
await expect(jobs.seedDemo({ deploymentId: d.id, profile: 'bold-plant', confirm: 'demo2' }, admin, NOW)).rejects.toMatchObject({ code: 'AGENT_TOO_OLD', message: expect.stringContaining('1.6.0') });
|
||||
});
|
||||
|
||||
test('2.25.0: any product can be a demo site, but only Events and the Website have demo data', async () => {
|
||||
const { d } = await liveDemo({ agentVersion: '1.6.0', isDemo: false });
|
||||
await db.deployment.update({ where: { id: d.id }, data: { product: 'accounts' } });
|
||||
expect(await jobs.setDemo(d.id, { isDemo: true, confirm: 'demo2' })).toMatchObject({ isDemo: true });
|
||||
await expect(jobs.seedDemo({ deploymentId: d.id, profile: 'small', confirm: 'demo2' }, admin, NOW)).rejects.toMatchObject({ code: 'NO_DEMO_DATA' });
|
||||
});
|
||||
|
||||
test('2.25.0: a demo client: all its installs demo sites (Accounts too), billing off, new installs demo too', async () => {
|
||||
const { server } = await joinServer();
|
||||
await db.customer.update({ where: { id: 'cust-1' }, data: { billingCycle: 'monthly', nextInvoiceDate: new Date('2026-12-01') } });
|
||||
for (const [id, product, port] of [['dep-ev', 'events', 20000], ['dep-acc', 'accounts', 20002]]) {
|
||||
await db.deployment.create({ data: { id, serverId: server.id, customerId: 'cust-1', product, shortName: 'hope', domain: `${product}.hope.test`, webPort: port, apiPort: port + 1, status: 'live', isDemo: false, removedAt: null } });
|
||||
}
|
||||
await db.invoice.create({ data: { id: 'inv-1', customerId: 'cust-1', status: 'approved' } });
|
||||
await expect(jobs.setCustomerDemo('cust-1', { isDemo: true, confirm: 'Hope' })).rejects.toMatchObject({ code: 'CONFIRM' });
|
||||
const out = await jobs.setCustomerDemo('cust-1', { isDemo: true, confirm: 'Hope Church' }, NOW);
|
||||
expect(out).toMatchObject({ sites: 2, warnings: [expect.stringContaining('1 invoice')] });
|
||||
expect(await db.customer.findUnique({ where: { id: 'cust-1' } })).toMatchObject({ isDemo: true, billingCycle: 'none', nextInvoiceDate: null, demoSince: NOW });
|
||||
expect((await db.deployment.findMany({ where: { customerId: 'cust-1' } })).map(x => x.isDemo)).toEqual([true, true]);
|
||||
await expect(jobs.setDemo('dep-acc', { isDemo: false })).rejects.toMatchObject({ code: 'DEMO_CLIENT' });
|
||||
expect(await jobs.customerIsDemo(db, 'cust-1')).toBe(true);
|
||||
|
||||
await jobs.setCustomerDemo('cust-1', { isDemo: false });
|
||||
expect(await db.customer.findUnique({ where: { id: 'cust-1' } })).toMatchObject({ isDemo: false, billingCycle: 'none', demoSince: null });
|
||||
expect((await db.deployment.findMany({ where: { customerId: 'cust-1' } })).map(x => x.isDemo)).toEqual([false, false]);
|
||||
});
|
||||
|
||||
test('2.25.0: a demo client\'s new install starts as a demo site', async () => {
|
||||
const { server } = await joinServer();
|
||||
await servers.setServerConfig(server.id, { TRUST_PROXY: 'loopback', DB_ADMIN_URL: 'postgresql://admin:pw@10.0.0.5/postgres' });
|
||||
await db.customer.update({ where: { id: 'cust-1' }, data: { isDemo: true } });
|
||||
const { deployment } = await jobs.newInstall({ customerId: 'cust-1', serverId: server.id, shortName: 'hope', domain: 'events.hope.co.za' }, admin, NOW);
|
||||
expect(deployment.isDemo).toBe(true);
|
||||
});
|
||||
});
|
||||
describe('sites added on a server are found and tied to their registration (2.6.0)', () => {
|
||||
const statusResult = (domain = 'accounts.found.co.za') => ({ churches: [{ church: 'found', address: 'found.co.za', products: [
|
||||
|
||||
Reference in New Issue
Block a user