commerce/cypress/e2e/homepage.cy.ts
Yassin 5a17eaf211 Gherkin use case for cart features with Cypress + Cumcumber + typescript
Gherkin use case for cart features with Cypress + Cumcumber + typescript
2024-09-25 17:09:42 +02:00

42 lines
1.6 KiB
TypeScript

import { DATA_TEST_SELECTORS } from 'cypress/utils/constants';
describe('Three Item Grid Tests', () => {
beforeEach(() => {
// Visiting the home page
cy.visit('/');
});
// List all selector that will be used for the home page
const threeGridItem = () => cy.get(DATA_TEST_SELECTORS.productGridSection.items().container);
const fullSizeGridItem = () =>
cy.get(DATA_TEST_SELECTORS.productGridSection.items('full', 0).container);
// First test case: checks if the grid displays the correct items
it('Verify all grid item', () => {
threeGridItem().should('exist').and('be.visible').and('have.length', 3);
// Checking if the first 'full size' grid item exists
fullSizeGridItem().should('exist');
// Verifying the price of the first full-size grid item (good to verify both amount and currency)
const fullSizeGridItemPrice = DATA_TEST_SELECTORS.productGridSection.items('full', 0).product
.price.amount;
cy.verifyProductPrice(
fullSizeGridItemPrice,
'€', // Currency symbol to be checked
'749.95', // Expected price amount
'EUR' // Expected currency code
);
});
// Second test case: checks if the user can navigate to the correct product page
it('should navigate to the correct product page', () => {
// Clicking the first product link in the product carousel section
cy.get(DATA_TEST_SELECTORS.productCarouselSection.items(0).product.link).click();
// Asserting that the correct product page is loaded by checking the URL
cy.url().should('include', '/product/');
cy.url().should('include', '/product/the-collection-snowboard-oxygen');
});
});