chore: commit current workspace changes
This commit is contained in:
@@ -8,6 +8,7 @@ use App\Models\ContentType;
|
||||
use App\Models\User;
|
||||
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||
use Illuminate\Pagination\LengthAwarePaginator;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Facades\Cache;
|
||||
use Tests\TestCase;
|
||||
|
||||
@@ -202,6 +203,63 @@ class BrowseApiTest extends TestCase
|
||||
$this->assertStringContainsString('Forest Light', $html);
|
||||
}
|
||||
|
||||
public function test_web_explore_does_not_lazy_load_presentation_relations_per_artwork(): void
|
||||
{
|
||||
DB::flushQueryLog();
|
||||
DB::enableQueryLog();
|
||||
|
||||
$user = User::factory()->create(['name' => 'Explore Author']);
|
||||
$contentType = ContentType::create([
|
||||
'name' => 'Skins',
|
||||
'slug' => 'skins',
|
||||
'description' => 'Skins content type',
|
||||
]);
|
||||
|
||||
$category = Category::create([
|
||||
'content_type_id' => $contentType->id,
|
||||
'name' => 'Minimal',
|
||||
'slug' => 'minimal',
|
||||
'description' => 'Minimal skins',
|
||||
'is_active' => true,
|
||||
'sort_order' => 1,
|
||||
]);
|
||||
|
||||
for ($i = 1; $i <= 4; $i++) {
|
||||
$artwork = Artwork::factory()
|
||||
->for($user)
|
||||
->create([
|
||||
'title' => 'Explore Item ' . $i,
|
||||
'slug' => 'explore-item-' . $i,
|
||||
'published_at' => now()->subMinutes($i),
|
||||
]);
|
||||
|
||||
$artwork->categories()->attach($category->id);
|
||||
}
|
||||
|
||||
$response = $this->get('/explore?sort=latest');
|
||||
|
||||
$response->assertOk()->assertSee('Explore Item 1');
|
||||
|
||||
$queries = collect(DB::getQueryLog())->pluck('query')->all();
|
||||
|
||||
$this->assertFalse(
|
||||
collect($queries)->contains(fn (string $query): bool => str_contains($query, 'from "users" where "users"."id" = ? limit 1')),
|
||||
'Explore should not lazy-load the artwork user relation per tile.'
|
||||
);
|
||||
|
||||
$this->assertFalse(
|
||||
collect($queries)->contains(fn (string $query): bool => str_contains($query, 'from "profiles" where "profiles"."user_id" = ? limit 1')),
|
||||
'Explore should not lazy-load the artwork profile relation per tile.'
|
||||
);
|
||||
|
||||
$this->assertFalse(
|
||||
collect($queries)->contains(fn (string $query): bool => str_contains($query, 'from "artwork_category" where "artwork_category"."artwork_id" = ?')),
|
||||
'Explore should not lazy-load artwork categories one tile at a time.'
|
||||
);
|
||||
|
||||
DB::disableQueryLog();
|
||||
}
|
||||
|
||||
public function test_web_browse_filters_out_artworks_that_are_no_longer_publicly_browsable(): void
|
||||
{
|
||||
$user = User::factory()->create(['name' => 'Visibility Author']);
|
||||
|
||||
Reference in New Issue
Block a user