feat: add cart editing feature to tenants
- Added 'cart_editing_enabled' attribute to Tenant model with default value true. - Updated StoreTenantRequest and UpdateTenantRequest to include validation for 'cart_editing_enabled'. - Modified TenantResource to expose 'cart_editing_enabled' in API responses. - Created migration to add 'cart_editing_enabled' column to tenants table, defaulting to true, and set to false for specific tenant. - Updated DesfilePuraTendenciaSeeder to set 'cart_editing_enabled' to false for the desfile tenant. - Enhanced Postman collection generation script to include 'cart_editing_enabled' in tenant creation and update requests. - Added tests to verify the correct behavior of 'cart_editing_enabled' during migrations and tenant provisioning.
This commit is contained in:
@@ -0,0 +1,38 @@
|
||||
<?php
|
||||
|
||||
namespace Tests\Feature\Migrations;
|
||||
|
||||
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Tests\TestCase;
|
||||
|
||||
class AddCartEditingEnabledToTenantsTest extends TestCase
|
||||
{
|
||||
use RefreshDatabase;
|
||||
|
||||
public function test_it_disables_cart_editing_only_for_desfile(): void
|
||||
{
|
||||
$migration = require database_path(
|
||||
'migrations/2026_08_18_060000_add_cart_editing_enabled_to_tenants_table.php'
|
||||
);
|
||||
|
||||
$migration->down();
|
||||
$migration->up();
|
||||
|
||||
$this->assertDatabaseHas('tenants', [
|
||||
'codigo' => 'desfile_pura_tendencia',
|
||||
'cart_editing_enabled' => false,
|
||||
]);
|
||||
|
||||
DB::table('tenants')->insert([
|
||||
'codigo' => 'cart-editing-default',
|
||||
'nombre' => 'Cart editing default',
|
||||
'dominio' => 'cart-editing-default.test',
|
||||
]);
|
||||
|
||||
$this->assertDatabaseHas('tenants', [
|
||||
'codigo' => 'cart-editing-default',
|
||||
'cart_editing_enabled' => true,
|
||||
]);
|
||||
}
|
||||
}
|
||||
@@ -44,6 +44,7 @@ class DesfilePuraTendenciaSeederTest extends TestCase
|
||||
'footer_bg_color' => '#D4441C',
|
||||
'display_categories' => false,
|
||||
'display_seach_bar' => false,
|
||||
'cart_editing_enabled' => false,
|
||||
'site_title' => 'Desfile Pura Tendencia',
|
||||
]);
|
||||
|
||||
|
||||
@@ -73,6 +73,7 @@ class BootstrapTenantControllerTest extends TestCase
|
||||
'display_categories' => false,
|
||||
'display_seach_bar' => false,
|
||||
'display_cart' => false,
|
||||
'cart_editing_enabled' => false,
|
||||
]);
|
||||
|
||||
$response = $this->getJson('/api/tenants/bootstrap?dominio=acme.com&path=%2F');
|
||||
@@ -89,6 +90,7 @@ class BootstrapTenantControllerTest extends TestCase
|
||||
->assertJsonPath('data.display_categories', false)
|
||||
->assertJsonPath('data.display_seach_bar', false)
|
||||
->assertJsonPath('data.display_cart', false)
|
||||
->assertJsonPath('data.cart_editing_enabled', false)
|
||||
->assertJsonPath('data.header_bg_color', '#ffffff')->assertJsonPath('data.footer_bg_color', '#ffffff');
|
||||
|
||||
$headerUrl = $response->json('data.header_logo');
|
||||
@@ -745,19 +747,22 @@ class BootstrapTenantControllerTest extends TestCase
|
||||
|
||||
$response = $this->putJson("/api/tenants/{$tenant->codigo}", [
|
||||
'primary_color' => '#000000',
|
||||
'cart_editing_enabled' => false,
|
||||
]);
|
||||
|
||||
$response
|
||||
->assertOk()
|
||||
->assertJsonPath('data.codigo', 'acme')
|
||||
->assertJsonPath('data.nombre', 'Acme')
|
||||
->assertJsonPath('data.primary_color', '#000000');
|
||||
->assertJsonPath('data.primary_color', '#000000')
|
||||
->assertJsonPath('data.cart_editing_enabled', false);
|
||||
|
||||
$this->assertDatabaseHas('tenants', [
|
||||
'id' => $tenant->id,
|
||||
'codigo' => 'acme',
|
||||
'nombre' => 'Acme',
|
||||
'primary_color' => '#000000',
|
||||
'cart_editing_enabled' => false,
|
||||
]);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user