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

Added Logs for debugging purpose #185

Open
wants to merge 5 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
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions cypress/integration/2.3-lineitems_required.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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')
}
)
Expand Down
3 changes: 3 additions & 0 deletions cypress/integration/2.4-lineitems_optional.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -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')
})

Expand Down
8 changes: 7 additions & 1 deletion cypress/integration/2.5-checkout_scenarios.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down Expand Up @@ -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')
}
)
Expand Down
13 changes: 5 additions & 8 deletions cypress/integration/wipe.spec.js
Original file line number Diff line number Diff line change
@@ -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()
Expand All @@ -15,8 +11,10 @@ describe('Wipe', () => {

it('Deleting checkout history', () => {
cy.getVtexItems().then(vtex => {
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',
Expand All @@ -26,7 +24,6 @@ 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) {
Expand Down
7 changes: 7 additions & 0 deletions cypress/support/commands.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 })
Expand Down
30 changes: 29 additions & 1 deletion cypress/support/grapqhl_testcase.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ export function getLast(workspace) {
'($workspace: String!)' +
'{getLast(workspace: $workspace){id email workspace layout javascript css javascriptActive cssActive colors}}'

cy.addGraphqlLogs(query, workspace)

return {
query,
queryVariables: { workspace },
Expand All @@ -26,6 +28,8 @@ export function saveChanges(configuration) {
'($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,
Expand All @@ -37,6 +41,11 @@ export function validateSaveChangesResponse(response) {
}

export function getHistory() {
const query =
'query' + '{getHistory {id,email,workspace,creationDate,appVersion}}'

cy.addGraphqlLogs(query)

return {
query:
'query' + '{getHistory {id,email,workspace,creationDate,appVersion}}',
Expand All @@ -51,6 +60,10 @@ export function validateGetHistoryResponse(response) {
}

export function version() {
const query = 'query' + '{version}'

cy.addGraphqlLogs(query)

return {
query: 'query' + '{version}',
queryVariables: {},
Expand All @@ -62,6 +75,11 @@ export function validateGetVersionResponse(response) {
}

export function getSetupConfig() {
const query =
'query' + '{getSetupConfig{adminSetup{hasSchema,schemaVersion,appVersion}}}'

cy.addGraphqlLogs(query)

return {
query:
'query' +
Expand All @@ -81,6 +99,13 @@ export function validateGetSetUpConfigResponse(response) {
}

export function getById(id) {
const query =
'query' +
'($id:String)' +
'{getById(id:$id){layout,colors,javascript,css,javascriptActive,cssActive}}'

cy.addGraphqlLogs(query, id)

return {
query:
'query' +
Expand All @@ -98,6 +123,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]
Expand All @@ -110,8 +136,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')
})
})
Expand Down
7 changes: 7 additions & 0 deletions cypress/support/testcase.js
Original file line number Diff line number Diff line change
Expand Up @@ -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')
}

Expand Down Expand Up @@ -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)
}