From db401eec1a11ab8a4db1d719c9b6eaa52dc34038 Mon Sep 17 00:00:00 2001 From: suman123 Date: Mon, 27 Feb 2023 17:51:50 +0530 Subject: [PATCH 1/3] added logs for debugging --- CHANGELOG.md | 3 ++ .../2.3-unavailable-product-scenarios.spec.js | 1 + cypress/support/availability-notify.apis.js | 49 ++++++++++++++++++- .../support/availability-notify.graphql.js | 19 +++++++ cypress/support/availability-notify.js | 1 + cypress/support/commands.js | 17 +++++++ 6 files changed, 89 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index f12a49f7..a310b611 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,9 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0. ## [Unreleased] +### Added +- Added logs for debugging + ## [1.11.0] - 2023-01-30 ### Added diff --git a/cypress/integration/2.3-unavailable-product-scenarios.spec.js b/cypress/integration/2.3-unavailable-product-scenarios.spec.js index 5577fd94..aa4e2e3b 100644 --- a/cypress/integration/2.3-unavailable-product-scenarios.spec.js +++ b/cypress/integration/2.3-unavailable-product-scenarios.spec.js @@ -26,6 +26,7 @@ describe('Updating product as unavailable', () => { updateRetry(3), () => { cy.subscribeToProduct({ email, name }) + cy.qe(`Verify email existance ${MESSAGES.EmailAlreadyExist}`) cy.get(availabilityNotifySelectors.AvailabilityNotifyAlert).should( 'have.text', MESSAGES.EmailAlreadyExist diff --git a/cypress/support/availability-notify.apis.js b/cypress/support/availability-notify.apis.js index 497af80e..e3c5a953 100644 --- a/cypress/support/availability-notify.apis.js +++ b/cypress/support/availability-notify.apis.js @@ -1,6 +1,6 @@ /* eslint-disable */ import { updateProductStatusAPI, getProcessAllRequestAPI } from './product.api' -import { VTEX_AUTH_HEADER, FAIL_ON_STATUS_CODE } from './common/constants' +import { VTEX_AUTH_HEADER, FAIL_ON_STATUS_CODE,FAIL_ON_STATUS_CODE_STRING} from './common/constants' import { updateRetry } from './common/support' const config = Cypress.env() @@ -35,8 +35,16 @@ export function updateProductStatus({ unlimited = false, }) { it(`${prefix} - Update the product status`, updateRetry(3), () => { + cy.qe( `Updating the product status`) cy.addDelayBetweenRetries(2000) cy.getVtexItems().then(vtex => { + cy.qe(`cy.request({ + method: 'PUT', + url: https://productusqa.vtexcommercestable.com.br/api/logistics/pvt/inventory/skus/${skuId}/warehouses/${warehouseId}, + ${`headers: ${VTEX_AUTH_HEADER(vtex.apiKey, vtex.apiToken)}`}, + ${FAIL_ON_STATUS_CODE_STRING}, + body: { unlimitedQuantity: unlimited, quantity: 0 }, + })`) cy.request({ method: 'PUT', url: updateProductStatusAPI(warehouseId, skuId), @@ -55,6 +63,13 @@ export function notifySearch(prefix) { cy.addDelayBetweenRetries(2000) cy.getVtexItems().then(vtex => { + + cy.qe(`cy.request({ + method: 'GET', + url: https://${vtex.account}.myvtex.com/api/dataentities/notify/search?_schema=reviewsSchema&_fields=email,skuId,name,createdAt, + ${`headers: ${VTEX_AUTH_HEADER(vtex.apiKey, vtex.apiToken)}`}, + ${FAIL_ON_STATUS_CODE_STRING}, + })`) cy.request({ method: 'GET', url: `https://${vtex.account}.myvtex.com/api/dataentities/notify/search?_schema=reviewsSchema&_fields=email,skuId,name,createdAt`, @@ -76,16 +91,34 @@ export function updateAppSettings(prefix, doShippingSim = false) { const APP = `${APP_NAME}@${APP_VERSION}` const CUSTOM_URL = `${vtex.baseUrl}/_v/private/admin-graphql-ide/v0/${APP}` + cy.qe('Configuting app settings') + + const GRAPHQL_MUTATION = 'mutation' + '($app:String,$version:String,$settings:String)' + '{saveAppSettings(app:$app,version:$version,settings:$settings){message}}' + + const QUERY_VARIABLES = { app, version, settings: `{\"doShippingSim\":${doShippingSim},\"notifyMarketplace\":\"productusqaseller\"}`, } + cy.addGraphqlLogs({query :GRAPHQL_MUTATION , QUERY_VARIABLES}) + + cy.qe(`cy.request({ + method:'POST', + url:${CUSTOM_URL}, + ${FAIL_ON_STATUS_CODE_STRING}, + body:{ + query: ${GRAPHQL_MUTATION}, + variables: ${QUERY_VARIABLES} + } + })`) + + // Mutating it to the new workspace cy.request({ method: 'POST', @@ -106,6 +139,7 @@ export function configureBroadcasterAdapter(prefix, workspace = 'master') { `${prefix} - Register target workspace as ${workspace} in ${BROADCASTER_APP}`, updateRetry(2), () => { + cy.qe(`Register target workspace as ${workspace} in ${BROADCASTER_APP}`) cy.getVtexItems().then(vtex => { // Define constants const APP_NAME = 'vtex.apps-graphql' @@ -123,6 +157,19 @@ export function configureBroadcasterAdapter(prefix, workspace = 'master') { version: '0.x', settings: `{"targetWorkspace":"${workspace}"}`, } + cy.addGraphqlLogs({query :GRAPHQL_MUTATION , QUERY_VARIABLES}) + + + cy.qe(`cy.request({ + method:'POST', + url:${CUSTOM_URL}, + ${FAIL_ON_STATUS_CODE_STRING}, + body:{ + query: ${GRAPHQL_MUTATION}, + variables: ${QUERY_VARIABLES} + } + })`) + // Mutating it to the new workspace cy.request({ diff --git a/cypress/support/availability-notify.graphql.js b/cypress/support/availability-notify.graphql.js index 830ac26e..6e79529a 100644 --- a/cypress/support/availability-notify.graphql.js +++ b/cypress/support/availability-notify.graphql.js @@ -1,4 +1,9 @@ export function version() { + cy.qe(`Get version via graphql`) + const query = 'query' + '{version}' + + cy.addGraphqlLogs(query) + return { query: 'query' + '{version}', queryVariables: {}, @@ -8,6 +13,8 @@ export function version() { export function deleteRequest(deleteId) { const query = 'mutation' + '($id: String)' + '{deleteRequest(id: $id)}' + cy.addGraphqlLogs(query, deleteId) + return { query, queryVariables: { @@ -17,6 +24,12 @@ export function deleteRequest(deleteId) { } export function listRequests() { + const query = + 'query' + + '{listRequests{id,name,email,skuId, notificationSent, notificationSentAt}}' + + cy.addGraphqlLogs(query) + return { query: 'query' + @@ -27,6 +40,10 @@ export function listRequests() { } export function processUnsentRequest() { + const query = 'mutation' + '{processUnsentRequests{email,skuId,sent}}' + + cy.addGraphqlLogs(query) + return { query: 'mutation' + '{processUnsentRequests{email,skuId,sent}}', queryVariables: {}, @@ -49,6 +66,8 @@ export function availabilitySubscribe(availabilityData) { '($name: String, $email: String, $skuId: String, $sellerObj: SellerObjInputType!)' + '{availabilitySubscribe(name: $name, email: $email, skuId: $skuId, sellerObj: $sellerObj)}' + cy.addGraphqlLogs(query, data) + return { query, queryVariables: data, diff --git a/cypress/support/availability-notify.js b/cypress/support/availability-notify.js index dba8a0ac..0af4bf7c 100644 --- a/cypress/support/availability-notify.js +++ b/cypress/support/availability-notify.js @@ -11,6 +11,7 @@ import { AVAILABILITY_NOTIFY_APP } from './graphql_apps' export function verifyEmail(prefix) { it(`${prefix} - Verifying email`, updateRetry(5), () => { + cy.qe('Verifying email') cy.addDelayBetweenRetries(30000) cy.getEmailItems().then(e => { graphql(AVAILABILITY_NOTIFY_APP, listRequests(), response => { diff --git a/cypress/support/commands.js b/cypress/support/commands.js index d003fd95..ef74dbc5 100644 --- a/cypress/support/commands.js +++ b/cypress/support/commands.js @@ -14,20 +14,29 @@ Cypress.Commands.add('gotoProductDetailPage', () => { }) Cypress.Commands.add('openStoreFront', (login = false) => { + cy.qe(`Adding intercept for events API before visiting the hompage`) cy.intercept('**/rc.vtex.com.br/api/events').as('events') cy.visit('/') if (login === true) { + cy.qe( + 'Verifying Profile label should be visible in the homepage and it should contain Hello' + ) cy.get(selectors.ProfileLabel, { timeout: 20000 }) .should('be.visible') .should('have.contain', `Hello,`) } + cy.qe(`Waiting for the events API to be complted`) cy.wait('@events') }) Cypress.Commands.add('openProduct', (product, detailPage = false) => { // Search product in search bar + cy.qe( + `Verifying that search bar shouldn't be disabled and it should be visible` + ) cy.get(selectors.Search).should('be.not.disabled').should('be.visible') + cy.qe(`Searching the ${product} in search bar`) cy.get(selectors.Search) .should('be.visible') @@ -35,7 +44,9 @@ Cypress.Commands.add('openProduct', (product, detailPage = false) => { .type(product) .type('{enter}') // Page should load successfully now Filter should be visible + cy.qe(`Search result should have the text ${product.toLowerCase()}`) cy.get(selectors.searchResult).should('have.text', product.toLowerCase()) + cy.qe(`Verifying that FilterHeading should be visible before the timeout`) cy.get(selectors.FilterHeading, { timeout: 30000 }).should('be.visible') if (detailPage) { @@ -67,9 +78,15 @@ Cypress.Commands.add('getEmailItems', () => { }) Cypress.Commands.add('subscribeToProduct', data => { + cy.qe('Saving email') cy.saveEmailId(data.email) + cy.qe('Entering the name') cy.get(availabilityNotifySelectors.name).type(data.name) + cy.qe('Entering the email') cy.get(availabilityNotifySelectors.email).type(data.email) + cy.qe( + `Verifying submit button should not be disabled and clicking on the submit button` + ) cy.get(availabilityNotifySelectors.AvailabilityNotifySubmitButton) .should('not.be.disabled') .click() From d7674bd532c98b51784270d692aebd7993bb5c4d Mon Sep 17 00:00:00 2001 From: suman123 Date: Fri, 3 Mar 2023 12:52:46 +0530 Subject: [PATCH 2/3] Updated RestAPI logs --- cypress/support/availability-notify.apis.js | 78 ++++++--------------- 1 file changed, 20 insertions(+), 58 deletions(-) diff --git a/cypress/support/availability-notify.apis.js b/cypress/support/availability-notify.apis.js index e3c5a953..9f17bea4 100644 --- a/cypress/support/availability-notify.apis.js +++ b/cypress/support/availability-notify.apis.js @@ -1,6 +1,10 @@ /* eslint-disable */ import { updateProductStatusAPI, getProcessAllRequestAPI } from './product.api' -import { VTEX_AUTH_HEADER, FAIL_ON_STATUS_CODE,FAIL_ON_STATUS_CODE_STRING} from './common/constants' +import { + VTEX_AUTH_HEADER, + FAIL_ON_STATUS_CODE, + FAIL_ON_STATUS_CODE_STRING, +} from './common/constants' import { updateRetry } from './common/support' const config = Cypress.env() @@ -35,23 +39,16 @@ export function updateProductStatus({ unlimited = false, }) { it(`${prefix} - Update the product status`, updateRetry(3), () => { - cy.qe( `Updating the product status`) + cy.qe(`Updating the product status`) cy.addDelayBetweenRetries(2000) cy.getVtexItems().then(vtex => { - cy.qe(`cy.request({ - method: 'PUT', - url: https://productusqa.vtexcommercestable.com.br/api/logistics/pvt/inventory/skus/${skuId}/warehouses/${warehouseId}, - ${`headers: ${VTEX_AUTH_HEADER(vtex.apiKey, vtex.apiToken)}`}, - ${FAIL_ON_STATUS_CODE_STRING}, - body: { unlimitedQuantity: unlimited, quantity: 0 }, - })`) - cy.request({ + cy.addLogsForRestAPI({ method: 'PUT', url: updateProductStatusAPI(warehouseId, skuId), headers: VTEX_AUTH_HEADER(vtex.apiKey, vtex.apiToken), - ...FAIL_ON_STATUS_CODE, body: { unlimitedQuantity: unlimited, quantity: 0 }, }).then(response => { + cy.qe('Verifying response.body to be true') expect(response.body).to.be.true }) }) @@ -63,19 +60,11 @@ export function notifySearch(prefix) { cy.addDelayBetweenRetries(2000) cy.getVtexItems().then(vtex => { - - cy.qe(`cy.request({ - method: 'GET', - url: https://${vtex.account}.myvtex.com/api/dataentities/notify/search?_schema=reviewsSchema&_fields=email,skuId,name,createdAt, - ${`headers: ${VTEX_AUTH_HEADER(vtex.apiKey, vtex.apiToken)}`}, - ${FAIL_ON_STATUS_CODE_STRING}, - })`) - cy.request({ - method: 'GET', - url: `https://${vtex.account}.myvtex.com/api/dataentities/notify/search?_schema=reviewsSchema&_fields=email,skuId,name,createdAt`, - headers: VTEX_AUTH_HEADER(vtex.apiKey, vtex.apiToken), - ...FAIL_ON_STATUS_CODE, - }).then(response => { + cy.getAPI( + `https://${vtex.account}.myvtex.com/api/dataentities/notify/search?_schema=reviewsSchema&_fields=email,skuId,name,createdAt`, + VTEX_AUTH_HEADER(vtex.apiKey, vtex.apiToken) + ).then(response => { + cy.qe(`Verifying the status to be ${response.status} `) expect(response.status).to.equal(200) }) }) @@ -93,42 +82,29 @@ export function updateAppSettings(prefix, doShippingSim = false) { cy.qe('Configuting app settings') - const GRAPHQL_MUTATION = 'mutation' + '($app:String,$version:String,$settings:String)' + '{saveAppSettings(app:$app,version:$version,settings:$settings){message}}' - - const QUERY_VARIABLES = { app, version, settings: `{\"doShippingSim\":${doShippingSim},\"notifyMarketplace\":\"productusqaseller\"}`, } - cy.addGraphqlLogs({query :GRAPHQL_MUTATION , QUERY_VARIABLES}) - - cy.qe(`cy.request({ - method:'POST', - url:${CUSTOM_URL}, - ${FAIL_ON_STATUS_CODE_STRING}, - body:{ - query: ${GRAPHQL_MUTATION}, - variables: ${QUERY_VARIABLES} - } - })`) - + cy.addGraphqlLogs({ query: GRAPHQL_MUTATION, QUERY_VARIABLES }) // Mutating it to the new workspace - cy.request({ + + cy.addLogsForRestAPI({ method: 'POST', url: CUSTOM_URL, - ...FAIL_ON_STATUS_CODE, body: { query: GRAPHQL_MUTATION, variables: QUERY_VARIABLES, }, - }).its('body.data.saveAppSettings.message', { timeout: 10000 }) + }) + .its('body.data.saveAppSettings.message', { timeout: 10000 }) }) }) } @@ -157,25 +133,11 @@ export function configureBroadcasterAdapter(prefix, workspace = 'master') { version: '0.x', settings: `{"targetWorkspace":"${workspace}"}`, } - cy.addGraphqlLogs({query :GRAPHQL_MUTATION , QUERY_VARIABLES}) - - - cy.qe(`cy.request({ - method:'POST', - url:${CUSTOM_URL}, - ${FAIL_ON_STATUS_CODE_STRING}, - body:{ - query: ${GRAPHQL_MUTATION}, - variables: ${QUERY_VARIABLES} - } - })`) - + cy.addGraphqlLogs({ query: GRAPHQL_MUTATION, QUERY_VARIABLES }) - // Mutating it to the new workspace - cy.request({ + cy.addLogsForRestAPI({ method: 'POST', url: CUSTOM_URL, - ...FAIL_ON_STATUS_CODE, body: { query: GRAPHQL_MUTATION, variables: QUERY_VARIABLES, From 584e8ae29f315b090d946ca93d1b830ac39e4f8c Mon Sep 17 00:00:00 2001 From: suman123 Date: Fri, 3 Mar 2023 13:30:27 +0530 Subject: [PATCH 3/3] removed unwanted qe logs --- cypress/support/availability-notify.apis.js | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/cypress/support/availability-notify.apis.js b/cypress/support/availability-notify.apis.js index 9f17bea4..61885d5a 100644 --- a/cypress/support/availability-notify.apis.js +++ b/cypress/support/availability-notify.apis.js @@ -80,8 +80,6 @@ export function updateAppSettings(prefix, doShippingSim = false) { const APP = `${APP_NAME}@${APP_VERSION}` const CUSTOM_URL = `${vtex.baseUrl}/_v/private/admin-graphql-ide/v0/${APP}` - cy.qe('Configuting app settings') - const GRAPHQL_MUTATION = 'mutation' + '($app:String,$version:String,$settings:String)' + @@ -103,8 +101,7 @@ export function updateAppSettings(prefix, doShippingSim = false) { query: GRAPHQL_MUTATION, variables: QUERY_VARIABLES, }, - }) - .its('body.data.saveAppSettings.message', { timeout: 10000 }) + }).its('body.data.saveAppSettings.message', { timeout: 10000 }) }) }) }