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

Cybersource logs #148

Draft
wants to merge 4 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from 3 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 @@ -6,6 +6,10 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.

## [Unreleased]

### Added
- In Cypress, Added logs for debugging


### Removed
- [ENGINEERS-1144] - Remove hardcoded cybersource ui version from cybersource tests

Expand Down
1 change: 1 addition & 0 deletions cypress/integration/2.2-singleProduct.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ describe('Single Product Testcase', () => {

it('Verifying tax and total amounts for a product with quantity 2', () => {
// Verify Tax
cy.qe(`Verifying the tax should have ${tax}`)
cy.get(selectors.TaxAmtLabel).last().should('have.text', tax)
// Verify Total
cy.verifyTotal(totalAmount)
Expand Down
1 change: 1 addition & 0 deletions cypress/integration/2.3-multiProduct.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ describe('Multi Product Testcase', () => {

it('Verify tax and total', updateRetry(3), () => {
// Verify Tax
cy.qe(`Verifying the tax should have ${tax}`)
cy.get(selectors.TaxAmtLabel).last().should('have.text', tax)
// Verify Total
cy.verifyTotal(totalAmount)
Expand Down
2 changes: 2 additions & 0 deletions cypress/integration/2.5-promotionalProduct.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ describe('Promotional Product Testcase', () => {

it('Verifying tax, total and discounts amounts for a product with quantity 2', () => {
// Verify Tax
cy.qe(`Verifying the tax should have ${tax}`)
cy.get(selectors.TaxAmtLabel).last().should('have.text', tax)
// Verify Total
cy.verifyTotal(totalAmount)
Expand All @@ -43,6 +44,7 @@ describe('Promotional Product Testcase', () => {

it('Verify free product is added', updateRetry(3), () => {
// Verify free product is added
cy.qe(`Verifying free product is available`)
cy.get('span[class="new-product-price"]')
.first()
.should('have.text', 'Free')
Expand Down
2 changes: 2 additions & 0 deletions cypress/integration/2.6-discountProduct.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,12 @@ describe('Discount Product Testcase', () => {

it('Verifying tax and total amounts,discount for a discounted product', () => {
// Verify Tax
cy.qe(`Verifying the tax should have ${tax}`)
cy.get(selectors.TaxAmtLabel).last().should('have.text', tax)
// Verify Total
cy.verifyTotal(totalAmount)
// Verify Discounts
cy.qe(`Discounts should exist`)
cy.get(selectors.Discounts).last().should('be.visible')
})

Expand Down
1 change: 1 addition & 0 deletions cypress/integration/2.7-discountShipping.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ describe('Discount Shipping Testcase', () => {

it('Verify tax and total', updateRetry(3), () => {
// Verify Tax
cy.qe(`Verifying the tax should have ${tax}`)
cy.get(selectors.TaxAmtLabel).last().should('have.text', tax)
// Verify Total
cy.verifyTotal(totalAmount)
Expand Down
1 change: 1 addition & 0 deletions cypress/integration/2.8-externalSeller.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ describe('External Seller Testcase', () => {

it('Verify tax and total', updateRetry(3), () => {
// Verify Tax
cy.qe(`Verifying the tax should have ${tax}`)
cy.get(selectors.TaxAmtLabel).last().should('have.text', tax)
// Verify Total
cy.verifyTotal(totalAmount)
Expand Down
12 changes: 11 additions & 1 deletion cypress/support/affiliation.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,11 @@ const CYBERSOURCE_AFFILIATION_ID = '21d78653-50d6-4b06-b553-2645e67a6f5e'
export function setWorkspaceInAffiliation(workspace = null, payerAuth = true) {
it(`Configuring workspace as '${workspace}' in payment affiliation`, () => {
cy.getVtexItems().then(vtex => {
cy.qe(`
curl --location --request GET '${vtex.baseUrl}/api/payments/pvt/affiliations/21d78653-50d6-4b06-b553-2645e67a6f5e' \
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Replace curl with cy.request

--header 'X-VTEX-API-AppKey: AppKey' \
--header 'X-VTEX-API-AppToken: AppToken' \
`)
cy.request({
method: 'GET',
url: `${vtex.baseUrl}/api/payments/pvt/affiliations/${CYBERSOURCE_AFFILIATION_ID}`,
Expand Down Expand Up @@ -39,7 +44,12 @@ export function setWorkspaceInAffiliation(workspace = null, payerAuth = true) {
response.body.configuration[payerAuthIndex].value = payerAuth
? 'active'
: 'disabled'

cy.qe(`
curl --location --request PUT '${vtex.baseUrl}/api/payments/pvt/affiliations/21d78653-50d6-4b06-b553-2645e67a6f5e' \
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Replace curl with cy.request
if it is a common function then do it in cy-runner rather than here

--header 'X-VTEX-API-AppKey: AppKey' \
--header 'X-VTEX-API-AppToken: AppToken' \
--data-raw 'data'
`)
cy.request({
method: 'PUT',
url: `${vtex.baseUrl}/api/payments/pvt/affiliations/${CYBERSOURCE_AFFILIATION_ID}`,
Expand Down
16 changes: 16 additions & 0 deletions cypress/support/appSettings.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,27 @@ export function saveAppSettings(settings) {

export function updateCybersourceConfiguration(orderSuffix = '') {
it('Update cybersource app settings', () => {
cy.qe(`
GetApp settings query -
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For this use cy.addGraphqlLogs command
This would be available once this PR been merged - https://github.com/vtex-apps/cy-runner/pull/249/files

query: 'query' + '{appSettings(app:"vtex.cybersource-ui"){message}}',
queryVariables: {},
`)
graphql(APP, getAppSettings(), ({ body }) => {
const { message } = body.data.appSettings
const jsonMessage = JSON.parse(message)

jsonMessage.OrderSuffix = orderSuffix

cy.qe(`
saveAppSettings - mutation
query:
'mutation($app:String,$settings:String)' +
{saveAppSettings(app:$app,settings:$settings){message}},
queryVariables: {
app: 'vtex.cybersource-ui',
settings: JSON.stringify(settings),
},
`)
graphql(APP, saveAppSettings(jsonMessage), response => {
const { OrderSuffix } = JSON.parse(
response.body.data.saveAppSettings.message
Expand Down
7 changes: 7 additions & 0 deletions cypress/support/commands.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,12 @@ import { FAIL_ON_STATUS_CODE, VTEX_AUTH_HEADER } from './common/constants.js'
// Order Tax API Test Case
Cypress.Commands.add('orderTaxApi', (requestPayload, tax) => {
cy.getVtexItems().then(vtex => {
cy.qe(`
curl --location --request POST '${vtex.baseUrl}/cybersource/checkout/order-tax' \
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

replace curl with cy.request

--header 'X-VTEX-API-AppKey: AppKey' \
--header 'X-VTEX-API-AppToken: AppToken' \
--data-raw 'tData":{req.body}'
`)
cy.request({
method: 'POST',
url: `${vtex.baseUrl}/${
Expand All @@ -28,6 +34,7 @@ Cypress.Commands.add('orderTaxApi', (requestPayload, tax) => {
})

Cypress.Commands.add('checkForTaxErrors', () => {
cy.qe(`communication error with Tax System has occurred should not exist`)
cy.contains('communication error with Tax System has occurred', {
timeout: 2000,
}).should('not.exist')
Expand Down
25 changes: 25 additions & 0 deletions cypress/support/testcase.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ export function completePayment({
cy.intercept('**/gatewayCallback/**').as('callback')

// Select Credit Card Option
cy.qe(`Completing payment using credit card option`)
cy.get('a[id*=creditCard]').should('be.visible').click()

cy.get('body').then($body => {
Expand All @@ -41,15 +42,19 @@ export function completePayment({
cy.getIframeBody(selectors.PaymentMethodIFrame).then($body => {
if (!$body.find(selectors.CardExist).length) {
// Credit cart not exist
cy.qe(`Enteriing credit card number 5555 5555 5555 4444`)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of entering use Type

cy.getIframeBody(selectors.PaymentMethodIFrame)
.find(selectors.CreditCardNumber)
.type('5555 5555 5555 4444')
cy.qe(`Entering firstName - syed`)
cy.getIframeBody(selectors.PaymentMethodIFrame)
.find(selectors.CreditCardHolderName)
.type('Syed')
cy.qe(`Selecting expiring month from dropdown - 01`)
cy.getIframeBody(selectors.PaymentMethodIFrame)
.find(selectors.CreditCardExpirationMonth)
.select('01')
cy.qe(`Selecting Expiry year from dropdown - 30`)
cy.getIframeBody(selectors.PaymentMethodIFrame)
.find(selectors.CreditCardExpirationYear)
.select('30')
Expand Down Expand Up @@ -157,6 +162,11 @@ export function verifyStatusInInteractionAPI({

cy.getVtexItems().then(vtex => {
cy.getOrderItems().then(item => {
cy.qe(`
curl --location --request GET '${vtex.baseUrl}/api/oms/pvt/orders/${item[orderIdEnv]}' \
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

replace curl with cy.request

--header 'X-VTEX-API-AppKey: AppKey' \
--header 'X-VTEX-API-AppToken: AppToken' \
`)
cy.getAPI(
`${invoiceAPI(vtex.baseUrl)}/${item[orderIdEnv]}`,
VTEX_AUTH_HEADER(vtex.apiKey, vtex.apiToken)
Expand All @@ -165,6 +175,11 @@ export function verifyStatusInInteractionAPI({
const [{ transactionId }] = response.body.paymentData.transactions

cy.setOrderItem(transactionIdEnv, transactionId)
cy.qe(`
curl --location --request GET '${vtex.baseUrl}/${transactionId}/interactions' \
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

replace curl with cy.request

--header 'X-VTEX-API-AppKey: AppKey' \
--header 'X-VTEX-API-AppToken: AppToken' \
`)
cy.getAPI(
`${transactionAPI(vtex.baseUrl)}/${transactionId}/interactions`,
VTEX_AUTH_HEADER(vtex.apiKey, vtex.apiToken)
Expand Down Expand Up @@ -339,6 +354,11 @@ export function verifyCyberSourceAPI({
cy.addDelayBetweenRetries(5000)
cy.getVtexItems().then(vtex => {
cy.getOrderItems().then(item => {
cy.qe(`
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

replace curl with cy.request

curl --location --request GET '${vtex.baseUrl}/api/payments/pvt/transactions/${item[transactionIdEnv]}/payments' \
--header 'X-VTEX-API-AppKey: AppKey' \
--header 'X-VTEX-API-AppToken: AppToken' \
`)
cy.getAPI(
`${transactionAPI(vtex.baseUrl)}/${item[transactionIdEnv]}/payments`,
VTEX_AUTH_HEADER(vtex.apiKey, vtex.apiToken)
Expand Down Expand Up @@ -425,6 +445,11 @@ export function invoiceAPITestCase(

cy.getVtexItems().then(vtex => {
cy.getOrderItems().then(item => {
cy.qe(`
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

replace curl with cy.request

curl --location --request GET '${vtex.baseUrl}/api/oms/pvt/orders/${item[orderIdEnv]}' \
--header 'X-VTEX-API-AppKey: AppKey' \
--header 'X-VTEX-API-AppToken: AppToken' \
`)
cy.getAPI(
`${
orderIdEnv === externalSeller.externalSaleEnv
Expand Down