feat(cart): update guest token cookie settings for improved session handling in tests

This commit is contained in:
2026-08-12 15:49:53 -03:00
parent a12b3dd0c8
commit 8359f0831f
2 changed files with 14 additions and 3 deletions

View File

@@ -82,11 +82,11 @@ class CartService
$guestToken,
60 * 24 * 180,
'/',
null,
false,
config('session.domain'),
(bool) config('session.secure'),
true,
false,
'lax',
config('session.same_site'),
);
}

View File

@@ -32,6 +32,10 @@ class CartControllerTest extends TestCase
public function test_it_adds_a_catalog_item_without_a_variant(): void
{
config()->set('session.domain', '.qa.shopit.com.ar');
config()->set('session.secure', true);
config()->set('session.same_site', 'none');
$tenant = $this->createTenant('acme');
$item = $this->createDirectItem($tenant, 10, '49.90');
@@ -50,6 +54,13 @@ class CartControllerTest extends TestCase
->assertJsonPath('data.items.0.product.nombre', 'Item acme')
->assertJsonPath('data.subtotal', '99.80');
$guestTokenCookie = $response->getCookie('guest_token', false);
$this->assertNotNull($guestTokenCookie);
$this->assertSame('.qa.shopit.com.ar', $guestTokenCookie->getDomain());
$this->assertTrue($guestTokenCookie->isSecure());
$this->assertTrue($guestTokenCookie->isHttpOnly());
$this->assertSame('none', $guestTokenCookie->getSameSite());
$this->assertDatabaseHas('carrito_items', [
'catalog_item_id' => $item->id,
'variant_id' => null,