feat: implement tenant update request validation and add feature tests for domain bootstrapping

This commit is contained in:
2026-06-26 16:23:14 -03:00
parent 54aa696145
commit 8708cea122
3 changed files with 36 additions and 4 deletions

View File

@@ -190,7 +190,7 @@ class BootstrapTenantControllerTest extends TestCase
'mime_type' => 'image/png',
]);
$successfulResponse = $this->putJson("/api/tenants/{$tenant->id}", [
$successfulResponse = $this->putJson("/api/tenants/{$tenant->codigo}", [
'codigo' => 'acme',
'nombre' => 'Acme Updated',
'dominio' => 'https://ACME.com:443/admin',
@@ -233,7 +233,7 @@ class BootstrapTenantControllerTest extends TestCase
'footer_logo_id' => $ftrAttachment->id,
]);
$failingResponse = $this->putJson("/api/tenants/{$otherTenant->id}", [
$failingResponse = $this->putJson("/api/tenants/{$otherTenant->codigo}", [
'codigo' => 'globex',
'nombre' => 'Globex',
'dominio' => 'https://ACME.com/storefront',
@@ -244,6 +244,33 @@ class BootstrapTenantControllerTest extends TestCase
->assertJsonValidationErrors(['dominio']);
}
public function test_it_allows_partial_update_without_required_fields(): void
{
$tenant = Tenant::create([
'codigo' => 'acme',
'nombre' => 'Acme',
'dominio' => 'acme.com',
'primary_color' => '#ffffff',
]);
$response = $this->putJson("/api/tenants/{$tenant->codigo}", [
'primary_color' => '#000000',
]);
$response
->assertOk()
->assertJsonPath('data.codigo', 'acme')
->assertJsonPath('data.nombre', 'Acme')
->assertJsonPath('data.primary_color', '#000000');
$this->assertDatabaseHas('tenants', [
'id' => $tenant->id,
'codigo' => 'acme',
'nombre' => 'Acme',
'primary_color' => '#000000',
]);
}
public function test_it_validates_aesthetic_colors(): void
{
$response = $this->postJson('/api/tenants', [