feat: Enhance tenant website extras by adding detailed description HTML for hero and additional info configurations; update related tests for validation
This commit is contained in:
@@ -120,6 +120,7 @@ class TenantSeeder extends Seeder
|
||||
'extras' => [
|
||||
'heroConfig' => [
|
||||
'title_html' => '<h1>Fiesta Fútbol Infantil</h1>',
|
||||
'description_html' => '<p>Viví una jornada inolvidable de fútbol infantil.</p>',
|
||||
'button_text' => 'Comprar entradas',
|
||||
'button_href' => '/tickets',
|
||||
'background_image_id' => $this->uploadedImage(
|
||||
@@ -145,7 +146,32 @@ class TenantSeeder extends Seeder
|
||||
],
|
||||
],
|
||||
'additionalInfoConfig' => [
|
||||
'description' => '<p>Viví una jornada inolvidable de fútbol infantil.</p>',
|
||||
'description' => <<<'HTML'
|
||||
<div class="container-fluid px-0">
|
||||
<div class="row g-4 text-start">
|
||||
<div class="col-12 col-md-6">
|
||||
<ul class="mb-0 ps-3">
|
||||
<li class="mb-3">
|
||||
<strong>Menores y Accesos:</strong> Los niños menores de [X] años ingresan gratis acompañados por un adulto con entrada válida.
|
||||
</li>
|
||||
<li>
|
||||
<strong>Jugadores y Accesos:</strong> Los niños que participen del torneo ingresan según la acreditación otorgada a su club.
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
<div class="col-12 col-md-6">
|
||||
<ul class="mb-0 ps-3">
|
||||
<li class="mb-3">
|
||||
<strong>Elementos prohibidos:</strong> No se permite el ingreso con pirotecnia, objetos cortantes, envases de vidrio ni bebidas alcohólicas.
|
||||
</li>
|
||||
<li>
|
||||
<strong>Entradas:</strong> No es necesario que imprimas tu entrada. Podés mostrar el código QR directamente desde tu celular. No tienen cambio ni devolución.
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
HTML,
|
||||
],
|
||||
],
|
||||
]);
|
||||
|
||||
@@ -90,7 +90,10 @@ class TenantSeederTest extends TestCase
|
||||
|
||||
$heroConfig = $extras->get('heroConfig')->config;
|
||||
$this->assertSame('<h1>Fiesta Fútbol Infantil</h1>', $heroConfig['title_html']);
|
||||
$this->assertArrayNotHasKey('description_html', $heroConfig);
|
||||
$this->assertSame(
|
||||
'<p>Viví una jornada inolvidable de fútbol infantil.</p>',
|
||||
$heroConfig['description_html'],
|
||||
);
|
||||
$this->assertIsInt($heroConfig['background_image_id']);
|
||||
$this->assertDatabaseHas('attachments', [
|
||||
'id' => $heroConfig['background_image_id'],
|
||||
@@ -115,8 +118,13 @@ class TenantSeederTest extends TestCase
|
||||
],
|
||||
], $extras->get('eventConfig')->config);
|
||||
|
||||
$this->assertSame([
|
||||
'description' => '<p>Viví una jornada inolvidable de fútbol infantil.</p>',
|
||||
], $extras->get('additionalInfoConfig')->config);
|
||||
$additionalInfo = $extras->get('additionalInfoConfig')->config['description'];
|
||||
|
||||
$this->assertStringContainsString('class="row g-4 text-start"', $additionalInfo);
|
||||
$this->assertSame(2, substr_count($additionalInfo, 'class="col-12 col-md-6"'));
|
||||
$this->assertStringContainsString('<strong>Menores y Accesos:</strong>', $additionalInfo);
|
||||
$this->assertStringContainsString('<strong>Jugadores y Accesos:</strong>', $additionalInfo);
|
||||
$this->assertStringContainsString('<strong>Elementos prohibidos:</strong>', $additionalInfo);
|
||||
$this->assertStringContainsString('<strong>Entradas:</strong>', $additionalInfo);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -170,6 +170,53 @@ class AdminAppWebsiteExtraControllerTest extends TestCase
|
||||
);
|
||||
}
|
||||
|
||||
public function test_adminapp_user_saves_the_banner_description_in_the_hero_extra(): void
|
||||
{
|
||||
$heroDefinition = $this->websiteType->extras()->create([
|
||||
'codigo' => 'heroConfig',
|
||||
'nombre' => 'Banner principal',
|
||||
'descripcion' => 'Configuración del banner principal.',
|
||||
'is_required' => false,
|
||||
'config_schema' => [
|
||||
'request_rules' => [
|
||||
'$' => 'required|array',
|
||||
'title_html' => 'nullable|string',
|
||||
'description_html' => 'nullable|string',
|
||||
'button_text' => 'nullable|string',
|
||||
'button_href' => 'nullable|string',
|
||||
'background_image_id' => 'nullable|string',
|
||||
],
|
||||
'transforms' => [],
|
||||
],
|
||||
]);
|
||||
$tenant = $this->createTenant('acme');
|
||||
|
||||
Sanctum::actingAs($this->createAdminAppUser($tenant));
|
||||
|
||||
$this->putJson('/api/v1/adminapp/tenant/website-extras/heroConfig', [
|
||||
'config' => [
|
||||
'title_html' => '<h1>Evento</h1>',
|
||||
'description_html' => '<p>Nueva descripción del banner</p>',
|
||||
'button_text' => 'Comprar',
|
||||
'button_href' => '/tickets',
|
||||
'background_image_id' => null,
|
||||
],
|
||||
])
|
||||
->assertOk()
|
||||
->assertJsonPath(
|
||||
'data.extras.heroConfig.description_html',
|
||||
'<p>Nueva descripción del banner</p>'
|
||||
);
|
||||
|
||||
$this->assertSame(
|
||||
'<p>Nueva descripción del banner</p>',
|
||||
$tenant->websiteExtras()
|
||||
->where('website_type_extra_id', $heroDefinition->id)
|
||||
->firstOrFail()
|
||||
->config['description_html']
|
||||
);
|
||||
}
|
||||
|
||||
public function test_update_returns_not_found_for_an_unsupported_extra_code(): void
|
||||
{
|
||||
$tenant = $this->createTenant('acme');
|
||||
|
||||
Reference in New Issue
Block a user