feat: add display_cart_item_images feature to tenants and update related resources
This commit is contained in:
@@ -75,6 +75,21 @@ class CartControllerTest extends TestCase
|
||||
]);
|
||||
}
|
||||
|
||||
public function test_it_filters_item_images_when_the_tenant_disables_them(): void
|
||||
{
|
||||
$tenant = $this->createTenant('acme');
|
||||
$tenant->update(['display_cart_item_images' => false]);
|
||||
$item = $this->createDirectItem($tenant, 10, '49.90');
|
||||
$item->attachments()->attach($this->createAttachment('cart-item'), ['orden' => 0]);
|
||||
|
||||
$this->postJson('/api/tenants/acme/cart/items', [
|
||||
'catalog_item_id' => $item->id,
|
||||
'cantidad' => 1,
|
||||
])
|
||||
->assertOk()
|
||||
->assertJsonPath('data.items.0.imagen', null);
|
||||
}
|
||||
|
||||
public function test_it_adds_a_specific_variant_and_merges_repeated_additions(): void
|
||||
{
|
||||
$tenant = $this->createTenant('acme');
|
||||
|
||||
@@ -0,0 +1,38 @@
|
||||
<?php
|
||||
|
||||
namespace Tests\Feature\Migrations;
|
||||
|
||||
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Tests\TestCase;
|
||||
|
||||
class AddDisplayCartItemImagesToTenantsTest extends TestCase
|
||||
{
|
||||
use RefreshDatabase;
|
||||
|
||||
public function test_it_hides_cart_item_images_only_for_desfile(): void
|
||||
{
|
||||
$migration = require database_path(
|
||||
'migrations/2026_08_18_061000_add_display_cart_item_images_to_tenants_table.php'
|
||||
);
|
||||
|
||||
$migration->down();
|
||||
$migration->up();
|
||||
|
||||
$this->assertDatabaseHas('tenants', [
|
||||
'codigo' => 'desfile_pura_tendencia',
|
||||
'display_cart_item_images' => false,
|
||||
]);
|
||||
|
||||
DB::table('tenants')->insert([
|
||||
'codigo' => 'cart-images-default',
|
||||
'nombre' => 'Cart images default',
|
||||
'dominio' => 'cart-images-default.test',
|
||||
]);
|
||||
|
||||
$this->assertDatabaseHas('tenants', [
|
||||
'codigo' => 'cart-images-default',
|
||||
'display_cart_item_images' => true,
|
||||
]);
|
||||
}
|
||||
}
|
||||
@@ -847,6 +847,30 @@ class StorePurchaseTest extends TestCase
|
||||
->assertJsonPath('data.total', '100.00');
|
||||
}
|
||||
|
||||
public function test_purchase_detail_filters_item_images_when_the_tenant_disables_them(): void
|
||||
{
|
||||
$tenant = $this->createTenant('sonder', 'Sonder', 'sonder.com.ar');
|
||||
$tenant->update(['display_cart_item_images' => false]);
|
||||
$user = User::factory()->create([
|
||||
'email' => 'buyer@example.com',
|
||||
]);
|
||||
$variant = $this->createVariantForTenant('sonder', 10, '50.00');
|
||||
$purchase = $this->createCheckoutPurchase($user, 'sonder', $variant, 2);
|
||||
$image = Attachment::create([
|
||||
'key' => (string) Str::uuid(),
|
||||
'path' => 'catalog/purchase-item.png',
|
||||
'filename' => 'purchase-item.png',
|
||||
'type' => AttachmentType::Image,
|
||||
'mime_type' => 'image/png',
|
||||
]);
|
||||
$purchase->items()->firstOrFail()->update(['image_attachment_id' => $image->id]);
|
||||
|
||||
$this->actingAs($user, 'sanctum')
|
||||
->getJson("/api/tenants/sonder/compras/{$purchase->id}")
|
||||
->assertOk()
|
||||
->assertJsonPath('data.items.0.item_details.imagen', null);
|
||||
}
|
||||
|
||||
public function test_purchase_detail_uses_purchase_items_for_pending_payment_purchase(): void
|
||||
{
|
||||
$this->createTenant('sonder', 'Sonder', 'sonder.com.ar');
|
||||
|
||||
@@ -45,6 +45,7 @@ class DesfilePuraTendenciaSeederTest extends TestCase
|
||||
'display_categories' => false,
|
||||
'display_seach_bar' => false,
|
||||
'cart_editing_enabled' => false,
|
||||
'display_cart_item_images' => false,
|
||||
'site_title' => 'Desfile Pura Tendencia',
|
||||
]);
|
||||
|
||||
|
||||
@@ -74,6 +74,7 @@ class BootstrapTenantControllerTest extends TestCase
|
||||
'display_seach_bar' => false,
|
||||
'display_cart' => false,
|
||||
'cart_editing_enabled' => false,
|
||||
'display_cart_item_images' => false,
|
||||
]);
|
||||
|
||||
$response = $this->getJson('/api/tenants/bootstrap?dominio=acme.com&path=%2F');
|
||||
@@ -91,6 +92,7 @@ class BootstrapTenantControllerTest extends TestCase
|
||||
->assertJsonPath('data.display_seach_bar', false)
|
||||
->assertJsonPath('data.display_cart', false)
|
||||
->assertJsonPath('data.cart_editing_enabled', false)
|
||||
->assertJsonPath('data.display_cart_item_images', false)
|
||||
->assertJsonPath('data.header_bg_color', '#ffffff')->assertJsonPath('data.footer_bg_color', '#ffffff');
|
||||
|
||||
$headerUrl = $response->json('data.header_logo');
|
||||
@@ -748,6 +750,7 @@ class BootstrapTenantControllerTest extends TestCase
|
||||
$response = $this->putJson("/api/tenants/{$tenant->codigo}", [
|
||||
'primary_color' => '#000000',
|
||||
'cart_editing_enabled' => false,
|
||||
'display_cart_item_images' => false,
|
||||
]);
|
||||
|
||||
$response
|
||||
@@ -755,7 +758,8 @@ class BootstrapTenantControllerTest extends TestCase
|
||||
->assertJsonPath('data.codigo', 'acme')
|
||||
->assertJsonPath('data.nombre', 'Acme')
|
||||
->assertJsonPath('data.primary_color', '#000000')
|
||||
->assertJsonPath('data.cart_editing_enabled', false);
|
||||
->assertJsonPath('data.cart_editing_enabled', false)
|
||||
->assertJsonPath('data.display_cart_item_images', false);
|
||||
|
||||
$this->assertDatabaseHas('tenants', [
|
||||
'id' => $tenant->id,
|
||||
@@ -763,6 +767,7 @@ class BootstrapTenantControllerTest extends TestCase
|
||||
'nombre' => 'Acme',
|
||||
'primary_color' => '#000000',
|
||||
'cart_editing_enabled' => false,
|
||||
'display_cart_item_images' => false,
|
||||
]);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user