Hub 2.9.0: whether people can sign in

- An Events install's page shows its sign-in mode, whether it's linked to the church's Accounts,
  and the last sign-in failure (Events 3.5.0 heartbeat, contracts 1.13.0 vendored).
- Alerts: signs in through Accounts but isn't linked (critical), linked to the wrong Accounts, a
  sign-in failed in the last 24 hours, an Accounts nothing is linked to while the church has Events.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-11-20 12:56:41 +02:00
co-authored by Claude Opus 5.5
parent 1150a82ecc
commit 894f2b2771
12 changed files with 130 additions and 19 deletions
+18
View File
@@ -127,6 +127,24 @@ describe('alerts', () => {
expect(types).toEqual(['offline']);
});
test('2.9.0: sign-in through Accounts without a link, linked to the wrong Accounts, failing; an Accounts nothing links to', () => {
const { churchesOf } = require('../src/utils/alerts');
const church = churchesOf([{ id: 'acc-1', product: 'accounts', customerId: 'c1' }, { id: 'ev-1', product: 'events', customerId: 'c1' }]).get('c1');
const signIn = (s) => problems({ ...healthy, product: 'events', church, stats: { signIn: s } }, settings, now);
expect(signIn({ mode: 'accounts', accounts: null, lastError: null }).map(p => [p.type, p.level])).toEqual([['signin_not_linked', 'critical']]);
expect(signIn({ mode: 'local', accounts: null, lastError: null })).toEqual([]);
expect(signIn({ mode: 'accounts', accounts: { installId: 'acc-1', url: 'https://accounts.hope.test' }, lastError: null })).toEqual([]);
expect(signIn({ mode: 'accounts', accounts: { installId: 'acc-other', url: 'https://accounts.other.test' }, lastError: null }).map(p => p.type)).toEqual(['signin_wrong_accounts']);
const failing = signIn({ mode: 'accounts', accounts: { installId: 'acc-1', url: 'https://accounts.hope.test' }, lastError: { at: '2026-10-24T11:00:00Z', code: 'ACCOUNTS_UNAVAILABLE', message: 'fetch failed' } });
expect(failing[0]).toMatchObject({ type: 'signin_failing', message: expect.stringContaining('fetch failed') });
// A day-old failure is history, not a problem.
expect(signIn({ mode: 'accounts', accounts: { installId: 'acc-1', url: 'x' }, lastError: { at: '2026-10-22T11:00:00Z', code: 'X', message: 'old' } })).toEqual([]);
// Older Events (no signIn): nothing to say.
expect(problems({ ...healthy, product: 'events', church, stats: {} }, settings, now)).toEqual([]);
expect(problems({ ...healthy, product: 'accounts', church, stats: { linkedProducts: 0 } }, { ...settings, latest_versions: {} }, now).map(p => p.type)).toEqual(['accounts_unlinked']);
expect(problems({ ...healthy, product: 'accounts', church, stats: { linkedProducts: 1 } }, { ...settings, latest_versions: {} }, now)).toEqual([]);
});
test('version comparison', () => {
expect(compareVersions('1.40.2', '1.41.0')).toBeLessThan(0);
expect(compareVersions('1.41.0', '1.41.0')).toBe(0);