Expand profile gender options and cover country plus activity persistence.
Allow the broader gender enum and add tests for country saves and discovery event recording.
This commit is contained in:
@@ -136,3 +136,49 @@ it('following tab shows only events from followed users', function () {
|
||||
expect($events)->toHaveCount(1);
|
||||
expect(data_get($events->first(), 'user.id'))->toBe($creator->id);
|
||||
});
|
||||
|
||||
it('comments and replies feeds do not query unrelated activity sources', function () {
|
||||
foreach (['comments', 'replies'] as $filter) {
|
||||
DB::flushQueryLog();
|
||||
DB::enableQueryLog();
|
||||
|
||||
$this->getJson('/api/activity?filter=' . $filter)
|
||||
->assertOk()
|
||||
->assertJsonPath('filter', $filter);
|
||||
|
||||
$sql = collect(DB::getQueryLog())
|
||||
->pluck('query')
|
||||
->map(fn (string $query): string => strtolower($query))
|
||||
->implode("\n");
|
||||
|
||||
expect($sql)
|
||||
->not->toContain('activity_events')
|
||||
->not->toContain('comment_reactions')
|
||||
->not->toContain('user_mentions');
|
||||
}
|
||||
});
|
||||
|
||||
it('my activity feed keeps only the authenticated actor activity', function () {
|
||||
$user = User::factory()->create();
|
||||
$other = User::factory()->create();
|
||||
$artwork = Artwork::factory()->create();
|
||||
|
||||
ActivityEvent::record($user->id, ActivityEvent::TYPE_UPLOAD, ActivityEvent::TARGET_ARTWORK, $artwork->id);
|
||||
ActivityEvent::record($other->id, ActivityEvent::TYPE_UPLOAD, ActivityEvent::TARGET_ARTWORK, $artwork->id);
|
||||
|
||||
$response = $this->actingAs($user)->getJson('/api/activity?filter=my');
|
||||
|
||||
$response->assertOk();
|
||||
expect(collect($response->json('data')))
|
||||
->toHaveCount(1)
|
||||
->and(data_get($response->json('data.0'), 'user.id'))->toBe($user->id);
|
||||
});
|
||||
|
||||
it('guest activity feed is capped to the latest page', function () {
|
||||
$response = $this->getJson('/api/activity?page=2&per_page=50');
|
||||
|
||||
$response->assertOk();
|
||||
expect($response->json('meta.current_page'))->toBe(1)
|
||||
->and($response->json('meta.per_page'))->toBe(20)
|
||||
->and(count($response->json('data')))->toBeLessThanOrEqual(20);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user