11import { test , expect , setRecipeFixture } from '../../fixtures' ;
2+ import assert from '../../fixtures/assertions' ;
23import { CartUtil } from '../../fixtures/cart-utils' ;
34
45setRecipeFixture ( {
@@ -70,28 +71,20 @@ test.describe('Custom Cart Method Recipe', () => {
7071 name : KNOWN_PRODUCT_WITH_VARIANTS . name ,
7172 } ) ;
7273 const initialUrl = await productLink . getAttribute ( 'href' ) ;
73- expect ( initialUrl ) . toBeTruthy ( ) ;
74+ assert ( initialUrl ) ;
7475
7576 const optionSelect = (
7677 await cart . waitForOptionSelectors ( firstLineItem )
7778 ) . first ( ) ;
7879 const { optionName, nextValue} =
7980 await cart . selectDifferentOption ( optionSelect ) ;
8081
81- await expect
82- . poll ( async ( ) => {
83- const href = await productLink . getAttribute ( 'href' ) ;
84- if ( ! href ) {
85- return false ;
86- }
87-
88- const updatedProductUrl = new URL ( href , page . url ( ) ) ;
89- return (
90- href !== initialUrl &&
91- updatedProductUrl . searchParams . get ( optionName ) === nextValue
92- ) ;
93- } )
94- . toBe ( true ) ;
82+ const href = await productLink . getAttribute ( 'href' ) ;
83+ assert ( href ) ;
84+
85+ const updatedProductUrl = new URL ( href , page . url ( ) ) ;
86+ expect ( href ) . not . toBe ( initialUrl ) ;
87+ expect ( updatedProductUrl . searchParams . get ( optionName ) ) . toBe ( nextValue ) ;
9588 } ) ;
9689
9790 test ( 'maintains single line item when changing variants' , async ( {
@@ -117,12 +110,9 @@ test.describe('Custom Cart Method Recipe', () => {
117110 await cart . selectDifferentOption ( optionSelect ) ;
118111
119112 // Wait for the cart update to complete before checking preservation
120- await expect
121- . poll ( async ( ) => {
122- const href = await productLink . getAttribute ( 'href' ) ;
123- return href !== null && href !== initialUrl ;
124- } )
125- . toBe ( true ) ;
113+ const href = await productLink . getAttribute ( 'href' ) ;
114+ assert ( href ) ;
115+ expect ( href ) . not . toBe ( initialUrl ) ;
126116
127117 await expect ( cart . getLineItems ( ) ) . toHaveCount ( 1 ) ;
128118 await expect ( firstLineItem ) . toContainText ( 'Quantity: 2' ) ;
@@ -147,12 +137,9 @@ test.describe('Custom Cart Method Recipe', () => {
147137 await cart . selectDifferentOption ( optionSelect ) ;
148138
149139 // Verify the cart update completed without navigating away
150- await expect
151- . poll ( async ( ) => {
152- const href = await productLink . getAttribute ( 'href' ) ;
153- return href !== null && href !== initialProductUrl ;
154- } )
155- . toBe ( true ) ;
140+ const href = await productLink . getAttribute ( 'href' ) ;
141+ assert ( href ) ;
142+ expect ( href ) . not . toBe ( initialProductUrl ) ;
156143
157144 expect ( page . url ( ) ) . toBe ( initialPageUrl ) ;
158145 await expect ( cartDialog ) . toBeVisible ( ) ;
0 commit comments