-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathcart.spec.ts
39 lines (24 loc) · 1.07 KB
/
cart.spec.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
import { test, expect } from '@playwright/test';
test.describe('cart', () => {
test('Should add to cart', async ({ page }) => {
await page.goto('http://localhost:8787');
await page.getByTestId('product-card').nth(1).click();
await expect(page).toHaveURL(/.*product/);
await page.getByText('Add to cart').click();
const cartCount = page.getByTestId('cart-count');
await expect(cartCount).toContainText('1');
await page.getByTestId('cart-link').click();
await expect(page).toHaveURL(/.*cart/);
await expect(page.getByTestId('cart-item')).toHaveCount(1);
});
test('Should remove item from cart', async ({ page }) => {
await page.goto('http://localhost:8787');
await page.getByTestId('product-card').nth(1).click();
await page.getByText('Add to cart').click();
const cartCount = page.getByTestId('cart-count');
await expect(cartCount).toContainText('1');
await page.getByTestId('cart-link').click();
await page.getByText('Remove').click();
await expect(page.getByTestId('cart-item')).toHaveCount(0);
});
});