Add notification inbox, toasts and alert scanner for orders, prints and filament
Deploy HickLab3D Dashboard / Deploy to production (push) Successful in 28s

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
Hickmeister
2026-10-11 21:02:35 +01:00
co-authored by Claude Sonnet 5.5
parent 04be9802dc
commit ab1fdb961f
17 changed files with 805 additions and 1 deletions
+53
View File
@@ -0,0 +1,53 @@
<?php
namespace Tests\Feature;
use App\Models\User;
use App\Notifications\DashboardAlert;
use Illuminate\Foundation\Testing\LazilyRefreshDatabase;
use Tests\TestCase;
class NotificationInboxTest extends TestCase
{
use LazilyRefreshDatabase;
public function test_guests_cannot_read_notifications(): void
{
$this->getJson(route('notifications.index'))->assertUnauthorized();
}
public function test_user_sees_only_their_notifications_and_can_mark_them_read(): void
{
$user = User::factory()->create();
$other = User::factory()->create();
$user->notify(new DashboardAlert('order', 'New Etsy order #1', 'Buyer · GBP 5.00', 'success', route('shipping')));
$other->notify(new DashboardAlert('order', 'Private', 'Not yours', 'info'));
$response = $this->actingAs($user)->getJson(route('notifications.index'))->assertOk()
->assertJsonPath('unread', 1)->assertJsonCount(1, 'items')
->assertJsonPath('items.0.title', 'New Etsy order #1')->assertJsonPath('items.0.level', 'success');
$id = $response->json('items.0.id');
$this->actingAs($other)->postJson(route('notifications.read', $id))->assertOk();
$this->assertSame(1, $user->unreadNotifications()->count());
$this->actingAs($user)->postJson(route('notifications.read', $id))->assertOk();
$this->assertSame(0, $user->unreadNotifications()->count());
}
public function test_mark_all_read_clears_the_unread_count(): void
{
$user = User::factory()->create();
$user->notify(new DashboardAlert('print', 'One', 'a'));
$user->notify(new DashboardAlert('print', 'Two', 'b'));
$this->actingAs($user)->postJson(route('notifications.read-all'))->assertOk();
$this->actingAs($user)->getJson(route('notifications.index'))->assertJsonPath('unread', 0);
}
public function test_pages_include_the_notification_bell(): void
{
$this->actingAs(User::factory()->create())->get(route('dashboard'))->assertOk()
->assertSee('data-notifications-toggle', false)->assertSee('data-toast-region', false);
}
}