-
Notifications
You must be signed in to change notification settings - Fork 386
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test: refactor e2e tools to reduce duplication (#17630)
- Loading branch information
1 parent
211bede
commit a2c3715
Showing
10 changed files
with
83 additions
and
124 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
60 changes: 60 additions & 0 deletions
60
projects/storefrontapp-e2e-cypress/cypress/helpers/common.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
/* | ||
* SPDX-FileCopyrightText: 2023 SAP Spartacus team <[email protected]> | ||
* | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
/** | ||
* Clicks on 'Add to cart' on the product details page. | ||
*/ | ||
export function clickOnAddToCartBtnOnPD(): void { | ||
cy.get('cx-add-to-cart button.btn-primary') | ||
.contains('Add to cart') | ||
.click() | ||
.then(() => { | ||
cy.get('cx-added-to-cart-dialog').should('be.visible'); | ||
cy.get('div.cx-dialog-body').should('be.visible'); | ||
cy.get('div.cx-dialog-buttons a.btn-primary') | ||
.contains('view cart') | ||
.should('be.visible'); | ||
cy.get('div.cx-dialog-buttons a.btn-secondary') | ||
.contains('proceed to checkout') | ||
.should('be.visible'); | ||
}); | ||
} | ||
|
||
/** | ||
* Clicks on 'View Cart' on the product details page. | ||
*/ | ||
export function clickOnViewCartBtnOnPD(): void { | ||
cy.get('div.cx-dialog-buttons a.btn-primary') | ||
.contains('view cart') | ||
.click() | ||
.then(() => { | ||
cy.location('pathname').should('contain', '/cart'); | ||
cy.get('cx-cart-details').should('be.visible'); | ||
}); | ||
} | ||
|
||
/** | ||
* Navigates to the product detail page. | ||
* | ||
* @param {string} shopName - shop name | ||
* @param {string} productId - Product ID | ||
*/ | ||
export function goToPDPage(shopName: string, productId: string): void { | ||
const location = `${shopName}/en/USD/product/${productId}/${productId}`; | ||
cy.visit(location).then(() => { | ||
checkLoadingMsgNotDisplayed(); | ||
cy.location('pathname').should('contain', location); | ||
cy.get('.ProductDetailsPageTemplate').should('be.visible'); | ||
}); | ||
} | ||
|
||
/** | ||
* Verifies whether the loading message is not displayed. | ||
*/ | ||
export function checkLoadingMsgNotDisplayed(): void { | ||
cy.log('Wait until the loading notification is not displayed anymore'); | ||
cy.get('cx-storefront').should('not.contain.value', 'Loading'); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters