Skip to content

Commit

Permalink
Merge branch 'main' into ntid/refactor-mit-priority
Browse files Browse the repository at this point in the history
  • Loading branch information
ShankarSinghC authored Jan 21, 2025
2 parents c1edf5e + 90c932a commit 7b8a37d
Show file tree
Hide file tree
Showing 6 changed files with 74 additions and 17 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/cypress-tests-runner.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ env:
CARGO_INCREMENTAL: 0
CARGO_NET_RETRY: 10
PAYMENTS_CONNECTORS: "cybersource stripe"
PAYOUTS_CONNECTORS: "adyenplatform wise"
PAYOUTS_CONNECTORS: "wise"
RUST_BACKTRACE: short
RUSTUP_MAX_RETRIES: 10
RUN_TESTS: ${{ ((github.event_name == 'pull_request') && (github.event.pull_request.head.repo.full_name == github.event.pull_request.base.repo.full_name)) || (github.event_name == 'merge_group')}}
Expand Down Expand Up @@ -149,7 +149,7 @@ jobs:
run: |
LOCAL_ADMIN_API_KEY=$(yq '.secrets.admin_api_key' ${TOML_PATH})
echo "CYPRESS_ADMINAPIKEY=${LOCAL_ADMIN_API_KEY}" >> $GITHUB_ENV
- name: Install mold linker
if: ${{ runner.os == 'Linux' && env.RUN_TESTS == 'true' }}
uses: rui314/setup-mold@v1
Expand Down
9 changes: 7 additions & 2 deletions cypress-tests/.gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
# Mac OS files
.DS_Store

# Output files
reports/
screenshots/
videos/

creds.json
reports
run_all.sh
screenshots
17 changes: 16 additions & 1 deletion cypress-tests/cypress.config.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { defineConfig } from "cypress";
import mochawesome from "cypress-mochawesome-reporter/plugin.js";
import fs from "fs";

let globalState;

Expand Down Expand Up @@ -28,7 +29,18 @@ export default defineConfig({
return null;
},
});

on("after:spec", (spec, results) => {
if (results && results.video) {
// Do we have failures for any retry attempts?
const failures = results.tests.some((test) =>
test.attempts.some((attempt) => attempt.state === "failed")
);
if (!failures) {
// delete the video if the spec passed and no tests retried
fs.unlinkSync(results.video);
}
}
});
return config;
},
experimentalRunAllSpecs: true,
Expand All @@ -47,5 +59,8 @@ export default defineConfig({
chromeWebSecurity: false,
defaultCommandTimeout: 10000,
pageLoadTimeout: 20000,
responseTimeout: 30000,
screenshotsFolder: screenshotsFolderName,
video: true,
videoCompression: 32,
});
4 changes: 2 additions & 2 deletions cypress-tests/cypress/e2e/PaymentUtils/Cybersource.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ const successfulNo3DSCardDetails = {
};

const successfulThreeDSTestCardDetails = {
card_number: "4000000000001091",
card_number: "4000000000002701",
card_exp_month: "01",
card_exp_year: "50",
card_holder_name: "joseph Doe",
Expand Down Expand Up @@ -79,7 +79,7 @@ const payment_method_data_no3ds = {

const payment_method_data_3ds = {
card: {
last4: "1091",
last4: "2701",
card_type: "CREDIT",
card_network: "Visa",
card_issuer: "INTL HDQTRS-CENTER OWNED",
Expand Down
6 changes: 6 additions & 0 deletions cypress-tests/cypress/support/e2e.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,9 @@ import "./commands";

// Alternatively you can use CommonJS syntax:
// require('./commands')

Cypress.on("uncaught:exception", (err) => {
// returning false here prevents Cypress from failing the test
cy.log(`Unhandled exception: ${err}`);
return false;
});
51 changes: 41 additions & 10 deletions cypress-tests/cypress/support/redirectionHandler.js
Original file line number Diff line number Diff line change
Expand Up @@ -272,12 +272,18 @@ function bankRedirectRedirection(
}

cy.then(() => {
verifyReturnUrl(redirection_url, expected_url, verifyUrl);
try {
verifyReturnUrl(redirection_url, expected_url, verifyUrl);
} catch (error) {
cy.log("Error during return URL verification:", error);
throw error;
}
});
}

function threeDsRedirection(redirection_url, expected_url, connectorId) {
cy.visit(redirection_url.href);

if (connectorId === "adyen") {
cy.get("iframe")
.its("0.contentDocument.body")
Expand All @@ -286,17 +292,32 @@ function threeDsRedirection(redirection_url, expected_url, connectorId) {
cy.get('input[type="password"]').type("password");
cy.get("#buttonSubmit").click();
});
} else if (
connectorId === "bankofamerica" ||
connectorId === "cybersource" ||
connectorId === "wellsfargo"
) {
} else if (connectorId === "bankofamerica" || connectorId === "wellsfargo") {
// Wait for iframe to be present and visible
cy.get("iframe", { timeout: TIMEOUT })
.should("be.visible")
.its("0.contentDocument.body")
.should("not.be.empty") // Ensure body has content
.within(() => {
cy.get('input[type="text"]').click().type("1234");
cy.get('input[value="SUBMIT"]').click();
// Add retry ability and multiple selector attempts
cy.get(
'input[type="text"], input[type="password"], input[name="challengeDataEntry"]',
{ timeout: TIMEOUT }
)
.should("be.visible")
.should("be.enabled")
.click()
.type("1234");

cy.get('input[value="SUBMIT"], button[type="submit"]', {
timeout: TIMEOUT,
})
.should("be.visible")
.click();
});
} else if (connectorId === "cybersource") {
cy.url({ timeout: TIMEOUT }).should("include", expected_url.origin);
return; // this is mandatory, else refunds section will fail with unhandled promise rejections even though it is handled
} else if (connectorId === "checkout") {
cy.get("iframe", { timeout: TIMEOUT })
.its("0.contentDocument.body")
Expand Down Expand Up @@ -381,7 +402,12 @@ function threeDsRedirection(redirection_url, expected_url, connectorId) {
}

cy.then(() => {
verifyReturnUrl(redirection_url, expected_url, true);
try {
verifyReturnUrl(redirection_url, expected_url, true);
} catch (error) {
cy.log("Error during return URL verification:", error);
throw error;
}
});
}

Expand Down Expand Up @@ -422,7 +448,12 @@ function upiRedirection(
}

cy.then(() => {
verifyReturnUrl(redirection_url, expected_url, verifyUrl);
try {
verifyReturnUrl(redirection_url, expected_url, verifyUrl);
} catch (error) {
cy.log("Error during return URL verification:", error);
throw error;
}
});
}

Expand Down

0 comments on commit 7b8a37d

Please sign in to comment.