This commit is contained in:
2026-05-03 09:21:13 +02:00
parent 44354e5bea
commit 90e93f0d42
18 changed files with 2831 additions and 347 deletions

View File

@@ -0,0 +1,39 @@
<?php
declare(strict_types=1);
namespace Tests\Feature\Admin;
use App\Models\User;
use Illuminate\Foundation\Testing\RefreshDatabase;
use Illuminate\Testing\Fluent\AssertableJson;
use Inertia\Testing\AssertableInertia;
use Tests\TestCase;
final class ModerationDailyActivityPageTest extends TestCase
{
use RefreshDatabase;
public function test_admin_can_open_daily_activity_page_with_selected_date(): void
{
$admin = User::factory()->create([
'role' => 'admin',
]);
$this->actingAs($admin)
->get('/moderation/activity?date=2026-04-29')
->assertOk()
->assertInertia(fn (AssertableInertia $page) => $page
->component('Admin/DailyActivity')
->where('selectedDate', '2026-04-29')
->where('summary.new_users', 0)
->where('queues.pending_uploads', 0)
->has('sections.users')
->has('sections.artworks')
->has('sections.stories')
->has('sections.uploads')
->has('sections.reports')
->has('sections.username_requests')
->has('sections.auth_events'));
}
}

View File

@@ -32,7 +32,7 @@ it('creator can create a draft story from editor form', function () {
expect($story->status)->toBe('draft');
expect($story->slug)->not->toBe('');
$response->assertRedirect(route('creator.stories.edit', ['story' => $story->id]));
$response->assertRedirect(route('studio.stories.edit', ['story' => $story->id]));
});
it('creator autosave updates draft fields and creates tags from csv', function () {

View File

@@ -0,0 +1,36 @@
<?php
declare(strict_types=1);
use App\Models\Story;
use App\Models\User;
use Illuminate\Foundation\Testing\RefreshDatabase;
use Illuminate\Support\Str;
uses(RefreshDatabase::class);
it('hydrates story edit forms with cdn-backed cover urls', function (): void {
config()->set('cdn.files_url', 'https://cdn.skinbase.test');
$creator = User::factory()->create();
$story = Story::query()->create([
'creator_id' => $creator->id,
'title' => 'Cover Story',
'slug' => 'cover-story-' . Str::lower(Str::random(6)),
'content' => '<p>Cover story content</p>',
'story_type' => 'creator_story',
'status' => 'draft',
'cover_image' => 'stories/md/a1/b2/a1b2c3d4e5f60123456789abcdef0123456789abcdef0123456789abcdef0123.webp',
'og_image' => 'stories/md/a1/b2/a1b2c3d4e5f60123456789abcdef0123456789abcdef0123456789abcdef0123.webp',
]);
$response = $this->actingAs($creator)->get(route('creator.stories.edit', ['story' => $story->id]));
$response->assertOk();
$html = $response->getContent();
$this->assertNotFalse($html);
expect($html)->toContain('https:\/\/cdn.skinbase.test\/stories\/md\/a1\/b2\/a1b2c3d4e5f60123456789abcdef0123456789abcdef0123456789abcdef0123.webp');
expect($html)->not->toContain('https:\/\/skinbase.org\/stories\/md\/a1\/b2\/a1b2c3d4e5f60123456789abcdef0123456789abcdef0123456789abcdef0123.webp');
});

View File

@@ -0,0 +1,37 @@
<?php
declare(strict_types=1);
use App\Models\User;
use Illuminate\Foundation\Testing\RefreshDatabase;
use Illuminate\Http\UploadedFile;
use Illuminate\Support\Facades\Storage;
uses(RefreshDatabase::class);
it('uploads story editor images to object storage with hashed cdn urls', function (): void {
Storage::fake('s3');
config()->set('uploads.object_storage.disk', 's3');
config()->set('cdn.files_url', 'https://cdn.skinbase.test');
$creator = User::factory()->create();
$response = $this->actingAs($creator)->postJson(route('api.story.upload-image'), [
'image' => UploadedFile::fake()->image('cover.png', 1600, 900),
]);
$response->assertOk();
$mediumUrl = (string) $response->json('medium_url');
$thumbnailUrl = (string) $response->json('thumbnail_url');
$originalUrl = (string) $response->json('original_url');
expect($mediumUrl)->toMatch('#^https://cdn\.skinbase\.test/stories/md/[a-f0-9]{2}/[a-f0-9]{2}/[a-f0-9]{64}\.webp$#');
expect($thumbnailUrl)->toMatch('#^https://cdn\.skinbase\.test/stories/sm/[a-f0-9]{2}/[a-f0-9]{2}/[a-f0-9]{64}\.webp$#');
expect($originalUrl)->toMatch('#^https://cdn\.skinbase\.test/stories/original/[a-f0-9]{2}/[a-f0-9]{2}/[a-f0-9]{64}\.(jpg|jpeg|png|webp)$#');
Storage::disk('s3')->assertExists(ltrim(parse_url($mediumUrl, PHP_URL_PATH) ?: '', '/'));
Storage::disk('s3')->assertExists(ltrim(parse_url($thumbnailUrl, PHP_URL_PATH) ?: '', '/'));
Storage::disk('s3')->assertExists(ltrim(parse_url($originalUrl, PHP_URL_PATH) ?: '', '/'));
});