create(); $participant = User::factory()->create(); $hunt = Hunts::withoutSyncingToSearch(fn () => Hunts::factory()->create([ 'creator_id' => $creator->id, ])); $response = $this ->actingAs($participant, 'sanctum') ->postJson("/api/hunts/{$hunt->id}/participate"); $response ->assertOk() ->assertJson([ 'message' => 'Successfully joined the hunt', ]); Notification::assertSentTo( $creator, HuntParticipantJoinedNotification::class, fn (HuntParticipantJoinedNotification $notification): bool => $notification->hunt->is($hunt) && $notification->participant->is($participant) && $notification instanceof ShouldQueue, ); }); it('does not notify the hunt creator when the user already participates', function () { Notification::fake(); $creator = User::factory()->create(); $participant = User::factory()->create(); $hunt = Hunts::withoutSyncingToSearch(fn () => Hunts::factory()->create([ 'creator_id' => $creator->id, ])); $hunt->participants()->attach($participant->id, [ 'current_step_number' => 0, 'status' => 'in_progress', ]); $response = $this ->actingAs($participant, 'sanctum') ->postJson("/api/hunts/{$hunt->id}/participate"); $response->assertConflict(); Notification::assertNotSentTo($creator, HuntParticipantJoinedNotification::class); }); it('queues email verification notifications', function () { expect(new VerifyEmailNotification)->toBeInstanceOf(ShouldQueue::class); });