Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions cypress/e2e/page/product.details.page.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,19 @@ class ProductDetailPage {
get backNavigation() {
return ('div.chakra-stack.css-dpkrn2')
}

get addToFavoritesBtn() {
return ('#add-to-favorite')
}

get removeFromFavoritesBtn() {
return ('#remove-from-favorite')
}

get alertPopUpMsg() {
return ('.chakra-alert__title.css-tidvy5')
}

//method
addToCart() {
cy.get(this.addToCartBtn).scrollIntoView()
Expand Down
28 changes: 28 additions & 0 deletions cypress/e2e/page/product.home.page.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,5 +64,33 @@ class ProductHomePage {
return ('img[src="/images/quality-pillow.jpg"]')
}

get addToFavoritesBtns() {
return ('#add-to-favorite')
}

get removeFromFavoritesBtn() {
return ('#remove-from-favorite')
}

get qualityMugFavoriteBtn() {
return ('#product-3 div.css-1m8iww1')
}

get qualityPillowFavoriteBtn() {
return ('#product-4 div.css-1m8iww1')
}

get hoodedSweatshirtFavoriteBtn() {
return ('#product-5 div.css-1m8iww1')
}

get alertPopUpMsg() {
return ('.chakra-alert__title.css-tidvy5')
}

get closePopUp() {
return ('button[aria-label="Close"]')
}

}
export default new ProductHomePage()
24 changes: 24 additions & 0 deletions cypress/e2e/page/wishlist.page.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
class WishListPage {

//getters
get favoritesMenuTab() {
return ('#top-favorite')
}

get favoritesBadge() {
return ('#top-favorite p')
}

get hoodedSweatShirtCartBtn() {
return ('button[data-item-id="quality-sweatshirt-hooded"]')
}

get favoriteProductTitles() {
return ('div.chakra-stack.css-1oeb4ru > p')
}


//methods

}
export default new WishListPage()
89 changes: 89 additions & 0 deletions cypress/e2e/test/wishlist.cy.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
import ProductDetailsPage from "../page/product.details.page"
import ProductHomePage from "../page/product.home.page"
import WishlistPage from "../page/wishlist.page"

describe('Wishlist', () => {
beforeEach('Visit the products home page', () =>{
cy.visit('/products')
cy.wait(1500)
})

it('Confirm that each product has an add to favorite option from the products gallery home page', () =>{
cy.get(ProductHomePage.addToFavoritesBtns).should('exist')
})

it('Confirm that a product can be added to favorites from the products gallery home page', () =>{
cy.get(ProductHomePage.qualityMugFavoriteBtn, {timeout: 1000}).should('exist')
cy.get(ProductHomePage.qualityMugFavoriteBtn).click()
cy.get(ProductHomePage.alertPopUpMsg).should('include.text', 'added to favorites')
cy.get(WishlistPage.favoritesBadge).should('include.text', '1')
})

it('Confirm that multiple products can be added to favorites from the products gallery home page', () =>{
cy.get(ProductHomePage.qualityMugFavoriteBtn, {timeout: 1000}).should('exist')
cy.get(ProductHomePage.qualityMugFavoriteBtn).click()
cy.get(ProductHomePage.alertPopUpMsg).should('include.text', 'added to favorites')
cy.get(WishlistPage.favoritesBadge).should('include.text', '1')


cy.get(ProductHomePage.hoodedSweatshirtFavoriteBtn, {timeout: 1000}).should('exist')
cy.get(ProductHomePage.hoodedSweatshirtFavoriteBtn).click()
cy.get(ProductHomePage.alertPopUpMsg).should('include.text', 'added to favorites')
cy.get(WishlistPage.favoritesBadge).should('include.text', '2')


cy.get(ProductHomePage.qualityPillowFavoriteBtn, {timeout: 1000}).should('exist')
cy.get(ProductHomePage.qualityPillowFavoriteBtn).click()
cy.get(ProductHomePage.alertPopUpMsg).should('include.text', 'added to favorites')
cy.get(WishlistPage.favoritesBadge).should('include.text', '3')

})

it('Confirm that a product can be added to favorites from the product details page', () =>{
cy.get(ProductHomePage.hoodedSweatshirt).scrollIntoView().click()
cy.location('pathname', { timeout: 40000 }).should('eq', '/products/quality-sweatshirt-hooded')
cy.get(ProductDetailsPage.productName, { timeout: 10000 }).should('exist')
cy.get(ProductDetailsPage.addToFavoritesBtn, {timeout: 1000}).should('exist')
cy.get(ProductDetailsPage.addToFavoritesBtn).click()
cy.get(ProductDetailsPage.alertPopUpMsg).should('include.text', 'added to favorites')
cy.get(WishlistPage.favoritesBadge).should('include.text', '1')
})

it('Confirm that a product can be removed from favorites from the products gallery home page', () =>{
cy.get(ProductHomePage.qualityMugFavoriteBtn, {timeout: 1000}).should('exist')
cy.get(ProductHomePage.qualityMugFavoriteBtn).click()
cy.get(ProductHomePage.alertPopUpMsg).should('include.text', 'added to favorites')
cy.get(WishlistPage.favoritesBadge).should('include.text', '1')
cy.get(ProductHomePage.removeFromFavoritesBtn).click()
cy.get(ProductHomePage.alertPopUpMsg).should('include.text', 'removed from favorites')
cy.get(WishlistPage.favoritesBadge).should('include.text', '0')
})

it('Confirm that a product can be removed from favorites from the product details page', () =>{
cy.get(ProductHomePage.hoodedSweatshirt).scrollIntoView().click()
cy.location('pathname', { timeout: 40000 }).should('eq', '/products/quality-sweatshirt-hooded')
cy.get(ProductDetailsPage.productName, { timeout: 10000 }).should('exist')
cy.get(ProductDetailsPage.addToFavoritesBtn, {timeout: 1000}).should('exist')
cy.get(ProductDetailsPage.addToFavoritesBtn).click()
cy.get(ProductDetailsPage.alertPopUpMsg).should('include.text', 'added to favorites')
cy.get(WishlistPage.favoritesBadge).should('include.text', '1')
cy.get(ProductDetailsPage.removeFromFavoritesBtn).click()
cy.get(ProductHomePage.alertPopUpMsg).should('include.text', 'removed from favorites')
cy.get(WishlistPage.favoritesBadge).should('include.text', '0')
})

it('Confirm that navigating to another page does not remove the product from the wishlist', () =>{
cy.get(ProductHomePage.qualityMugFavoriteBtn, {timeout: 1000}).should('exist')
cy.get(ProductHomePage.qualityMugFavoriteBtn).click()
cy.get(WishlistPage.favoritesMenuTab).click()
cy.get(WishlistPage.favoriteProductTitles).should('exist')
cy.get(WishlistPage.favoriteProductTitles).should('include.text', 'Quality Mug')
cy.get(ProductHomePage.closePopUp).click()
cy.get(ProductHomePage.contactTab).click()
cy.get(WishlistPage.favoritesBadge).should('include.text', '1')
cy.get(WishlistPage.favoritesMenuTab).click()
cy.get(WishlistPage.favoriteProductTitles).should('exist')
cy.get(WishlistPage.favoriteProductTitles).should('include.text', 'Quality Mug')
})

})