Skip to content

Commit

Permalink
[QUOTE] Failing cypress test (#17993)
Browse files Browse the repository at this point in the history
  • Loading branch information
Larisa-Staroverova authored Oct 23, 2023
1 parent 8f5f597 commit aa3e366
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ context('Quote', () => {
cy.visit('/');
quote.login(BUYER_EMAIL, BUYER_PASSWORD, BUYER_USER);
quote.registerGetQuoteRoute(POWERTOOLS);
quote.registerUpdateQuantityRoute(POWERTOOLS);
});

describe('Request quote process', () => {
Expand Down
36 changes: 33 additions & 3 deletions projects/storefrontapp-e2e-cypress/cypress/helpers/quote.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,10 @@
import * as authentication from './auth-forms';
import * as common from './common';

/** alias for GET Quote Route */
/** Aliases for Quote Routes */
export const GET_QUOTE_ALIAS = '@GET_QUOTE';
export const PATH_QUANTITY_ALIAS = '@PATH_QUANTITY';

export const STATUS_SUBMITTED = 'Submitted';
export const STATUS_CANCELED = 'Cancelled';
const STATUS_DRAFT = 'Draft';
Expand Down Expand Up @@ -167,7 +169,15 @@ export function changeItemQuantityByStepper(
}
cy.get(`cx-quote-items .cx-item-list-row:nth-child(${itemIndex})`).within(
() => {
cy.get('cx-item-counter button').contains(changeType).click();
cy.get('cx-item-counter button')
.contains(changeType)
.click()
.then(() => {
cy.wait(PATH_QUANTITY_ALIAS)
.its('response.statusCode')
.should('eq', 200);
cy.get('cx-item-counter input[type=number]:not([disabled])'); // wait until counter is accessible after clicking '+' or '-'
});
}
);
}
Expand All @@ -189,8 +199,12 @@ export function changeItemQuantityByCounter(
cy.get(`cx-quote-items .cx-item-list-row:nth-child(${itemIndex})`).within(
() => {
cy.get('cx-item-counter input')
.type('{selectall}' + newQuantity)
.click()
.focused()
.type('{selectall}' + newQuantity, { force: true })
.pressTab();

cy.wait(PATH_QUANTITY_ALIAS).its('response.statusCode').should('eq', 200);
}
);
}
Expand Down Expand Up @@ -777,6 +791,7 @@ export function checkExpiryDate() {
cy.get('.cx-card-paragraph-text').contains(createFormattedExpiryDate());
});
}

/**
* Creates the formatted expiry date string.
*
Expand Down Expand Up @@ -910,6 +925,21 @@ export function registerGetQuoteRoute(shopName: string) {
}).as(GET_QUOTE_ALIAS.substring(1)); // strip the '@'
}

/**
* Registers PATCH quantity route.
*
* @param shopName - Name of the current shop
*/
export function registerUpdateQuantityRoute(shopName: string) {
log('Registers GET quote route.', registerUpdateQuantityRoute.name);
cy.intercept({
method: 'PATCH',
path: `${Cypress.env(
'OCC_PREFIX'
)}/${shopName}/users/*/carts/*/entries/0?lang=en&curr=USD`,
}).as(PATH_QUANTITY_ALIAS.substring(1)); // strip the '@'
}

/**
* Reloads the quote page.
* This method is equal to F5.
Expand Down

0 comments on commit aa3e366

Please sign in to comment.