File tree Expand file tree Collapse file tree 1 file changed +11
-5
lines changed Expand file tree Collapse file tree 1 file changed +11
-5
lines changed Original file line number Diff line number Diff line change @@ -17,12 +17,18 @@ test.describe('Produkter', () => {
1717
1818 await expect ( page . getByRole ( 'button' , { name : 'KJØP' } ) ) . toBeVisible ( ) ;
1919
20+ // Click the buy button and wait for it to complete
2021 await page . getByRole ( 'button' , { name : 'KJØP' } ) . click ( ) ;
21-
22- await page . locator ( '#header' ) . getByText ( '1' ) . waitFor ( ) ;
23-
24- await expect ( page . locator ( '#header' ) . getByText ( '1' ) ) . toBeVisible ( {
25- timeout : 15000 ,
22+
23+ // Wait for network idle to ensure any API calls complete
24+ await page . waitForLoadState ( 'networkidle' ) ;
25+
26+ // More specific selector for the cart count and consistent timeout
27+ const cartCountSelector = '#header' ;
28+
29+ // Wait for cart count to be visible and equal to "1"
30+ await expect ( page . locator ( cartCountSelector ) . getByText ( '1' ) ) . toBeVisible ( {
31+ timeout : 30000
2632 } ) ;
2733
2834 await page . getByRole ( 'link' , { name : 'Handlekurv' } ) . click ( ) ;
You can’t perform that action at this time.
0 commit comments