feat(onticket): add immersive hero configuration and carousel, update tenant seeder and tests
This commit is contained in:
@@ -0,0 +1,96 @@
|
||||
<?php
|
||||
|
||||
namespace Tests\Feature\Migrations;
|
||||
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
use Tests\TestCase;
|
||||
|
||||
class AddOnticketImmersiveHeroConfigurationTest extends TestCase
|
||||
{
|
||||
public function test_it_preserves_existing_tenants_and_extra_content(): void
|
||||
{
|
||||
Schema::create('storefront_website_types', function (Blueprint $table): void {
|
||||
$table->id();
|
||||
$table->string('codigo')->unique();
|
||||
$table->string('nombre');
|
||||
$table->string('header_type');
|
||||
$table->timestamps();
|
||||
});
|
||||
Schema::create('storefront_website_type_extras', function (Blueprint $table): void {
|
||||
$table->id();
|
||||
$table->string('storefront_website_type_code');
|
||||
$table->string('codigo');
|
||||
$table->string('nombre');
|
||||
$table->text('descripcion');
|
||||
$table->boolean('is_required');
|
||||
$table->json('config_schema');
|
||||
$table->timestamps();
|
||||
$table->unique(['storefront_website_type_code', 'codigo']);
|
||||
});
|
||||
Schema::create('tenants', function (Blueprint $table): void {
|
||||
$table->id();
|
||||
$table->string('codigo')->unique();
|
||||
$table->string('storefront_website_type_code');
|
||||
$table->boolean('display_seach_bar');
|
||||
$table->timestamps();
|
||||
});
|
||||
Schema::create('websites_extras', function (Blueprint $table): void {
|
||||
$table->id();
|
||||
$table->string('website_code');
|
||||
$table->foreignId('website_type_extra_id');
|
||||
$table->json('config');
|
||||
$table->boolean('is_enabled');
|
||||
$table->timestamps();
|
||||
$table->unique(['website_code', 'website_type_extra_id']);
|
||||
});
|
||||
|
||||
DB::table('storefront_website_types')->insert([
|
||||
'codigo' => 'onticket_multi_event', 'nombre' => 'OnTicket', 'header_type' => 'immersive',
|
||||
]);
|
||||
DB::table('tenants')->insert([
|
||||
['id' => 10, 'codigo' => 'onticket', 'storefront_website_type_code' => 'onticket', 'display_seach_bar' => false],
|
||||
['id' => 20, 'codigo' => 'sonder', 'storefront_website_type_code' => 'shopit', 'display_seach_bar' => false],
|
||||
]);
|
||||
DB::table('storefront_website_type_extras')->insert([
|
||||
'id' => 30, 'storefront_website_type_code' => 'onticket_multi_event', 'codigo' => 'heroCarousel',
|
||||
'nombre' => 'Carrusel', 'descripcion' => 'Existente', 'is_required' => false, 'config_schema' => '{}',
|
||||
]);
|
||||
DB::table('websites_extras')->insert([
|
||||
'id' => 40, 'website_code' => 'onticket', 'website_type_extra_id' => 30,
|
||||
'config' => '[1,2]', 'is_enabled' => true,
|
||||
]);
|
||||
|
||||
$migration = require database_path('migrations/2026_09_18_000000_add_onticket_immersive_hero_configuration.php');
|
||||
$migration->up();
|
||||
|
||||
$this->assertSame(10, DB::table('tenants')->where('codigo', 'onticket')->value('id'));
|
||||
$this->assertSame(20, DB::table('tenants')->where('codigo', 'sonder')->value('id'));
|
||||
$this->assertSame(0, DB::table('tenants')->where('codigo', 'sonder')->value('display_seach_bar'));
|
||||
$this->assertSame(1, DB::table('tenants')->where('codigo', 'onticket')->value('display_seach_bar'));
|
||||
$this->assertSame('onticket_multi_event', DB::table('tenants')->where('codigo', 'onticket')->value('storefront_website_type_code'));
|
||||
$this->assertSame('[1,2]', DB::table('websites_extras')->where('id', 40)->value('config'));
|
||||
|
||||
$extraId = DB::table('storefront_website_type_extras')
|
||||
->where('storefront_website_type_code', 'onticket_multi_event')
|
||||
->where('codigo', 'immersiveHero')->value('id');
|
||||
$this->assertNotNull($extraId);
|
||||
$websiteExtra = DB::table('websites_extras')
|
||||
->where('website_code', 'onticket')->where('website_type_extra_id', $extraId)->sole();
|
||||
$this->assertSame([
|
||||
'eyebrow' => 'Encendé tu', 'title' => 'experiencia',
|
||||
'description' => 'Reservá tu entrada y formá parte',
|
||||
], json_decode($websiteExtra->config, true));
|
||||
|
||||
DB::table('websites_extras')->where('id', $websiteExtra->id)->update([
|
||||
'config' => '{"eyebrow":"Personalizado"}',
|
||||
]);
|
||||
$migration->up();
|
||||
|
||||
$this->assertSame('{"eyebrow":"Personalizado"}', DB::table('websites_extras')
|
||||
->where('id', $websiteExtra->id)->value('config'));
|
||||
$this->assertSame(1, DB::table('websites_extras')
|
||||
->where('website_code', 'onticket')->where('website_type_extra_id', $extraId)->count());
|
||||
}
|
||||
}
|
||||
@@ -32,6 +32,7 @@ class TenantSeederTest extends TestCase
|
||||
$this->assertSame('onticket', $tenant->client->code);
|
||||
$this->assertSame($websiteType->codigo, $tenant->admin_website_type_code);
|
||||
$this->assertSame('onticket_multi_event', $tenant->storefront_website_type_code);
|
||||
$this->assertTrue($tenant->display_seach_bar);
|
||||
$this->assertSame($websiteType->nombre, $tenant->nombre);
|
||||
$this->assertSame($websiteType->dominio, $tenant->dominio);
|
||||
$this->assertSame($websiteType->site_title, $tenant->site_title);
|
||||
@@ -50,7 +51,7 @@ class TenantSeederTest extends TestCase
|
||||
}
|
||||
|
||||
$carousel = $tenant->websiteExtras()
|
||||
->whereHas('websiteTypeExtra', fn ($query) => $query->where('codigo', 'heroCarousel'))
|
||||
->whereHas('websiteTypeExtra', fn ($query) => $query->where('codigo', 'immersiveHeroCarousel'))
|
||||
->sole();
|
||||
$imageIds = $carousel->config;
|
||||
$this->assertCount(8, $imageIds);
|
||||
@@ -71,6 +72,13 @@ class TenantSeederTest extends TestCase
|
||||
|
||||
$this->seed(TenantSeeder::class);
|
||||
$this->assertSame($imageIds, $carousel->fresh()->config);
|
||||
$this->assertSame([
|
||||
'eyebrow' => 'Encendé tu',
|
||||
'title' => 'experiencia',
|
||||
'description' => 'Reservá tu entrada y formá parte',
|
||||
], $tenant->websiteExtras()
|
||||
->whereHas('websiteTypeExtra', fn ($query) => $query->where('codigo', 'immersiveHero'))
|
||||
->sole()->config);
|
||||
}
|
||||
|
||||
public function test_it_assigns_social_media_to_both_tenants_in_order(): void
|
||||
|
||||
@@ -89,8 +89,8 @@ class WebsiteTypeSeederTest extends TestCase
|
||||
$this->assertSame('standard', $onTicketStorefront->header_type);
|
||||
$multiEventStorefront = StorefrontWebsiteType::query()->where('codigo', 'onticket_multi_event')->with('extras')->sole();
|
||||
$this->assertSame('immersive', $multiEventStorefront->header_type);
|
||||
$this->assertSame(['heroCarousel'], $multiEventStorefront->extras->pluck('codigo')->all());
|
||||
$this->assertSame($shopItStorefront->extras->sole()->config_schema, $multiEventStorefront->extras->sole()->config_schema);
|
||||
$this->assertEqualsCanonicalizing(['immersiveHeroCarousel', 'immersiveHero'], $multiEventStorefront->extras->pluck('codigo')->all());
|
||||
$this->assertSame($shopItStorefront->extras->sole()->config_schema, $multiEventStorefront->extras->firstWhere('codigo', 'immersiveHeroCarousel')->config_schema);
|
||||
$this->assertEqualsCanonicalizing(
|
||||
['heroConfig', 'eventConfig', 'additionalInfoConfig'],
|
||||
$onTicketStorefront->extras->pluck('codigo')->all(),
|
||||
|
||||
@@ -345,12 +345,12 @@ class BootstrapTenantControllerTest extends TestCase
|
||||
->where('codigo', 'onticket_multi_event')
|
||||
->firstOrFail()
|
||||
->extras()
|
||||
->where('codigo', 'heroCarousel')
|
||||
->where('codigo', 'immersiveHeroCarousel')
|
||||
->firstOrFail();
|
||||
|
||||
$images = collect(['first.jpg', 'second.jpg'])->map(fn (string $filename): Attachment => Attachment::query()->create([
|
||||
'key' => (string) Str::uuid(),
|
||||
'path' => "tenants/acme/extras/heroCarousel/{$filename}",
|
||||
'path' => "tenants/acme/extras/immersiveHeroCarousel/{$filename}",
|
||||
'filename' => $filename,
|
||||
'type' => AttachmentType::Image,
|
||||
'mime_type' => 'image/jpeg',
|
||||
@@ -365,10 +365,10 @@ class BootstrapTenantControllerTest extends TestCase
|
||||
$this->assertSame($images->pluck('id')->all(), $extra->fresh()->config);
|
||||
|
||||
$response = $this->getJson('/api/tenants/bootstrap?dominio=acme.com&path=%2F')->assertOk();
|
||||
$response->assertJsonCount(2, 'data.extras.heroCarousel');
|
||||
$response->assertJsonCount(2, 'data.extras.immersiveHeroCarousel');
|
||||
|
||||
foreach ($images->values() as $index => $image) {
|
||||
$response->assertJsonPath("data.extras.heroCarousel.{$index}", function (string $url) use ($image): bool {
|
||||
$response->assertJsonPath("data.extras.immersiveHeroCarousel.{$index}", function (string $url) use ($image): bool {
|
||||
return str_contains($url, $image->path)
|
||||
&& (str_contains($url, 'Expires=') || str_contains($url, 'X-Amz-Expires='));
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user