Skip to content

Commit

Permalink
feat(cypress): add multiple creds and flags support (#6588)
Browse files Browse the repository at this point in the history
Co-authored-by: hyperswitch-bot[bot] <148525504+hyperswitch-bot[bot]@users.noreply.github.com>
  • Loading branch information
pixincreate and hyperswitch-bot[bot] authored Dec 3, 2024
1 parent 79a75ce commit 82caded
Show file tree
Hide file tree
Showing 68 changed files with 5,618 additions and 4,955 deletions.
61 changes: 60 additions & 1 deletion .github/workflows/cypress-tests-runner.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,65 @@ env:
RUST_MIN_STACK: 10485760

jobs:
formatter:
name: Run formatter on Cypress tests and address lints
if: ${{ github.event_name == 'pull_request' }}
runs-on: ubuntu-latest
steps:
- name: Generate a token
if: ${{ github.event.pull_request.head.repo.full_name == github.event.pull_request.base.repo.full_name }}
id: generate_token
uses: actions/create-github-app-token@v1
with:
app-id: ${{ secrets.HYPERSWITCH_BOT_APP_ID }}
private-key: ${{ secrets.HYPERSWITCH_BOT_APP_PRIVATE_KEY }}

- name: Checkout repository with token
if: ${{ github.event.pull_request.head.repo.full_name == github.event.pull_request.base.repo.full_name }}
uses: actions/checkout@v4
with:
fetch-depth: 0
ref: ${{ github.event.pull_request.head.ref }}
token: ${{ steps.generate_token.outputs.token }}

- name: Checkout repository for fork
if: ${{ github.event.pull_request.head.repo.full_name != github.event.pull_request.base.repo.full_name }}
uses: actions/checkout@v4

- name: Install Node.js
uses: actions/setup-node@v4
with:
node-version: '20'

- name: Install Cypress and dependencies
run: |
npm ci --prefix ./cypress-tests
- name: Check formatting for forked pull requests
if: ${{ github.event.pull_request.head.repo.full_name != github.event.pull_request.base.repo.full_name }}
shell: bash
run: |
npm run format:check --prefix cypress-tests
npm run lint --prefix cypress-tests
- name: Check formatting
if: ${{ github.event.pull_request.head.repo.full_name == github.event.pull_request.base.repo.full_name }}
shell: bash
run: |
npm run format --prefix cypress-tests
npm run lint --prefix cypress-tests -- --fix
if ! git diff --exit-code --quiet -- cypress-tests; then
echo "::notice::Cypress formatting and lint check failed"
git config --local user.name 'hyperswitch-bot[bot]'
git config --local user.email '148525504+hyperswitch-bot[bot]@users.noreply.github.com'
git add cypress-tests
git commit --message 'chore(cypress): run formatter and address lints'
git push
fi
runner:
name: Run Cypress tests
runs-on: ubuntu-latest
Expand Down Expand Up @@ -69,7 +128,7 @@ jobs:
CONNECTOR_AUTH_PASSPHRASE: ${{ secrets.CONNECTOR_AUTH_PASSPHRASE }}
CONNECTOR_CREDS_S3_BUCKET_URI: ${{ secrets.CONNECTOR_CREDS_S3_BUCKET_URI}}
DESTINATION_FILE_NAME: "creds.json.gpg"
S3_SOURCE_FILE_NAME: "5a3f7679-445e-4621-86c5-39bd8d26b7c5.json.gpg"
S3_SOURCE_FILE_NAME: "c5701d35-aede-4d85-a866-0da4721acf30.json.gpg"
shell: bash
run: |
mkdir -p ".github/secrets" ".github/test"
Expand Down
1 change: 1 addition & 0 deletions cypress-tests/.gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
.DS_Store
creds.json
reports
run_all.sh
Expand Down
9 changes: 9 additions & 0 deletions cypress-tests/.prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"bracketSpacing": true,
"endOfLine": "auto",
"printWidth": 80,
"semi": true,
"singleQuote": false,
"tabWidth": 2,
"trailingComma": "es5"
}
6 changes: 0 additions & 6 deletions cypress-tests/.prettierrc.json

This file was deleted.

14 changes: 7 additions & 7 deletions cypress-tests/cypress.config.js
Original file line number Diff line number Diff line change
@@ -1,18 +1,16 @@
const { defineConfig } = require("cypress");
const fs = require("fs-extra");
const path = require("path");
import { defineConfig } from "cypress";
import "cypress-mochawesome-reporter/plugin.js";

let globalState;

// Fetch from environment variable
const connectorId = process.env.CYPRESS_CONNECTOR || "service";
const screenshotsFolderName = `screenshots/${connectorId}`;
const reportName = process.env.REPORT_NAME || `${connectorId}_report`;

module.exports = defineConfig({
export default defineConfig({
e2e: {
setupNodeEvents(on, config) {
require("cypress-mochawesome-reporter/plugin")(on);

setupNodeEvents(on) {
on("task", {
setGlobalState: (val) => {
return (globalState = val || {});
Expand All @@ -21,7 +19,9 @@ module.exports = defineConfig({
return globalState || {};
},
cli_log: (message) => {
// eslint-disable-next-line no-console
console.log("Logging console message from task");
// eslint-disable-next-line no-console
console.log(message);
return null;
},
Expand Down
1 change: 0 additions & 1 deletion cypress-tests/cypress.env.json

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -67,14 +67,17 @@ describe("Payment Method list using Constraint Graph flow tests", () => {

// creating payment with currency as EUR and no billing address
it("create-payment-call-test", () => {
let data = getConnectorDetails("stripe")["pm_list"]["PaymentIntent"];
let req_data = data["RequestCurrencyEUR"];
let res_data = data["Response"];
const data = getConnectorDetails("stripe")["pm_list"]["PaymentIntent"];

const newData = {
...data,
Request: data.RequestCurrencyEUR,
RequestCurrencyEUR: undefined, // we do not need this anymore
};

cy.createPaymentIntentTest(
create_payment_body_with_currency("EUR"),
req_data,
res_data,
newData,
"no_three_ds",
"automatic",
globalState
Expand All @@ -83,7 +86,7 @@ describe("Payment Method list using Constraint Graph flow tests", () => {

// payment method list which should only have ideal with stripe
it("payment-method-list-call-test", () => {
let data =
const data =
getConnectorDetails("stripe")["pm_list"]["PmListResponse"][
"PmListWithStripeForIdeal"
];
Expand Down Expand Up @@ -147,14 +150,17 @@ describe("Payment Method list using Constraint Graph flow tests", () => {

// creating payment with currency as INR and no billing address
it("create-payment-call-test", () => {
let data = getConnectorDetails("stripe")["pm_list"]["PaymentIntent"];
let req_data = data["RequestCurrencyINR"];
let res_data = data["Response"];
const data = getConnectorDetails("stripe")["pm_list"]["PaymentIntent"];

const newData = {
...data,
Request: data.RequestCurrencyINR,
RequestCurrencyINR: undefined, // we do not need this anymore
};

cy.createPaymentIntentTest(
create_payment_body_with_currency("INR"),
req_data,
res_data,
newData,
"no_three_ds",
"automatic",
globalState
Expand All @@ -163,7 +169,7 @@ describe("Payment Method list using Constraint Graph flow tests", () => {

// payment method list which should only have ideal with stripe
it("payment-method-list-call-test", () => {
let data =
const data =
getConnectorDetails("stripe")["pm_list"]["PmListResponse"][
"PmListNull"
];
Expand Down Expand Up @@ -227,14 +233,17 @@ describe("Payment Method list using Constraint Graph flow tests", () => {

// creating payment with currency as USD and billing address as US
it("create-payment-call-test", () => {
let data = getConnectorDetails("stripe")["pm_list"]["PaymentIntent"];
let req_data = data["RequestCurrencyUSD"];
let res_data = data["Response"];
const data = getConnectorDetails("stripe")["pm_list"]["PaymentIntent"];

const newData = {
...data,
Request: data.RequestCurrencyUSD,
RequestCurrencyUSD: undefined, // we do not need this anymore
};

cy.createPaymentIntentTest(
create_payment_body_with_currency("USD"),
req_data,
res_data,
newData,
"no_three_ds",
"automatic",
globalState
Expand All @@ -243,7 +252,7 @@ describe("Payment Method list using Constraint Graph flow tests", () => {

// payment method list which should only have credit with Stripe and Cybersource
it("payment-method-list-call-test", () => {
let data =
const data =
getConnectorDetails("stripe")["pm_list"]["PmListResponse"][
"PmListWithCreditTwoConnector"
];
Expand Down Expand Up @@ -307,14 +316,17 @@ describe("Payment Method list using Constraint Graph flow tests", () => {

// creating payment with currency as EUR and billing address as US
it("create-payment-call-test", () => {
let data = getConnectorDetails("stripe")["pm_list"]["PaymentIntent"];
let req_data = data["RequestCurrencyEUR"];
let res_data = data["Response"];
const data = getConnectorDetails("stripe")["pm_list"]["PaymentIntent"];

const newData = {
...data,
Request: data.RequestCurrencyEUR,
RequestCurrencyEUR: undefined, // we do not need this anymore
};

cy.createPaymentIntentTest(
create_payment_body_with_currency_country("EUR", "US", "US"),
req_data,
res_data,
newData,
"no_three_ds",
"automatic",
globalState
Expand All @@ -323,7 +335,7 @@ describe("Payment Method list using Constraint Graph flow tests", () => {

// payment method list which shouldn't have anything
it("payment-method-list-call-test", () => {
let data =
const data =
getConnectorDetails("stripe")["pm_list"]["PmListResponse"][
"PmListNull"
];
Expand Down Expand Up @@ -389,14 +401,17 @@ describe("Payment Method list using Constraint Graph flow tests", () => {

// creating payment with currency as USD and billing address as IN
it("create-payment-call-test", () => {
let data = getConnectorDetails("stripe")["pm_list"]["PaymentIntent"];
let req_data = data["RequestCurrencyUSD"];
let res_data = data["Response"];
const data = getConnectorDetails("stripe")["pm_list"]["PaymentIntent"];

const newData = {
...data,
Request: data.RequestCurrencyUSD,
RequestCurrencyUSD: undefined, // we do not need this anymore
};

cy.createPaymentIntentTest(
create_payment_body_with_currency_country("USD", "IN", "IN"),
req_data,
res_data,
newData,
"no_three_ds",
"automatic",
globalState
Expand All @@ -405,7 +420,7 @@ describe("Payment Method list using Constraint Graph flow tests", () => {

// payment method list which should have credit with stripe and cybersource and no ideal
it("payment-method-list-call-test", () => {
let data =
const data =
getConnectorDetails("stripe")["pm_list"]["PmListResponse"][
"PmListWithCreditTwoConnector"
];
Expand Down Expand Up @@ -470,14 +485,17 @@ describe("Payment Method list using Constraint Graph flow tests", () => {

// creating payment with currency as USD and billing address as IN
it("create-payment-call-test", () => {
let data = getConnectorDetails("stripe")["pm_list"]["PaymentIntent"];
let req_data = data["RequestCurrencyUSD"];
let res_data = data["Response"];
const data = getConnectorDetails("stripe")["pm_list"]["PaymentIntent"];

const newData = {
...data,
Request: data.RequestCurrencyUSD,
RequestCurrencyUSD: undefined, // we do not need this anymore
};

cy.createPaymentIntentTest(
create_payment_body_with_currency("USD"),
req_data,
res_data,
newData,
"no_three_ds",
"automatic",
globalState
Expand All @@ -486,7 +504,7 @@ describe("Payment Method list using Constraint Graph flow tests", () => {

// payment method list which should have credit with stripe and cybersource and no ideal
it("payment-method-list-call-test", () => {
let data =
const data =
getConnectorDetails("stripe")["pm_list"]["PmListResponse"][
"PmListWithCreditTwoConnector"
];
Expand Down Expand Up @@ -550,14 +568,17 @@ describe("Payment Method list using Constraint Graph flow tests", () => {

// creating payment with currency as EUR and no billing address
it("create-payment-call-test", () => {
let data = getConnectorDetails("stripe")["pm_list"]["PaymentIntent"];
let req_data = data["RequestCurrencyEUR"];
let res_data = data["Response"];
const data = getConnectorDetails("stripe")["pm_list"]["PaymentIntent"];

const newData = {
...data,
Request: data.RequestCurrencyEUR,
RequestCurrencyEUR: undefined, // we do not need this anymore
};

cy.createPaymentIntentTest(
create_payment_body_with_currency_country("EUR", "NL", "US"),
req_data,
res_data,
newData,
"no_three_ds",
"automatic",
globalState
Expand All @@ -566,7 +587,7 @@ describe("Payment Method list using Constraint Graph flow tests", () => {

// payment method list which should only have ideal with stripe
it("payment-method-list-call-test", () => {
let data =
const data =
getConnectorDetails("stripe")["pm_list"]["PmListResponse"][
"PmListWithStripeForIdeal"
];
Expand Down
9 changes: 0 additions & 9 deletions cypress-tests/cypress/e2e/PaymentMethodListUtils/Commons.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,3 @@
import State from "../../utils/State";

const globalState = new State({
connectorId: Cypress.env("CONNECTOR"),
baseUrl: Cypress.env("BASEURL"),
adminApiKey: Cypress.env("ADMINAPIKEY"),
connectorAuthFilePath: Cypress.env("CONNECTOR_AUTH_FILE_PATH"),
});

export const card_credit_enabled = [
{
payment_method: "card",
Expand Down
8 changes: 0 additions & 8 deletions cypress-tests/cypress/e2e/PaymentMethodListUtils/Stripe.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,3 @@
const successfulNo3DSCardDetails = {
card_number: "4242424242424242",
card_exp_month: "10",
card_exp_year: "50",
card_holder_name: "morino",
card_cvc: "737",
};

export const connectorDetails = {
pm_list: {
PaymentIntent: {
Expand Down
Loading

0 comments on commit 82caded

Please sign in to comment.