Improve creator studio browsing and versioning

This commit is contained in:
2026-04-16 15:01:15 +02:00
parent 56eaa3bcbf
commit cdd42a0186
12 changed files with 728 additions and 140 deletions

View File

@@ -3,6 +3,8 @@
use App\Models\User;
use App\Models\Artwork;
use App\Models\ArtworkStats;
use App\Models\Category;
use App\Models\ContentType;
use Illuminate\Support\Facades\DB;
use Inertia\Testing\AssertableInertia;
@@ -92,6 +94,83 @@ test('studio artworks page loads', function () {
->assertInertia(fn (AssertableInertia $page) => $page->component('Studio/StudioArtworks')->where('title', 'Artworks'));
});
test('studio artworks listing is not truncated before pagination', function () {
Artwork::withoutEvents(fn () => Artwork::factory()->count(245)->create([
'user_id' => $this->user->id,
'is_public' => true,
'published_at' => now(),
'deleted_at' => null,
]));
$this->get('/studio/artworks')
->assertStatus(200)
->assertInertia(fn (AssertableInertia $page) => $page
->component('Studio/StudioArtworks')
->where('summary.count', 245)
->where('listing.meta.total', 245)
->where('listing.meta.last_page', 11)
->has('listing.items', 24));
});
test('studio artworks can be filtered by content type', function () {
$photography = ContentType::query()->create([
'name' => 'Photography',
'slug' => 'photography',
'order' => 1,
'hide_from_menu' => false,
]);
$skins = ContentType::query()->create([
'name' => 'Skins',
'slug' => 'skins',
'order' => 2,
'hide_from_menu' => false,
]);
$nature = Category::query()->create([
'content_type_id' => $photography->id,
'name' => 'Nature',
'slug' => 'nature',
'is_active' => true,
'sort_order' => 1,
]);
$winamp = Category::query()->create([
'content_type_id' => $skins->id,
'name' => 'Winamp',
'slug' => 'winamp',
'is_active' => true,
'sort_order' => 1,
]);
$photoArtwork = studioArtwork([
'user_id' => $this->user->id,
'title' => 'Photo Work',
'is_public' => true,
'published_at' => now(),
]);
$photoArtwork->categories()->attach($nature->id);
$skinArtwork = studioArtwork([
'user_id' => $this->user->id,
'title' => 'Skin Work',
'is_public' => true,
'published_at' => now(),
]);
$skinArtwork->categories()->attach($winamp->id);
$this->get('/studio/artworks?content_type=photography')
->assertStatus(200)
->assertInertia(fn (AssertableInertia $page) => $page
->component('Studio/StudioArtworks')
->where('listing.filters.content_type', 'photography')
->where('listing.meta.total', 1)
->where('listing.items.0.title', 'Photo Work')
->where('listing.advanced_filters.0.key', 'content_type')
->has('listing.advanced_filters.1.options', 2)
->where('listing.advanced_filters.1.options.1.value', 'nature'));
});
test('studio drafts page loads', function () {
$this->get('/studio/artworks/drafts')
->assertRedirect('/studio/drafts');