@@ -13,7 +13,7 @@ import {
1313 * - Cart stored in localStorage under `cart:${locale}` (e.g. cart:us, cart:ca)
1414 * - Schema: { version: 1, items: [...] }
1515 * - On desktop (≥900px): opens minicart popover (#minicart) after add-to-cart
16- * - On mobile (<900px): minicart does not open; cart icon href navigates to /order/ cart
16+ * - On mobile (<900px): redirects to /order/ cart after successful add-to- cart
1717 * - Default max quantity per SKU: 3; blocked adds silently re-enable the button
1818 * - Paid warranty tier stored as a hidden linked item (custom.linkedTo, local.showInCart: false)
1919 * - visibleItemCount excludes hidden items; cart badge tracks visibleItemCount
@@ -255,19 +255,45 @@ test.describe('Edge Checkout', () => {
255255 } ) ;
256256 } ) ;
257257
258+ // ─── Mobile add-to-cart redirect ─────────────────────────────────────────────
259+
260+ test . describe ( 'Mobile Add-to-cart Redirect' , ( ) => {
261+ const productPath = '/us/en_us/products/ascent-x2' ;
262+
263+ test . use ( { viewport : { width : 390 , height : 844 } } ) ;
264+
265+ test ( 'redirects to cart page after add-to-cart on mobile' , async ( { page } ) => {
266+ await page . goto ( buildProductUrl ( productPath , currentBranch , { cart : 'edge' } ) ) ;
267+ await waitForAddToCartButton ( page ) ;
268+
269+ const btn = page . locator ( '.quantity-container button' ) ;
270+ await btn . click ( ) ;
271+
272+ await page . waitForURL ( '**/order/cart' , { timeout : 15000 } ) ;
273+ expect ( page . url ( ) ) . toContain ( '/order/cart' ) ;
274+
275+ // Verify the item was persisted before the redirect
276+ const cart = await getCart ( page ) ;
277+ expect ( cart ) . not . toBeNull ( ) ;
278+ expect ( cart . items . length ) . toBeGreaterThanOrEqual ( 1 ) ;
279+ console . log ( '✓ Mobile add-to-cart redirected to cart page with item persisted' ) ;
280+ } ) ;
281+ } ) ;
282+
258283 // ─── Quantity limits ─────────────────────────────────────────────────────────
259284
260- // Mobile viewport prevents minicart from opening between clicks,
261- // which would otherwise block subsequent interactions.
285+ // Quantity-limit tests run at desktop width so add-to-cart stays on the PDP
286+ // (mobile redirects to the cart page, making multi-click flows impractical).
287+ // Cart is pre-seeded via localStorage where needed to avoid repeated clicks.
262288 test . describe ( 'Quantity Limits' , ( ) => {
263289 const productPath = '/us/en_us/products/ascent-x2' ;
264290
265- test . use ( { viewport : { width : 390 , height : 844 } } ) ;
291+ test . use ( { viewport : { width : 1280 , height : 720 } } ) ;
266292
267- // Helper: click add-to-cart and wait for the async operation to finish .
293+ // Helper: click add-to-cart and wait for the button to re-enable (desktop) .
268294 async function clickAndWait ( btn , page ) {
269295 await btn . click ( ) ;
270- await expect ( btn ) . not . toHaveAttribute ( 'aria-disabled' , 'true' , { timeout : 5000 } ) ;
296+ await expect ( btn ) . not . toHaveAttribute ( 'aria-disabled' , 'true' , { timeout : 10000 } ) ;
271297 await page . waitForTimeout ( 300 ) ;
272298 }
273299
@@ -635,19 +661,23 @@ test.describe('Edge Checkout', () => {
635661 test . describe ( 'Add-to-cart Behaviour' , ( ) => {
636662 const productPath = '/us/en_us/products/ascent-x2' ;
637663
638- // Mobile viewport so minicart does not open between clicks.
639- test . use ( { viewport : { width : 390 , height : 844 } } ) ;
664+ // Desktop viewport so add-to-cart stays on the PDP between clicks
665+ // (mobile redirects to the cart page after each add).
666+ test . use ( { viewport : { width : 1280 , height : 720 } } ) ;
667+
668+ async function clickAndWait ( btn , page ) {
669+ await btn . click ( ) ;
670+ await expect ( btn ) . not . toHaveAttribute ( 'aria-disabled' , 'true' , { timeout : 10000 } ) ;
671+ await page . waitForTimeout ( 300 ) ;
672+ }
640673
641674 test ( 'adding the same item twice increments quantity, not a separate entry' , async ( { page } ) => {
642675 await page . goto ( buildProductUrl ( productPath , currentBranch , { cart : 'edge' } ) ) ;
643676 await waitForAddToCartButton ( page ) ;
644677
645678 const btn = page . locator ( '.quantity-container button' ) ;
646- await btn . click ( ) ;
647- await expect ( btn ) . not . toHaveAttribute ( 'aria-disabled' , 'true' , { timeout : 5000 } ) ;
648- await page . waitForTimeout ( 300 ) ;
649- await btn . click ( ) ;
650- await expect ( btn ) . not . toHaveAttribute ( 'aria-disabled' , 'true' , { timeout : 5000 } ) ;
679+ await clickAndWait ( btn , page ) ;
680+ await clickAndWait ( btn , page ) ;
651681
652682 await expect . poll (
653683 ( ) => getCart ( page ) . then ( ( c ) => c ?. items ?. [ 0 ] ?. quantity ?? 0 ) ,
0 commit comments