Implement academy analytics, billing, and web stories updates
This commit is contained in:
@@ -2,7 +2,15 @@
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
use App\Models\Artwork;
|
||||
use App\Models\Category;
|
||||
use App\Models\ContentType;
|
||||
use App\Models\Tag;
|
||||
use App\Models\User;
|
||||
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
|
||||
uses(RefreshDatabase::class);
|
||||
|
||||
it('renders the tag page with correct title and canonical', function (): void {
|
||||
$tag = Tag::factory()->create(['name' => 'Cyberpunk', 'slug' => 'cyberpunk', 'is_active' => true]);
|
||||
@@ -61,3 +69,61 @@ it('supports sort parameter without error', function (): void {
|
||||
$this->get("/tag/space?sort={$sort}")->assertOk();
|
||||
}
|
||||
});
|
||||
|
||||
it('keeps tag page artwork relation queries bounded when the gallery is populated', function (): void {
|
||||
$tag = Tag::factory()->create(['name' => 'Pixel Art', 'slug' => 'pixel-art', 'is_active' => true]);
|
||||
|
||||
$author = User::factory()->create([
|
||||
'name' => 'Pixel Artist',
|
||||
'username' => 'pixelartist',
|
||||
]);
|
||||
|
||||
$contentType = ContentType::create([
|
||||
'name' => 'Photography',
|
||||
'slug' => 'photography',
|
||||
'description' => 'Photography content',
|
||||
]);
|
||||
|
||||
$category = Category::create([
|
||||
'content_type_id' => $contentType->id,
|
||||
'parent_id' => null,
|
||||
'name' => 'Abstract',
|
||||
'slug' => 'abstract-pixel-art',
|
||||
'description' => 'Abstract works',
|
||||
'is_active' => true,
|
||||
'sort_order' => 0,
|
||||
]);
|
||||
|
||||
foreach (range(1, 12) as $index) {
|
||||
$artwork = Artwork::factory()->for($author)->create([
|
||||
'title' => 'Pixel Art ' . $index,
|
||||
'slug' => 'pixel-art-' . $index,
|
||||
'published_at' => now()->subMinutes($index),
|
||||
'is_public' => true,
|
||||
'is_approved' => true,
|
||||
]);
|
||||
|
||||
$artwork->categories()->attach($category->id);
|
||||
$artwork->tags()->attach($tag->id, ['source' => 'user', 'confidence' => 1]);
|
||||
}
|
||||
|
||||
$categoryQueryCount = 0;
|
||||
$userQueryCount = 0;
|
||||
|
||||
DB::listen(function ($query) use (&$categoryQueryCount, &$userQueryCount): void {
|
||||
if (preg_match('/\bfrom\s+["`\[]?categories\b/i', $query->sql) === 1 || preg_match('/\bfrom\s+["`\[]?category_content_type\b/i', $query->sql) === 1) {
|
||||
$categoryQueryCount++;
|
||||
}
|
||||
|
||||
if (preg_match('/\bfrom\s+["`\[]?users\b/i', $query->sql) === 1) {
|
||||
$userQueryCount++;
|
||||
}
|
||||
});
|
||||
|
||||
$this->get('/tag/pixel-art')
|
||||
->assertOk()
|
||||
->assertSee('Pixel Art', false);
|
||||
|
||||
expect($categoryQueryCount)->toBeLessThanOrEqual(4);
|
||||
expect($userQueryCount)->toBeLessThanOrEqual(3);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user