Skip to content

Commit

Permalink
CXSPA-4232 add test: edit quote name + description
Browse files Browse the repository at this point in the history
  • Loading branch information
Stofftiger committed Aug 17, 2023
1 parent 0f8eafb commit 25665cf
Show file tree
Hide file tree
Showing 2 changed files with 174 additions and 81 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ const SALESREP_EMAIL = '[email protected]';
const SALESREP_PASSWORD = '12341234';
const SALESREP_USER = 'Darrin Hesser';
const MSG_TYPE_WARNING = '[GlobalMessage] Warning';
const CARD_TITLE_QUOTE_INFORMATION = 'Quote Information';
const getTestTitle = (
test: Mocha.Suite = (Cypress as any).mocha.getRunner().suite.ctx.test
): string =>
Expand Down Expand Up @@ -44,57 +45,62 @@ context('Quote', () => {

describe('Request quote process', () => {
it('should display a message and disable submit button if threshold is not met', () => {
quote.log('requestQuote', getTestTitle());
quote.log('request a quote', getTestTitle());
quote.requestQuote(POWERTOOLS, TESTPRODUCTHAMMERDRILLINGID, '1');
quote.log('checkQuoteInDraftState', getTestTitle());
quote.log('check if the quote is in draft state', getTestTitle());
quote.checkQuoteInDraftState(false, TESTPRODUCTHAMMERDRILLINGID);
});

it('should be possible(submit) if threshold is met', () => {
quote.log('requestQuote', getTestTitle());
quote.log('request a quote', getTestTitle());
quote.requestQuote(POWERTOOLS, TESTPRODUCTHAMMERDRILLINGID, '30');
cy.url().as('quoteURL');
quote.log('checkQuoteInDraftState', getTestTitle());
quote.log('check if the quote is in "draft" state', getTestTitle());
quote.checkQuoteInDraftState(true, TESTPRODUCTHAMMERDRILLINGID);
quote.log('addCommentAndWait', getTestTitle());
quote.log('add a comment', getTestTitle());
quote.addCommentAndWait(
'Can you please make me a good offer for this large volume of goods?'
);
quote.log('checkComment', getTestTitle());
quote.log('check if the comment exists', getTestTitle());
quote.checkComment(
1,
'Can you please make me a good offer for this large volume of goods?'
);
quote.log('addItemCommentAndWait', getTestTitle());
quote.log('add an comment with a linked item', getTestTitle());
quote.addItemCommentAndWait(
TESTPRODUCTHAMMERDRILLINGNAME,
'since there is a newer model out, is it possible to get a discount for this item?'
);
quote.log('checkItemComment', getTestTitle());
quote.log('check if the comment with the item exists', getTestTitle());
quote.checkItemComment(
2,
TESTPRODUCTHAMMERDRILLINGNAME,
'since there is a newer model out, is it possible to get a discount for this item?'
);
quote.log('clickItemLinkInComment', getTestTitle());
quote.log('click on the link in within the comment', getTestTitle());
quote.clickItemLinkInComment(2, TESTPRODUCTHAMMERDRILLINGNAME);
quote.log('checkLinkedItemInViewport', getTestTitle());
quote.log(
'Check if the linked item is within the viewport',
getTestTitle()
);
quote.checkLinkedItemInViewport(1);
quote.log('submitQuote', getTestTitle());
quote.log('Submit the quote', getTestTitle());
quote.submitQuote();
quote.log('checkQuoteState Submitted', getTestTitle());
quote.log('check if quote state is "Submitted"', getTestTitle());
quote.checkQuoteState(quote.STATUS_SUBMITTED);
quote.log('checkCommentsNotEditable', getTestTitle());
quote.log('check if comments are not editable', getTestTitle());
quote.checkCommentsNotEditable();
});
});

it('should edit name, description and quantity of items within a quote draft (CXSPA-3852)', () => {
describe('Edit quote process - buyer perspective', () => {
it('should edit quantity of items within a buyer quote draft (CXSPA-3852)', () => {
quote.log('requestQuote', getTestTitle());
const amount: number = 30;
const PRODUCT_AMOUNT: number = 30;
quote.requestQuote(
POWERTOOLS,
TESTPRODUCTHAMMERDRILLINGID,
amount.toString()
PRODUCT_AMOUNT.toString()
);
cy.url().as('quoteURL');
quote.log('checkQuoteInDraftState', getTestTitle());
Expand All @@ -110,24 +116,26 @@ context('Quote', () => {
true
);
quote.log(
`validate the item quantity at index ${itemIndex} equals ${amount}`,
`validate the item quantity at index ${itemIndex} equals ${PRODUCT_AMOUNT}`,
getTestTitle()
);
quote.validateItemQuantity(itemIndex, amount.toString());
quote.validateItemQuantity(itemIndex, PRODUCT_AMOUNT.toString());
quote.log('increase the item quantity by 1', getTestTitle());
quote.changeItemQuantityOnClick(itemIndex, '+');
quote.log(
`validate the item quantity at index ${itemIndex} equals ${amount + 1}`,
`validate the item quantity at index ${itemIndex} equals ${
PRODUCT_AMOUNT + 1
}`,
getTestTitle()
);
quote.validateItemQuantity(itemIndex, (amount + 1).toString());
quote.log('decrease the item quantity by 1', getTestTitle());
quote.validateItemQuantity(itemIndex, (PRODUCT_AMOUNT + 1).toString());
quote.log('decrease the item quantity by 1', getTestTitle());
quote.changeItemQuantityOnClick(itemIndex, '-');
quote.log(
`validate the item quantity at index ${itemIndex} equals ${amount}`,
`validate the item quantity at index ${itemIndex} equals ${PRODUCT_AMOUNT}`,
getTestTitle()
);
quote.validateItemQuantity(itemIndex, amount.toString());
quote.validateItemQuantity(itemIndex, PRODUCT_AMOUNT.toString());
quote.log('change the item quantity to 1', getTestTitle());
quote.changeItemQuantityWithInputField(1, '1');
quote.log(
Expand All @@ -140,46 +148,70 @@ context('Quote', () => {
getTestTitle()
);
quote.checkSubmitButton(false);
quote.log(`verify item exists at index ${itemIndex}`, getTestTitle());
quote.log(`verify the item exists at index ${itemIndex}`, getTestTitle());
quote.checkItemAtIndexExists(
itemIndex,
TESTPRODUCTHAMMERDRILLINGID,
true
);
quote.log(`remove item at index ${itemIndex}`, getTestTitle());
quote.log(`remove the item at index ${itemIndex}`, getTestTitle());
quote.removeItemOnClick(itemIndex);
quote.log(
`verify item got removed and does not exist at index anymore and ${itemIndex}`,
`verify the item got removed and does not exist at index ${itemIndex}`,
getTestTitle()
);
quote.checkItemAtIndexExists(
itemIndex,
TESTPRODUCTHAMMERDRILLINGID,
false
);

//########### not yet implemented ########
//ToDo: edit quote name
//ToDO: edit quote description
});

it('should logout as user and login seller in asm mode ', () => {
it('should edit name and description of the quote while in buyer draft (CXSPA-3852)', () => {
quote.log('requestQuote', getTestTitle());
quote.requestQuote(POWERTOOLS, TESTPRODUCTHAMMERDRILLINGID, '30');
quote.log('create Alias for quoteURL', getTestTitle());
const PRODUCT_AMOUNT: number = 30;
const QUOTENAME = 'Quote name test';
const QUOTEDESCRIPTION = 'Quote description for the test';
quote.requestQuote(
POWERTOOLS,
TESTPRODUCTHAMMERDRILLINGID,
PRODUCT_AMOUNT.toString()
);
cy.url().as('quoteURL');
quote.log('checkQuoteInDraftState', getTestTitle());
quote.checkQuoteInDraftState(true, TESTPRODUCTHAMMERDRILLINGID);
quote.log('submitQuote', getTestTitle());
quote.submitQuote();
quote.log('checkQuoteState Submitted', getTestTitle());
quote.checkQuoteState(quote.STATUS_SUBMITTED);
quote.log(`logout user ${BUYER_USER}`, getTestTitle());
quote.logoutBuyer(POWERTOOLS);
quote.log('enable ASM mode', getTestTitle());
quote.enableASMMode(POWERTOOLS);
quote.log(`login sales rep ${SALESREP_USER} in ASM mode`, getTestTitle());
quote.loginASM(POWERTOOLS, SALESREP_EMAIL, SALESREP_PASSWORD);
quote.log(
'verify the "Quote Information" card is not in edit mode',
getTestTitle()
);
quote.verifyQuoteInformationCardInEditMode(
CARD_TITLE_QUOTE_INFORMATION,
false
);
quote.log('click on edit button in quote summary card', getTestTitle());
quote.clickEditOnQuoteInformationCard(CARD_TITLE_QUOTE_INFORMATION);
quote.log('change the quote name and description text', getTestTitle());
quote.changeQuoteSummaryCardEntries(
CARD_TITLE_QUOTE_INFORMATION,
QUOTENAME,
QUOTEDESCRIPTION
);
quote.log('click on save within the quote summary card', getTestTitle());
quote.clickSaveOnQuoteSummaryCard(CARD_TITLE_QUOTE_INFORMATION);
quote.log(
'verify the quote summary card is not in edit mode',
getTestTitle()
);
quote.verifyQuoteInformationCardInEditMode(
CARD_TITLE_QUOTE_INFORMATION,
false
);
quote.log(
'verify the quote name and description texts are updated',
getTestTitle()
);
quote.verifyQuoteInformationContent(QUOTENAME);
quote.verifyQuoteInformationContent(QUOTEDESCRIPTION);
});
});

Expand Down
137 changes: 99 additions & 38 deletions projects/storefrontapp-e2e-cypress/cypress/helpers/quote.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,44 +60,6 @@ export function login(email: string, password: string, name: string): void {
cy.get('.cx-login-greet').should('contain', name);
cy.get('cx-login').should('not.contain', 'Sign In');
}
/**
* logs out the buyer
* @param shopName Name of the current shop (Powertools)
*/
export function logoutBuyer(shopName: string): void {
log(logoutBuyer.name);
cy.visit(`${shopName}/en/USD/logout`);
cy.get('cx-login [role="link"]');
}

/**
* Enables the asm mode for the given shop
* @param shopName Name of the shop (Powertools)
*/
export function enableASMMode(shopName: string) {
log(enableASMMode.name);
cy.visit(`${shopName}/en/USD/?asm=true`);
}
/**
* Use the cx-login-form to login into the asm mode
* @param shopName Name of the given shop (Powertools)
* @param sellerEmail Email address of the seller; used for the login
* @param sellerPassword Password of the seller; used for the login
*/
export function loginASM(
shopName: string,
sellerEmail: string,
sellerPassword: string
) {
log(loginASM.name);
cy.visit(`${shopName}/en/USD/`);
cy.get('cx-csagent-login-form form').within(() => {
cy.get('[formcontrolname="userId"]').clear().type(sellerEmail);
cy.get('[formcontrolname="password"]').clear().type(sellerPassword);
cy.get('button[type=submit]').click();
});
cy.get('cx-customer-selection').should('be.visible');
}

/**
* Request a quote from cart
Expand Down Expand Up @@ -243,10 +205,108 @@ export function checkItemAtIndexExists(
}
}

/**
* Checks if the "Quote Information" card is in edit mode
* @param cardTitle Title of the card
* @param cardEditModeActive Indicates if the card is in edit mode
*/
export function verifyQuoteInformationCardInEditMode(
cardTitle: string,
cardEditModeActive: boolean
): void {
log(verifyQuoteInformationCardInEditMode.name);
cy.get(`cx-quote-details-overview .cx-container .card-body`)
.contains(cardTitle)
.should('exist')
.then(() => {
if (cardEditModeActive) {
cy.get('button').contains('Save').should('exist');
} else {
cy.get('button').contains('Safe').should('not.exist');
}
});
}

/**
* Changes the "Quote Name" and the "Quote description" to given values
* @param cardTitle Title of the card
* @param newQuoteName New quote name
* @param newQuoteDescription New quote description
*/
export function changeQuoteSummaryCardEntries(
cardTitle: string,
newQuoteName: string,
newQuoteDescription: string
): void {
log(changeQuoteSummaryCardEntries.name);
cy.get(`cx-quote-details-overview .cx-container .card-body`)
.contains(cardTitle)
.should('exist')
.then(() => {
cy.get(`cx-quote-details-overview .cx-container .card-body input`)
.should('exist')
.clear()
.type(newQuoteName);
cy.get(`cx-quote-details-overview .cx-container .card-body textarea`)
.should('exist')
.clear()
.type(newQuoteDescription);
});
}

/**
* Clicks on "Save" button in the quote Information card. This requires the card to be in edit mode.
* @param cardTitle Title of the card
*/
export function clickSaveOnQuoteSummaryCard(cardTitle: string): void {
log(clickSaveOnQuoteSummaryCard.name);
verifyQuoteInformationCardInEditMode(cardTitle, true);
cy.get(`cx-quote-details-overview .cx-container .card-body`)
.contains(cardTitle)
.should('exist')
.then(() => {
cy.get('button').contains('Save').should('exist').click();
});
}

/**
* Verify the expected quote name equals the current quote name
* @param cardTitle Title of the card
* @param expectedQuoteInformationContent expected quote name
*/
export function verifyQuoteInformationContent(
expectedQuoteInformationContent: string
): void {
log(verifyQuoteInformationContent.name);
cy.get('cx-quote-details-overview .cx-container .card-body')
.find('.cx-card-paragraph-text')
.contains(expectedQuoteInformationContent);
}

/**
* Clicks on the edit button to change the quote information within the "Quote Information" card.
* @param cardTitle Title of the card
*/
export function clickEditOnQuoteInformationCard(cardTitle: string): void {
log(clickEditOnQuoteInformationCard.name);
cy.get(`cx-quote-details-overview .cx-container .card-body`)
.contains(cardTitle)
.should('exist')
.then(() => {
cy.get('.cx-edit-btn')
.should('exist')
.click()
.then(() => {
verifyQuoteInformationCardInEditMode(cardTitle, true);
});
});
}

/**
* Clicks on 'Yes' on the quote confirm request dialog popup.
*/
export function clickOnYesBtnOnQuoteSubmitPopUp(): void {
log(clickOnYesBtnOnQuoteSubmitPopUp.name);
cy.get('cx-quote-confirm-action-dialog button.btn-primary').click();
cy.wait(GET_QUOTE_ALIAS);
}
Expand Down Expand Up @@ -360,6 +420,7 @@ export function checkItemInQuoteCart(productId: string) {
* @param status Expected Status of the quote
*/
export function checkQuoteState(status: string) {
log(checkQuoteState.name);
cy.get('cx-quote-details-overview h3.cx-status').contains(status);
}

Expand Down

0 comments on commit 25665cf

Please sign in to comment.