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..61885d5a 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 } 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,15 +39,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.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 }) }) @@ -55,12 +60,11 @@ export function notifySearch(prefix) { cy.addDelayBetweenRetries(2000) cy.getVtexItems().then(vtex => { - 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) }) }) @@ -86,11 +90,13 @@ export function updateAppSettings(prefix, doShippingSim = false) { version, settings: `{\"doShippingSim\":${doShippingSim},\"notifyMarketplace\":\"productusqaseller\"}`, } + 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, @@ -106,6 +112,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,12 +130,11 @@ export function configureBroadcasterAdapter(prefix, workspace = 'master') { version: '0.x', settings: `{"targetWorkspace":"${workspace}"}`, } + 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, 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()