Skip to content

Commit

Permalink
Improve test
Browse files Browse the repository at this point in the history
  • Loading branch information
w3bdesign committed Jan 31, 2025
1 parent 913ad13 commit 03df835
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions src/tests/Produkter/Produkter.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,18 @@ test.describe('Produkter', () => {

await expect(page.getByRole('button', { name: 'KJØP' })).toBeVisible();

// Click the buy button and wait for it to complete
await page.getByRole('button', { name: 'KJØP' }).click();

await page.locator('#header').getByText('1').waitFor();

await expect(page.locator('#header').getByText('1')).toBeVisible({
timeout: 15000,

// Wait for network idle to ensure any API calls complete
await page.waitForLoadState('networkidle');

// More specific selector for the cart count and consistent timeout
const cartCountSelector = '#header';

// Wait for cart count to be visible and equal to "1"
await expect(page.locator(cartCountSelector).getByText('1')).toBeVisible({

Check failure on line 30 in src/tests/Produkter/Produkter.spec.ts

View workflow job for this annotation

GitHub Actions / test

[webkit] › src/tests/Produkter/Produkter.spec.ts:8:7 › Produkter › Test at vi kan kjøpe produktet

1) [webkit] › src/tests/Produkter/Produkter.spec.ts:8:7 › Produkter › Test at vi kan kjøpe produktet Error: Timed out 30000ms waiting for expect(locator).toBeVisible() Locator: locator('#header').getByText('1') Expected: visible Received: <element(s) not found> Call log: - expect.toBeVisible with timeout 30000ms - waiting for locator('#header').getByText('1') 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 32 | }); 33 | at /home/runner/work/nextjs-woocommerce/nextjs-woocommerce/src/tests/Produkter/Produkter.spec.ts:30:66
timeout: 30000
});

await page.getByRole('link', { name: 'Handlekurv' }).click();
Expand Down

0 comments on commit 03df835

Please sign in to comment.