Skip to content

Commit

Permalink
test: reactivate vc mobile and vc tabbing cypress tests (SAP#16795)
Browse files Browse the repository at this point in the history
Tests have been improved to reduce flakiness
closes https://jira.tools.sap/browse/CXSPA-2125
closes https://jira.tools.sap/browse/CXSPA-2277
  • Loading branch information
Uli-Tiger authored Jan 25, 2023
1 parent c32545f commit 75e903b
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 25 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,11 @@ export const UPDATE_CONFIG_ALIAS = '@updateConfig';
*/
export const GET_CONFIG_ALIAS = '@readConfig';

/**
* Alias used for reading the config prices
*/
export const CONFIG_PRICING_ALIAS = '@readConfigPricing';

/**
* Navigates to the product configuration page.
*
Expand Down Expand Up @@ -290,7 +295,18 @@ export function isConflictLinkAttached(attribute: string): void {
*/
export function clickOnViewInConfiguration(attribute: string): void {
cy.log('Click View in Configuration Link');
clickOnConflictSolverLink(attribute, 'iew in Configuration Link');
clickOnConflictSolverLink(attribute, 'View in Configuration Link');
}

/**
* Assuming the given attribute is involved in the conflict, it navigates from the conflict group to standard group
* containing the corresponding attribute and waits for request to finish.
*
* @param attribute - Attribute name
*/
export function clickOnViewInConfigurationAndWait(attribute: string): void {
clickOnViewInConfiguration(attribute);
cy.wait(GET_CONFIG_ALIAS);
}

/**
Expand Down Expand Up @@ -534,6 +550,18 @@ export function registerConfigurationUpdateRoute() {
}).as(UPDATE_CONFIG_ALIAS.substring(1)); // strip the '@'
}

/**
* Register configuration update route using name @see UPDATE_CONFIG_ALIAS
*/
export function registerConfigurationPricingRoute() {
cy.intercept({
method: 'GET',
path: `${Cypress.env('OCC_PREFIX')}/${Cypress.env(
'BASE_SITE'
)}/ccpconfigurator/*/pricing*`,
}).as(CONFIG_PRICING_ALIAS.substring(1)); // strip the '@'
}

/**
* Selects a corresponding attribute value and waits for the patch request to complete.
* Assumes that @see registerConfigurationUpdateRoute was called beforehand.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,9 @@ const SPECIFICATION = 'Specification';

context('Product Configuration', () => {
beforeEach(() => {
configurationVc.registerConfigurationRoute();
configurationVc.registerConfigurationUpdateRoute();
configurationVc.registerConfigurationPricingRoute();
cy.visit('/');
});

Expand All @@ -51,14 +54,13 @@ context('Product Configuration', () => {
tabConfig.productConfigurationPage
);

configuration.selectAttribute(
configurationVc.selectAttributeAndWait(
CAMERA_MODE,
RADIO_GROUP,
CAMERA_MODE_PROFESSIONAL
);
configuration.navigateToOverviewPage();
configurationVc.checkGlobalMessageNotDisplayed();
configuration.checkUpdatingMessageNotDisplayed();
configurationOverview.checkConfigOverviewPageDisplayed();
configurationVc.checkGhostAnimationNotDisplayed();
if (commerceIsAtLeast2211) {
Expand All @@ -79,50 +81,35 @@ context('Product Configuration', () => {

describe('Product Config Keep Focus', () => {
it('should keep focus after selection', () => {
cy.intercept({
method: 'PATCH',
path: `${Cypress.env('OCC_PREFIX')}/${Cypress.env(
'BASE_SITE'
)}/ccpconfigurator/*`,
}).as('updateConfig');

cy.intercept({
method: 'GET',
path: `${Cypress.env('OCC_PREFIX')}/${Cypress.env(
'BASE_SITE'
)}/ccpconfigurator/*/pricing*`,
}).as('priceUpdate');
clickAllowAllFromBanner();
configurationVc.goToConfigurationPage(electronicsShop, testProduct);

cy.wait('@priceUpdate');
cy.wait(configurationVc.CONFIG_PRICING_ALIAS);

configuration.selectAttribute(
configurationVc.selectAttributeAndWait(
CAMERA_COLOR,
RADIO_GROUP,
CAMERA_COLOR_METALLIC
);

cy.wait('@updateConfig');
cy.wait('@priceUpdate');
cy.wait(configurationVc.CONFIG_PRICING_ALIAS);

configuration.checkFocus(
CAMERA_COLOR,
RADIO_GROUP,
CAMERA_COLOR_METALLIC
);

configuration.clickOnNextBtn(SPECIFICATION);
configurationVc.clickOnNextBtnAndWait(SPECIFICATION);
configuration.checkFocus(CAMERA_PIXELS, RADIO_GROUP, CAMERA_PIXELS_P8);

configuration.selectAttribute(
configurationVc.selectAttributeAndWait(
CAMERA_SD_CARD,
CHECKBOX_LIST,
CAMERA_SD_CARD_SDXC
);

cy.wait('@updateConfig');
cy.wait('@priceUpdate');
cy.wait(configurationVc.CONFIG_PRICING_ALIAS);

configuration.checkFocus(
CAMERA_SD_CARD,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ const CAMERA_MODE = 'CAMERA_MODE';
viewportContext(['mobile'], () => {
describe('Group Handling', () => {
it('should navigate using the group menu in mobile resolution', () => {
configurationVc.registerConfigurationRoute();
cy.window().then((win) => win.sessionStorage.clear());
cy.visit('/');
clickAllowAllFromBanner();
Expand All @@ -25,7 +26,7 @@ viewportContext(['mobile'], () => {
configuration.clickHamburger();
configuration.checkGroupMenuDisplayed();

configurationVc.clickOnGroup(2);
configurationVc.clickOnGroupAndWait(2);
configuration.checkAttributeDisplayed(CAMERA_DISPLAY, radioGroup);
});
});
Expand Down

0 comments on commit 75e903b

Please sign in to comment.