feat(tenant): add hero carousel images and update related services and tests
This commit is contained in:
@@ -12,6 +12,7 @@ use App\Domains\Menu\Models\Menu;
|
||||
use App\Domains\Tenant\Models\Tenant;
|
||||
use App\Domains\Tenant\Models\AdminWebsiteType;
|
||||
use App\Domains\Tenant\Models\StorefrontWebsiteType;
|
||||
use Database\Seeders\WebsiteTypeSeeder;
|
||||
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||
use Illuminate\Http\UploadedFile;
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
@@ -333,6 +334,47 @@ class BootstrapTenantControllerTest extends TestCase
|
||||
->assertJsonMissingPath('data.extras.banner');
|
||||
}
|
||||
|
||||
public function test_it_returns_signed_hero_carousel_urls_from_stored_attachment_ids(): void
|
||||
{
|
||||
Storage::fake('s3');
|
||||
$this->seed(WebsiteTypeSeeder::class);
|
||||
|
||||
$tenant = $this->createTenant();
|
||||
$tenant->update(['storefront_website_type_code' => 'onticket_multi_event']);
|
||||
$definition = StorefrontWebsiteType::query()
|
||||
->where('codigo', 'onticket_multi_event')
|
||||
->firstOrFail()
|
||||
->extras()
|
||||
->where('codigo', 'heroCarousel')
|
||||
->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}",
|
||||
'filename' => $filename,
|
||||
'type' => AttachmentType::Image,
|
||||
'mime_type' => 'image/jpeg',
|
||||
'extension' => 'jpg',
|
||||
]));
|
||||
|
||||
$extra = $tenant->websiteExtras()->create([
|
||||
'website_type_extra_id' => $definition->id,
|
||||
'config' => $images->pluck('id')->all(),
|
||||
]);
|
||||
|
||||
$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');
|
||||
|
||||
foreach ($images->values() as $index => $image) {
|
||||
$response->assertJsonPath("data.extras.heroCarousel.{$index}", function (string $url) use ($image): bool {
|
||||
return str_contains($url, $image->path)
|
||||
&& (str_contains($url, 'Expires=') || str_contains($url, 'X-Amz-Expires='));
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
public function test_the_bootstrap_returns_only_the_cropped_banner_url(): void
|
||||
{
|
||||
Storage::fake('s3');
|
||||
|
||||
Reference in New Issue
Block a user