Files
SkinbaseNova/tests/Feature/Uploads/UploadArtworkPublishValidationTest.php

29 lines
896 B
PHP

<?php
declare(strict_types=1);
use App\Models\Artwork;
use App\Models\User;
use Illuminate\Foundation\Testing\RefreshDatabase;
uses(RefreshDatabase::class);
it('rejects publishing existing artwork drafts with raw html descriptions', function (): void {
$user = User::factory()->create();
$artwork = Artwork::factory()->for($user)->create([
'title' => 'Draft upload',
'slug' => 'draft-upload',
'is_public' => false,
'visibility' => Artwork::VISIBILITY_PRIVATE,
'is_approved' => false,
'published_at' => null,
'artwork_status' => 'draft',
]);
$this->actingAs($user)
->postJson("/api/uploads/{$artwork->id}/publish", [
'description' => '<figure><img src="https://spam.example/test.jpg" alt=""></figure>',
])
->assertStatus(422)
->assertJsonValidationErrors(['description']);
});