Website 1.3.0, agent 1.6.0, contracts 1.19.0: demo data for the Church Website
Eight demo churches, two per template (the second on the template's other recommended variants and header), loaded from the Hub on demo sites with `crosscode demo <church> website --profile <p>`. A profile replaces the content only: the church's profile from Accounts, the site settings, the site icon and the admins stay, and the copy names the church. - contracts: WEBSITE_DEMO_PROFILES, DEMO_PRODUCTS, SEED_WEBSITE_DEMO_MIN_AGENT; seed-demo takes an optional product (events by default) - agent: a Website seed-demo job runs `crosscode demo <church> website` - crosscode script: backup, demo as the site's user, reload, health check Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -4,8 +4,9 @@ import fs from 'node:fs';
|
||||
import os from 'node:os';
|
||||
import path from 'node:path';
|
||||
import request from 'supertest';
|
||||
import { WEBSITE_TEMPLATES } from '@crosscode/contracts';
|
||||
import { loadDemo } from '../src/demo/demoChurch.js';
|
||||
import { WEBSITE_TEMPLATES, agent } from '@crosscode/contracts';
|
||||
import { demoProfile, loadDemo, seedDesign } from '../src/demo/demoChurch.js';
|
||||
import { DEMO_SEEDS, demoSeeds } from '../src/demo/seeds.js';
|
||||
import { siteContent, spotifyEmbed, youtubeId } from '../src/site/content.js';
|
||||
import { buildPalette, contrast, hexToRgb } from '../src/site/palette.js';
|
||||
import { parseSectionData } from '../src/site/sections.js';
|
||||
@@ -122,6 +123,67 @@ describe('the public site\'s content', () => {
|
||||
});
|
||||
}
|
||||
|
||||
for (const profile of agent.WEBSITE_DEMO_PROFILES) {
|
||||
it(`1.3.0: loads the ${profile} demo, keeping the church's own profile and naming it`, async () => {
|
||||
const h = await harness({ linked: false });
|
||||
const dir = tmp();
|
||||
const own = { ...demoProfile('http://x.test'), name: 'Grace Point Church', shortName: 'Grace Point', branding: { ...demoProfile('').branding, colours: { primary: '#8a1538', accent: '#f2c14e' } } };
|
||||
await h.ctx.settings.set('church_profile_local', JSON.stringify(own));
|
||||
await loadDemo(h.ctx, profile, { uploadDir: dir });
|
||||
const c = await siteContent(h.ctx);
|
||||
assert.equal(c.mode, 'published');
|
||||
if (c.mode !== 'published') return;
|
||||
const seed = DEMO_SEEDS[profile];
|
||||
assert.equal(c.snapshot.design.template, seed.template);
|
||||
assert.equal(c.church?.name, 'Grace Point Church', 'the organisation settings stay');
|
||||
assert.equal(c.snapshot.pages.length, 9);
|
||||
assert.equal(c.snapshot.ministries.length, 4);
|
||||
assert.equal(c.messages.length, 3);
|
||||
assert.equal(c.events.length, 3);
|
||||
const all = JSON.stringify(c.snapshot);
|
||||
assert.doesNotMatch(all, /\{(name|short|city)\}/, 'every placeholder is filled in');
|
||||
assert.doesNotMatch(all, /Acacia/, 'nothing of the development church');
|
||||
assert.equal(c.snapshot.design.variants.hero, seedDesign(seed.template, seed.alternate).variants.hero);
|
||||
assert.match(fs.readFileSync(path.join(dir, 'demo', 'hero.svg'), 'utf8'), /#8a1538/, 'pictures in the church\'s colours');
|
||||
});
|
||||
}
|
||||
|
||||
it('1.3.0: the two profiles of a template differ, the second on its other recommended variants and header', () => {
|
||||
for (const template of WEBSITE_TEMPLATES) {
|
||||
const [a, b] = demoSeeds().filter((s) => s.template === template);
|
||||
assert.ok(a && b && !a.alternate && b.alternate, template);
|
||||
const alt = seedDesign(template, true);
|
||||
assert.notDeepEqual(alt.variants, seedDesign(template, false).variants);
|
||||
assert.notEqual(alt.style.header, seedDesign(template, false).style.header);
|
||||
assert.notEqual(a.hero.headline, b.hero.headline);
|
||||
}
|
||||
});
|
||||
|
||||
it('1.3.0: a profile keeps the site icon and the settings, and clears the old content, slugs and preview links', async () => {
|
||||
const h = await harness({ linked: false });
|
||||
const dir = tmp();
|
||||
await loadDemo(h.ctx, 'heritage', { uploadDir: dir });
|
||||
const icon = (await h.db.mediaAsset.create({ data: { filename: 'icon.png', mime: 'image/png', bytes: 10, width: 64, height: 64, alt: 'Icon' } })) as { id: string };
|
||||
await h.ctx.settings.set('favicon_media_id', icon.id);
|
||||
await h.ctx.settings.set('coming_soon_text', 'Soon!');
|
||||
await h.db.slugHistory.create({ data: { slug: 'old-about', pageId: 'gone' } });
|
||||
await loadDemo(h.ctx, 'community-town', { uploadDir: dir });
|
||||
assert.ok(await h.db.mediaAsset.findUnique({ where: { id: icon.id } }), 'the site icon stays');
|
||||
assert.equal(await h.ctx.settings.get('favicon_media_id'), icon.id);
|
||||
assert.equal(await h.ctx.settings.get('coming_soon_text'), 'Soon!');
|
||||
assert.equal(await h.db.mediaAsset.count(), 11, 'the ten pictures and the icon');
|
||||
assert.equal(await h.db.slugHistory.count(), 0);
|
||||
assert.equal((await siteContent(h.ctx)).church?.name, 'Acacia Hill Church', 'the profile saved by the first demo stays');
|
||||
});
|
||||
|
||||
it('1.3.0: a profile on a site with no church profile at all saves the demo one, so the site has a name', async () => {
|
||||
const h = await harness({ linked: false });
|
||||
await loadDemo(h.ctx, 'clean-campus', { uploadDir: tmp() });
|
||||
const c = await siteContent(h.ctx);
|
||||
assert.equal(c.church?.name, 'Acacia Hill Church');
|
||||
assert.ok(c.mode === 'published' && JSON.stringify(c.snapshot).includes('Welcome to Acacia Hill'));
|
||||
});
|
||||
|
||||
it('serves the uploads, never a folder or outside it, and the content over HTTP', async () => {
|
||||
const dir = tmp();
|
||||
const h = await harness({ linked: false, env: { UPLOAD_DIR: dir } });
|
||||
|
||||
Reference in New Issue
Block a user