feat: implement product attributes and tenant properties management with CRUD controllers, requests, and domain models

This commit is contained in:
2026-06-26 11:40:07 -03:00
parent edb4c128d6
commit 4c237fb729
14 changed files with 102 additions and 74 deletions

View File

@@ -42,11 +42,11 @@ class ProductAttributeControllerTest extends TestCase
$response
->assertCreated()
->assertJsonPath('tenant_codigo', 'acme')
->assertJsonPath('codigo', 'color')
->assertJsonPath('type', 'select')
->assertJsonPath('options.0.label', 'Red')
->assertJsonPath('options.1.metadata.hex', '#0000ff');
->assertJsonPath('data.tenant_codigo', 'acme')
->assertJsonPath('data.codigo', 'color')
->assertJsonPath('data.type', 'select')
->assertJsonPath('data.options.0.label', 'Red')
->assertJsonPath('data.options.1.metadata.hex', '#0000ff');
$this->assertDatabaseHas('productos_attributes', [
'tenant_codigo' => 'acme',
@@ -60,7 +60,7 @@ class ProductAttributeControllerTest extends TestCase
]);
}
public function test_it_rejects_options_for_text_attributes(): void
public function test_it_rejects_options_for_string_attributes(): void
{
Tenant::create([
'codigo' => 'acme',
@@ -71,7 +71,7 @@ class ProductAttributeControllerTest extends TestCase
$response = $this->postJson('/api/tenants/acme/product-attributes', [
'codigo' => 'material',
'nombre' => 'Material',
'type' => 'text',
'type' => 'string',
'options' => [
['label' => 'Cotton'],
],

View File

@@ -33,9 +33,9 @@ class BootstrapTenantControllerTest extends TestCase
$response
->assertOk()
->assertJsonPath('codigo', 'acme')
->assertJsonPath('dominio', 'acme.com')
->assertJsonPath('props.primary_color', 'blue');
->assertJsonPath('data.codigo', 'acme')
->assertJsonPath('data.dominio', 'acme.com')
->assertJsonPath('data.props.primary_color', 'blue');
}
public function test_it_bootstraps_a_tenant_from_a_full_url(): void
@@ -52,8 +52,8 @@ class BootstrapTenantControllerTest extends TestCase
$response
->assertOk()
->assertJsonPath('codigo', 'acme')
->assertJsonPath('dominio', 'acme.com');
->assertJsonPath('data.codigo', 'acme')
->assertJsonPath('data.dominio', 'acme.com');
}
public function test_it_returns_not_found_when_the_domain_does_not_exist(): void
@@ -84,8 +84,8 @@ class BootstrapTenantControllerTest extends TestCase
$firstResponse
->assertCreated()
->assertJsonPath('dominio', 'acme.com')
->assertJsonPath('props.primary_color', 'blue');
->assertJsonPath('data.dominio', 'acme.com')
->assertJsonPath('data.props.primary_color', 'blue');
$this->assertDatabaseHas('tenant_prop_values', [
'tenant_codigo' => 'acme',
@@ -137,9 +137,9 @@ class BootstrapTenantControllerTest extends TestCase
$successfulResponse
->assertOk()
->assertJsonPath('nombre', 'Acme Updated')
->assertJsonPath('dominio', 'acme.com')
->assertJsonPath('props.primary_color', 'green');
->assertJsonPath('data.nombre', 'Acme Updated')
->assertJsonPath('data.dominio', 'acme.com')
->assertJsonPath('data.props.primary_color', 'green');
$failingResponse = $this->putJson("/api/tenants/{$otherTenant->id}", [
'codigo' => 'globex',

View File

@@ -21,8 +21,8 @@ class TenantPropControllerTest extends TestCase
$response
->assertCreated()
->assertJsonPath('codigo', 'primary_color')
->assertJsonPath('data_type', 'string');
->assertJsonPath('data.codigo', 'primary_color')
->assertJsonPath('data.data_type', 'string');
$this->assertDatabaseHas('tenant_props', [
'codigo' => 'primary_color',