fixed language switching in the frontend

This commit is contained in:
Codex Agent
2025-12-02 13:31:58 +01:00
parent 28539754a7
commit dd3198cb79
20 changed files with 395 additions and 203 deletions

View File

@@ -0,0 +1,58 @@
<?php
namespace Tests\Feature\Marketing;
use Inertia\Testing\AssertableInertia as Assert;
use Tests\TestCase;
use Illuminate\Foundation\Testing\RefreshDatabase;
class MarketingLocaleRoutingTest extends TestCase
{
use RefreshDatabase;
public function test_home_route_accepts_german_locale_prefix(): void
{
$response = $this->get('/de');
$response->assertOk();
$response->assertInertia(fn (Assert $page) => $page
->component('marketing/Home')
->where('locale', 'de')
->where('supportedLocales.0', 'de')
);
}
public function test_home_route_accepts_english_locale_prefix(): void
{
$response = $this->get('/en');
$response->assertOk();
$response->assertInertia(fn (Assert $page) => $page
->component('marketing/Home')
->where('locale', 'en')
->where('supportedLocales.1', 'en')
);
}
public function test_contact_route_respects_locale_and_component(): void
{
$response = $this->get('/en/contact');
// Debug response headers for redirect source during development
// @phpstan-ignore-next-line
// var_dump($response->headers->all());
$response->assertOk();
$response->assertInertia(fn (Assert $page) => $page
->component('marketing/Kontakt')
->where('locale', 'en')
);
$responseDe = $this->get('/de/kontakt');
$responseDe->assertOk();
$responseDe->assertInertia(fn (Assert $page) => $page
->component('marketing/Kontakt')
->where('locale', 'de')
);
}
}