Fix 500 error on admin access: make navigation layout resilient and auto-run pending migrations on admin entry

This commit is contained in:
2026-11-02 10:38:22 +01:00
parent 44c440222a
commit cf55f3c9f9
7 changed files with 76 additions and 9 deletions
@@ -10,6 +10,7 @@ use App\Models\Order;
use App\Models\User;
use Illuminate\Foundation\Testing\RefreshDatabase;
use Illuminate\Support\Facades\Mail;
use Illuminate\Support\Facades\Schema;
use Tests\TestCase;
class CustomerCommunicationTest extends TestCase
@@ -231,4 +232,14 @@ class CustomerCommunicationTest extends TestCase
$this->actingAs($this->customer)->get(route('admin.communications.index'))->assertRedirect(route('home'));
$this->actingAs($this->customer)->get(route('admin.customers.index'))->assertRedirect(route('home'));
}
public function test_admin_layout_does_not_crash_even_if_communications_table_is_initially_missing(): void
{
Schema::dropIfExists('communication_replies');
Schema::dropIfExists('communications');
// Layout renders with HTTP 200 without 500 server error even when table was absent
$response = $this->actingAs($this->admin)->get(route('admin.content.index'));
$response->assertStatus(200);
}
}