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
|
public function makeGuestTokenCookie(string $guestToken): Cookie
|
||||||
{
|
{
|
||||||
return cookie(
|
$secure = (bool) config('session.secure');
|
||||||
'guest_token',
|
$sameSite = config('session.same_site');
|
||||||
$guestToken,
|
$partitioned = (bool) config('session.partitioned')
|
||||||
60 * 24 * 180,
|
|| ($secure && strtolower((string) $sameSite) === 'none');
|
||||||
'/',
|
|
||||||
config('session.domain'),
|
return Cookie::create(
|
||||||
(bool) config('session.secure'),
|
name: 'guest_token',
|
||||||
true,
|
value: $guestToken,
|
||||||
false,
|
expire: now()->addDays(180),
|
||||||
config('session.same_site'),
|
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_categories' => false,
|
||||||
'display_seach_bar' => false,
|
'display_seach_bar' => false,
|
||||||
'display_cart' => true,
|
'display_cart' => true,
|
||||||
'cart_editing_policy' => 'disabled',
|
'cart_editing_policy' => 'full',
|
||||||
'checkout_editing_policy' => 'disabled',
|
'checkout_editing_policy' => 'disabled',
|
||||||
'display_cart_item_images' => false,
|
'display_cart_item_images' => false,
|
||||||
'scanner_category_validation_enabled' => false,
|
'scanner_category_validation_enabled' => false,
|
||||||
|
|||||||
@@ -63,6 +63,7 @@ class CartControllerTest extends TestCase
|
|||||||
$this->assertTrue($guestTokenCookie->isSecure());
|
$this->assertTrue($guestTokenCookie->isSecure());
|
||||||
$this->assertTrue($guestTokenCookie->isHttpOnly());
|
$this->assertTrue($guestTokenCookie->isHttpOnly());
|
||||||
$this->assertSame('none', $guestTokenCookie->getSameSite());
|
$this->assertSame('none', $guestTokenCookie->getSameSite());
|
||||||
|
$this->assertTrue($guestTokenCookie->isPartitioned());
|
||||||
|
|
||||||
$this->assertDatabaseHas('carrito_items', [
|
$this->assertDatabaseHas('carrito_items', [
|
||||||
'catalog_item_id' => $item->id,
|
'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',
|
'footer_bg_color' => '#D4441C',
|
||||||
'display_categories' => false,
|
'display_categories' => false,
|
||||||
'display_seach_bar' => false,
|
'display_seach_bar' => false,
|
||||||
'cart_editing_policy' => 'disabled',
|
'cart_editing_policy' => 'full',
|
||||||
'checkout_editing_policy' => 'disabled',
|
'checkout_editing_policy' => 'disabled',
|
||||||
'display_cart_item_images' => false,
|
'display_cart_item_images' => false,
|
||||||
'site_title' => 'Desfile Pura Tendencia',
|
'site_title' => 'Desfile Pura Tendencia',
|
||||||
|
|||||||
Reference in New Issue
Block a user