diff --git a/CHANGELOG.md b/CHANGELOG.md index 42306a6..885fc0c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 diff --git a/cy-runner.yml b/cy-runner.yml index 9a80d13..395acb0 100644 --- a/cy-runner.yml +++ b/cy-runner.yml @@ -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 \ No newline at end of file diff --git a/cypress/integration/2.4-add-product-in-wishlist-with-login.spec.js b/cypress/integration/2.4-add-product-in-wishlist-with-login.spec.js index 7f4d04f..ee22404 100644 --- a/cypress/integration/2.4-add-product-in-wishlist-with-login.spec.js +++ b/cypress/integration/2.4-add-product-in-wishlist-with-login.spec.js @@ -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() diff --git a/cypress/support/api_testcase.js b/cypress/support/api_testcase.js index 79faa5c..e845177 100644 --- a/cypress/support/api_testcase.js +++ b/cypress/support/api_testcase.js @@ -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, @@ -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') @@ -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, '']) diff --git a/cypress/support/commands.js b/cypress/support/commands.js index caab6c6..2765eb0 100644 --- a/cypress/support/commands.js +++ b/cypress/support/commands.js @@ -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') @@ -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') @@ -86,15 +99,22 @@ 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,`) @@ -102,6 +122,10 @@ Cypress.Commands.add('addProductToWishList', (productLink, login = false) => { }) 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') @@ -109,6 +133,9 @@ Cypress.Commands.add('removeProductFromWishlist', productLink => { }) 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() @@ -116,45 +143,56 @@ Cypress.Commands.add('addWishListItem', (searchKey, link) => { .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) { @@ -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() @@ -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') @@ -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() diff --git a/cypress/support/graphql_testcase.js b/cypress/support/graphql_testcase.js index b2d0870..bbb9f67 100644 --- a/cypress/support/graphql_testcase.js +++ b/cypress/support/graphql_testcase.js @@ -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' + @@ -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, 'saravananvenkatesan@bitcot.com') return { query: 'query' + @@ -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: 'saravananvenkatesan@bitcot.com', + productId: '880300', + } + cy.addGraphqlLogs(query, queryVariables) return { query: 'query' + @@ -43,6 +66,14 @@ export function checkList() { } export function listNames() { + const query = + 'query' + '($shopperId: String!)' + '{ listNames(shopperId:$shopperId)}' + const queryVariables = { + shopperId: 'saravananvenkatesan@bitcot.com', + } + + cy.addGraphqlLogs(query, queryVariables) + return { query: 'query' + '($shopperId: String!)' + '{ listNames(shopperId:$shopperId)}', @@ -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, @@ -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: { @@ -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' +