Skip to content

Commit

Permalink
test: fix failing cypress tests (#18558)
Browse files Browse the repository at this point in the history
  • Loading branch information
Stofftiger authored Feb 28, 2024
1 parent fec7e51 commit f9dca35
Show file tree
Hide file tree
Showing 4 changed files with 124 additions and 34 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import { clickAllowAllFromBanner } from '../../helpers/anonymous-consents';
import * as configuration from '../../helpers/product-configurator';
import * as configurationOverview from '../../helpers/product-configurator-overview';
import * as configurationVc from '../../helpers/product-configurator-vc';
import * as configuratorOverviewVc from '../../helpers/product-configurator-overview-vc';
/**
* This suite is marked as flaky due to performance (synchronization) issues on
* https://spartacus-devci767.eastus.cloudapp.azure.com:9002 that we analyze in
Expand Down Expand Up @@ -62,6 +63,7 @@ context('Product Configuration', () => {
cy.cxConfig(configuratorCoreConfig);
configurationVc.registerConfigurationRoute();
configurationVc.registerConfigurationUpdateRoute();
configuratorOverviewVc.registerConfigurationOverviewRoute();
cy.visit('/');
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,17 @@ const GROUP_ID_OPTIONS = '5';
const GROUP_ID_LENS = '4';

context('Product Configuration', () => {
const commerceRelease: configurationVc.CommerceRelease = {};

beforeEach(() => {
cy.visit('/');
configurationOverviewVc.registerConfigurationOverviewRoute();
configurationOverviewVc.registerConfigurationOverviewUpdateRoute();
configurationVc.checkCommerceRelease(
electronicsShop,
testProduct,
commerceRelease
);
});

it('should display sidebar with filter and menu on overview page', () => {
Expand All @@ -40,7 +47,7 @@ context('Product Configuration', () => {
it('should be able filter the overview page', () => {
cy.viewport(1000, 660);
clickAllowAllFromBanner();
completeDigitalCameraConfiguration();
completeDigitalCameraConfiguration(commerceRelease.isPricingEnabled);
configuration.navigateToOverviewPage();

// no filter
Expand Down Expand Up @@ -102,41 +109,119 @@ context('Product Configuration', () => {
});
});

function completeDigitalCameraConfiguration() {
function completeDigitalCameraConfiguration(isPricingEnabled?: boolean) {
configurationVc.registerConfigurationRoute();
configurationVc.registerConfigurationUpdateRoute();
configurationVc.goToConfigurationPage(electronicsShop, testProduct);
configurationVc.selectAttributeAndWait('CAMERA_MODE', RB, 'P');
configurationVc.selectAttributeAndWait('CAMERA_COLOR', RB, 'BLACK');
configurationVc.selectAttributeAndWait(
'CAMERA_MODE',
RB,
'P',
isPricingEnabled
);
configurationVc.selectAttributeAndWait(
'CAMERA_COLOR',
RB,
'BLACK',
isPricingEnabled
);

configurationVc.clickOnNextBtnAndWait('Specification');
configurationVc.selectAttributeAndWait('CAMERA_PIXELS', RB, 'P16');
configurationVc.selectAttributeAndWait('CAMERA_SENSOR', RB, 'F');
configurationVc.selectAttributeAndWait('CAMERA_VIEWFINDER', RB, 'R');
configurationVc.selectAttributeAndWait('CAMERA_SD_CARD', CBL, 'SDHC');
configurationVc.selectAttributeAndWait('CAMERA_SD_CARD', CBL, 'SDXC');
configurationVc.selectAttributeAndWait('CAMERA_SECOND_SLOT', RB, 'Y');
configurationVc.selectAttributeAndWait('CAMERA_FORMAT_PICTURES', RB, 'RAW');
configurationVc.selectAttributeAndWait('CAMERA_MAX_ISO', RB, '25600');
configurationVc.selectAttributeAndWait(
'CAMERA_PIXELS',
RB,
'P16',
isPricingEnabled
);
configurationVc.selectAttributeAndWait(
'CAMERA_SENSOR',
RB,
'F',
isPricingEnabled
);
configurationVc.selectAttributeAndWait(
'CAMERA_VIEWFINDER',
RB,
'R',
isPricingEnabled
);
configurationVc.selectAttributeAndWait(
'CAMERA_SD_CARD',
CBL,
'SDHC',
isPricingEnabled
);

configurationVc.selectAttributeAndWait(
'CAMERA_SD_CARD',
CBL,
'SDXC',
isPricingEnabled
);
configurationVc.selectAttributeAndWait(
'CAMERA_SECOND_SLOT',
RB,
'Y',
isPricingEnabled
);
configurationVc.selectAttributeAndWait(
'CAMERA_FORMAT_PICTURES',
RB,
'RAW',
isPricingEnabled
);
configurationVc.selectAttributeAndWait(
'CAMERA_MAX_ISO',
RB,
'25600',
isPricingEnabled
);

configurationVc.clickOnNextBtnAndWait('Display');
configurationVc.selectAttributeAndWait('CAMERA_DISPLAY', RB, 'P10');
configurationVc.selectAttributeAndWait('CAMERA_TOUCHSCREEN', RB, 'Y');
configurationVc.selectAttributeAndWait('CAMERA_TILTABLE', RB, 'Y');
configurationVc.selectAttributeAndWait(
'CAMERA_DISPLAY',
RB,
'P10',
isPricingEnabled
);
configurationVc.selectAttributeAndWait(
'CAMERA_TOUCHSCREEN',
RB,
'Y',
isPricingEnabled
);
configurationVc.selectAttributeAndWait(
'CAMERA_TILTABLE',
RB,
'Y',
isPricingEnabled
);

configurationVc.clickOnNextBtnAndWait('Lens');
configurationVc.selectAttributeAndWait(
'CAMERA_LENS_MANUFACTURER',
RB,
'LEICA'
'LEICA',
isPricingEnabled
);
configurationVc.selectAttributeAndWait(
'CAMERA_LENS_TYPE',
RB,
'STANDARD_ZOOM_24_70'
'STANDARD_ZOOM_24_70',
isPricingEnabled
);

configurationVc.clickOnNextBtnAndWait('Options');
configurationVc.selectAttributeAndWait('CAMERA_OPTIONS', CBL, 'W');
configurationVc.selectAttributeAndWait('CAMERA_OPTIONS', CBL, 'I');
configurationVc.selectAttributeAndWait(
'CAMERA_OPTIONS',
CBL,
'W',
isPricingEnabled
);
configurationVc.selectAttributeAndWait(
'CAMERA_OPTIONS',
CBL,
'I',
isPricingEnabled
);
}
Original file line number Diff line number Diff line change
Expand Up @@ -66,16 +66,13 @@ export function verifyNotificationBannerInCart(
/**
* Checks Terms & Conditions.
*/
export function checkTermsAndConditions(currency: string = 'USD'): void {
export function checkTermsAndConditions(): void {
cy.log("Check 'Terms & Conditions'");
cy.findByText('Terms & Conditions')
.should('have.attr', 'target', '_blank')
.should(
'have.attr',
'href',
`/${Cypress.env('BASE_SITE')}/en/${currency}/terms-and-conditions`
);
cy.get('input[formcontrolname="termsAndConditions"]').check();
cy.get('input[formcontrolname="termsAndConditions"]')
.check()
.then(() => {
cy.get('cx-place-order form').should('have.class', 'ng-valid');
});
}

/**
Expand All @@ -101,9 +98,9 @@ export function completeCheckout(): void {
checkoutForms.fillShippingAddress(shippingAddressData, true);
checkout.verifyDeliveryMethod();
cy.log('Fulfill payment details form');
checkoutForms.fillPaymentDetails(paymentDetailsData, billingAddress);
this.checkTermsAndConditions();
this.placeOrder();
checkoutForms.fillPaymentDetails(paymentDetailsData, billingAddress, true);
checkTermsAndConditions();
placeOrder();
cy.log('Define order number alias');
configurationCart.defineOrderNumberAlias();
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ import * as login from './login';
import * as configurationCartVc from './product-configurator-cart-vc';
import * as productSearch from './product-search';
import * as common from './common';
import * as productConfiguratorOverviewVc from './product-configurator-overview-vc';
import * as productConfiguratorVc from './product-configurator-vc';
import { verifyGlobalMessageAfterRegistration } from './register';

const nextBtnSelector =
Expand Down Expand Up @@ -450,9 +452,13 @@ export function checkTotalPrice(formattedPrice: string): void {
* Navigates to the overview page via the overview tab.
*/
export function navigateToOverviewPage(): void {
cy.get('cx-configurator-tab-bar a:contains("Overview")').click({
force: true,
});
cy.get('cx-configurator-tab-bar a:contains("Overview")')
.click({
force: true,
})
.then(() => {
cy.wait(productConfiguratorOverviewVc.READ_CONFIG_OV_ALIAS);
});
}

/**
Expand Down

0 comments on commit f9dca35

Please sign in to comment.