Skip to content

Commit

Permalink
test: creation of test payment using sdk cypress (#1555)
Browse files Browse the repository at this point in the history
  • Loading branch information
s-vamshi authored Oct 23, 2024
1 parent c571a28 commit 1bd1e56
Show file tree
Hide file tree
Showing 3 changed files with 57 additions and 11 deletions.
2 changes: 1 addition & 1 deletion config/config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ primary_hover_color="#005ED6"
sidebar_color="#242F48"
[default.endpoints]
api_url="http://localhost:8080"
sdk_url=""
sdk_url="http://localhost:9050/HyperLoader.js"
logo_url=""
favicon_url=""
agreement_url=""
Expand Down
1 change: 1 addition & 0 deletions cypress.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ module.exports = defineConfig({
// with any changed environment variables
return config;
},
chromeWebSecurity: false,
},
env: {
CYPRESS_USERNAME: process.env.CYPRESS_USERNAME || "[email protected]",
Expand Down
65 changes: 55 additions & 10 deletions cypress/e2e/connector/connector.cy.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,16 @@
describe("connector", () => {
const username = `cypress${Math.round(+new Date() / 1000)}@gmail.com`;
const password = "Cypress98#";
const username = `cypress${Math.round(+new Date() / 1000)}@gmail.com`;

const getIframeBody = () => {
return cy
.get("iframe")
.its("0.contentDocument.body")
.should("not.be.empty")
.then(cy.wrap);
};

// Login before each testcase
beforeEach(() => {
before(() => {
cy.visit("http://localhost:9000/dashboard/login");
cy.url().should("include", "/login");
cy.get("[data-testid=card-header]").should(
Expand All @@ -23,16 +30,27 @@ describe("connector", () => {
cy.get('button[type="submit"]').click({ force: true });
cy.get("[data-testid=skip-now]").click({ force: true });

cy.url().should("include", "/dashboard/home");
});

it("Create a dummy connector", () => {
cy.url().should("include", "/dashboard/home");

cy.get('[data-form-label="Business name"]').should("exist");
cy.get("[data-testid=merchant_name]").type("test_business");
cy.get("[data-button-for=startExploring]").click();
cy.reload(true);
});

beforeEach(function () {
if (this.currentTest.title !== "Create a dummy connector") {
cy.visit("http://localhost:9000/dashboard/login");
cy.url().should("include", "/login");
cy.get("[data-testid=card-header]").should(
"contain",
"Hey there, Welcome back!",
);
cy.get("[data-testid=email]").type(username);
cy.get("[data-testid=password]").type(password);
cy.get('button[type="submit"]').click({ force: true });
cy.get("[data-testid=skip-now]").click({ force: true });
}
});

it("Create a dummy connector", () => {
cy.get("[data-testid=connectors]").click();
cy.get("[data-testid=paymentprocessors]").click();
cy.contains("Payment Processors").should("be.visible");
Expand Down Expand Up @@ -69,4 +87,31 @@ describe("connector", () => {
.scrollIntoView()
.should("be.visible");
});
it("Use the SDK to process a payment", () => {
cy.get("[data-testid=connectors]").click();
cy.get("[data-testid=paymentprocessors]").click();
cy.contains("Payment Processors").should("be.visible");
cy.get("[data-testid=home]").click();
cy.get("[data-button-for=tryItOut]").click();
cy.get('[data-breadcrumb="Explore Demo Checkout Experience"]').should(
"exist",
);
cy.get('[data-value="unitedStates(USD)"]').click();
cy.get('[data-dropdown-value="Germany (EUR)"]').click();
cy.get("[data-testid=amount]").find("input").clear().type("77");
cy.get("[data-button-for=showPreview]").click();
getIframeBody()
.find("[data-testid=cardNoInput]", { timeout: 20000 })
.should("exist")
.type("4242424242424242");
getIframeBody()
.find("[data-testid=expiryInput]")
.should("exist")
.type("0127");
getIframeBody().find("[data-testid=cvvInput]").should("exist").type("492");
cy.get("[data-button-for=payEUR77]").should("exist").click();
cy.contains("Payment Successful").should("be.visible");
cy.get("[data-button-for=goToPayment]").should("exist").click();
cy.url().should("include", "dashboard/payments");
});
});

0 comments on commit 1bd1e56

Please sign in to comment.