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

24 lines
765 B
TypeScript

import { Given } from '@badeball/cypress-cucumber-preprocessor';
import { toSlug, verifyRequest } from 'cypress/utils/url';
Given('I am on the product detail page for {string}', (productName: string) => {
const slugifiedProductName = toSlug(productName);
cy.intercept('GET', `/product/${slugifiedProductName}`).as('getProduct');
cy.intercept('POST', '/product/*').as('postProduct');
// Visite de la page produit
cy.visit(`/product/${slugifiedProductName}`);
// Femrer la notification de NextJs
cy.get('body > main > section')
.find('button')
.should('exist')
.and('be.visible')
.and('not.be.disabled')
.trigger('click');
// Vérifie la réponse du produit
verifyRequest('@getProduct');
verifyRequest('@postProduct');
});