Skip to content

Commit

Permalink
Merge branch 'develop' into feat/CXSPA-9287
Browse files Browse the repository at this point in the history
  • Loading branch information
kimhw0630 authored Jan 24, 2025
2 parents d750b10 + 288ed01 commit ec04b57
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 60 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,46 +4,50 @@
* SPDX-License-Identifier: Apache-2.0
*/

import { loginUser, signOut } from '../../../helpers/checkout-flow';
import {
addCheapProductToCartAndBeginCheckoutForSignedInCustomer,
goToCheapProductDetailsPage,
loginUser,
signOut,
} from '../../../helpers/checkout-flow';
import {
addProductToCart,
cheapProduct,
checkoutDeliveryMode,
checkoutPaymentDetails,
checkoutShippingAddress,
my_user,
orderConfirmation,
reviewAndPlaceOrder,
my_user,
} from '../../../helpers/estimated-delivery-date';

describe('estimated delivery date', () => {
it('should see estimated delivery date in cart and order pages', () => {
cy.visit('/apparel-uk-spa/en/GBP/login');
loginUser(my_user);
cy.wait(3000);
cy.visit('/apparel-uk-spa/en/GBP/product/M_CR_1015');
cy.visit('/apparel-uk-spa/en/GBP/product/M_CR_1016');
cy.wait(4000);
cy.get('cx-add-to-cart')
.findByText(/Add To Cart/i)
.click();
cy.wait(4000);
addCheapProductToCartAndBeginCheckoutForSignedInCustomer(cheapProduct);
cy.findByText(/proceed to checkout/i).click();
cy.wait(8000);
checkoutShippingAddress();
checkoutDeliveryMode();
//going back to PDP and adding a product again to show Estimated delivery date in cart
goToCheapProductDetailsPage(cheapProduct);
addProductToCart(cheapProduct);
//going back to cart to show Estimated delivery date in cart
cy.visit('/apparel-uk-spa/en/GBP/cart');
cy.wait(4000);
cy.get('cx-estimated-delivery-date').should('exist');
cy.findByText(/proceed to checkout/i).click();
cy.wait(8000);
checkoutShippingAddress();
checkoutDeliveryMode();
checkoutPaymentDetails();
reviewAndPlaceOrder();
orderConfirmation();
});
it('should see estimated delivery date in order history', () => {
cy.visit('apparel-uk-spa/en/GBP/my-account/order/');
cy.get('.cx-list').should('have.length', 1);
cy.get('cx-order-history-code').click();
//For this test to run successfully ensure a order is already present.
cy.visit('/apparel-uk-spa/en/GBP/login');
loginUser(my_user);
cy.visit('apparel-uk-spa/en/GBP/my-account/orders/');
cy.wait(6000);
cy.get('.cx-order-history-code').click({ multiple: true });
cy.contains('Estimated delivery date');
signOut();
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,11 @@
* SPDX-License-Identifier: Apache-2.0
*/

import { waitForPage, addCheapProductToCart } from './checkout-flow';
import { SampleProduct } from '../sample-data/checkout-flow';

export const cheapProduct: SampleProduct = {
name: 'Coney Flare',
code: 'M_CR_1015',
name: 'Frozen Peas',
code: 'M_CR_1016',
};

export const my_user = {
Expand All @@ -19,60 +18,45 @@ export const my_user = {
};

export function checkoutShippingAddress() {
const deliveryModePage = waitForPage(
'/checkout/delivery-mode',
'getDeliveryModePage'
);
cy.get('cx-delivery-address').within(() => {
cy.findByText('Selected');
cy.findByText('Continue').click();
});
cy.wait(`@${deliveryModePage}`).its('response.statusCode').should('eq', 200);
}

export function checkoutDeliveryMode() {
const PaymentDetailsPage = waitForPage(
'/checkout/payment-details',
'getPaymentDetailsPage'
);
cy.get('[formcontrolname="deliveryModeId"]').eq(0).click();
cy.get('cx-delivery-mode').within(() => {
cy.wait(3000);
cy.findByText('Continue').click();
});
cy.wait(`@${PaymentDetailsPage}`)
.its('response.statusCode')
.should('eq', 200);
}

export function checkoutPaymentDetails() {
const ReviewOrderPage = waitForPage(
'/checkout/review-order',
'getReviewOrderPage'
);
cy.get('cx-payment-method').within(() => {
cy.get('cx-card')
.eq(0)
.within(() => {
cy.findByText('Use this payment').click();
cy.wait(3000);
cy.findByText('OMSA Customer');
cy.findByText('5105105105105100');
cy.findByText('Expires: 08/2030');
cy.findByText('Use this payment', { timeout: 10000 })
.should(Cypress._.noop) // No-op to avoid failures if not found
.then(($button) => {
if ($button.length > 0) {
cy.wrap($button).click();
}
});
});
cy.findByText('Continue').click();
});
cy.wait(`@${ReviewOrderPage}`).its('response.statusCode').should('eq', 200);
}

export function reviewAndPlaceOrder() {
const ConfirmOrderPage = waitForPage(
'/order-confirmation',
'getOrderConfirmationPage'
);
cy.contains('Estimated delivery date');
cy.contains('Estimated delivery date').should('exist');
cy.get('cx-place-order').within(() => {
cy.get('[formcontrolname="termsAndConditions"]').check();
cy.findByText('Place Order').click();
});
cy.wait(`@${ConfirmOrderPage}`).its('response.statusCode').should('eq', 200);
}

export function orderConfirmation() {
Expand All @@ -82,17 +66,3 @@ export function orderConfirmation() {
cy.get('cx-order-confirmation-thank-you-message');
cy.contains('Estimated delivery date');
}

export function addProductToCart(sampleProduct: SampleProduct = cheapProduct) {
addCheapProductToCart(sampleProduct);

const deliveryAddressPage = waitForPage(
'/checkout/delivery-address',
'getDeliveryAddressPage'
);
cy.contains('Estimated delivery date');
cy.findByText(/proceed to checkout/i).click();
cy.wait(`@${deliveryAddressPage}`)
.its('response.statusCode')
.should('eq', 200);
}

0 comments on commit ec04b57

Please sign in to comment.