Fixes
This commit is contained in:
@@ -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 () {
|
||||
|
||||
36
tests/Feature/Stories/StoryCoverCdnTest.php
Normal file
36
tests/Feature/Stories/StoryCoverCdnTest.php
Normal 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');
|
||||
});
|
||||
37
tests/Feature/Stories/StoryImageUploadTest.php
Normal file
37
tests/Feature/Stories/StoryImageUploadTest.php
Normal 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) ?: '', '/'));
|
||||
});
|
||||
Reference in New Issue
Block a user