import { readFileSync } from 'node:fs'; import { resolve } from 'node:path'; import { runInNewContext } from 'node:vm'; import { describe, expect, it } from 'vitest'; import indexHtml from '../index.html?raw'; import { initialLang } from './i18n/i18n'; import { initialTheme } from './shell/theme'; const publicFile = (name: string) => readFileSync(resolve(import.meta.dirname, '../public', name)); /** Breite, Höhe und Farbtyp aus dem IHDR-Block eines PNG (Farbtyp 2 = RGB ohne Alphakanal, 6 = RGBA). */ function pngInfo(buf: Buffer) { expect(buf.subarray(0, 8).toString('hex')).toBe('89504e470d0a1a0a'); expect(buf.subarray(12, 16).toString('ascii')).toBe('IHDR'); return { width: buf.readUInt32BE(16), height: buf.readUInt32BE(20), colorType: buf[25] }; } describe('Name und Kopfbereich', () => { it('Titel und Meta-Angaben nennen AirCard-IOS', () => { // Statisch englisch, damit Link-Vorschauen englisch sind; der Router setzt danach den Titel in der gewählten Sprache. expect(indexHtml).toContain('AirCard-IOS – Card designs for Apple Wallet'); expect(indexHtml).toContain( '', ); expect(indexHtml).toContain(''); expect(indexHtml).toContain(''); }); it('Icon-Links: SVG, 32-px-PNG, Apple-Touch-Icon', () => { expect(indexHtml).toContain(''); expect(indexHtml).toContain(''); expect(indexHtml).toContain(''); }); it('Kopfzeile: dekoratives Logo (28 x 28) links vom Namen, beides im Markenlink', () => { expect(indexHtml).toContain( 'AirCard-IOS', ); }); it('Fußzeile ist leer: ihren Text setzt mountFooter in der gewählten Sprache', () => { expect(indexHtml).toContain(''); expect(indexHtml).not.toContain('Inoffizielles Hobbyprojekt'); }); }); describe('Icon-Dateien', () => { it('favicon-32.png ist 32 x 32', () => { expect(pngInfo(publicFile('favicon-32.png'))).toMatchObject({ width: 32, height: 32 }); }); it('apple-touch-icon.png ist 180 x 180 und deckend (RGB ohne Alphakanal, kein transparenter Rand)', () => { expect(pngInfo(publicFile('apple-touch-icon.png'))).toEqual({ width: 180, height: 180, colorType: 2 }); }); }); describe('Inline-Skript für Hell/Dunkel und Sprache in index.html', () => { const script = /