feat(tenant): add checkout editing policy
This commit is contained in:
@@ -0,0 +1,40 @@
|
||||
<?php
|
||||
|
||||
namespace Tests\Feature\Migrations;
|
||||
|
||||
use App\Domains\Tenant\Models\Tenant;
|
||||
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||
use Tests\TestCase;
|
||||
|
||||
class AddCheckoutEditingPolicyToTenantsTest extends TestCase
|
||||
{
|
||||
use RefreshDatabase;
|
||||
|
||||
public function test_it_disables_checkout_editing_for_every_tenant(): void
|
||||
{
|
||||
Tenant::query()->where('codigo', 'sonder')->update([
|
||||
'cart_editing_policy' => 'disabled',
|
||||
]);
|
||||
Tenant::query()->where('codigo', 'fiesta_futbol_infantil')->update([
|
||||
'cart_editing_policy' => 'quantity_and_remove',
|
||||
]);
|
||||
|
||||
$migration = require database_path(
|
||||
'migrations/2026_08_20_000000_add_checkout_editing_policy_to_tenants.php'
|
||||
);
|
||||
|
||||
$migration->down();
|
||||
$migration->up();
|
||||
|
||||
$this->assertDatabaseHas('tenants', [
|
||||
'codigo' => 'sonder',
|
||||
'cart_editing_policy' => 'disabled',
|
||||
'checkout_editing_policy' => 'disabled',
|
||||
]);
|
||||
$this->assertDatabaseHas('tenants', [
|
||||
'codigo' => 'fiesta_futbol_infantil',
|
||||
'cart_editing_policy' => 'quantity_and_remove',
|
||||
'checkout_editing_policy' => 'disabled',
|
||||
]);
|
||||
}
|
||||
}
|
||||
@@ -45,6 +45,7 @@ class DesfilePuraTendenciaSeederTest extends TestCase
|
||||
'display_categories' => false,
|
||||
'display_seach_bar' => false,
|
||||
'cart_editing_policy' => 'disabled',
|
||||
'checkout_editing_policy' => 'disabled',
|
||||
'display_cart_item_images' => false,
|
||||
'site_title' => 'Desfile Pura Tendencia',
|
||||
]);
|
||||
|
||||
@@ -62,6 +62,7 @@ class TenantSeederTest extends TestCase
|
||||
|
||||
$this->assertSame('shopit', $sonder->website_type_code);
|
||||
$this->assertSame('quantity_and_remove', $sonder->cart_editing_policy->value);
|
||||
$this->assertSame('disabled', $sonder->checkout_editing_policy->value);
|
||||
|
||||
$carousel = $sonder->websiteExtras
|
||||
->firstWhere('websiteTypeExtra.codigo', 'carousel');
|
||||
@@ -83,6 +84,7 @@ class TenantSeederTest extends TestCase
|
||||
|
||||
$this->assertSame('onticket', $fiesta->website_type_code);
|
||||
$this->assertSame('full', $fiesta->cart_editing_policy->value);
|
||||
$this->assertSame('disabled', $fiesta->checkout_editing_policy->value);
|
||||
|
||||
$extras = $fiesta->websiteExtras->keyBy('websiteTypeExtra.codigo');
|
||||
$this->assertEqualsCanonicalizing(
|
||||
|
||||
@@ -74,6 +74,7 @@ class BootstrapTenantControllerTest extends TestCase
|
||||
'display_seach_bar' => false,
|
||||
'display_cart' => false,
|
||||
'cart_editing_policy' => 'disabled',
|
||||
'checkout_editing_policy' => 'quantity_and_remove',
|
||||
'display_cart_item_images' => false,
|
||||
]);
|
||||
|
||||
@@ -96,6 +97,11 @@ class BootstrapTenantControllerTest extends TestCase
|
||||
->assertJsonPath('data.cart_editing_policy.allow_delete', false)
|
||||
->assertJsonPath('data.cart_editing_policy.allow_update_quantity', false)
|
||||
->assertJsonPath('data.cart_editing_policy.allow_update_variant', false)
|
||||
->assertJsonPath('data.checkout_editing_policy.code', 'quantity_and_remove')
|
||||
->assertJsonPath('data.checkout_editing_policy.allow_modify', true)
|
||||
->assertJsonPath('data.checkout_editing_policy.allow_delete', true)
|
||||
->assertJsonPath('data.checkout_editing_policy.allow_update_quantity', true)
|
||||
->assertJsonPath('data.checkout_editing_policy.allow_update_variant', false)
|
||||
->assertJsonPath('data.display_cart_item_images', false)
|
||||
->assertJsonPath('data.header_bg_color', '#ffffff')->assertJsonPath('data.footer_bg_color', '#ffffff');
|
||||
|
||||
@@ -763,6 +769,7 @@ class BootstrapTenantControllerTest extends TestCase
|
||||
$response = $this->putJson("/api/tenants/{$tenant->codigo}", [
|
||||
'primary_color' => '#000000',
|
||||
'cart_editing_policy' => 'quantity_and_remove',
|
||||
'checkout_editing_policy' => 'disabled',
|
||||
'display_cart_item_images' => false,
|
||||
]);
|
||||
|
||||
@@ -776,6 +783,8 @@ class BootstrapTenantControllerTest extends TestCase
|
||||
->assertJsonPath('data.cart_editing_policy.allow_delete', true)
|
||||
->assertJsonPath('data.cart_editing_policy.allow_update_quantity', true)
|
||||
->assertJsonPath('data.cart_editing_policy.allow_update_variant', false)
|
||||
->assertJsonPath('data.checkout_editing_policy.code', 'disabled')
|
||||
->assertJsonPath('data.checkout_editing_policy.allow_modify', false)
|
||||
->assertJsonPath('data.display_cart_item_images', false);
|
||||
|
||||
$this->assertDatabaseHas('tenants', [
|
||||
@@ -784,6 +793,7 @@ class BootstrapTenantControllerTest extends TestCase
|
||||
'nombre' => 'Acme',
|
||||
'primary_color' => '#000000',
|
||||
'cart_editing_policy' => 'quantity_and_remove',
|
||||
'checkout_editing_policy' => 'disabled',
|
||||
'display_cart_item_images' => false,
|
||||
]);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user