Die Domain-Auflösung matchte den Host exakt gegen domain_name — www.presseecho.de fiel dadurch aufs Portal-Default-Theme zurück, dessen theme-portal.css im Web-Build nicht existiert. Alle Route::view-Seiten ohne Controller (Impressum, Datenschutz, AGB, FAQ, …) antworteten auf www-Hosts mit 500 (ViteException, Dauereintrag im Live-Log); die Controller-Seiten traf es nicht, weil WebPortalContext den Host tolerant matcht. resolve() normalisiert Hosts jetzt (lowercase, www. entfernt) auf beiden Seiten des Vergleichs. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
106 lines
3.6 KiB
PHP
106 lines
3.6 KiB
PHP
<?php
|
|
|
|
use App\Support\DomainAssetContext;
|
|
use Illuminate\Http\Request;
|
|
|
|
test('pressekonto homepage resolves to web assets', function () {
|
|
$defaults = ['theme' => 'fallback', 'assets_dir' => 'build/b2in'];
|
|
$domains = config('domains.domains');
|
|
|
|
$config = DomainAssetContext::resolve(
|
|
'pressekonto.test',
|
|
$defaults,
|
|
$domains,
|
|
null,
|
|
Request::create('https://pressekonto.test/', 'GET'),
|
|
);
|
|
|
|
expect($config['theme'])->toBe('pressekonto')
|
|
->and($config['assets_dir'])->toBe('build/web');
|
|
});
|
|
|
|
test('pressekonto admin routes resolve to portal assets', function () {
|
|
$defaults = ['theme' => 'fallback', 'assets_dir' => 'build/b2in'];
|
|
$domains = config('domains.domains');
|
|
|
|
$config = DomainAssetContext::resolve(
|
|
'pressekonto.test',
|
|
$defaults,
|
|
$domains,
|
|
null,
|
|
Request::create('https://pressekonto.test/admin/users', 'GET'),
|
|
);
|
|
|
|
expect($config['theme'])->toBe('portal')
|
|
->and($config['assets_dir'])->toBe('build/portal')
|
|
->and($config['asset_url'])->toBe('https://assets.pressekonto.test');
|
|
});
|
|
|
|
test('presseecho resolves to its own web theme', function () {
|
|
$defaults = ['theme' => 'fallback', 'assets_dir' => 'build/b2in'];
|
|
$domains = config('domains.domains');
|
|
|
|
$config = DomainAssetContext::resolve(
|
|
'presseecho.test',
|
|
$defaults,
|
|
$domains,
|
|
);
|
|
|
|
expect($config['theme'])->toBe('presseecho')
|
|
->and($config['assets_dir'])->toBe('build/web');
|
|
});
|
|
|
|
test('www hosts resolve like their apex domain instead of the portal fallback', function () {
|
|
$defaults = ['theme' => 'portal', 'assets_dir' => 'build/portal'];
|
|
$domains = config('domains.domains');
|
|
|
|
// Ohne www-Normalisierung fiele der Host aufs Portal-Default zurück,
|
|
// dessen theme-portal.css im Web-Build fehlt → 500 auf Route::view-Seiten.
|
|
$config = DomainAssetContext::resolve('www.presseecho.test', $defaults, $domains);
|
|
|
|
expect($config['theme'])->toBe('presseecho')
|
|
->and($config['assets_dir'])->toBe('build/web');
|
|
|
|
$hub = DomainAssetContext::resolve(
|
|
'WWW.pressekonto.test',
|
|
$defaults,
|
|
$domains,
|
|
null,
|
|
Request::create('https://www.pressekonto.test/', 'GET'),
|
|
);
|
|
|
|
expect($hub['theme'])->toBe('pressekonto');
|
|
});
|
|
|
|
test('hot file path depends on asset bundle', function () {
|
|
expect(DomainAssetContext::hotFilePath('build/web'))
|
|
->toEndWith('hot-web')
|
|
->and(DomainAssetContext::hotFilePath('build/portal'))
|
|
->toEndWith('hot-portal');
|
|
});
|
|
|
|
test('static asset origin always uses main domain not vite subdomain', function () {
|
|
expect(DomainAssetContext::staticAssetOrigin([
|
|
'url' => 'https://pressekonto.test',
|
|
'asset_url' => 'https://assets.pressekonto.test',
|
|
]))->toBe('https://pressekonto.test');
|
|
});
|
|
|
|
test('vite dev server url uses asset subdomain from domain config', function () {
|
|
expect(DomainAssetContext::viteDevServerUrl([
|
|
'url' => 'https://pressekonto.test',
|
|
'asset_url' => 'https://assets.pressekonto.test',
|
|
'assets_dir' => 'build/portal',
|
|
]))->toBe('https://assets.pressekonto.test');
|
|
});
|
|
|
|
test('backend request detection covers admin and livewire paths', function () {
|
|
expect(DomainAssetContext::isBackendRequest(Request::create('/admin/users')))
|
|
->toBeTrue()
|
|
->and(DomainAssetContext::isBackendRequest(Request::create('/livewire/update', 'POST')))
|
|
->toBeTrue()
|
|
->and(DomainAssetContext::isBackendRequest(Request::create('/kategorien')))
|
|
->toBeFalse()
|
|
->and(DomainAssetContext::isBackendRequest(Request::create('/')))
|
|
->toBeFalse();
|
|
});
|