Skip to content

Commit

Permalink
Fixed flaky tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
dmiseev committed Nov 20, 2024
1 parent a3bb6bb commit 774fb40
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 52 deletions.
44 changes: 34 additions & 10 deletions cypress/e2e/yves/order-amendment/order-amendment-start.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand All @@ -88,18 +85,27 @@ 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');
});
});

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({
Expand All @@ -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({
Expand All @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
]
}
]
}
]
}
Expand Down

0 comments on commit 774fb40

Please sign in to comment.