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

Ci(Cypress): Enhance Cybersource Testcases #6285

Open
wants to merge 19 commits into
base: main
Choose a base branch
from
Open

Conversation

Gnanasundari24
Copy link
Contributor

@Gnanasundari24 Gnanasundari24 commented Oct 10, 2024

Type of Change

  • Bugfix
  • New feature
  • Enhancement
  • Refactoring
  • Dependency updates
  • Documentation
  • CI/CD

Description

Added field level verifications for payment retrieve , payment intent , payment attempt , List payment methods
Added Business Profile cases
Added Payment methods Test cases
Added Connector agnostic Test cases

Additional Changes

  • This PR modifies the API contract
  • This PR modifies the database schema
  • This PR modifies application configuration/environment variables

Motivation and Context

How did you test it?

Screenshot 2024-10-09 at 1 50 41 PM Screenshot 2024-10-10 at 12 42 51 PM image image
  • Cybersource
image
  • Stripe
image
  • Adyen
image
  • Bluesnap
image
  • Paypal
image
  • nmi
image

Checklist

  • I formatted the code cargo +nightly fmt --all
  • I addressed lints thrown by cargo clippy
  • I reviewed the submitted code
  • I added unit tests for my changes where possible

@Gnanasundari24 Gnanasundari24 added the A-CI-CD Area: Continuous Integration/Deployment label Oct 10, 2024
@Gnanasundari24 Gnanasundari24 self-assigned this Oct 10, 2024
@Gnanasundari24 Gnanasundari24 requested a review from a team as a code owner October 10, 2024 07:14
Copy link

semanticdiff-com bot commented Oct 10, 2024

Review changes with SemanticDiff.

Analyzed 40 of 40 files.

Overall, the semantic diff is 6% smaller than the GitHub diff.

20 files do not contain logic changes.

File Information
Filename Status
✔️ cypress-tests/cypress/support/commands.js 19.43% smaller
✔️ cypress-tests/cypress/fixtures/create-business-profile.json Analyzed
✔️ cypress-tests/cypress/fixtures/create-connector-body.json 11.22% smaller
✔️ cypress-tests/cypress/fixtures/create-payment-body.json Analyzed
✔️ cypress-tests/cypress/fixtures/create-payment-method-body.json Analyzed
✔️ cypress-tests/cypress/fixtures/imports.js Analyzed
✔️ cypress-tests/cypress/fixtures/session-token.json Analyzed
✔️ cypress-tests/cypress/fixtures/update-business-profile.json Analyzed
✔️ cypress-tests/cypress/e2e/PaymentUtils/Adyen.js Analyzed
✔️ cypress-tests/cypress/e2e/PaymentUtils/BankOfAmerica.js Analyzed
✔️ cypress-tests/cypress/e2e/PaymentUtils/Bluesnap.js Analyzed
✔️ cypress-tests/cypress/e2e/PaymentUtils/Commons.js Analyzed
✔️ cypress-tests/cypress/e2e/PaymentUtils/Cybersource.js 1.16% smaller
✔️ cypress-tests/cypress/e2e/PaymentUtils/Nmi.js Analyzed
✔️ cypress-tests/cypress/e2e/PaymentUtils/Paypal.js Analyzed
✔️ cypress-tests/cypress/e2e/PaymentUtils/Stripe.js Analyzed
✔️ cypress-tests/cypress/e2e/PaymentTest/00000-CoreFlows.cy.js No logic changes found
✔️ cypress-tests/cypress/e2e/PaymentTest/00001-AccountCreate.cy.js No logic changes found
✔️ cypress-tests/cypress/e2e/PaymentTest/00002-CustomerCreate.cy.js No logic changes found
✔️ cypress-tests/cypress/e2e/PaymentTest/00003-ConnectorCreate.cy.js No logic changes found
✔️ cypress-tests/cypress/e2e/PaymentTest/00004-NoThreeDSAutoCapture.cy.js No logic changes found
✔️ cypress-tests/cypress/e2e/PaymentTest/00005-ThreeDSAutoCapture.cy.js No logic changes found
✔️ cypress-tests/cypress/e2e/PaymentTest/00006-NoThreeDSManualCapture.cy.js No logic changes found
✔️ cypress-tests/cypress/e2e/PaymentTest/00007-VoidPayment.cy.js No logic changes found
✔️ cypress-tests/cypress/e2e/PaymentTest/00008-SyncPayment.cy.js No logic changes found
✔️ cypress-tests/cypress/e2e/PaymentTest/00009-RefundPayment.cy.js No logic changes found
✔️ cypress-tests/cypress/e2e/PaymentTest/00010-SyncRefund.cy.js No logic changes found
✔️ cypress-tests/cypress/e2e/PaymentTest/00011-CreateSingleuseMandate.cy.js No logic changes found
✔️ cypress-tests/cypress/e2e/PaymentTest/00012-CreateMultiuseMandate.cy.js No logic changes found
✔️ cypress-tests/cypress/e2e/PaymentTest/00013-ListAndRevokeMandate.cy.js No logic changes found
✔️ cypress-tests/cypress/e2e/PaymentTest/00014-SaveCardFlow.cy.js Analyzed
✔️ cypress-tests/cypress/e2e/PaymentTest/00015-ZeroAuthMandate.cy.js Analyzed
✔️ cypress-tests/cypress/e2e/PaymentTest/00016-ThreeDSManualCapture.cy.js No logic changes found
✔️ cypress-tests/cypress/e2e/PaymentTest/00017-BankTransfers.cy.js No logic changes found
✔️ cypress-tests/cypress/e2e/PaymentTest/00018-BankRedirect.cy.js No logic changes found
✔️ cypress-tests/cypress/e2e/PaymentTest/00019-MandatesUsingPMID.cy.js No logic changes found
✔️ cypress-tests/cypress/e2e/PaymentTest/00020-UPI.cy.js No logic changes found
✔️ cypress-tests/cypress/e2e/PaymentTest/00021-Variations.cy.js No logic changes found
✔️ cypress-tests/cypress/e2e/PaymentTest/00022-PaymentMethods.cy.js Analyzed
✔️ cypress-tests/cypress/e2e/PaymentTest/00023-ConnectorAgnostic.cy.js Analyzed

@Gnanasundari24 Gnanasundari24 changed the title CI(Cypress): Field level assertion for customer and customer paymentmethod list CI(Cypress): Enhance Cybersource Testcases Oct 10, 2024
@likhinbopanna likhinbopanna changed the title CI(Cypress): Enhance Cybersource Testcases Ci(Cypress): Enhance Cybersource Testcases Oct 10, 2024
@pixincreate
Copy link
Member

marking this pr as draft until ready.

@pixincreate pixincreate marked this pull request as draft October 10, 2024 15:50
@likhinbopanna likhinbopanna marked this pull request as ready for review October 17, 2024 16:16
Comment on lines +1139 to +1142
// expect(
// response.body.connector_transaction_id,
// "connector_transaction_id"
// ).to.not.be.null;
Copy link
Contributor

Choose a reason for hiding this comment

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

remove if not needed

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It is a required check but for cybersource the connector_transaction_id is null for 3ds payments so as of now i have commented this code

Comment on lines +1474 to +1477
// expect(
// response.body.connector_transaction_id,
// "connector_transaction_id"
// ).to.not.be.null;
Copy link
Contributor

Choose a reason for hiding this comment

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

remove if not needed

Comment on lines +1594 to +1597
// expect(
// response.body.connector_transaction_id,
// "connector_transaction_id"
// ).to.not.be.null;
Copy link
Contributor

Choose a reason for hiding this comment

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

remove if not needed

Comment on lines +1743 to +1746
// expect(
// response.body.connector_transaction_id,
// "connector_transaction_id"
// ).to.not.be.null;
Copy link
Contributor

Choose a reason for hiding this comment

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

remove if not needed

@@ -883,6 +968,16 @@ Cypress.Commands.add(
).to.be.null;
expect(response.body.connector_mandate_id, "connector_mandate_id").to.be
.null;
Copy link
Contributor

Choose a reason for hiding this comment

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

Along with the above checks,

  1. add payment_id not null check
  2. merchant_id not null
  3. status = 'requires_payment_method'
  4. Check deep equals (nested object should be covered, eg: JSON.stringify(obj1) === JSON.stringify(obj2)) for the shipping address
  5. Check deep equals for billing address
  6. check if the profile id is the expected one instead of doing null check
  7. external_3ds_authentication_attempted is same as the request body

If the above items are not generic and will change from case to case, add a callback function and pass the required check from the calling place

order_tax_amount, external_3ds_authentication_attempted etc cannot be generic, so for those, we can have a callback function to verify them based on the calling place

Copy link
Contributor Author

Choose a reason for hiding this comment

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

3.status = 'requires_payment_method'

We are already checking this in each connector.js file
expect(res_data.body[key]).to.equal(
response.body[key],
Expected ${res_data.body[key]} but got ${response.body[key]}
);

6.check if the profile id is the expected one instead of doing null check
Its a random created profile_id and even we are getting profile id from the global state so it will fail if the profile id is not present or its not stored in globalstate.

4.Check deep equals (nested object should be covered, eg: JSON.stringify(obj1) === JSON.stringify(obj2)) for the shipping address
5.Check deep equals for billing address

  • Billling and shipping address we are not passing in the intent create. We are passing only the mandatory field in payment intent create. So we are verifying these checks in confirm and other calls

7.external_3ds_authentication_attempted is same as the request body
As we have not added these scenario's yet so havent added these checks in the response once we have implemented that feature we will include these cases.

}).then((response) => {
logRequestId(response.headers["x-request-id"]);

expect(response.headers["content-type"]).to.include("application/json");
if (response.status === 200) {
expect(response.body).to.have.property("payment_method_id");
expect(response.body).to.have.property("client_secret");
expect(response.body.client_secret, "client_secret").to.equal(
Copy link
Contributor

Choose a reason for hiding this comment

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

please add check for merchant_id, customer_id, payment_method, payment_method_type, last_used etc
if appliable check for all the details related to the card also

const recurringEnabledFromConfirm =
globalState.get("recurring_enabled");
if (
req_data.customer_acceptance === "object" &&
Copy link
Contributor

Choose a reason for hiding this comment

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

is this a valid check? usually typeof will be added to check object type

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes we have to check recurringEnabled is true or false for mandate payments. And these checks are based on multiple factors(In confirm customer acceptance passed/not and in create its a off_session payment or not then it will be true). So to handle that i made these changes.

Copy link
Member

Choose a reason for hiding this comment

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

No, it is not a valid check. It should be if (typeof(req_data.customer_acceptance) === "object") instead.

});

it("List Payment Method for Customer using Client Secret", () => {
cy.listCustomerPMByClientSecret(globalState);
Copy link
Contributor

Choose a reason for hiding this comment

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

should check the count of payment methods

Copy link
Contributor

Choose a reason for hiding this comment

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

once creds issue is resolved we can add

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-CI-CD Area: Continuous Integration/Deployment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants