lernschiff/tests/Feature/Frontend/BrandAssetsTest.php

73 lines
3.0 KiB
PHP

<?php
/**
* Verifies brand assets (logos, favicons, PWA icons, manifest) are
* physically present in public/ and that the Brand component renders.
*/
use Illuminate\Support\Facades\File;
it('logo SVG files exist in public/logo', function () {
$base = base_path('public/logo');
foreach (['favicon.svg', 'favicon.ico', 'lernschiff-icon.svg', 'lernschiff-wordmark.svg', 'lernschiff-icon-monochrome.svg'] as $f) {
expect(File::exists("{$base}/{$f}"))->toBeTrue("Missing logo asset: {$f}");
}
});
it('PWA icons exist in public/icons', function () {
$base = base_path('public/icons');
foreach (['icon-192.png', 'icon-512.png', 'icon-512-maskable.png', 'apple-touch-icon.png', 'favicon-16.png', 'favicon-32.png'] as $f) {
expect(File::exists("{$base}/{$f}"))->toBeTrue("Missing PWA icon: {$f}");
}
});
it('PWA icon-192 is a real PNG (>= 4KB), not empty stub', function () {
$size = filesize(base_path('public/icons/icon-192.png'));
expect($size)->toBeGreaterThan(4000, "icon-192.png too small ({$size} bytes) — looks like empty stub");
});
it('PWA manifest exists, has icons array', function () {
$path = base_path('public/manifest.webmanifest');
expect(File::exists($path))->toBeTrue('manifest.webmanifest missing');
$manifest = json_decode(File::get($path), true);
expect($manifest)->toBeArray();
expect($manifest)->toHaveKeys(['name', 'short_name', 'icons']);
expect($manifest['icons'])->toBeArray()->not->toBeEmpty();
});
it('brand component template exists', function () {
expect(File::exists(base_path('resources/views/components/layout/brand.blade.php')))->toBeTrue();
});
it('brand component default variant renders icon + wordmark text', function () {
$html = view('components.layout.brand')->render();
expect($html)->toContain('lernschiff-icon.svg');
expect($html)->toContain('Lernschiff');
expect($html)->toContain('aria-label="Lernschiff Home"');
});
it('brand component wordmark variant renders wordmark SVG', function () {
$html = view('components.layout.brand', ['variant' => 'wordmark'])->render();
expect($html)->toContain('lernschiff-wordmark.svg');
});
it('brand component icon-only variant renders just icon', function () {
$html = view('components.layout.brand', ['variant' => 'icon-only'])->render();
expect($html)->toContain('lernschiff-icon.svg');
expect($html)->not->toContain('lernschiff-wordmark.svg');
});
it('dashboard layout references favicon SVG + manifest', function () {
$tpl = file_get_contents(base_path('resources/views/layouts/dashboard.blade.php'));
expect($tpl)->toContain('logo/favicon.svg');
expect($tpl)->toContain('manifest.webmanifest');
expect($tpl)->toContain('apple-touch-icon');
});
it('guest layout references favicon SVG + manifest', function () {
$tpl = file_get_contents(base_path('resources/views/layouts/guest.blade.php'));
expect($tpl)->toContain('logo/favicon.svg');
expect($tpl)->toContain('manifest.webmanifest');
});