diff --git a/tests/base/config/test-toggles.json b/tests/base/config/test-toggles.json index e04a315..874be4b 100644 --- a/tests/base/config/test-toggles.json +++ b/tests/base/config/test-toggles.json @@ -13,6 +13,7 @@ "minicart": { "testMiniCartCheckoutButton": true, "testMiniCartLink": true, - "testMiniCartQuantity": true + "testMiniCartQuantity": true, + "testMiniCartDeletion": true } } \ No newline at end of file diff --git a/tests/base/fixtures/during/selectors/global.json b/tests/base/fixtures/during/selectors/global.json index 0d102eb..daf372f 100644 --- a/tests/base/fixtures/during/selectors/global.json +++ b/tests/base/fixtures/during/selectors/global.json @@ -1,3 +1,4 @@ { - "mainColumn": ".column.main" + "mainColumn": ".column.main", + "successMessages": ".message.success" } \ No newline at end of file diff --git a/tests/base/fixtures/during/selectors/minicart.json b/tests/base/fixtures/during/selectors/minicart.json index e8831da..8ede7a1 100644 --- a/tests/base/fixtures/during/selectors/minicart.json +++ b/tests/base/fixtures/during/selectors/minicart.json @@ -4,5 +4,6 @@ "miniCartCheckoutButtonSelector": "a.btn.btn-primary[href$='/checkout/']", "miniCartCartLinkSelector": "a.underline[href$='/checkout/cart/']", "miniCartQuantityButtonSelector": "a[href*='checkout/cart/configure/']", + "miniCartDeleteProductButtonSelector": "button[aria-label^='Remove product']", "miniCartQuantitySelector": "span[x-html='item.qty']" } \ No newline at end of file diff --git a/tests/base/fixtures/verify/expects/minicart.json b/tests/base/fixtures/verify/expects/minicart.json index c2e75ae..47fd8db 100644 --- a/tests/base/fixtures/verify/expects/minicart.json +++ b/tests/base/fixtures/verify/expects/minicart.json @@ -1,3 +1,4 @@ { - "productQuantity": "2" + "productQuantity": "2", + "productDeletedFromCartNotificationText": "You removed the item." } \ No newline at end of file diff --git a/tests/base/minicart.spec.ts b/tests/base/minicart.spec.ts index 8f8166e..82f1ab2 100644 --- a/tests/base/minicart.spec.ts +++ b/tests/base/minicart.spec.ts @@ -4,6 +4,8 @@ import { Cart } from './utils/Cart'; import toggle from './config/test-toggles.json'; import slugs from './fixtures/before/slugs.json'; +import globalSelector from './fixtures/during/selectors/global.json'; + import miniCartSelector from './fixtures/during/selectors/minicart.json'; import miniCartExpected from './fixtures/verify/expects/minicart.json'; @@ -46,4 +48,16 @@ if(toggle.minicart.testMiniCartQuantity) { await expect(page.locator(miniCartSelector.miniCartQuantitySelector)).toContainText(miniCartExpected.productQuantity); }); +} + +if(toggle.minicart.testMiniCartDeletion) { + test('Test minicart deletion', async ({ page }) => { + const cart = new Cart(page); + await cart.addSimpleProductToCart(slugs.simpleProductSlug); + await cart.openMiniCart(); + await page.click(miniCartSelector.miniCartDeleteProductButtonSelector); + + const successMessage = page.locator(globalSelector.successMessages, { hasText: miniCartExpected.productDeletedFromCartNotificationText }); + await expect(successMessage).toContainText(miniCartExpected.productDeletedFromCartNotificationText); + }); } \ No newline at end of file