chore: commit current workspace changes
This commit is contained in:
@@ -6,6 +6,8 @@ use App\Models\HomepageAnnouncement;
|
||||
use App\Models\User;
|
||||
use App\Services\HomepageAnnouncementService;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Http\UploadedFile;
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
use Illuminate\Support\Facades\Hash;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
use Tests\TestCase;
|
||||
@@ -235,7 +237,7 @@ it('preview sanitizes html content', function (): void {
|
||||
'title' => 'Preview announcement',
|
||||
'subtitle' => 'Unsafe html should be stripped.',
|
||||
'badge_text' => 'Preview',
|
||||
'content_html' => '<p>Hello<script>alert(1)</script></p><a href="https://skinbase.top" onclick="evil()">Visit</a>',
|
||||
'content_html' => '<p>Hello<script>alert(1)</script></p><a href="https://skinbase.org" onclick="evil()">Visit</a>',
|
||||
'type' => HomepageAnnouncement::TYPE_NOTICE,
|
||||
'status' => HomepageAnnouncement::STATUS_PUBLISHED,
|
||||
'is_active' => true,
|
||||
@@ -255,7 +257,7 @@ it('preview sanitizes html content', function (): void {
|
||||
|
||||
$response
|
||||
->assertOk()
|
||||
->assertJsonPath('announcement.content_html', '<p>Hello</p><a href="https://skinbase.top" rel="noopener noreferrer" target="_blank">Visit</a>');
|
||||
->assertJsonPath('announcement.content_html', '<p>Hello</p><a href="https://skinbase.org" rel="noopener noreferrer" target="_blank">Visit</a>');
|
||||
});
|
||||
|
||||
it('preview rejects unsafe custom links', function (): void {
|
||||
@@ -283,4 +285,38 @@ it('preview rejects unsafe custom links', function (): void {
|
||||
'secondary_link_type' => HomepageAnnouncement::LINK_TYPE_NONE,
|
||||
])
|
||||
->assertSessionHasErrors(['primary_link_url']);
|
||||
});
|
||||
|
||||
it('stores announcement background uploads on the configured object storage disk', function (): void {
|
||||
$admin = adminUser();
|
||||
|
||||
Storage::fake('s3');
|
||||
config([
|
||||
'homepage.announcements.background_image.disk' => 's3',
|
||||
'homepage.announcements.background_image.prefix' => 'homepage-announcements',
|
||||
'filesystems.disks.s3.url' => 'https://cdn.skinbase.test',
|
||||
]);
|
||||
|
||||
$this->withoutMiddleware(\App\Http\Middleware\HandleInertiaRequests::class);
|
||||
|
||||
$response = $this->actingAs($admin)
|
||||
->from(route('admin.homepage-announcements.create'))
|
||||
->post(route('admin.homepage-announcements.store'), array_merge(announcementPayload(), [
|
||||
'background_image_file' => UploadedFile::fake()->image('announcement.png', 1600, 900),
|
||||
]));
|
||||
|
||||
$response->assertRedirect();
|
||||
|
||||
$announcement = HomepageAnnouncement::query()->latest('id')->firstOrFail();
|
||||
|
||||
expect($announcement->background_image)
|
||||
->toStartWith('homepage-announcements/')
|
||||
->toEndWith('.webp');
|
||||
|
||||
Storage::disk('s3')->assertExists($announcement->background_image);
|
||||
|
||||
$payload = app(HomepageAnnouncementService::class)->toHomepagePayload($announcement);
|
||||
|
||||
expect($payload['background_image_url'])
|
||||
->toBe('https://cdn.skinbase.test/' . $announcement->background_image);
|
||||
});
|
||||
Reference in New Issue
Block a user