feat: add webshop offline maintenance mode with admin toggle and red maintenance screen

This commit is contained in:
2026-11-01 16:28:30 +01:00
parent 4994d4a8ef
commit b3add6f0c2
10 changed files with 419 additions and 1 deletions
+46
View File
@@ -257,4 +257,50 @@ class AdminContentTest extends TestCase
$storagePath = str_replace('/storage/', '', $url);
Storage::disk('public')->assertExists($storagePath);
}
public function test_admin_can_toggle_webshop_offline_mode(): void
{
$this->assertEquals('0', Setting::get('shop_offline', '0'));
// Toggle offline via admin button
$response = $this->actingAs($this->admin)->post(route('admin.toggle-offline'));
$response->assertRedirect();
Setting::flushCache();
$this->assertEquals('1', Setting::get('shop_offline'));
// Logout admin so subsequent requests are unauthenticated guest requests
auth()->logout();
$this->flushSession();
// Guest visitor receives 503 with big red offline banner
$guestResponse = $this->get(route('home'));
$guestResponse->assertStatus(503);
$guestResponse->assertSee('Aan deze webshop wordt hard gewerkt', false);
$guestResponse->assertSee('Webshop Tijdelijk Offline');
// Other customer routes are blocked
$catalogResponse = $this->get(route('catalog'));
$catalogResponse->assertStatus(503);
// Login page remains accessible
$loginResponse = $this->get(route('login'));
$loginResponse->assertStatus(200);
// Admin can still view storefront normally with preview banner
$adminShopResponse = $this->actingAs($this->admin)->get(route('home'));
$adminShopResponse->assertStatus(200);
$adminShopResponse->assertSee('OFFLINE BEHEERDERS-PREVIEW');
// Toggle back online
$this->actingAs($this->admin)->post(route('admin.toggle-offline'));
Setting::flushCache();
$this->assertEquals('0', Setting::get('shop_offline'));
// Logout admin and verify guest can visit normally again
auth()->logout();
$this->flushSession();
$guestOnlineResponse = $this->get(route('home'));
$guestOnlineResponse->assertStatus(200);
}
}