create([ 'profile_id' => $profileId, 'type' => 'photo', 'scope' => 'public', 'visibility' => 'public', 'is_nsfw' => false, 'uri' => null, 'local' => true, ]); } it('returns exactly one id per author', function () { $author = User::factory()->create(); $author->refresh(); // Several public photos by the same author. publicPhoto($author->profile_id); publicPhoto($author->profile_id); publicPhoto($author->profile_id); $pool = DiscoverService::getDailyIdPool(); expect($pool)->toHaveCount(1); }); it('keeps the newest post per author', function () { $author = User::factory()->create(); $author->refresh(); $ids = collect([ publicPhoto($author->profile_id)->id, publicPhoto($author->profile_id)->id, publicPhoto($author->profile_id)->id, ]); $newestId = $ids->max(); $pool = DiscoverService::getDailyIdPool(); expect($pool->map(fn ($id) => (int) $id)->all())->toBe([(int) $newestId]); }); it('includes one id from each of several authors', function () { $a = User::factory()->create(); $a->refresh(); $b = User::factory()->create(); $b->refresh(); publicPhoto($a->profile_id); publicPhoto($a->profile_id); publicPhoto($b->profile_id); $pool = DiscoverService::getDailyIdPool()->map(fn ($id) => (int) $id); expect($pool)->toHaveCount(2); });