Skip to content

Commit 6476fab

Browse files
authored
Merge pull request #1423 from w3bdesign/develop
Improve test
2 parents 913ad13 + 03df835 commit 6476fab

File tree

1 file changed

+11
-5
lines changed

1 file changed

+11
-5
lines changed

src/tests/Produkter/Produkter.spec.ts

+11-5
Original file line numberDiff line numberDiff 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();

0 commit comments

Comments
 (0)