Skip to content

Commit

Permalink
fix(tests): handle optimistic cart updates (#1448)
Browse files Browse the repository at this point in the history
  • Loading branch information
deini authored Oct 11, 2024
1 parent 44151ce commit 0e092d0
Show file tree
Hide file tree
Showing 6 changed files with 8 additions and 0 deletions.
1 change: 1 addition & 0 deletions core/tests/ui/e2e/cart.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ test.beforeEach(async ({ page }) => {
).toBeVisible();

await page.getByRole('button', { name: 'Add to Cart' }).first().click();
await page.getByRole('button', { name: 'Add to Cart' }).first().isEnabled();
});

test('Add a single product to cart', async ({ page }) => {
Expand Down
3 changes: 3 additions & 0 deletions core/tests/ui/e2e/checkout.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ test.describe('desktop', () => {
).toBeVisible();

await page.getByRole('button', { name: 'Add to Cart' }).first().click();
await page.getByRole('button', { name: 'Add to Cart' }).first().isEnabled();
await page.getByRole('link', { name: 'Cart Items 1' }).click();
await page.getByRole('heading', { level: 1, name: 'Your cart' }).click();
await page.getByRole('button', { name: 'Proceed to checkout' }).click();
Expand Down Expand Up @@ -91,6 +92,7 @@ test.describe('desktop', () => {
page.getByRole('heading', { level: 1, name: '[Sample] Laundry Detergent' }),
).toBeVisible();
await page.getByRole('button', { name: 'Add to Cart' }).first().click();
await page.getByRole('button', { name: 'Add to Cart' }).first().isEnabled();
await page.getByRole('link', { name: 'Cart Items 1' }).click();
await page.getByRole('heading', { level: 1, name: 'Your cart' }).click();
await page.getByRole('button', { name: 'Proceed to checkout' }).click();
Expand Down Expand Up @@ -121,6 +123,7 @@ test.describe('mobile', () => {
).toBeVisible();

await page.getByRole('button', { name: 'Add to Cart' }).first().click();
await page.getByRole('button', { name: 'Add to Cart' }).first().isEnabled();
await page.getByRole('link', { name: 'Cart Items 1' }).click();
await page.getByRole('heading', { level: 1, name: 'Your cart' }).click();
await page.getByRole('button', { name: 'Proceed to checkout' }).click();
Expand Down
1 change: 1 addition & 0 deletions core/tests/ui/e2e/coupon.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ test.beforeEach(async ({ page }) => {
).toBeVisible();

await page.getByRole('button', { name: 'Add to Cart' }).first().click();
await page.getByRole('button', { name: 'Add to Cart' }).first().isEnabled();

await page.getByRole('link', { name: 'Cart Items 1' }).click();

Expand Down
1 change: 1 addition & 0 deletions core/tests/ui/e2e/shipping.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ test.beforeEach(async ({ page }) => {
).toBeVisible();

await page.getByRole('button', { name: 'Add to Cart' }).first().click();
await page.getByRole('button', { name: 'Add to Cart' }).first().isEnabled();
await page.getByRole('link', { name: 'Cart Items 1' }).click();

await expect(page.getByRole('heading', { level: 1, name: 'Your cart' })).toBeVisible();
Expand Down
1 change: 1 addition & 0 deletions core/tests/visual-regression/components/button.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ test('As a child', async ({ page }) => {

// Act
await page.getByRole('button', { name: 'Add to Cart' }).first().click();
await page.getByRole('button', { name: 'Add to Cart' }).first().isEnabled();
await page.getByRole('link', { name: 'Cart Items 1' }).click();
await page.getByText('Shipping cost').waitFor();

Expand Down
1 change: 1 addition & 0 deletions core/tests/visual-regression/components/input.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ test('Input with placeholder', async ({ page }) => {

// Act
await page.getByRole('button', { name: 'Add to Cart' }).first().click();
await page.getByRole('button', { name: 'Add to Cart' }).first().isEnabled();
await page.getByRole('link', { name: 'Cart Items 1' }).click();
await page.getByText('Shipping cost').waitFor();
await page.getByRole('button', { name: 'Add' }).first().click();
Expand Down

0 comments on commit 0e092d0

Please sign in to comment.