From 98fcd0ab57afeac704c5dec27863fcb9b93cd6d5 Mon Sep 17 00:00:00 2001 From: suman123 Date: Tue, 14 Feb 2023 22:19:31 +0530 Subject: [PATCH 1/4] checkout Ui custom logs --- .../2.3-lineitems_required.spec.js | 2 + .../2.4-lineitems_optional.spec.js | 3 ++ .../2.5-checkout_scenarios.spec.js | 8 +++- cypress/integration/wipe.spec.js | 12 ++++++ cypress/support/commands.js | 7 +++ cypress/support/grapqhl_testcase.js | 43 ++++++++++++++++++- cypress/support/testcase.js | 7 +++ 7 files changed, 80 insertions(+), 2 deletions(-) diff --git a/cypress/integration/2.3-lineitems_required.spec.js b/cypress/integration/2.3-lineitems_required.spec.js index d2a34d5c..ff117992 100644 --- a/cypress/integration/2.3-lineitems_required.spec.js +++ b/cypress/integration/2.3-lineitems_required.spec.js @@ -29,6 +29,7 @@ describe(`Testing line items(required) with this product - ${product}`, () => { `${prefix} - Verify line items displayed in checkout ui`, updateRetry(3), () => { + cy.qe(`LineItems should exists in the dom`) cy.get(checkoutUiCustomSelectors.LineItemAssemble).should('exist') cy.removeProduct(lineitemProducts.jumper.id) cy.get(checkoutUiCustomSelectors.ChooseProducts) @@ -48,6 +49,7 @@ describe(`Testing line items(required) with this product - ${product}`, () => { ) cy.get(selectors.AddtoCart).should('be.visible').click() cy.checkoutProduct() + cy.qe(`LineItems should exists in the dom`) cy.get(checkoutUiCustomSelectors.LineItemAssemble).should('exist') } ) diff --git a/cypress/integration/2.4-lineitems_optional.spec.js b/cypress/integration/2.4-lineitems_optional.spec.js index cb05b6b6..82890c52 100644 --- a/cypress/integration/2.4-lineitems_optional.spec.js +++ b/cypress/integration/2.4-lineitems_optional.spec.js @@ -40,13 +40,16 @@ describe(`Testing line items(optional) with this product - ${product}`, () => { checkoutUiCustomConstants.lineItems, checkoutUiCustomConstants.maxCharecters.max25 ) + cy.qe('Entering the postal code') cy.get(selectors.PostalCode).clear().type('33180').type('{enter}') cy.get(selectors.ProductsQAShipping).click() + cy.qe(`Clicking on AddtoCart button`) cy.get(selectors.AddtoCart).click() }) it(`${prefix} - Verify line items displaying`, () => { cy.checkoutProduct() + cy.qe(`LineItems should exists in the dom`) cy.get(checkoutUiCustomSelectors.LineItemAssemble).should('exist') }) diff --git a/cypress/integration/2.5-checkout_scenarios.spec.js b/cypress/integration/2.5-checkout_scenarios.spec.js index d91f73bd..87ede2c1 100644 --- a/cypress/integration/2.5-checkout_scenarios.spec.js +++ b/cypress/integration/2.5-checkout_scenarios.spec.js @@ -11,6 +11,7 @@ function discountValidation(quantity = 1) { const productPrice = 10 * quantity // Discounts should be shown + cy.qe('Discount should exists in the dom') cy.get(selectors.Discounts).should('be.exist') cy.get(checkoutUiCustomSelectors.DiscountAmount) .first() @@ -65,15 +66,20 @@ describe('Testing Checkout with different scenarios', () => { `${prefix} - vat number should be visible & test input field`, updateRetry(3), () => { - // VAT number field should be visibel to the user + // VAT number field should be visible to the user + cy.qe(`Verifying VatInput should be visible`) cy.get(selectors.VatInput).should('be.visible') // Providing VAT number + cy.qe(`Entering the VatInput - FR40303265045`) cy.get(selectors.VatInput).type('FR40303265045') + cy.qe(`Submitting Vat`) cy.get(selectors.SubmitVat).click() // Tax should not exist + cy.qe(`Verifying VatRemoveButton is visible and clicking on it`) cy.get(checkoutUiCustomSelectors.VatRemoveButton) .should('be.visible') .click() + cy.qe(`Verifying VatInput should be empty`) cy.get(selectors.VatInput).should('be.empty') } ) diff --git a/cypress/integration/wipe.spec.js b/cypress/integration/wipe.spec.js index 300d61ee..c2e7a17d 100644 --- a/cypress/integration/wipe.spec.js +++ b/cypress/integration/wipe.spec.js @@ -15,6 +15,18 @@ describe('Wipe', () => { it('Deleting checkout history', () => { cy.getVtexItems().then(vtex => { + cy.qe(` + + curl --location --request GET 'https://productusqa.vtexcommercestable.com.br/api/dataentities/checkoutcustom/search' \ + qs: { + _fields: 'workspace,email,id', + _schema: 'v0.1.3', + workspace: ${name}, + }, +--header 'X-VTEX-API-AppKey: AppKey' \ +--header 'X-VTEX-API-AppToken: AppToken' \ +--header 'Cookie: Cookie' + `) cy.request({ url: `https://productusqa.vtexcommercestable.com.br/api/dataentities/checkoutcustom/search`, qs: { diff --git a/cypress/support/commands.js b/cypress/support/commands.js index 9012f0ad..b6eb1c6e 100644 --- a/cypress/support/commands.js +++ b/cypress/support/commands.js @@ -55,14 +55,21 @@ Cypress.Commands.add('openProduct', (product, detailPage = false) => { Cypress.Commands.add('removeProduct', product => { cy.get(selectors.CartTimeline, { timeout: 30000 }).should('be.visible') + cy.qe( + `Verifying a[id=item-remove-${product}] is visible and then clicking on it ` + ) cy.get(`a[id=item-remove-${product}]`).should('be.visible').click() + cy.qe(`It should show Your cart is empty`) cy.contains('Your cart is empty') }) Cypress.Commands.add('checkoutProduct', () => { + cy.qe(`Verifying the total price in the minicart`) cy.get(selectors.TotalPrice).should('be.visible') cy.get('#items-price div[class*=price]').should('have.contain', '$') + cy.qe(`Verifying ProceedtoCheckout button is visible and clicking on it`) cy.get(selectors.ProceedtoCheckout).should('be.visible').click() + cy.qe('Verifying CartTimeline is visible') cy.get(selectors.CartTimeline, { timeout: 30000 }) .should('be.visible') .click({ force: true }) diff --git a/cypress/support/grapqhl_testcase.js b/cypress/support/grapqhl_testcase.js index 74566be8..5e0c9f68 100644 --- a/cypress/support/grapqhl_testcase.js +++ b/cypress/support/grapqhl_testcase.js @@ -5,6 +5,12 @@ import { graphql } from './common/graphql_utils' const APP = 'vtex.checkout-ui-custom@*.x' export function getLast(workspace) { + cy.qe(` + getLast query - + 'query' + + '($workspace: String!)' + + '{getLast(workspace: $workspace){id email workspace layout javascript css javascriptActive cssActive colors}}' + `) const query = 'query' + '($workspace: String!)' + @@ -21,6 +27,12 @@ export function validateGetLastResponse(response) { } export function saveChanges(configuration) { + cy.qe(` + save changes mutation - + 'mutation' + + '($email: String, $workspace: String, $layout: CustomFields, $javascript: String, $css: String, $javascriptActive: Boolean, $cssActive: Boolean, $colors: CustomFields)' + + '{saveChanges(email: $email, workspace: $workspace, layout: $layout, javascript: $javascript, css: $css, javascriptActive: $javascriptActive, cssActive: $cssActive, colors: $colors) @context(provider: "vtex.checkout-ui-custom@*.x")}' + `) const query = 'mutation' + '($email: String, $workspace: String, $layout: CustomFields, $javascript: String, $css: String, $javascriptActive: Boolean, $cssActive: Boolean, $colors: CustomFields)' + @@ -37,6 +49,13 @@ export function validateSaveChangesResponse(response) { } export function getHistory() { + cy.qe(` + getHistory query - + query: + 'query' + '{getHistory {id,email,workspace,creationDate,appVersion}}', + queryVariables: {}, + `) + return { query: 'query' + '{getHistory {id,email,workspace,creationDate,appVersion}}', @@ -51,6 +70,12 @@ export function validateGetHistoryResponse(response) { } export function version() { + cy.qe(` +version query - +query: 'query' + '{version}', +queryVariables: {}, +`) + return { query: 'query' + '{version}', queryVariables: {}, @@ -62,6 +87,12 @@ export function validateGetVersionResponse(response) { } export function getSetupConfig() { + cy.qe(` + getSetupConfig query - + 'query' + + '{getSetupConfig{adminSetup{hasSchema,schemaVersion,appVersion}}}' + `) + return { query: 'query' + @@ -81,6 +112,13 @@ export function validateGetSetUpConfigResponse(response) { } export function getById(id) { + cy.qe(` + getById query - +'query' + + '($id:String)' + + '{getById(id:$id){layout,colors,javascript,css,javascriptActive,cssActive}}' + `) + return { query: 'query' + @@ -98,6 +136,7 @@ export function ValidategetByIdResponse(response) { export function updateLayoutSettings(option) { it(`${option} Layout Settings via Graphql`, updateRetry(3), () => { + cy.qe(`${option} layout settings via Graphql`) cy.getCheckOutItems().then(items => { cy.log(items) const configurations = items[ENVS.CONFIG_SETTINGS] @@ -110,8 +149,10 @@ export function updateLayoutSettings(option) { configurations.layout.showNoteField = bool configurations.layout.hideEmailStep = bool configurations.layout.customAddressForm = bool - graphql(APP, saveChanges(configurations), response => { + cy.qe( + `Validating ${response.body.data.saveChanges} to include 'DocumentId'` + ) expect(response.body.data.saveChanges).to.include('DocumentId') }) }) diff --git a/cypress/support/testcase.js b/cypress/support/testcase.js index e76f8cd7..4305387b 100644 --- a/cypress/support/testcase.js +++ b/cypress/support/testcase.js @@ -49,10 +49,13 @@ export function verifySettings(type) { }) it(`${prefix} - Display items unit price option`, updateRetry(2), () => { + cy.qe(`Clicking on CartLink`) cy.get(checkoutUiCustomSelectors.CartLink).click() if (enable) { + cy.qe(`If enable - QuantityPrice should exist`) cy.get(checkoutUiCustomSelectors.QuantityUnitPrice).should('exist') } else { + cy.qe(`If disable - QuantityPrice should not exist `) cy.get(checkoutUiCustomSelectors.QuantityUnitPrice).should('not.exist') } @@ -110,8 +113,12 @@ export function fillLineItems(items, maxChar) { .should('have.attr', 'maxlength') .then(maxlength => { cy.log(maxlength) + cy.qe( + `${maxlength} of the ProductLineItem should be equal to ${maxChar} ` + ) expect(maxlength).to.equal(maxChar) }) + cy.qe(`Filling the line items`) cy.get(checkoutUiCustomSelectors.ProductLineItem).eq(1).type(items.lineItem2) cy.get(checkoutUiCustomSelectors.ProductLineItem).eq(2).type(items.lineItem3) } From 728845f28ba656c5ced8835a349867816a06d722 Mon Sep 17 00:00:00 2001 From: suman123 Date: Wed, 8 Mar 2023 17:27:04 +0530 Subject: [PATCH 2/4] Added Logs for debugging --- CHANGELOG.md | 4 +++ cypress/support/grapqhl_testcase.js | 55 +++++++++++------------------ 2 files changed, 25 insertions(+), 34 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index c0237e2f..a70b4e82 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0. ## [Unreleased] +### Added + +- Added logs for debugging purpose + ## [0.8.32] - 2023-01-11 ### Removed diff --git a/cypress/support/grapqhl_testcase.js b/cypress/support/grapqhl_testcase.js index 5e0c9f68..7c8c17cf 100644 --- a/cypress/support/grapqhl_testcase.js +++ b/cypress/support/grapqhl_testcase.js @@ -5,17 +5,13 @@ import { graphql } from './common/graphql_utils' const APP = 'vtex.checkout-ui-custom@*.x' export function getLast(workspace) { - cy.qe(` - getLast query - - 'query' + - '($workspace: String!)' + - '{getLast(workspace: $workspace){id email workspace layout javascript css javascriptActive cssActive colors}}' - `) const query = 'query' + '($workspace: String!)' + '{getLast(workspace: $workspace){id email workspace layout javascript css javascriptActive cssActive colors}}' + cy.addGraphqlLogs(query, workspace) + return { query, queryVariables: { workspace }, @@ -27,17 +23,13 @@ export function validateGetLastResponse(response) { } export function saveChanges(configuration) { - cy.qe(` - save changes mutation - - 'mutation' + - '($email: String, $workspace: String, $layout: CustomFields, $javascript: String, $css: String, $javascriptActive: Boolean, $cssActive: Boolean, $colors: CustomFields)' + - '{saveChanges(email: $email, workspace: $workspace, layout: $layout, javascript: $javascript, css: $css, javascriptActive: $javascriptActive, cssActive: $cssActive, colors: $colors) @context(provider: "vtex.checkout-ui-custom@*.x")}' - `) const query = 'mutation' + '($email: String, $workspace: String, $layout: CustomFields, $javascript: String, $css: String, $javascriptActive: Boolean, $cssActive: Boolean, $colors: CustomFields)' + '{saveChanges(email: $email, workspace: $workspace, layout: $layout, javascript: $javascript, css: $css, javascriptActive: $javascriptActive, cssActive: $cssActive, colors: $colors) @context(provider: "vtex.checkout-ui-custom@*.x")}' + cy.addGraphqlLogs(query, configuration) + return { query, queryVariables: configuration, @@ -49,12 +41,10 @@ export function validateSaveChangesResponse(response) { } export function getHistory() { - cy.qe(` - getHistory query - - query: - 'query' + '{getHistory {id,email,workspace,creationDate,appVersion}}', - queryVariables: {}, - `) + const query = + 'query' + '{getHistory {id,email,workspace,creationDate,appVersion}}' + + cy.addGraphqlLogs(query) return { query: @@ -70,11 +60,9 @@ export function validateGetHistoryResponse(response) { } export function version() { - cy.qe(` -version query - -query: 'query' + '{version}', -queryVariables: {}, -`) + const query = 'query' + '{version}' + + cy.addGraphqlLogs(query) return { query: 'query' + '{version}', @@ -87,11 +75,10 @@ export function validateGetVersionResponse(response) { } export function getSetupConfig() { - cy.qe(` - getSetupConfig query - - 'query' + - '{getSetupConfig{adminSetup{hasSchema,schemaVersion,appVersion}}}' - `) + const query = + 'query' + '{getSetupConfig{adminSetup{hasSchema,schemaVersion,appVersion}}}' + + cy.addGraphqlLogs(query) return { query: @@ -112,12 +99,12 @@ export function validateGetSetUpConfigResponse(response) { } export function getById(id) { - cy.qe(` - getById query - -'query' + - '($id:String)' + - '{getById(id:$id){layout,colors,javascript,css,javascriptActive,cssActive}}' - `) + const query = + 'query' + + '($id:String)' + + '{getById(id:$id){layout,colors,javascript,css,javascriptActive,cssActive}}' + + cy.addGraphqlLogs(query, id) return { query: From 76cbf4c93c6ff19a1c7359a2a7cd7c24909d19a2 Mon Sep 17 00:00:00 2001 From: suman123 Date: Wed, 8 Mar 2023 17:41:35 +0530 Subject: [PATCH 3/4] Updated logs for restAPI --- cypress/integration/wipe.spec.js | 45 ++++++++++++++++++-------------- 1 file changed, 25 insertions(+), 20 deletions(-) diff --git a/cypress/integration/wipe.spec.js b/cypress/integration/wipe.spec.js index c2e7a17d..3ce41d6f 100644 --- a/cypress/integration/wipe.spec.js +++ b/cypress/integration/wipe.spec.js @@ -15,20 +15,10 @@ describe('Wipe', () => { it('Deleting checkout history', () => { cy.getVtexItems().then(vtex => { - cy.qe(` - - curl --location --request GET 'https://productusqa.vtexcommercestable.com.br/api/dataentities/checkoutcustom/search' \ - qs: { - _fields: 'workspace,email,id', - _schema: 'v0.1.3', - workspace: ${name}, - }, ---header 'X-VTEX-API-AppKey: AppKey' \ ---header 'X-VTEX-API-AppToken: AppToken' \ ---header 'Cookie: Cookie' - `) - cy.request({ - url: `https://productusqa.vtexcommercestable.com.br/api/dataentities/checkoutcustom/search`, + cy.addLogsForRestAPI({ + url: + 'https://productusqa.vtexcommercestable.com.br/api/dataentities/checkoutcustom/search', + method: 'GET', qs: { _fields: 'workspace,email,id', _schema: 'v0.1.3', @@ -38,13 +28,28 @@ describe('Wipe', () => { ...VTEX_AUTH_HEADER(vtex.apiKey, vtex.apiToken), 'REST-Range': 'resources=0-50', }, - ...FAIL_ON_STATUS_CODE, - }).then(response => { - expect(response.status).to.equal(200) - for (const { id } of response.body) { - cy.deleteDocumentInMasterData(ENTITIES.CHECKOUTCUSTOM, id) - } }) + + // cy.request({ + // url: `https://productusqa.vtexcommercestable.com.br/api/dataentities/checkoutcustom/search`, + + // qs: { + // _fields: 'workspace,email,id', + // _schema: 'v0.1.3', + // workspace: name, + // }, + // headers: { + // ...VTEX_AUTH_HEADER(vtex.apiKey, vtex.apiToken), + // 'REST-Range': 'resources=0-50', + // }, + // ...FAIL_ON_STATUS_CODE, + // }) + .then(response => { + expect(response.status).to.equal(200) + for (const { id } of response.body) { + cy.deleteDocumentInMasterData(ENTITIES.CHECKOUTCUSTOM, id) + } + }) }) }) it('Getting user & then deleting addresses associated with that user', () => { From 94634ce1638fa603410a0f1f763206dc54ac2216 Mon Sep 17 00:00:00 2001 From: suman123 Date: Wed, 8 Mar 2023 17:45:16 +0530 Subject: [PATCH 4/4] removed unused variables --- cypress/integration/wipe.spec.js | 32 ++++++-------------------------- 1 file changed, 6 insertions(+), 26 deletions(-) diff --git a/cypress/integration/wipe.spec.js b/cypress/integration/wipe.spec.js index 3ce41d6f..0c637c66 100644 --- a/cypress/integration/wipe.spec.js +++ b/cypress/integration/wipe.spec.js @@ -1,8 +1,4 @@ -import { - ENTITIES, - FAIL_ON_STATUS_CODE, - VTEX_AUTH_HEADER, -} from '../support/common/constants.js' +import { ENTITIES, VTEX_AUTH_HEADER } from '../support/common/constants.js' import { testSetup } from '../support/common/support.js' const config = Cypress.env() @@ -28,28 +24,12 @@ describe('Wipe', () => { ...VTEX_AUTH_HEADER(vtex.apiKey, vtex.apiToken), 'REST-Range': 'resources=0-50', }, + }).then(response => { + expect(response.status).to.equal(200) + for (const { id } of response.body) { + cy.deleteDocumentInMasterData(ENTITIES.CHECKOUTCUSTOM, id) + } }) - - // cy.request({ - // url: `https://productusqa.vtexcommercestable.com.br/api/dataentities/checkoutcustom/search`, - - // qs: { - // _fields: 'workspace,email,id', - // _schema: 'v0.1.3', - // workspace: name, - // }, - // headers: { - // ...VTEX_AUTH_HEADER(vtex.apiKey, vtex.apiToken), - // 'REST-Range': 'resources=0-50', - // }, - // ...FAIL_ON_STATUS_CODE, - // }) - .then(response => { - expect(response.status).to.equal(200) - for (const { id } of response.body) { - cy.deleteDocumentInMasterData(ENTITIES.CHECKOUTCUSTOM, id) - } - }) }) }) it('Getting user & then deleting addresses associated with that user', () => {