Skip to content

Commit

Permalink
test: Improve currency checkout page core e2e (SAP#15909)
Browse files Browse the repository at this point in the history
  • Loading branch information
bgambocjaviniar authored Jun 28, 2022
1 parent 3d9d790 commit f1d48e7
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 37 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import { manipulateCartQuantity } from '../../../../helpers/cart';
import { waitForCartPageData } from '../../../../helpers/b2b/b2b-saved-cart';
import * as siteContextSelector from '../../../../helpers/site-context-selector';
import { product } from '../../../../sample-data/checkout-flow';
import { clearAllStorage } from '../../../../support/utils/clear-all-storage';

describe('Currency switch - checkout page', () => {
const checkoutShippingPath =
Expand All @@ -9,28 +11,20 @@ describe('Currency switch - checkout page', () => {
const checkoutReviewPath = siteContextSelector.CHECKOUT_REVIEW_ORDER_PATH;

before(() => {
cy.window().then((win) => {
win.sessionStorage.clear();
win.localStorage.clear();
});
clearAllStorage();
cy.requireLoggedIn();
siteContextSelector.doPlaceOrder();
waitForCartPageData(product);
});

siteContextSelector.stub(
siteContextSelector.CURRENCY_REQUEST,
siteContextSelector.CURRENCIES
);

describe('populate cart, history, quantity', () => {
it('should have basic data', () => {
manipulateCartQuantity();
});
});

describe('checkout page', () => {
it('should change currency in the shipping address url', () => {
// page being already tested in currency-address-book
describe('checkout page steps', () => {
it('should change currency in the respective checkout steps', () => {
// CHECKOUT DELIVERY ADDRESS STEP
cy.intercept({
method: 'PUT',
pathname: `${Cypress.env('OCC_PREFIX')}/${Cypress.env(
Expand All @@ -48,38 +42,28 @@ describe('Currency switch - checkout page', () => {
);

siteContextSelector.addressBookNextStep();
});

it('should change currency in the checkoutDeliveryPath url', () => {
// CHECKOUT DELIVERY MODE STEP
siteContextSelector.assertSiteContextChange(
siteContextSelector.FULL_BASE_URL_EN_JPY + checkoutDeliveryPath
);
});

it('should change currency in the checkoutDeliveryPath page', () => {
cy.get('cx-delivery-mode .cx-delivery-price:first').should(
'contain',
'¥'
);
siteContextSelector.deliveryModeNextStep();
});

it('should change currency in the checkoutPaymentPath url', () => {
// page being already tested in currency-payment-details
// CHECKOUT PAYMENT METHOD STEP
siteContextSelector.assertSiteContextChange(
siteContextSelector.FULL_BASE_URL_EN_JPY + checkoutPaymentPath
);

siteContextSelector.paymentDetailsNextStep();
});

it('should change currency in the checkoutReviewPath url', () => {
// CHECKOUT REVIEW STEP
siteContextSelector.assertSiteContextChange(
siteContextSelector.FULL_BASE_URL_EN_JPY + checkoutReviewPath
);
});

it('should change currency in the checkoutReviewPath page', () => {
cy.get('cx-review-submit .cx-price .cx-value').should('contain', '¥');
});
});
Expand Down
14 changes: 4 additions & 10 deletions projects/storefrontapp-e2e-cypress/cypress/plugins/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,6 @@ const fs = require('fs');

module.exports = (on, config) => {
on('file:preprocessor', cypressTypeScriptPreprocessor);

/* Set exact timestamp to be shared in all spec files */
config.env.TIMESTAMP = Date.now() - 1535535333333;
return config;
};

/**
* Read file but return null if no file found (instead of failing the test).
*/
module.exports = (on, config) => {
on('task', {
readFile(filename) {
if (fs.existsSync(filename)) {
Expand All @@ -22,4 +12,8 @@ module.exports = (on, config) => {
return null;
},
});

/* Set exact timestamp to be shared in all spec files */
config.env.TIMESTAMP = Date.now() - 1535535333333;
return config;
};

0 comments on commit f1d48e7

Please sign in to comment.