Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Wishlist logs #158

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
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
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.

## [Unreleased]

### Added

- Added logs for debugging purpose
## [1.15.8] - 2023-02-27

### Fixed
Expand Down
2 changes: 1 addition & 1 deletion cy-runner.yml
Original file line number Diff line number Diff line change
Expand Up @@ -107,4 +107,4 @@ strategy:
dependency:
- cypress/integration/2.3-add-product-in-wishlist-without-login.spec.js
- cypress/integration/2.4-add-product-in-wishlist-with-login.spec.js
- cypress/integration/2.5-orderProduct-from-wishlist.spec.js
- cypress/integration/2.5-orderProduct-from-wishlist.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,18 +64,25 @@ describe(`${prefix} - Testing wishlist with logged in user`, () => {

it(`${prefix} - Re add the product onion to wishlist`, updateRetry(1), () => {
const searchKey = wishlistProducts.onion.name
cy.qe(`Verifying the searchbar should be visible and searching the product`)
cy.get(selectors.Search)
.should('be.visible')
.type(searchKey)
.type('{enter}')
// Page should load successfully now searchResult & Filter should be visible
cy.qe(
`Verifying the searchbar should have text ${searchKey.toLocaleLowerCase()}`
)
cy.get(selectors.searchResult).should('have.text', searchKey.toLowerCase())
cy.qe(`Verifying the filter heading should be visible`)
cy.get(selectors.FilterHeading).should('be.visible')

cy.qe(
`Verifying the ${wishlistProducts.onion.link} should be visible and clicking on it`
)
cy.get(wishlistProducts.onion.link)
.should('be.visible')
.click()

cy.qe(`Clicking on wishlist icon of the product`)
cy.get(wishListSelectors.WishListIcon)
.should('be.visible')
.click()
Expand Down
9 changes: 3 additions & 6 deletions cypress/support/api_testcase.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { VTEX_AUTH_HEADER, FAIL_ON_STATUS_CODE } from './common/constants'
import { VTEX_AUTH_HEADER } from './common/constants'
import { updateRetry } from './common/support'
import {
wishlistSchemaAPI,
Expand Down Expand Up @@ -65,15 +65,13 @@ export function updateMasterdata(shopperId, newShopperId) {
data.email = newShopperId

cy.getVtexItems().then(vtex => {
cy.request({
cy.addLogsForRestAPI({
method: 'PATCH',
url: updateWishlistAPI(vtex.baseUrl),

headers: {
...VTEX_AUTH_HEADER(vtex.apiKey, vtex.apiToken),
},
body: data,
...FAIL_ON_STATUS_CODE,
}).then(response => {
expect(response.status).to.have.equal(200)
expect(response.body).to.have.property('DocumentId')
Expand All @@ -94,13 +92,12 @@ export function deleteWishlistdata(env) {
const arr = wishListId[env]

for (const { id } of arr) {
cy.request({
cy.addLogsForRestAPI({
method: 'DELETE',
url: deleteWishlistAPI(vtex.baseUrl, id),
headers: {
...VTEX_AUTH_HEADER(vtex.apiKey, vtex.apiToken),
},
...FAIL_ON_STATUS_CODE,
}).then(response => {
expect(response.status).to.equal(204)
expect(response.body).to.have.oneOf([null, ''])
Expand Down
59 changes: 57 additions & 2 deletions cypress/support/commands.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ function clickWishListIcon(productLink = '', login = '') {
const addWishListOperation = 'AddToList'

cy.getVtexItems().then(vtex => {
cy.qe(`Verifying the wishlistcontainer should be visible`)
cy.get(wishListSelectors.WishListContainer).should('be.visible')
if (productLink) {
cy.get(productLink).should('be.visible')
Expand All @@ -57,19 +58,31 @@ function clickWishListIcon(productLink = '', login = '') {
cy.get('body').then($body => {
if ($body.find(wishListOutLineSelector).length) {
interceptByOperationName(vtex, addWishListOperation)
cy.qe(
`Verifying wishlistIcon sholud be visible and enabled then clicking on it`
)
cy.get(wishListIconSelector, { timeout: 15000 })
.should('be.visible')
.should('be.enabled')
.click({ force: true })
if (!login) {
cy.qe(
`Verifying ToastMsgInB2B should contain ${MESSAGES.AddedToWishList} before timeout`
)
cy.get(selectors.ToastMsgInB2B, { timeout: 10000 })
.contains(MESSAGES.AddedToWishList)
.should('be.visible')
cy.qe(
`Verify wishlistFillSelector should be visible before the timeout`
)
cy.get(wishListFillSelector, { timeout: 10000 }).should('be.visible')
cy.wait(`@${addWishListOperation}`, { timeout: 20000 }).then(req => {
expect(req.response.statusCode).to.equal(200)
})
} else {
cy.qe(
`Verifying ToastMsgInB2B should contain ${MESSAGES.AddedToWishList} before timeout`
)
cy.get(selectors.ToastMsgInB2B, { timeout: 10000 })
.contains(MESSAGES.NotLoggedInUser)
.should('be.visible')
Expand All @@ -86,75 +99,100 @@ Cypress.Commands.add('addProductToWishList', (productLink, login = false) => {
clickWishListIcon(productLink, login)
// eslint-disable-next-line vtex/prefer-early-return
if (login) {
cy.qe(
`Verifying ToastMsgInB2B should contain ${MESSAGES.AddedToWishList} before timeout`
)
cy.get(selectors.ToastMsgInB2B, { timeout: 15000 }).contains(
MESSAGES.NotLoggedInUser
)
cy.qe(`Verifying the toast button should be visible and clicking on it`)
cy.get(wishListSelectors.ToastButton)
.should('be.visible')
.click()
cy.getVtexItems().then(vtex => {
cy.loginStoreFrontAsUser(vtex.robotMail, vtex.robotPassword)
})
cy.qe(
`Verifying profile lable should be visible and it should contain Hello`
)
cy.get(selectors.ProfileLabel)
.should('be.visible')
.should('have.contain', `Hello,`)
}
})

Cypress.Commands.add('removeProductFromWishlist', productLink => {
cy.qe(`Verifying wishlist product summary container should be visible`)
cy.qe(
`Clicking on wishlist icon to remove the product from the product summary container`
)
cy.get(wishListSelectors.ProductSummaryContainer).should('be.visible')
cy.get(`${productLink} ${wishListSelectors.WishListIcon}`)
.should('be.visible')
.click()
})

Cypress.Commands.add('addWishListItem', (searchKey, link) => {
cy.qe(
`Verifying the search bar should be visible and searching the product - ${searchKey}`
)
cy.get(selectors.Search)
.should('be.visible')
.clear()
.type(searchKey)
.type('{enter}')

// Page should load successfully now searchResult & Filter should be visible
cy.qe(
`Verifying the search result should have text in the lowercase ${searchKey.toLowerCase()}`
)
cy.get(selectors.searchResult).should('have.text', searchKey.toLowerCase())
cy.qe(`Verifying filter heading should be visible`)
cy.get(selectors.FilterHeading).should('be.visible')

cy.get(link)
.should('be.visible')
.click()

cy.qe('Verifying the thumpnailswiper should be visible')
cy.get(wishListSelectors.ThumbnailSwiper).should('be.visible')

clickWishListIcon()
})

Cypress.Commands.add('addProductFromProductSpecification', productLink => {
cy.qe(`Verifying ${productLink} should be visible then clicking on it`)
cy.get(productLink)
.should('be.visible')
.click()
cy.qe(`Verifying the wishlist icon should be visible and clicking on it`)
cy.get(wishListSelectors.WishListIcon)
.should('be.visible')
.click()
})

Cypress.Commands.add('loginStoreFrontAsUser', (email, password) => {
cy.qe(`Login as a loginStoreFrontAsUser`)
cy.qe(`Entering the email`)
cy.get(wishListSelectors.LoginEmail)
.should('be.visible')
.clear()
.type(email, { log: false })
cy.qe(`Entering the password`)
cy.get(wishListSelectors.LoginPassword)
.should('be.visible')
.clear()
.type(password, { log: false })

cy.qe(`Clicking on login button`)
cy.get(wishListSelectors.LoginButton).click()
})

Cypress.Commands.add('verifyExcelFile', (fileName, fixtureFile, products) => {
cy.qe(`Verifying the data of the XLS file by using readXLSX`)
cy.task('readXlsx', {
file: fileName,
sheet: 'Sheet1',
}).then(rows => {
cy.qe(`Writing the data in cypress/fixtures/${fixtureFile} `)
cy.writeFile(`cypress/fixtures/${fixtureFile}`, rows)
})
for (const product of products) {
Expand All @@ -170,14 +208,21 @@ Cypress.Commands.add('verifyExcelFile', (fileName, fixtureFile, products) => {
})

Cypress.Commands.add('verifyWishlistProduct', productLink => {
cy.qe(
`Verifying Profile lable should be visible and it should contain 'Hello'`
)
cy.get(selectors.ProfileLabel)
.should('be.visible')
.should('have.contain', `Hello,`)

scroll()
cy.qe(
`Verifying ToastMsgInB2B should contain ${MESSAGES.AddedToWishList} before timeout`
)
cy.get(selectors.ToastMsgInB2B, { timeout: 60000 }).contains(
MESSAGES.AddedToWishList
)
cy.qe(`Verifying the Toast button should be visible and clicking on it`)
cy.get(wishListSelectors.ToastButton)
.should('be.visible')
.click()
Expand All @@ -192,12 +237,14 @@ Cypress.Commands.add('verifyWishlistProduct', productLink => {
)
cy.wait('@ViewList', { timeout: 40000 })
})
cy.qe(`Verifying the products in wishlist container`)
cy.get(
`${wishListSelectors.ProductSummaryContainer} > ${productLink}`
).should('exist')
})

Cypress.Commands.add('verifyProductInWishList', productLink => {
cy.qe(`Verifying the products in wishlist container`)
cy.get(`${wishListSelectors.ProductSummaryContainer} > ${productLink}`, {
timeout: 40000,
}).should('exist')
Expand All @@ -219,16 +266,24 @@ Cypress.Commands.add('getWishListItem', () => {
})

Cypress.Commands.add('visitWishlistPage', () => {
cy.qe(`Verifying wishlistmenu should be visble and clicking on it`)
cy.get(wishListSelectors.WishListMenu)
.should('be.visible')
.click()
cy.qe(`Verifying ProductSummaryContainer should be visible`)
cy.get(wishListSelectors.ProductSummaryContainer).should('be.visible')
})

Cypress.Commands.add('gotoMyAccountWishListPage', () => {
cy.qe(`Verifying the profile label should be visible`)
cy.get(selectors.ProfileLabel).should('be.visible')
cy.qe(`Clicking on SignIn button`)
cy.get(selectors.SignInBtn).click()
cy.qe('Clicking on myAccount')
cy.get(selectors.MyAccount, { timeout: 5000 }).click()
cy.qe(
`Verifying the wishlistAccountPage should be visible and clicking on it`
)
cy.get(wishListSelectors.WishListAccountPage)
.should('be.visible')
.click()
Expand Down
39 changes: 39 additions & 0 deletions cypress/support/graphql_testcase.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,19 @@
export function version() {
const query = 'query' + '{version}'
cy.addGraphqlLogs(query)

return {
query: 'query' + '{version}',
queryVariables: {},
}
}
export function viewList({ shopperId, name }) {
const query =
'query' +
'($shopperId: String!,$name: String!)' +
'{ viewList(shopperId:$shopperId,name:$name) {public,name,range {total,from,to},data {id,productId,sku,title}}}'

cy.addGraphqlLogs(query, { shopperId, name })
return {
query:
'query' +
Expand All @@ -18,6 +27,11 @@ export function viewList({ shopperId, name }) {
}

export function viewLists() {
const query =
'query' +
'($shopperId: String!)' +
'{ viewLists(shopperId:$shopperId) {public,name,range {total,from,to},data {id,productId,sku,title}}}'
cy.addGraphqlLogs(query, '[email protected]')
return {
query:
'query' +
Expand All @@ -30,6 +44,15 @@ export function viewLists() {
}

export function checkList() {
const query =
'query' +
'($shopperId: String!,$productId:String!)' +
'{ checkList(shopperId:$shopperId,productId:$productId) {inList,listNames,listIds,message}}'
const queryVariables = {
shopperId: '[email protected]',
productId: '880300',
}
cy.addGraphqlLogs(query, queryVariables)
return {
query:
'query' +
Expand All @@ -43,6 +66,14 @@ export function checkList() {
}

export function listNames() {
const query =
'query' + '($shopperId: String!)' + '{ listNames(shopperId:$shopperId)}'
const queryVariables = {
shopperId: '[email protected]',
}

cy.addGraphqlLogs(query, queryVariables)

return {
query:
'query' + '($shopperId: String!)' + '{ listNames(shopperId:$shopperId)}',
Expand All @@ -58,6 +89,7 @@ export function addToList(productId) {
'($shopperId: String!, $listItem: ListItemInputType!, $name: String!)' +
'{addToList(shopperId: $shopperId, listItem: $listItem, name: $name)}'

cy.addGraphqlLogs(query, productId)
return {
query,
queryVariables: productId,
Expand All @@ -70,6 +102,8 @@ export function removeFromList(productId, { shopperId, name }) {
'($shopperId: String!,$id: ID!,$name: String)' +
'{removeFromList(shopperId: $shopperId,id: $id,name: $name)}'

cy.addGraphqlLogs(query, productId)

return {
query,
queryVariables: {
Expand All @@ -81,6 +115,11 @@ export function removeFromList(productId, { shopperId, name }) {
}

export function exportList(email) {
const query =
'query' +
'{ exportList{email,listItemsWrapper{listItems{id,productId,sku,title},isPublic}}}'

cy.addGraphqlLogs(query, email)
return {
query:
'query' +
Expand Down