Expand support API validation for writable resources
Some checks failed
linter / quality (push) Has been cancelled
tests / ci (push) Has been cancelled
tests / ui (push) Has been cancelled

This commit is contained in:
Codex Agent
2026-01-28 20:46:12 +01:00
parent 981df2ee45
commit f0e8cee850
7 changed files with 367 additions and 17 deletions

View File

@@ -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']);
}
}