Skip to content

Commit

Permalink
Merge pull request #4 from elgentos/gitlab-4
Browse files Browse the repository at this point in the history
Added test for deletion from minicart
  • Loading branch information
dheesen authored Oct 24, 2024
2 parents 52fe504 + 3e31228 commit 2bf1321
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 3 deletions.
3 changes: 2 additions & 1 deletion tests/base/config/test-toggles.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
"minicart": {
"testMiniCartCheckoutButton": true,
"testMiniCartLink": true,
"testMiniCartQuantity": true
"testMiniCartQuantity": true,
"testMiniCartDeletion": true
}
}
3 changes: 2 additions & 1 deletion tests/base/fixtures/during/selectors/global.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
{
"mainColumn": ".column.main"
"mainColumn": ".column.main",
"successMessages": ".message.success"
}
1 change: 1 addition & 0 deletions tests/base/fixtures/during/selectors/minicart.json
Original file line number Diff line number Diff line change
Expand Up @@ -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']"
}
3 changes: 2 additions & 1 deletion tests/base/fixtures/verify/expects/minicart.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
{
"productQuantity": "2"
"productQuantity": "2",
"productDeletedFromCartNotificationText": "You removed the item."
}
14 changes: 14 additions & 0 deletions tests/base/minicart.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';

Expand Down Expand Up @@ -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);
});
}

0 comments on commit 2bf1321

Please sign in to comment.