Something went wrong. Try again.
Central platform for European atproto.<cc> country community websites
Something went wrong. Try again.
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172import { describe, it, expect } from 'vitest';import { SCOPES, NAV_DEFAULTS, navFor } from './scopes';import { ACCENT_PACKS } from './accents';
const scopes = Object.entries(SCOPES);const isDid = (s: string) => /^did:(plc|web):/.test(s);
describe('scope accent packs', () => { it('every scope references packs that exist in accents.ts', () => { for (const [id, s] of scopes) { expect(ACCENT_PACKS, `scope ${id} accent "${s.accent}"`).toHaveProperty(s.accent); expect(ACCENT_PACKS, `scope ${id} accent2 "${s.accent2}"`).toHaveProperty(s.accent2); } });
// The design intent (Guido): every country gets a DISTINCT, flag-derived colour lockup. With the // two-colour wordmark, the PAIR (accent, accent2) must be unique — the primary alone may repeat // (e.g. .no red/cobalt and .ch red/grey both have red UI, but read differently). This fails loudly // when a new scope reuses a full pair (e.g. a green/red twin of .it) instead of shipping two // identical-looking wordmarks. it('no two scopes share the same accent pair', () => { const byPair = new Map<string, string[]>(); for (const [id, s] of scopes) { const key = `${s.accent}/${s.accent2}`; byPair.set(key, [...(byPair.get(key) ?? []), id]); } const clashes = [...byPair].filter(([, ids]) => ids.length > 1); expect(clashes, `accent pairs used by more than one scope: ${JSON.stringify(clashes)}`).toEqual( [], ); });
it('every scope has a distinct cc', () => { const ccs = scopes.map(([, s]) => s.cc); expect(new Set(ccs).size).toBe(ccs.length); });});
// The community-manager control panel (decisions/2026-09-21-centralized-country-config.md). These// guard the identity-sensitive fields: managers/seeds/verifier/events are DIDs (never handles, per// the hard rule), and nav toggles resolve against the documented defaults.describe('scope control-panel fields', () => { it('managers, memberSeed, eventDids and verifiers are DIDs, never handles', () => { for (const [id, s] of scopes) { for (const did of s.managers ?? []) expect(isDid(did), `${id} manager "${did}" must be a DID`).toBe(true); for (const did of s.memberSeed ?? []) expect(isDid(did), `${id} memberSeed "${did}" must be a DID`).toBe(true); for (const e of s.eventDids ?? []) expect(isDid(e.did), `${id} eventDids "${e.did}" must be a DID`).toBe(true); for (const v of s.verifiers ?? []) { expect(isDid(v.did), `${id} verifier "${v.handle}" must key on a DID`).toBe(true); expect(v.remit.en, `${id} verifier "${v.handle}" needs an 'en' remit`).toBeTruthy(); } } });
it('navFor merges overrides over the all-shown defaults', () => { for (const [, s] of scopes) { expect(navFor(s)).toEqual({ ...NAV_DEFAULTS, ...(s.nav ?? {}) }); } // A scope with no nav override shows everything. expect(navFor(SCOPES.nl)).toEqual(NAV_DEFAULTS); });
it('a scope with delegated verifiers is also a verifier scope', () => { for (const [id, s] of scopes) { if (s.verifiers?.length) expect(s.verify, `${id} lists verifiers but verify:false`).toBe(true); } });});