fix tests for stripe (#2260)

This commit is contained in:
Karolina Rakoczy 2022-08-26 13:03:29 +02:00 committed by GitHub
parent 15274e14d7
commit 43be1d60e2
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 15 additions and 13 deletions

View file

@ -135,6 +135,8 @@ jobs:
CYPRESS_mailHogUrl: ${{ secrets.CYPRESS_MAILHOG }} CYPRESS_mailHogUrl: ${{ secrets.CYPRESS_MAILHOG }}
COMMIT_INFO_MESSAGE: All tests triggered via ${{ github.event_name}} on ${{ steps.get-env-uri.outputs.ENV_URI }} COMMIT_INFO_MESSAGE: All tests triggered via ${{ github.event_name}} on ${{ steps.get-env-uri.outputs.ENV_URI }}
CYPRESS_grepTags: ${{ github.event.inputs.tags }} CYPRESS_grepTags: ${{ github.event.inputs.tags }}
STRIPE_SECRET_KEY: ${{ secrets.STRIPE_SECRET_KEY }}
STRIPE_PUBLIC_KEY: ${{ secrets.STRIPE_PUBLIC_KEY }}
with: with:
parallel: true parallel: true
group: 'UI - Chrome' group: 'UI - Chrome'

View file

@ -8,7 +8,7 @@ export function getPaymentMethodStripeId({
cardNumber, cardNumber,
cvc, cvc,
expMonth, expMonth,
expYear expYear,
}) { }) {
return cy.request({ return cy.request({
url: urlList.stripeApiPaymentMethods, url: urlList.stripeApiPaymentMethods,
@ -21,11 +21,11 @@ export function getPaymentMethodStripeId({
"card[exp_month]": expMonth, "card[exp_month]": expMonth,
"card[exp_year]": expYear, "card[exp_year]": expYear,
pasted_fields: "number", pasted_fields: "number",
key: stripePublicKey key: stripePublicKey,
}, },
headers: { headers: {
Authorization: stripeAuthBearer Authorization: stripeAuthBearer,
} },
}); });
} }
@ -36,15 +36,15 @@ export function sendConfirmationToStripe(paymentMethodId, confirmationId) {
form: true, form: true,
failOnStatusCode: false, failOnStatusCode: false,
headers: { headers: {
Authorization: stripeAuthBearer Authorization: stripeAuthBearer,
}, },
body: { body: {
payment_method: paymentMethodId, payment_method: paymentMethodId,
return_url: Cypress.config().baseUrl, return_url: Cypress.config().baseUrl,
webauthn_uvpa_available: "true", webauthn_uvpa_available: "true",
spc_eligible: "false", 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 { body } = new DOMParser().parseFromString(resp.body, "text/html");
const formUrl = body.querySelector('[id="form"]').getAttribute("action"); const formUrl = body.querySelector('[id="form"]').getAttribute("action");
const source = body const source = body
.querySelector('[name="source"]') .querySelector('[name="source_slug"]')
.getAttribute("value"); .getAttribute("value");
returnUrl = body returnUrl = body
.querySelector('[name="return_url"]') .querySelector('[name="return_url"]')
@ -71,7 +71,7 @@ export function confirmThreeDSecure(nextActionUrl, withSuccess = true) {
.getAttribute("value"); .getAttribute("value");
const usage = body.querySelector('[name="usage"]').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}&currency= const url = `${formUrl}?source_slug=${source}&livemode=false&type=three_d_secure&pass_through=&return_url=${returnUrl}&amount=${amount}&currency=
${currency}&usage=${usage}`; ${currency}&usage=${usage}`;
cy.request(url); cy.request(url);
}) })
@ -82,8 +82,8 @@ export function confirmThreeDSecure(nextActionUrl, withSuccess = true) {
form: true, form: true,
body: { body: {
PaRes: "success", PaRes: "success",
MD: "" MD: "",
} },
}); });
}) })
.then(resp => { .then(resp => {
@ -99,8 +99,8 @@ export function confirmThreeDSecure(nextActionUrl, withSuccess = true) {
body: { body: {
PaRes: paRes, PaRes: paRes,
MD: "", MD: "",
Merchant: merchant Merchant: merchant,
} },
}); });
}); });
} }