From 7df935e045b610ca1e9935455ebb9ffc89641759 Mon Sep 17 00:00:00 2001 From: Simon Date: Mon, 16 Nov 2026 02:12:49 +0000 Subject: [PATCH] feat: keep the chosen notification kinds on the user, so the API counts them too The web kept the Replies/Quotes/Stars/Mentions/Follows/Moderation choice in a cookie per browser, so the API could not read it and every unread_notifications_count it sent counted every kind. The choice now lives in users.notification_types, a browser's old cookie is taken over the first time it is seen, and PUT /api/v1/me/notification-types lets apps change it. --- KNOWLEDGE_BASE.md | 3 +- app/Actions/CreateExport.php | 1 + app/Actions/UpdateUserNotificationTypes.php | 27 +++++++ .../Api/UserNotificationTypesController.php | 29 +++++++ .../Api/UserSettingsController.php | 4 +- app/Http/Middleware/HandleInertiaRequests.php | 2 +- .../Requests/ListNotificationsRequest.php | 19 +++-- .../UpdateApiUserNotificationTypesRequest.php | 27 +++++++ app/Models/User.php | 11 +++ app/Queries/NotificationGroupsQuery.php | 5 +- ..._add_notification_types_to_users_table.php | 21 +++++ routes/api.php | 4 + .../UserNotificationTypesControllerTest.php | 79 +++++++++++++++++++ .../Controllers/ExportControllerTest.php | 1 + tests/Feature/NotificationInboxTest.php | 75 +++++++++++++++--- 15 files changed, 287 insertions(+), 21 deletions(-) create mode 100644 app/Actions/UpdateUserNotificationTypes.php create mode 100644 app/Http/Controllers/Api/UserNotificationTypesController.php create mode 100644 app/Http/Requests/UpdateApiUserNotificationTypesRequest.php create mode 100644 database/migrations/2026_11_16_120000_add_notification_types_to_users_table.php create mode 100644 tests/Feature/Controllers/Api/UserNotificationTypesControllerTest.php diff --git a/KNOWLEDGE_BASE.md b/KNOWLEDGE_BASE.md index a34915941e..d1cfdf498a 100644 --- a/KNOWLEDGE_BASE.md +++ b/KNOWLEDGE_BASE.md @@ -392,7 +392,7 @@ Sources: [Pastéis setting](resources/js/components/pasteis-mode-setting.tsx), [ ### Notifications -Open **Notifications** to read in-app activity: follows, replies, quotes, mentions, stars, first commits of people you follow, and moderation messages about rejected commits (approvals do not notify). The navigation shows unread activity and checks for more every 30 seconds. While you have unread notifications or messages, the browser tab's icon shows an orange dot; a tab in the background checks about every five minutes. Related activity is grouped, with expandable details: stars per commit, follows per day, and replies and mentions per thread. Filters (Replies, Quotes, Stars, Mentions, Follows, Moderation) are remembered, and the unread count follows them. Opening the inbox marks all notifications read. You can follow back or unfollow from follower notifications. +Open **Notifications** to read in-app activity: follows, replies, quotes, mentions, stars, first commits of people you follow, and moderation messages about rejected commits (approvals do not notify). The navigation shows unread activity and checks for more every 30 seconds. While you have unread notifications or messages, the browser tab's icon shows an orange dot; a tab in the background checks about every five minutes. Related activity is grouped, with expandable details: stars per commit, follows per day, and replies and mentions per thread. Filters (Replies, Quotes, Stars, Mentions, Follows, Moderation) are remembered with your account, so every browser and the apps show and count the same ones, and the unread count follows them. Opening the inbox marks all notifications read. You can follow back or unfollow from follower notifications. When someone you follow makes their first commit, you get a notification for it under **All**, so a newcomer's first post gets seen and answered. It comes once per person, after approval, and never for replies. @@ -586,6 +586,7 @@ An app can use the same `/api/v1` for you with signed requests. It keeps an SSH A signed request sees what the web shows you, such as your own pending commits and your organizations'. It can also, with the web's validation, moderation, and rate limits: - read your account, logs, replies, notifications (including grouped activity), and starred commits; +- choose which kinds of notifications you see and the unread count counts, the same choice the web's notification filters save; - read the organizations you are a member of, your role in each, and whether posting as an organization is switched on; - commit, reply, and quote, with images, and delete your commits, with the same undo window as the web; - preview commit drafts without publishing them; diff --git a/app/Actions/CreateExport.php b/app/Actions/CreateExport.php index 9fc47fc58e..e7317f8bf4 100644 --- a/app/Actions/CreateExport.php +++ b/app/Actions/CreateExport.php @@ -115,6 +115,7 @@ public function handle(User $user): array 'push_mentions' => $user->push_mentions, 'push_direct_remotes' => $user->push_direct_remotes, 'push_org_remotes' => $user->push_org_remotes, + 'notification_types' => $user->notification_types, 'pinned_commit_id' => $user->pinned_commit_id, 'live_platform' => $user->live_platform?->value, 'live_url' => $user->live_url, diff --git a/app/Actions/UpdateUserNotificationTypes.php b/app/Actions/UpdateUserNotificationTypes.php new file mode 100644 index 0000000000..17f372f38f --- /dev/null +++ b/app/Actions/UpdateUserNotificationTypes.php @@ -0,0 +1,27 @@ +notification_types === $type) { + return; + } + + $user->update(['notification_types' => $type]); + + event(new UsersUpdated([$user->id], UserUpdate::Notifications)); + } +} diff --git a/app/Http/Controllers/Api/UserNotificationTypesController.php b/app/Http/Controllers/Api/UserNotificationTypesController.php new file mode 100644 index 0000000000..4171a00777 --- /dev/null +++ b/app/Http/Controllers/Api/UserNotificationTypesController.php @@ -0,0 +1,29 @@ +handle($user, $request->string('type')->value()); + + return response()->json([ + 'data' => ['type' => $user->notificationTypes()], + 'unread_notifications_count' => $notifications->unreadCount($user), + ])->header('Cache-Control', 'private, no-store'); + } +} diff --git a/app/Http/Controllers/Api/UserSettingsController.php b/app/Http/Controllers/Api/UserSettingsController.php index 3536b14a64..93c846fa53 100644 --- a/app/Http/Controllers/Api/UserSettingsController.php +++ b/app/Http/Controllers/Api/UserSettingsController.php @@ -16,7 +16,8 @@ /** * What the web's settings show only the user: their timezone and the language commits are translated into, `null` * to follow the device, whether commits are translated automatically, the languages they may pick from, whether - * the web shows them its admin pages, which the app only links to, and what they want pushed to their phones. + * the web shows them its admin pages, which the app only links to, what they want pushed to their phones, and which + * kinds of notifications they see, as `?type=` takes them. */ public function show(#[CurrentUser] User $user, CommitTranslations $translations): JsonResponse { @@ -32,6 +33,7 @@ public function show(#[CurrentUser] User $user, CommitTranslations $translations ])->sortBy('name')->values()->all(), 'is_admin' => $user->isAdmin(), 'push' => PushPreference::allFor($user), + 'notification_types' => $user->notificationTypes(), ]])->header('Cache-Control', 'private, no-store'); } } diff --git a/app/Http/Middleware/HandleInertiaRequests.php b/app/Http/Middleware/HandleInertiaRequests.php index a283eaf0b1..4003416c2b 100644 --- a/app/Http/Middleware/HandleInertiaRequests.php +++ b/app/Http/Middleware/HandleInertiaRequests.php @@ -145,7 +145,7 @@ public function share(Request $request): array 'mustReadCommitRules' => $live(fn (): bool => $user instanceof User && $user->commit_rules_accepted_at === null, UserUpdate::Account), 'termsToAccept' => $live(fn (): ?string => $user instanceof User && ! $user->hasAcceptedCurrentTerms() ? config()->string('legal.terms_version') : null, UserUpdate::Account), 'log' => $live(fn (): ?Log => $request->user()?->log, UserUpdate::Account), - // Each browser filters notifications its own way, and reloading the count goes through its cookie. + // Counts only the kinds the user chose to see, taking over a browser's old cookie the first time. 'unreadNotificationsCount' => $live(fn (): int => $user instanceof User ? resolve(NotificationGroupsQuery::class)->unreadCount($user, ListNotificationsRequest::rememberedType($request, $user)) : 0, UserUpdate::Notifications), 'unreadMessagesCount' => $live(fn (): int => $user?->remotes_enabled ? resolve(ConversationsQuery::class)->unreadCount($user) : 0, UserUpdate::Messages, UserUpdate::Inbox), 'remotes' => $live(fn (): ?array => $user?->remotes_enabled ? [ diff --git a/app/Http/Requests/ListNotificationsRequest.php b/app/Http/Requests/ListNotificationsRequest.php index ea4d1b5d30..87fc0158ca 100644 --- a/app/Http/Requests/ListNotificationsRequest.php +++ b/app/Http/Requests/ListNotificationsRequest.php @@ -4,6 +4,7 @@ namespace App\Http\Requests; +use App\Actions\UpdateUserNotificationTypes; use App\Models\User; use Carbon\CarbonImmutable; use Illuminate\Foundation\Http\FormRequest; @@ -14,11 +15,21 @@ final class ListNotificationsRequest extends FormRequest { public const string TYPE_RULE = 'regex:/\A(?:all|none|(?:replies|quotes|stars|mentions|follows|moderation)(?:,(?:replies|quotes|stars|mentions|follows|moderation))*)\z/'; + /** + * The kinds the user chose, kept on the user so the API counts and lists the same ones. Browsers that still have + * the cookie this used to live in hand it over the first time they're seen. + */ public static function rememberedType(Request $request, User $user): string { - $type = $request->cookie('notification_types_'.$user->id, 'all'); + $cookie = 'notification_types_'.$user->id; + $type = $request->cookie($cookie); + + if ($user->notification_types === null && is_string($type) && preg_match(mb_substr(self::TYPE_RULE, 6), $type) === 1) { + resolve(UpdateUserNotificationTypes::class)->handle($user, $type); + Cookie::queue(Cookie::forget($cookie)); + } - return is_string($type) && preg_match(mb_substr(self::TYPE_RULE, 6), $type) === 1 ? $type : 'all'; + return $user->notificationTypes(); } public function authorize(): bool @@ -37,11 +48,9 @@ public function rules(): array public function type(User $user): string { - $cookie = 'notification_types_'.$user->id; - if ($this->has('type')) { $type = $this->filled('type') ? $this->string('type')->value() : 'all'; - Cookie::queue($cookie, $type, 60 * 24 * 365); + resolve(UpdateUserNotificationTypes::class)->handle($user, $type); return $type; } diff --git a/app/Http/Requests/UpdateApiUserNotificationTypesRequest.php b/app/Http/Requests/UpdateApiUserNotificationTypesRequest.php new file mode 100644 index 0000000000..e11e467c21 --- /dev/null +++ b/app/Http/Requests/UpdateApiUserNotificationTypesRequest.php @@ -0,0 +1,27 @@ +> + */ + public function rules(): array + { + return [ + 'type' => ['required', 'string', ListNotificationsRequest::TYPE_RULE], + ]; + } +} diff --git a/app/Models/User.php b/app/Models/User.php index 30b5b8716f..d06fcc25f6 100644 --- a/app/Models/User.php +++ b/app/Models/User.php @@ -51,6 +51,7 @@ * @property-read bool $push_mentions * @property-read bool $push_direct_remotes * @property-read bool $push_org_remotes + * @property-read string|null $notification_types * @property-read int $pasteis_received * @property-read int $pasteis_given_today * @property-read CarbonInterface|null $pasteis_given_on @@ -114,6 +115,7 @@ 'push_mentions', 'push_direct_remotes', 'push_org_remotes', + 'notification_types', 'pasteis_received', 'pasteis_given_today', 'pasteis_given_on', @@ -173,6 +175,7 @@ final class User extends Authenticatable 'push_mentions' => true, 'push_direct_remotes' => true, 'push_org_remotes' => true, + 'notification_types' => null, 'pasteis_received' => 0, 'pasteis_given_today' => 0, 'pasteis_given_on' => null, @@ -501,6 +504,14 @@ public function broadcastChannel(): string return 'users.'.$this->id; } + /** + * Which kinds of notifications the user chose to see, as `?type=` takes them, or all of them until they choose. + */ + public function notificationTypes(): string + { + return $this->notification_types ?? 'all'; + } + public function isAdmin(): bool { /** @var list $admins */ diff --git a/app/Queries/NotificationGroupsQuery.php b/app/Queries/NotificationGroupsQuery.php index bda5e2b45a..2834bcf3e6 100644 --- a/app/Queries/NotificationGroupsQuery.php +++ b/app/Queries/NotificationGroupsQuery.php @@ -92,9 +92,12 @@ public function withStarredCommitImages(CursorPaginator $groups): CursorPaginato /** * Whether two unread notifications share a group only depends on what happened between them, so grouping from the * oldest unread one onward counts the same groups as grouping the whole history, which every page would pay for. + * Only the kinds the user chose to see count, unless another filter is given. */ - public function unreadCount(User $user, string $type = 'all'): int + public function unreadCount(User $user, ?string $type = null): int { + $type ??= $user->notificationTypes(); + if ($type === 'none') { return 0; } diff --git a/database/migrations/2026_11_16_120000_add_notification_types_to_users_table.php b/database/migrations/2026_11_16_120000_add_notification_types_to_users_table.php new file mode 100644 index 0000000000..698254ad9f --- /dev/null +++ b/database/migrations/2026_11_16_120000_add_notification_types_to_users_table.php @@ -0,0 +1,21 @@ +string('notification_types')->nullable(); + }); + } +}; diff --git a/routes/api.php b/routes/api.php index 29ad18e7e2..007194bdb8 100644 --- a/routes/api.php +++ b/routes/api.php @@ -81,6 +81,7 @@ use App\Http\Controllers\Api\UserLiveController; use App\Http\Controllers\Api\UserModerationHistoryController; use App\Http\Controllers\Api\UserMuteController; +use App\Http\Controllers\Api\UserNotificationTypesController; use App\Http\Controllers\Api\UserPasteisModeController; use App\Http\Controllers\Api\UserProfileController; use App\Http\Controllers\Api\UserPushPreferencesController; @@ -213,6 +214,9 @@ Route::delete('me/push-token', [DevicePushTokenController::class, 'destroy'])->name('api-device-push-token.destroy'); Route::put('me/push-preferences', [UserPushPreferencesController::class, 'update'])->name('api-user-push-preferences.update'); + // Which kinds of notifications the user sees, and the unread count counts, as the web's notifications page saves them... + Route::put('me/notification-types', [UserNotificationTypesController::class, 'update'])->name('api-user-notification-types.update'); + // Who follows whom, for members like on the web, so scrapers can't walk the graph... Route::get('users/{user:handle}/followers', [UserFollowersController::class, 'index']) ->name('api-user-followers.index'); diff --git a/tests/Feature/Controllers/Api/UserNotificationTypesControllerTest.php b/tests/Feature/Controllers/Api/UserNotificationTypesControllerTest.php new file mode 100644 index 0000000000..8c0ef0109e --- /dev/null +++ b/tests/Feature/Controllers/Api/UserNotificationTypesControllerTest.php @@ -0,0 +1,79 @@ +create()), 'GET', route('api-user-settings.show')) + ->assertOk() + ->assertJsonPath('data.notification_types', 'all'); +}); + +it('saves the kinds the user wants to see, and answers with them and the unread count of only those', function (string $type, int $expected): void { + $user = User::factory()->create(); + $keyPair = apiKeyPairFor($user); + Notification::factory()->for($user, 'recipient')->replied(Commit::factory()->for($user)->create())->create(); + Notification::factory()->for($user, 'recipient')->starred()->create(); + Notification::factory()->for($user, 'recipient')->create(); + + signedApiRequest($keyPair, 'PUT', route('api-user-notification-types.update'), ['type' => $type]) + ->assertOk() + ->assertHeader('Cache-Control', 'no-store, private') + ->assertExactJson(['data' => ['type' => $type], 'unread_notifications_count' => $expected]); + + expect($user->refresh()->notification_types)->toBe($type) + ->and(signedApiRequest($keyPair, 'GET', route('api-user-settings.show'))->json('data.notification_types'))->toBe($type); +})->with([ + 'all' => ['all', 3], + 'one kind' => ['replies', 1], + 'several kinds' => ['replies,stars', 2], + 'none' => ['none', 0], +]); + +it('counts only the chosen kinds everywhere the API answers with the unread count, and lists them by default', function (): void { + $user = User::factory()->create(); + $keyPair = apiKeyPairFor($user); + $reply = Notification::factory()->for($user, 'recipient')->replied(Commit::factory()->for($user)->create())->create(); + Notification::factory()->for($user, 'recipient')->create(); + + signedApiRequest($keyPair, 'PUT', route('api-user-notification-types.update'), ['type' => 'replies'])->assertOk(); + + signedApiRequest($keyPair, 'GET', route('api-current-user.show'))->assertJsonPath('unread_notifications_count', 1); + signedApiRequest($keyPair, 'PUT', route('api-user-timezone.update'), ['timezone' => 'Europe/Lisbon'])->assertJsonPath('unread_notifications_count', 1); + signedApiRequest($keyPair, 'GET', route('api-notification.index')) + ->assertJsonPath('filters.type', 'replies') + ->assertJsonCount(1, 'data') + ->assertJsonPath('data.0.id', $reply->id); +}); + +it('saves the kinds the list was asked for, as the web does', function (): void { + $user = User::factory()->create(); + + signedApiRequest(apiKeyPairFor($user), 'GET', route('api-notification.index', ['type' => 'follows,mentions'])) + ->assertOk() + ->assertJsonPath('filters.type', 'follows,mentions'); + + expect($user->refresh()->notification_types)->toBe('follows,mentions'); +}); + +it('needs kinds the notifications list knows', function (mixed $type): void { + $user = User::factory()->create(['notification_types' => 'replies']); + + signedApiRequest(apiKeyPairFor($user), 'PUT', route('api-user-notification-types.update'), $type === null ? [] : ['type' => $type]) + ->assertUnprocessable() + ->assertJsonValidationErrors('type'); + + expect($user->refresh()->notification_types)->toBe('replies'); +})->with([ + 'missing' => [null], + 'empty' => [''], + 'unknown kind' => ['replies,secret'], + 'not a string' => [['replies']], +]); + +it('rejects requests that are not signed', function (): void { + $this->putJson(route('api-user-notification-types.update'), ['type' => 'none'])->assertUnauthorized(); +}); diff --git a/tests/Feature/Controllers/ExportControllerTest.php b/tests/Feature/Controllers/ExportControllerTest.php index 3476046121..a69b9a7576 100644 --- a/tests/Feature/Controllers/ExportControllerTest.php +++ b/tests/Feature/Controllers/ExportControllerTest.php @@ -127,6 +127,7 @@ 'push_mentions' => true, 'push_direct_remotes' => true, 'push_org_remotes' => true, + 'notification_types' => null, 'pinned_commit_id' => null, 'live_platform' => null, 'live_url' => null, diff --git a/tests/Feature/NotificationInboxTest.php b/tests/Feature/NotificationInboxTest.php index ce58bfbd34..df97755da7 100644 --- a/tests/Feature/NotificationInboxTest.php +++ b/tests/Feature/NotificationInboxTest.php @@ -8,12 +8,15 @@ use App\Enums\ModerationReason; use App\Enums\NotificationType; use App\Enums\TimeoutDuration; +use App\Enums\UserUpdate; +use App\Events\UsersUpdated; use App\Http\Middleware\HandleInertiaRequests; use App\Models\Commit; use App\Models\Notification; use App\Models\User; use App\Models\UserTimeout; use App\Queries\NotificationGroupsQuery; +use Illuminate\Support\Facades\Event; it('polls only the unread count outside the inbox without acknowledging activity', function (): void { $user = User::factory()->create(); @@ -50,8 +53,8 @@ expect($notice->refresh()->read_at)->toBeNull(); }); -it('filters the menu count using the current users saved notification types', function (string $type, int $expected): void { - $user = User::factory()->create(); +it('filters the menu count using the current users saved notification types', function (?string $type, int $expected): void { + $user = User::factory()->create(['notification_types' => $type]); $thread = Commit::factory()->for($user)->create(); $reply = Notification::factory()->for($user, 'recipient')->replied($thread)->create(); Notification::factory()->for($user, 'recipient')->for($reply->commit, 'commit')->mentioned()->read()->create(); @@ -59,8 +62,7 @@ Notification::factory()->for($user, 'recipient')->create(); Notification::factory()->for($user, 'recipient')->starred()->create(); - $this->actingAs($user)->withCookie('notification_types_'.$user->id, $type) - ->withCookie('notification_types_'.User::factory()->create()->id, 'none') + $this->actingAs($user) ->withHeaders([ 'X-Inertia' => 'true', 'X-Inertia-Version' => (string) new HandleInertiaRequests()->version(request()), @@ -69,18 +71,57 @@ ])->get(route('log.show', ['log' => 'trending', 'type' => 'none']))->assertOk() ->assertJsonPath('props.auth.unreadNotificationsCount', $expected); - expect($reply->refresh()->read_at)->toBeNull(); + expect($reply->refresh()->read_at)->toBeNull() + ->and($user->refresh()->notification_types)->toBe($type); })->with([ + 'never chosen' => [null, 4], 'all types' => ['all', 4], 'replies' => ['replies', 2], 'multiple types' => ['replies,stars', 3], 'only read matches in an unread group' => ['mentions', 0], 'no matching type' => ['quotes', 0], 'no selected types' => ['none', 0], - 'invalid saved filter' => ['invalid', 4], - 'partially invalid saved filter' => ['replies,invalid', 4], ]); +it('takes over the types a browser saved in its cookie before they were kept on the user', function (string $cookie, ?string $saved, int $expected): void { + $user = User::factory()->create(); + Notification::factory()->for($user, 'recipient')->replied()->create(); + Notification::factory()->for($user, 'recipient')->create(); + + $response = $this->actingAs($user)->withCookie('notification_types_'.$user->id, $cookie) + ->withCookie('notification_types_'.User::factory()->create()->id, 'none') + ->withHeaders([ + 'X-Inertia' => 'true', + 'X-Inertia-Version' => (string) new HandleInertiaRequests()->version(request()), + 'X-Inertia-Partial-Component' => 'log/show', + 'X-Inertia-Partial-Data' => 'auth.unreadNotificationsCount', + ])->get(route('log.show', ['log' => 'trending']))->assertOk() + ->assertJsonPath('props.auth.unreadNotificationsCount', $expected); + + expect($user->refresh()->notification_types)->toBe($saved); + + if ($saved !== null) { + $response->assertCookieExpired('notification_types_'.$user->id); + } +})->with([ + 'replies' => ['replies', 'replies', 1], + 'no selected types' => ['none', 'none', 0], + 'invalid' => ['invalid', null, 2], + 'partially invalid' => ['replies,invalid', null, 2], +]); + +it('keeps the types saved on the user over an old cookie', function (): void { + $user = User::factory()->create(['notification_types' => 'follows']); + Notification::factory()->for($user, 'recipient')->replied()->create(); + Notification::factory()->for($user, 'recipient')->create(); + + $this->actingAs($user)->withCookie('notification_types_'.$user->id, 'replies') + ->get(route('notification.index')) + ->assertInertia(fn ($page) => $page->has('notifications.data', 1)->where('filters.type', 'follows')); + + expect($user->refresh()->notification_types)->toBe('follows'); +}); + it('refreshes the entire loaded inbox window without losing older pages', function (): void { $user = User::factory()->create(); $notices = collect(); @@ -621,20 +662,30 @@ it('remembers selected categories for the current account including no categories', function (): void { $user = User::factory()->create(); Notification::factory()->for($user, 'recipient')->create(); - $cookie = 'notification_types_'.$user->id; $this->actingAs($user)->get(route('notification.index', ['type' => 'none'])) - ->assertCookie($cookie, 'none') ->assertInertia(fn ($page) => $page->has('notifications.data', 0)->where('filters.type', 'none')); - $this->withCookie($cookie, 'none')->get(route('notification.index')) + expect($user->refresh()->notification_types)->toBe('none'); + $this->get(route('notification.index')) ->assertInertia(fn ($page) => $page->has('notifications.data', 0)->where('filters.type', 'none')); - $this->get(route('notification.index', ['type' => 'all'])) - ->assertCookie($cookie, 'all') + $this->get(route('notification.index', ['type' => ''])) ->assertInertia(fn ($page) => $page->has('notifications.data', 1)->where('filters.type', 'all')); + expect($user->refresh()->notification_types)->toBe('all'); $this->actingAs(User::factory()->create())->get(route('notification.index')) ->assertInertia(fn ($page) => $page->where('filters.type', 'all')); }); +it('refreshes the unread count wherever the user is signed in when the types change, and only then', function (): void { + Event::fake([UsersUpdated::class]); + $user = User::factory()->create(['notification_types' => 'replies']); + + $this->actingAs($user)->get(route('notification.index', ['type' => 'replies']))->assertOk(); + Event::assertNotDispatched(UsersUpdated::class); + + $this->get(route('notification.index', ['type' => 'replies,stars']))->assertOk(); + Event::assertDispatched(UsersUpdated::class, fn (UsersUpdated $event): bool => $event->userIds === [$user->id] && $event->update === UserUpdate::Notifications); +}); + it('rejects invalid combinations of categories', function (): void { $this->actingAs(User::factory()->create()) ->getJson(route('notification.index', ['type' => 'replies,secret']))