- Accounts: account and admin pages in Cross Events' layout (top bar, sidebar, a page per section, dark footer); quick links to the church's sites (GET /me/apps); nightly pg_dump backups with Admin -> Backups (run, keep, download, audited; heartbeat lastBackupAt); a fuller built-in privacy notice with headings and bullets; a fixed favicon. /backups/ ignored (anchored, so src/backups is kept). - Contracts 1.11.0: people.removeDemo (only @example.com, never an admin). - Events: uploads served from the folder they're saved in (a backend started outside backend/ answered 404 for a logo it had just saved); Branding checks the file loads before saving; logout waits for the sign-out call so Accounts signs out too; set-demo removes the last demo's people from Accounts. Tests: Accounts 62 + e2e 8, Events 782, contracts 225; npm run check passes. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
40 lines
1.7 KiB
TypeScript
40 lines
1.7 KiB
TypeScript
// 3.3.0: new demo data (set-demo) removes the last demo's people from the church's Accounts
|
|
// (contracts 1.11.0 people.removeDemo), only while sign-in goes through Accounts.
|
|
const mockRequests: Record<string, unknown>[] = [];
|
|
let mockMode = 'accounts';
|
|
|
|
jest.mock('../src/config/db', () => ({}));
|
|
jest.mock('../src/accounts/client', () => ({
|
|
accounts: async () => ({
|
|
request: async (body: { subs: string[] }) => { mockRequests.push(body); return { removed: body.subs.length - 1, kept: [{ sub: body.subs[0], reason: 'not_demo' }] }; },
|
|
}),
|
|
accountsLink: async () => null,
|
|
AccountsUnavailable: class extends Error {},
|
|
}));
|
|
jest.mock('../src/accounts/mode', () => ({
|
|
...jest.requireActual('../src/accounts/mode'),
|
|
authMode: async () => mockMode,
|
|
}));
|
|
|
|
import { removeDemoPeople } from '../src/accounts/move';
|
|
|
|
const sub = (n: number) => `00000000-0000-4000-8000-${String(n).padStart(12, '0')}`;
|
|
|
|
beforeEach(() => { mockRequests.length = 0; mockMode = 'accounts'; });
|
|
|
|
test('asks Accounts to remove each old demo person once, a thousand at a time', async () => {
|
|
const subs = Array.from({ length: 1500 }, (_, i) => sub(i));
|
|
const r = await removeDemoPeople([...subs, subs[0]!, ''], 'admin-sub');
|
|
expect(mockRequests.map((q) => (q.subs as string[]).length)).toEqual([1000, 500]);
|
|
expect(mockRequests[0]).toMatchObject({ type: 'people.removeDemo', actor: 'admin-sub' });
|
|
expect(r).toEqual({ removed: 1498, kept: 2 });
|
|
});
|
|
|
|
test('nothing to ask while sign-in is Events\' own, or with nobody to remove', async () => {
|
|
mockMode = 'events';
|
|
expect(await removeDemoPeople([sub(1)])).toEqual({ removed: 0, kept: 0 });
|
|
mockMode = 'accounts';
|
|
expect(await removeDemoPeople([])).toEqual({ removed: 0, kept: 0 });
|
|
expect(mockRequests).toHaveLength(0);
|
|
});
|