Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test: Update route and server usage in e2e #11129

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { user } from '../../sample-data/checkout-flow';
import { focusableSelectors } from '../../support/utils/a11y-tab';
import { register as authRegister } from '../auth-forms';
import { waitForPage } from '../checkout-flow';
import { CMS_CART_PAGE, CMS_HOMEPAGE, CMS_LOGIN_PAGE } from '../interceptors';
import { loginUser } from '../login';
import { TabbingOrderTypes, TabElement } from './tabbing-order.model';

Expand Down Expand Up @@ -155,31 +156,26 @@ export function getFormFieldByValue(value: string) {
}

export function register() {
const loginPage = waitForPage('/login', 'getLoginPage');
cy.visit('/login/register');
authRegister(user);
cy.wait(`@${loginPage}`);
cy.wait(CMS_LOGIN_PAGE);
}

export function login() {
const homePage = waitForPage('homepage', 'getHomePage');
cy.visit('/login');
loginUser();
cy.wait(`@${homePage}`);
cy.wait(CMS_HOMEPAGE);
}

export function registerAndLogin(): void {
const loginPage = waitForPage('/login', 'getLoginPage');
const homePage = waitForPage('homepage', 'getHomePage');
cy.visit('/login/register');
authRegister(user);
cy.wait(`@${loginPage}`);
cy.wait(CMS_LOGIN_PAGE);
loginUser();
cy.wait(`@${homePage}`);
cy.wait(CMS_HOMEPAGE);
}

export function addProduct(productCode?: string): void {
const cartPage = waitForPage('/cart', 'getCartPage');
const productUrl = productCode ? `/product/${productCode}` : testProductUrl;

cy.visit(productUrl);
Expand All @@ -191,11 +187,11 @@ export function addProduct(productCode?: string): void {
.first()
.click();
});
cy.wait(`@${cartPage}`);
cy.wait(CMS_CART_PAGE);
}

export function checkoutNextStep(url: string) {
const nextStep = waitForPage(url, 'getNextStep');
cy.findAllByText('Continue').first().click({ force: true });
cy.wait(`@${nextStep}`);
cy.wait(nextStep);
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import * as asm from '../../../helpers/asm';
import { verifyTabbingOrder } from '../tabbing-order';
import { TabElement } from '../tabbing-order.model';
import * as asm from '../../../helpers/asm';

const containerSelector = 'cx-asm-main-ui';

Expand All @@ -17,7 +17,9 @@ export function asmTabbingOrderNoSelectedUser(config: TabElement[]) {
cy.get('cx-customer-selection form').within(() => {
cy.get('[formcontrolname="searchTerm"]').type('Linda Wolf');
});
cy.wait(customerSearchRequestAlias).its('status').should('eq', 200);
cy.wait(customerSearchRequestAlias)
.its('response.statusCode')
.should('eq', 200);

verifyTabbingOrder(containerSelector, config);
}
Expand All @@ -30,7 +32,9 @@ export function asmTabbingOrderWithSelectedUser(config: TabElement[]) {
cy.get('cx-customer-selection form').within(() => {
cy.get('[formcontrolname="searchTerm"]').type('Linda Wolf');
});
cy.wait(customerSearchRequestAlias).its('status').should('eq', 200);
cy.wait(customerSearchRequestAlias)
.its('response.statusCode')
.should('eq', 200);
cy.get('cx-customer-selection div.asm-results button').first().click();

verifyTabbingOrder(containerSelector, config);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,18 +1,13 @@
import { waitForPage } from '../../../checkout-flow';
import { CMS_DELIVERY_PAGE } from '../../../interceptors';
import { checkoutNextStep, verifyTabbingOrder } from '../../tabbing-order';
import { TabElement } from '../../tabbing-order.model';

const containerSelector = 'cx-page-layout.MultiStepCheckoutSummaryPageTemplate';

export function checkoutDeliveryModeTabbingOrder(config: TabElement[]) {
const deliveryPage = waitForPage(
'/checkout/delivery-mode',
'getDeliveryPage'
);

cy.visit('/checkout/delivery-mode');

cy.wait(`@${deliveryPage}`).its('status').should('eq', 200);
cy.wait(CMS_DELIVERY_PAGE).its('response.statusCode').should('eq', 200);

cy.get('cx-delivery-mode input').should('exist');

Expand All @@ -22,13 +17,8 @@ export function checkoutDeliveryModeTabbingOrder(config: TabElement[]) {
}

export function checkoutDeliveryModeTabbingOrderAccount(config: TabElement[]) {
const deliveryPage = waitForPage(
'/checkout/delivery-mode',
'getDeliveryPage'
);

cy.visit('/checkout/delivery-mode');
cy.wait(`@${deliveryPage}`).its('status').should('eq', 200);
cy.wait(CMS_DELIVERY_PAGE).its('response.statusCode').should('eq', 200);

cy.get('cx-delivery-mode input').should('exist');

Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { user } from '../../../../sample-data/checkout-flow';
import { waitForPage } from '../../../checkout-flow';
import {
fillBillingAddress,
fillPaymentDetails,
} from '../../../checkout-forms';
import { CMS_PAYMENT_PAGE } from '../../../interceptors';
import { checkoutNextStep, verifyTabbingOrder } from '../../tabbing-order';
import { TabElement } from '../../tabbing-order.model';

Expand All @@ -21,13 +21,8 @@ export function checkoutPaymentDetailsTabbingOrder(config: TabElement[]) {
)}/countries?type=BILLING*`
).as('countries');

const paymentPage = waitForPage(
'/checkout/payment-details',
'getPaymentPage'
);

cy.visit('/checkout/payment-details');
cy.wait(`@${paymentPage}`).its('status').should('eq', 200);
cy.wait(CMS_PAYMENT_PAGE).its('response.statusCode').should('eq', 200);

cy.wait('@cardTypes');
cy.wait('@countries');
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { waitForPage } from '../../../checkout-flow';
import { CMS_REVIEW_PAGE } from '../../../interceptors';
import { verifyTabbingOrder } from '../../tabbing-order';
import { TabElement } from '../../tabbing-order.model';

Expand All @@ -8,11 +9,9 @@ export function checkoutReviewOrderTabbingOrder(
config: TabElement[],
checkout: boolean = false
) {
const reviewPage = waitForPage('/checkout/review-order', 'getReviewPage');

cy.visit('/checkout/review-order');

cy.wait(`@${reviewPage}`);
cy.wait(CMS_REVIEW_PAGE);

cy.get('cx-review-submit .cx-review-title').should('exist');

Expand All @@ -31,6 +30,6 @@ export function checkoutReviewOrderTabbingOrder(
'getOrderConfirmationPage'
);
cy.get('cx-place-order button.btn-primary').click();
cy.wait(`@${orderConfirmationPage}`).its('status').should('eq', 200);
cy.wait(orderConfirmationPage).its('response.statusCode').should('eq', 200);
}
}
Original file line number Diff line number Diff line change
@@ -1,18 +1,16 @@
import { user } from '../../../../sample-data/checkout-flow';
import { waitForPage } from '../../../checkout-flow';
import { fillShippingAddress } from '../../../checkout-forms';
import { CMS_SHIPPING_ADDRESS_PAGE } from '../../../interceptors';
import { checkoutNextStep, verifyTabbingOrder } from '../../tabbing-order';
import { TabElement } from '../../tabbing-order.model';

const containerSelector = 'cx-page-layout.MultiStepCheckoutSummaryPageTemplate';

export function checkoutShippingAddressNewTabbingOrder(config: TabElement[]) {
const shippingAddressPage = waitForPage(
'/checkout/shipping-address',
'getShippingAddress'
);
cy.visit('/checkout/shipping-address');
cy.wait(`@${shippingAddressPage}`).its('status').should('eq', 200);
cy.wait(CMS_SHIPPING_ADDRESS_PAGE)
.its('response.statusCode')
.should('eq', 200);

const { firstName, lastName, phone, address } = user;
fillShippingAddress({ firstName, lastName, phone, address }, false);
Expand All @@ -25,12 +23,10 @@ export function checkoutShippingAddressNewTabbingOrder(config: TabElement[]) {
export function checkoutShippingAddressExistingTabbingOrder(
config: TabElement[]
) {
const shippingAddressPage = waitForPage(
'/checkout/shipping-address',
'getShippingAddress'
);
cy.visit('/checkout/shipping-address');
cy.wait(`@${shippingAddressPage}`).its('status').should('eq', 200);
cy.wait(CMS_SHIPPING_ADDRESS_PAGE)
.its('response.statusCode')
.should('eq', 200);

cy.get('cx-card').within(() => {
cy.get('.cx-card-label-bold').should('not.be.empty');
Expand All @@ -44,11 +40,6 @@ export function checkoutShippingAddressExistingTabbingOrder(
}

export function checkoutShippingAddressAccount(config: TabElement[]) {
const shippingAddressPage = waitForPage(
'/checkout/shipping-address',
'getShippingAddress'
);

cy.route(
'PUT',
`${Cypress.env('OCC_PREFIX')}/${Cypress.env(
Expand All @@ -57,7 +48,9 @@ export function checkoutShippingAddressAccount(config: TabElement[]) {
).as('setAddress');

cy.visit('/checkout/shipping-address');
cy.wait(`@${shippingAddressPage}`).its('status').should('eq', 200);
cy.wait(CMS_SHIPPING_ADDRESS_PAGE)
.its('response.statusCode')
.should('eq', 200);

cy.wait('@setAddress').its('status').should('eq', 200);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,13 +114,12 @@ export function addDifferentProducts(isMobile: Boolean = false) {
cy.get('cx-added-to-cart-dialog .btn-primary').click();
cy.get('cx-breadcrumb h1').should('contain', 'Your Shopping Cart');

cy.server();
cy.route(
'GET',
`${Cypress.env('OCC_PREFIX')}/${Cypress.env(
cy.intercept({
pathname: `${Cypress.env('OCC_PREFIX')}/${Cypress.env(
'BASE_SITE'
)}/users/anonymous/carts/*`
).as('getRefreshedCart');
)}/users/anonymous/carts/**`,
method: 'GET',
}).as('getRefreshedCart');

// delete a product and check if the total is updated
cy.get('cx-cart-item-list .cx-item-list-items')
Expand Down Expand Up @@ -158,7 +157,7 @@ export function addDifferentProducts(isMobile: Boolean = false) {
expect(totalPrice).equal('$927.89');
});

cy.wait('@getRefreshedCart').its('status').should('eq', 200);
cy.wait('@getRefreshedCart').its('response.statusCode').should('eq', 200);
// delete the last product in cart
cy.get('cx-cart-item-list .cx-item-list-items')
.contains('.cx-info', productName2)
Expand Down
32 changes: 20 additions & 12 deletions projects/storefrontapp-e2e-cypress/cypress/helpers/address-book.ts
Original file line number Diff line number Diff line change
Expand Up @@ -133,24 +133,32 @@ export function verifyAsAnonymous() {
}

export function deleteFirstAddress() {
cy.server();
cy.route(
'DELETE',
`${Cypress.env('OCC_PREFIX')}/${Cypress.env(
cy.intercept({
pathname: `${Cypress.env('OCC_PREFIX')}/${Cypress.env(
'BASE_SITE'
)}/users/*/addresses/*?lang=en&curr=USD`
).as('deleteAddress');
cy.route(
`${Cypress.env('OCC_PREFIX')}/${Cypress.env(
)}/users/*/addresses/*`,
query: {
lang: 'en',
curr: 'USD',
},
method: 'DELETE',
}).as('deleteAddress');
cy.intercept({
pathname: `${Cypress.env('OCC_PREFIX')}/${Cypress.env(
'BASE_SITE'
)}/users/*/addresses?lang=en&curr=USD`
).as('fetchAddresses');
)}/users/*/addresses`,
query: {
lang: 'en',
curr: 'USD',
},
method: 'GET',
}).as('fetchAddresses');

const firstCard = cy.get('cx-card').first();
firstCard.contains('Delete').click();
cy.get('.cx-card-delete button.btn-primary').click();
cy.wait('@deleteAddress').its('status').should('eq', 200);
cy.wait('@fetchAddresses').its('status').should('eq', 200);
cy.wait('@deleteAddress').its('response.statusCode').should('eq', 200);
cy.wait('@fetchAddresses').its('response.statusCode').should('eq', 200);
}

export function addressBookTest() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { switchSiteContext } from '../support/utils/switch-site-context';
import { login, register } from './auth-forms';
import { waitForPage } from './checkout-flow';
import { checkBanner } from './homepage';
import { CMS_LOGIN_PAGE, CMS_REGISTER_PAGE } from './interceptors';
import { signOutUser } from './login';
import { LANGUAGE_DE, LANGUAGE_LABEL } from './site-context-selector';
import { generateMail, randomString } from './user';
Expand Down Expand Up @@ -70,12 +71,10 @@ export function registerNewUserAndLogin(
giveRegistrationConsent = false,
hiddenConsent?
) {
const loginPage = waitForPage('/login', 'getLoginPage');
cy.get('cx-login [role="link"]').click();
cy.wait(`@${loginPage}`).its('status').should('eq', 200);
const registerPage = waitForPage('/login/register', 'getRegisterPage');
cy.wait(CMS_LOGIN_PAGE).its('response.statusCode').should('eq', 200);
cy.findByText('Register').click();
cy.wait(`@${registerPage}`).its('status').should('eq', 200);
cy.wait(CMS_REGISTER_PAGE).its('response.statusCode').should('eq', 200);
register(newUser, giveRegistrationConsent, hiddenConsent);
cy.get('cx-breadcrumb').contains('Login');

Expand All @@ -87,7 +86,7 @@ export function navigateToConsentPage() {
cy.selectUserMenuOption({
option: 'Consent Management',
});
cy.wait(`@${consentsPage}`).its('status').should('eq', 200);
cy.wait(consentsPage).its('response.statusCode').should('eq', 200);
}

export function seeBannerAsAnonymous() {
Expand Down Expand Up @@ -254,9 +253,8 @@ export function moveAnonymousUserToLoggedInUser() {
toggleAnonymousConsent(2);
closeDialog();

const loginPage = waitForPage('/login', 'getLoginPage');
cy.get('cx-login [role="link"]').click();
cy.wait(`@${loginPage}`).its('status').should('eq', 200);
cy.wait(CMS_LOGIN_PAGE).its('response.statusCode').should('eq', 200);

login(
standardUser.registrationData.email,
Expand Down Expand Up @@ -288,9 +286,8 @@ export function testAsLoggedInUser() {
toggleAnonymousConsent(2);
closeDialog();

const loginPage = waitForPage('/login', 'getLoginPage');
cy.get('cx-login [role="link"]').click();
cy.wait(`@${loginPage}`).its('status').should('eq', 200);
cy.wait(CMS_LOGIN_PAGE).its('response.statusCode').should('eq', 200);

login(
standardUser.registrationData.email,
Expand All @@ -314,9 +311,14 @@ export function changeLanguageTest() {
checkAllInputConsentState(BE_CHECKED);
closeDialog();

cy.route('GET', `*${LANGUAGE_DE}*`).as('switchedContext');
cy.intercept({
query: {
lang: LANGUAGE_DE,
},
method: 'GET',
}).as('switchedContext');
switchSiteContext(LANGUAGE_DE, LANGUAGE_LABEL);
cy.wait('@switchedContext').its('status').should('eq', 200);
cy.wait('@switchedContext').its('response.statusCode').should('eq', 200);

openDialogUsingFooterLink();
checkAllInputConsentState(BE_CHECKED);
Expand Down
Loading