From 43be1d60e236bc6a0294964b0169c9b409757aea Mon Sep 17 00:00:00 2001 From: Karolina Rakoczy Date: Fri, 26 Aug 2022 13:03:29 +0200 Subject: [PATCH] fix tests for stripe (#2260) --- .github/workflows/tests-nightly.yml | 2 ++ cypress/support/api/requests/stripe.js | 26 +++++++++++++------------- 2 files changed, 15 insertions(+), 13 deletions(-) diff --git a/.github/workflows/tests-nightly.yml b/.github/workflows/tests-nightly.yml index 93161f9fb..16e9133a3 100644 --- a/.github/workflows/tests-nightly.yml +++ b/.github/workflows/tests-nightly.yml @@ -135,6 +135,8 @@ jobs: CYPRESS_mailHogUrl: ${{ secrets.CYPRESS_MAILHOG }} COMMIT_INFO_MESSAGE: All tests triggered via ${{ github.event_name}} on ${{ steps.get-env-uri.outputs.ENV_URI }} CYPRESS_grepTags: ${{ github.event.inputs.tags }} + STRIPE_SECRET_KEY: ${{ secrets.STRIPE_SECRET_KEY }} + STRIPE_PUBLIC_KEY: ${{ secrets.STRIPE_PUBLIC_KEY }} with: parallel: true group: 'UI - Chrome' diff --git a/cypress/support/api/requests/stripe.js b/cypress/support/api/requests/stripe.js index 4c39c872e..eabd6ad0f 100644 --- a/cypress/support/api/requests/stripe.js +++ b/cypress/support/api/requests/stripe.js @@ -8,7 +8,7 @@ export function getPaymentMethodStripeId({ cardNumber, cvc, expMonth, - expYear + expYear, }) { return cy.request({ url: urlList.stripeApiPaymentMethods, @@ -21,11 +21,11 @@ export function getPaymentMethodStripeId({ "card[exp_month]": expMonth, "card[exp_year]": expYear, pasted_fields: "number", - key: stripePublicKey + key: stripePublicKey, }, headers: { - Authorization: stripeAuthBearer - } + Authorization: stripeAuthBearer, + }, }); } @@ -36,15 +36,15 @@ export function sendConfirmationToStripe(paymentMethodId, confirmationId) { form: true, failOnStatusCode: false, headers: { - Authorization: stripeAuthBearer + Authorization: stripeAuthBearer, }, body: { payment_method: paymentMethodId, return_url: Cypress.config().baseUrl, webauthn_uvpa_available: "true", spc_eligible: "false", - key: stripePublicKey - } + key: stripePublicKey, + }, }); } @@ -58,7 +58,7 @@ export function confirmThreeDSecure(nextActionUrl, withSuccess = true) { const { body } = new DOMParser().parseFromString(resp.body, "text/html"); const formUrl = body.querySelector('[id="form"]').getAttribute("action"); const source = body - .querySelector('[name="source"]') + .querySelector('[name="source_slug"]') .getAttribute("value"); returnUrl = body .querySelector('[name="return_url"]') @@ -71,7 +71,7 @@ export function confirmThreeDSecure(nextActionUrl, withSuccess = true) { .getAttribute("value"); const usage = body.querySelector('[name="usage"]').getAttribute("value"); - const url = `${formUrl}?source=${source}&livemode=false&type=three_d_secure&pass_through=&return_url=${returnUrl}&amount=${amount}¤cy= + const url = `${formUrl}?source_slug=${source}&livemode=false&type=three_d_secure&pass_through=&return_url=${returnUrl}&amount=${amount}¤cy= ${currency}&usage=${usage}`; cy.request(url); }) @@ -82,8 +82,8 @@ export function confirmThreeDSecure(nextActionUrl, withSuccess = true) { form: true, body: { PaRes: "success", - MD: "" - } + MD: "", + }, }); }) .then(resp => { @@ -99,8 +99,8 @@ export function confirmThreeDSecure(nextActionUrl, withSuccess = true) { body: { PaRes: paRes, MD: "", - Merchant: merchant - } + Merchant: merchant, + }, }); }); }