feat: enable full cart editing for Desfile tenant and update related tests
This commit is contained in:
@@ -296,16 +296,22 @@ class CartService
|
||||
|
||||
public function makeGuestTokenCookie(string $guestToken): Cookie
|
||||
{
|
||||
return cookie(
|
||||
'guest_token',
|
||||
$guestToken,
|
||||
60 * 24 * 180,
|
||||
'/',
|
||||
config('session.domain'),
|
||||
(bool) config('session.secure'),
|
||||
true,
|
||||
false,
|
||||
config('session.same_site'),
|
||||
$secure = (bool) config('session.secure');
|
||||
$sameSite = config('session.same_site');
|
||||
$partitioned = (bool) config('session.partitioned')
|
||||
|| ($secure && strtolower((string) $sameSite) === 'none');
|
||||
|
||||
return Cookie::create(
|
||||
name: 'guest_token',
|
||||
value: $guestToken,
|
||||
expire: now()->addDays(180),
|
||||
path: '/',
|
||||
domain: config('session.domain'),
|
||||
secure: $secure,
|
||||
httpOnly: true,
|
||||
raw: false,
|
||||
sameSite: $sameSite,
|
||||
partitioned: $partitioned,
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,23 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
private const TENANT_CODE = 'desfile_pura_tendencia';
|
||||
|
||||
public function up(): void
|
||||
{
|
||||
DB::table('tenants')
|
||||
->where('codigo', self::TENANT_CODE)
|
||||
->update(['cart_editing_policy' => 'full']);
|
||||
}
|
||||
|
||||
public function down(): void
|
||||
{
|
||||
DB::table('tenants')
|
||||
->where('codigo', self::TENANT_CODE)
|
||||
->update(['cart_editing_policy' => 'disabled']);
|
||||
}
|
||||
};
|
||||
@@ -74,7 +74,7 @@ class DesfilePuraTendenciaSeeder extends Seeder
|
||||
'display_categories' => false,
|
||||
'display_seach_bar' => false,
|
||||
'display_cart' => true,
|
||||
'cart_editing_policy' => 'disabled',
|
||||
'cart_editing_policy' => 'full',
|
||||
'checkout_editing_policy' => 'disabled',
|
||||
'display_cart_item_images' => false,
|
||||
'scanner_category_validation_enabled' => false,
|
||||
|
||||
@@ -63,6 +63,7 @@ class CartControllerTest extends TestCase
|
||||
$this->assertTrue($guestTokenCookie->isSecure());
|
||||
$this->assertTrue($guestTokenCookie->isHttpOnly());
|
||||
$this->assertSame('none', $guestTokenCookie->getSameSite());
|
||||
$this->assertTrue($guestTokenCookie->isPartitioned());
|
||||
|
||||
$this->assertDatabaseHas('carrito_items', [
|
||||
'catalog_item_id' => $item->id,
|
||||
|
||||
@@ -0,0 +1,26 @@
|
||||
<?php
|
||||
|
||||
namespace Tests\Feature\Migrations;
|
||||
|
||||
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||
use Tests\TestCase;
|
||||
|
||||
class EnableFullCartEditingForDesfileTest extends TestCase
|
||||
{
|
||||
use RefreshDatabase;
|
||||
|
||||
public function test_it_enables_quantity_variant_and_removal_changes_for_desfile(): void
|
||||
{
|
||||
$migration = require database_path(
|
||||
'migrations/2026_08_20_020000_enable_full_cart_editing_for_desfile.php'
|
||||
);
|
||||
|
||||
$migration->down();
|
||||
$migration->up();
|
||||
|
||||
$this->assertDatabaseHas('tenants', [
|
||||
'codigo' => 'desfile_pura_tendencia',
|
||||
'cart_editing_policy' => 'full',
|
||||
]);
|
||||
}
|
||||
}
|
||||
@@ -44,7 +44,7 @@ class DesfilePuraTendenciaSeederTest extends TestCase
|
||||
'footer_bg_color' => '#D4441C',
|
||||
'display_categories' => false,
|
||||
'display_seach_bar' => false,
|
||||
'cart_editing_policy' => 'disabled',
|
||||
'cart_editing_policy' => 'full',
|
||||
'checkout_editing_policy' => 'disabled',
|
||||
'display_cart_item_images' => false,
|
||||
'site_title' => 'Desfile Pura Tendencia',
|
||||
|
||||
Reference in New Issue
Block a user