Skip to content

Commit 8912be1

Browse files
committed
fix: say how starred an expanded reply is in the notification inbox
1 parent aca050d commit 8912be1

2 files changed

Lines changed: 17 additions & 2 deletions

File tree

‎app/Http/Controllers/NotificationGroupController.php‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,8 @@
1515
{
1616
public function show(ShowNotificationGroupRequest $request, #[CurrentUser] User $user, Notification $notification, NotificationGroupsQuery $query): JsonResponse
1717
{
18-
return response()->json($query->members($user, $notification, $request->type())
19-
->with('commit')->latest()->latest('id')->cursorPaginate(20)->withQueryString());
18+
// Expanded replies, mentions and quotes can be starred from the inbox too, so they say how starred they are.
19+
return response()->json($query->withCommitStars($user, $query->members($user, $notification, $request->type())
20+
->with('commit')->latest()->latest('id')->cursorPaginate(20)->withQueryString()));
2021
}
2122
}

‎tests/Feature/Controllers/NotificationControllerTest.php‎

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,20 @@
8080
->where('notifications.data.0.commit.starred', true));
8181
});
8282

83+
it('says how starred an expanded reply is and whether the user starred it', function (): void {
84+
$user = User::factory()->create();
85+
$replied = Notification::factory()->for($user, 'recipient')->replied()->create();
86+
$reply = Commit::query()->findOrFail($replied->commit_id);
87+
resolve(CreateCommitStar::class)->handle($user, $reply);
88+
resolve(CreateCommitStar::class)->handle(User::factory()->create(), $reply);
89+
90+
$this->actingAs($user)->getJson(route('notification-group.show', $replied))
91+
->assertOk()
92+
->assertJsonPath('data.0.commit.id', $reply->id)
93+
->assertJsonPath('data.0.commit.stars_count', 2)
94+
->assertJsonPath('data.0.commit.starred', true);
95+
});
96+
8397
it('hides notifications that no longer hold', function (): void {
8498
$user = User::factory()->create();
8599
$notification = Notification::factory()->for($user, 'recipient')->create();

0 commit comments

Comments
 (0)