Expand support API validation for writable resources
This commit is contained in:
@@ -2,6 +2,8 @@
|
||||
|
||||
namespace Tests\Feature\Support;
|
||||
|
||||
use App\Models\BlogCategory;
|
||||
use App\Models\Photo;
|
||||
use App\Models\Tenant;
|
||||
use App\Models\User;
|
||||
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||
@@ -82,4 +84,50 @@ class SupportApiTest extends TestCase
|
||||
|
||||
Bus::assertDispatched(\App\Jobs\GenerateDataExport::class);
|
||||
}
|
||||
|
||||
public function test_support_photo_reject_requires_moderation_notes(): void
|
||||
{
|
||||
$user = User::factory()->create([
|
||||
'role' => 'super_admin',
|
||||
]);
|
||||
|
||||
$photo = Photo::factory()->create();
|
||||
|
||||
Sanctum::actingAs($user, ['support-admin', 'support:write']);
|
||||
|
||||
$response = $this->patchJson('/api/v1/support/photos/'.$photo->id, [
|
||||
'data' => [
|
||||
'status' => 'rejected',
|
||||
],
|
||||
]);
|
||||
|
||||
$response->assertStatus(422)
|
||||
->assertJsonValidationErrors(['moderation_notes']);
|
||||
}
|
||||
|
||||
public function test_support_blog_post_create_requires_title_and_content(): void
|
||||
{
|
||||
$user = User::factory()->create([
|
||||
'role' => 'super_admin',
|
||||
]);
|
||||
|
||||
$category = BlogCategory::create([
|
||||
'slug' => 'news',
|
||||
'name' => ['de' => 'News', 'en' => 'News'],
|
||||
'is_visible' => true,
|
||||
]);
|
||||
|
||||
Sanctum::actingAs($user, ['support-admin', 'support:content']);
|
||||
|
||||
$response = $this->postJson('/api/v1/support/blog-posts', [
|
||||
'data' => [
|
||||
'blog_category_id' => $category->id,
|
||||
'slug' => 'missing-title',
|
||||
'is_published' => false,
|
||||
],
|
||||
]);
|
||||
|
||||
$response->assertStatus(422)
|
||||
->assertJsonValidationErrors(['title', 'content']);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user