import { describe, it, expect } from 'vitest'; import { readFileSync, existsSync } from 'node:fs'; import { fileURLToPath } from 'node:url'; import { dirname, resolve } from 'node:path'; import { BRAND, BRAND_GLYPHS } from './brand'; // Assets are referenced by absolute URL (/brand/...) and served from client/public. const publicDir = resolve(dirname(fileURLToPath(import.meta.url)), '../public'); const toFile = (assetUrl: string) => resolve(publicDir, assetUrl.replace(/^\//, '')); describe('brand glyph assets', () => { // TS proves each BrandGlyphName has an asset path; it can't prove the FILE exists. // This is the exact failure mode of "images added but the path is wrong / renamed". it('every glyph resolves to a real, non-empty SVG file on disk', () => { for (const [name, glyph] of Object.entries(BRAND_GLYPHS)) { expect(glyph.asset, `${name} asset path shape`).toMatch(/^\/brand\/glyphs\/.+\.svg$/); const file = toFile(glyph.asset); expect(existsSync(file), `${name} → ${glyph.asset} missing on disk`).toBe(true); expect(readFileSync(file, 'utf8'), `${name} is a valid `).toMatch(/]/); } }); it('every /brand asset referenced in brand.ts exists on disk', () => { for (const [key, url] of Object.entries(BRAND.assets)) { if (!url.startsWith('/brand/')) continue; // skip third-party (/img/) icons expect(existsSync(toFile(url)), `${key} → ${url} missing on disk`).toBe(true); } }); });