All checks were successful
CD / Build and push images (push) Successful in 3m24s
CI / Lint, typecheck, test (push) Successful in 3m6s
CI / Auth e2e pack (push) Successful in 4m8s
CI / Build container images (push) Has been skipped
CD / Deploy to Test (push) Successful in 8s
CD / Smoke tests against Test (push) Successful in 1m13s
CD / Promote to Int (push) Successful in 11s
Self-hosted Google Fonts with per-pond selection (ADR 0016), the GDPR "zero external requests" posture (security.md, CSP `font-src 'self'`). - Catalog: a curated 15-family OFL/Apache list in shared (family, weights, category, license, google-webfonts-helper id). `deploy/fonts/build-fonts.mjs` validates every entry has license info (fails the build otherwise), downloads the WOFF2 weights into apps/web/public/fonts/ (gitignored), and generates the @font-face stylesheet — run at image build time from the web Dockerfile (with retries), never from a visitor's browser. - Application: PondFontScope sets --font-heading/body/mono (+ weights) from pond.settings.fonts on the editor + read view; the existing global CSS already reads those custom properties, so headings/body/code re-resolve to the pond's fonts. A pond with no settings arrives with the defaulted values (Roboto 400 / Roboto 200 / Fira Code), so the vision defaults always render. - Admin UI: pond-settings 'Appearance' section — three slots (family + weight) with a live preview, Pond-Admin-gated (fonts added to updatePondInputSchema and merged in PondsService.update); a font catalog attribution page (/fonts) listing families and licenses. New `font` i18n namespace (de+en). - CSP: strict Content-Security-Policy in nginx.conf (default-src 'self'; font-src 'self'; style-src 'self' 'unsafe-inline'; script-src 'self'; …) — the app's scripts are all external files, inline styles cover CSS variables. - Tests: shared catalog-integrity unit test (the invariant the build enforces); e2e fonts pack — no request leaves the origin when rendering a pond (the GDPR network assertion), a font choice applies to a page and persists, and a pond without settings renders the defaults. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01EwZ4jR4KFAPvpjWevfUGX1
44 lines
1.9 KiB
TypeScript
44 lines
1.9 KiB
TypeScript
import { describe, expect, it } from 'vitest';
|
|
|
|
import { DEFAULT_FONTS, FONT_CATALOG, fontEntry, fontSlug, fontStack } from './fonts';
|
|
|
|
describe('font catalog (issue #66, ADR 0016)', () => {
|
|
it('is non-trivial and has unique families', () => {
|
|
expect(FONT_CATALOG.length).toBeGreaterThanOrEqual(15);
|
|
const families = FONT_CATALOG.map((f) => f.family);
|
|
expect(new Set(families).size).toBe(families.length);
|
|
});
|
|
|
|
it('every entry carries license info and weights (what the build step enforces)', () => {
|
|
for (const entry of FONT_CATALOG) {
|
|
expect(entry.family, entry.id).toBeTruthy();
|
|
expect(entry.license, entry.family).toMatch(/OFL-1\.1|Apache-2\.0/);
|
|
expect(entry.licenseUrl, entry.family).toMatch(/^https:\/\//);
|
|
expect(entry.weights.length, entry.family).toBeGreaterThan(0);
|
|
expect(entry.id, entry.family).toMatch(/^[a-z0-9-]+$/);
|
|
}
|
|
});
|
|
|
|
it('the vision defaults exist in the catalog at their weights', () => {
|
|
for (const slot of ['heading', 'body', 'mono'] as const) {
|
|
const { family, weight } = DEFAULT_FONTS[slot];
|
|
const entry = fontEntry(family);
|
|
expect(entry, `${slot} default family`).toBeDefined();
|
|
expect(entry!.weights, `${family} @ ${weight}`).toContain(weight);
|
|
}
|
|
});
|
|
|
|
it('builds a stack with the family ahead of a category fallback', () => {
|
|
expect(fontStack('Roboto')).toBe("'Roboto', system-ui, -apple-system, 'Segoe UI', sans-serif");
|
|
expect(fontStack('Merriweather')).toContain("'Merriweather'");
|
|
expect(fontStack('Fira Code')).toContain('monospace');
|
|
// An unknown family falls back to the sans system stack, no bogus family.
|
|
expect(fontStack('Nonexistent Font')).not.toContain('Nonexistent');
|
|
});
|
|
|
|
it('slugs families to the on-disk /fonts layout', () => {
|
|
expect(fontSlug('Source Serif 4')).toBe('source-serif-4');
|
|
expect(fontSlug('IBM Plex Mono')).toBe('ibm-plex-mono');
|
|
});
|
|
});
|