From 774fb40fc0b5c02627d293712b75343f96a52880 Mon Sep 17 00:00:00 2001 From: Dmytro Asieiev Date: Wed, 20 Nov 2024 18:07:00 +0300 Subject: [PATCH] Fixed flaky tests. --- .../order-amendment-start.cy.ts | 44 ++++++++++++++----- .../dynamic-order-amendment-start.json | 42 ------------------ 2 files changed, 34 insertions(+), 52 deletions(-) diff --git a/cypress/e2e/yves/order-amendment/order-amendment-start.cy.ts b/cypress/e2e/yves/order-amendment/order-amendment-start.cy.ts index f90225e0..d4643d03 100644 --- a/cypress/e2e/yves/order-amendment/order-amendment-start.cy.ts +++ b/cypress/e2e/yves/order-amendment/order-amendment-start.cy.ts @@ -69,10 +69,7 @@ import { DeactivateProductScenario } from '../../../support/scenarios/backoffice it('customer should be able to replace current cart (quote) with previous order items', (): void => { placeCustomerOrder(dynamicFixtures.customer3.email, dynamicFixtures.address3.id_customer_address); - - catalogPage.visit(); - catalogPage.searchProductFromSuggestions({ query: dynamicFixtures.product.sku }); - productPage.addToCart({ quantity: 2 }); + addProductsToCart(dynamicFixtures.product.sku, 2); customerOverviewPage.viewLastPlacedOrder(); orderDetailsPage.editOrder(); @@ -88,10 +85,7 @@ import { DeactivateProductScenario } from '../../../support/scenarios/backoffice cartPage.visit(); cartPage.changeQuantity({ sku: dynamicFixtures.product.sku, quantity: 2 }); - - catalogPage.visit(); - catalogPage.searchProductFromSuggestions({ query: dynamicFixtures.product.sku }); - productPage.addToCart({ quantity: 2 }); + addProductsToCart(dynamicFixtures.product.sku, 2); cartPage.getCartItemChangeQuantityField(dynamicFixtures.product.sku).each(($input) => { cy.wrap($input).should('have.value', '2'); @@ -99,7 +93,19 @@ import { DeactivateProductScenario } from '../../../support/scenarios/backoffice }); it('customer should not be able to amend order when item was deactivated', (): void => { - placeCustomerOrder(dynamicFixtures.customer5.email, dynamicFixtures.address5.id_customer_address); + customerLoginScenario.execute({ + email: dynamicFixtures.customer5.email, + password: staticFixtures.defaultPassword, + }); + + addProductsToCart(dynamicFixtures.product.sku); + addProductsToCart(dynamicFixtures.productInActive.sku); + + checkoutScenario.execute({ + idCustomerAddress: dynamicFixtures.address5.id_customer_address, + shouldTriggerOmsInCli: true, + }); + deactivateProductInBackoffice(); customerLoginScenario.execute({ @@ -119,7 +125,19 @@ import { DeactivateProductScenario } from '../../../support/scenarios/backoffice }); it('customer should not be able to amend order when item was out-of-stock', (): void => { - placeCustomerOrder(dynamicFixtures.customer6.email, dynamicFixtures.address6.id_customer_address); + customerLoginScenario.execute({ + email: dynamicFixtures.customer6.email, + password: staticFixtures.defaultPassword, + }); + + addProductsToCart(dynamicFixtures.product.sku); + addProductsToCart(dynamicFixtures.productOutOfStock.sku); + + checkoutScenario.execute({ + idCustomerAddress: dynamicFixtures.address6.id_customer_address, + shouldTriggerOmsInCli: true, + }); + removeProductStock(); customerLoginScenario.execute({ @@ -136,6 +154,12 @@ import { DeactivateProductScenario } from '../../../support/scenarios/backoffice cy.get('body').contains(dynamicFixtures.productOutOfStock.localized_attributes[0].name).should('not.exist'); }); + function addProductsToCart(sku: string, quantity?: number): void { + catalogPage.visit(); + catalogPage.searchProductFromSuggestions({ query: sku }); + productPage.addToCart({ quantity: quantity ?? 1 }); + } + function placeCustomerOrder(email: string, idCustomerAddress: number): void { customerLoginScenario.execute({ email: email, diff --git a/cypress/fixtures/suite/yves/order-amendment/dynamic-order-amendment-start.json b/cypress/fixtures/suite/yves/order-amendment/dynamic-order-amendment-start.json index 5b8e3699..b2d9cf8b 100644 --- a/cypress/fixtures/suite/yves/order-amendment/dynamic-order-amendment-start.json +++ b/cypress/fixtures/suite/yves/order-amendment/dynamic-order-amendment-start.json @@ -308,48 +308,6 @@ ] } ] - }, - { - "type": "helper", - "name": "havePersistentQuote", - "arguments": [ - { - "customer": "#customer5", - "items": [ - { - "sku": "#product.sku", - "abstractSku": "#product.abstract_sku", - "quantity": 1 - }, - { - "sku": "#productInActive.sku", - "abstractSku": "#productInActive.abstract_sku", - "quantity": 1 - } - ] - } - ] - }, - { - "type": "helper", - "name": "havePersistentQuote", - "arguments": [ - { - "customer": "#customer6", - "items": [ - { - "sku": "#product.sku", - "abstractSku": "#product.abstract_sku", - "quantity": 1 - }, - { - "sku": "#productOutOfStock.sku", - "abstractSku": "#productOutOfStock.abstract_sku", - "quantity": 1 - } - ] - } - ] } ] }