Implement academy analytics, billing, and web stories updates
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
<?php
|
||||
|
||||
use App\Http\Middleware\HandleInertiaRequests;
|
||||
use App\Models\Artwork;
|
||||
use App\Models\User;
|
||||
use cPad\Plugins\Forum\Models\ForumBoard;
|
||||
use cPad\Plugins\Forum\Models\ForumCategory;
|
||||
@@ -86,4 +87,79 @@ it('keeps board page opening-post queries bounded across many topics', function
|
||||
->assertSee('Opening post for topic 1');
|
||||
|
||||
expect($forumPostQueryCount)->toBeLessThanOrEqual(3);
|
||||
});
|
||||
|
||||
it('keeps board page artwork preview queries bounded when opening posts include embeds', function (): void {
|
||||
$author = User::query()->create([
|
||||
'username' => 'illustrator-embeds',
|
||||
'username_changed_at' => now()->subDays(120),
|
||||
'last_username_change_at' => now()->subDays(120),
|
||||
'onboarding_step' => 'complete',
|
||||
'name' => 'Illustration Embed Author',
|
||||
'email' => 'illustration-embeds@example.com',
|
||||
'email_verified_at' => now(),
|
||||
'password' => 'password',
|
||||
'is_active' => true,
|
||||
]);
|
||||
|
||||
$category = ForumCategory::query()->create([
|
||||
'name' => 'Art Query Budget Embeds',
|
||||
'title' => 'Art Embeds',
|
||||
'slug' => 'art-query-budget-embeds',
|
||||
'description' => 'Art discussion with embeds',
|
||||
'is_active' => true,
|
||||
'position' => 1,
|
||||
]);
|
||||
|
||||
$board = ForumBoard::query()->create([
|
||||
'category_id' => $category->id,
|
||||
'title' => 'Illustration Embeds',
|
||||
'slug' => 'illustration-query-budget-embeds',
|
||||
'description' => 'Illustration board with embeds',
|
||||
'is_active' => true,
|
||||
'position' => 1,
|
||||
]);
|
||||
|
||||
$artwork = Artwork::factory()->for($author)->create([
|
||||
'title' => 'Forum Preview Artwork',
|
||||
'slug' => 'forum-preview-artwork',
|
||||
'is_public' => true,
|
||||
'is_approved' => true,
|
||||
'published_at' => now()->subDay(),
|
||||
]);
|
||||
|
||||
for ($index = 1; $index <= 10; $index++) {
|
||||
$topic = ForumTopic::query()->create([
|
||||
'board_id' => $board->id,
|
||||
'user_id' => $author->id,
|
||||
'title' => 'Embed Topic ' . $index,
|
||||
'slug' => 'embed-topic-' . $index,
|
||||
'replies_count' => 1,
|
||||
'last_post_at' => now()->subMinutes($index),
|
||||
]);
|
||||
|
||||
ForumPost::query()->create([
|
||||
'thread_id' => $topic->id,
|
||||
'topic_id' => $topic->id,
|
||||
'user_id' => $author->id,
|
||||
'content' => 'Opening post for embed topic ' . $index . ' [artwork:' . $artwork->id . ']',
|
||||
'created_at' => now()->subMinutes($index + 30),
|
||||
'updated_at' => now()->subMinutes($index + 30),
|
||||
]);
|
||||
}
|
||||
|
||||
$artworkQueryCount = 0;
|
||||
DB::listen(function ($query) use (&$artworkQueryCount): void {
|
||||
if (preg_match('/\b(from|join)\s+["`\[]?artworks\b/i', $query->sql) === 1) {
|
||||
$artworkQueryCount++;
|
||||
}
|
||||
});
|
||||
|
||||
$this->get(route('forum.board.show', ['boardSlug' => $board->slug]))
|
||||
->assertOk()
|
||||
->assertSee('Illustration Embeds')
|
||||
->assertSee('Embed Topic 1')
|
||||
->assertSee('Opening post for embed topic 1');
|
||||
|
||||
expect($artworkQueryCount)->toBeLessThanOrEqual(1);
|
||||
});
|
||||
Reference in New Issue
Block a user