mirror of
https://github.com/juspay/hyperswitch.git
synced 2025-10-30 01:27:31 +08:00
feat(cypress-v2): introduce list apis to cypress v2 (#5973)
This commit is contained in:
@ -59,6 +59,15 @@ describe("Core APIs", () => {
|
|||||||
globalState
|
globalState
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
it("Second merchant account create call", () => {
|
||||||
|
cy.merchantAccountCreateCall(
|
||||||
|
fixtures.merchant_account_body.ma_create,
|
||||||
|
globalState
|
||||||
|
);
|
||||||
|
});
|
||||||
|
it("List merchant accounts call", () => {
|
||||||
|
cy.merchantAccountsListCall(globalState);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
context("Business profile APIs", () => {
|
context("Business profile APIs", () => {
|
||||||
@ -87,6 +96,16 @@ describe("Core APIs", () => {
|
|||||||
globalState
|
globalState
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
it("Second business profile create call", () => {
|
||||||
|
fixtures.business_profile_body.bp_create.profile_name = "HyperSx2";
|
||||||
|
cy.businessProfileCreateCall(
|
||||||
|
fixtures.business_profile_body.bp_create,
|
||||||
|
globalState
|
||||||
|
);
|
||||||
|
});
|
||||||
|
it("List business profiles", () => {
|
||||||
|
cy.businessProfilesListCall(globalState);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
context("Merchant connector account APIs", () => {
|
context("Merchant connector account APIs", () => {
|
||||||
@ -127,6 +146,9 @@ describe("Core APIs", () => {
|
|||||||
payment_methods_enabled
|
payment_methods_enabled
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
it("[Payment] Merchant connector accounts list call", () => {
|
||||||
|
cy.mcaListCall(globalState, null);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
context("API Key APIs", () => {
|
context("API Key APIs", () => {
|
||||||
@ -149,5 +171,11 @@ describe("Core APIs", () => {
|
|||||||
it("API Key update call", () => {
|
it("API Key update call", () => {
|
||||||
cy.apiKeyUpdateCall(fixtures.api_key_body.api_key_update, globalState);
|
cy.apiKeyUpdateCall(fixtures.api_key_body.api_key_update, globalState);
|
||||||
});
|
});
|
||||||
|
it("Second API Key create call", () => {
|
||||||
|
cy.apiKeyCreateCall(fixtures.api_key_body.api_key_create, globalState);
|
||||||
|
});
|
||||||
|
it("API Keys list call", () => {
|
||||||
|
cy.apiKeysListCall(globalState);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@ -37,7 +37,7 @@ describe("Routing core APIs", () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it("List MCA call", () => {
|
it("List MCA call", () => {
|
||||||
cy.listMcaCall(globalState);
|
cy.mcaListCall(globalState, "routing");
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@ -167,7 +167,7 @@ Cypress.Commands.add(
|
|||||||
const api_key = globalState.get("adminApiKey");
|
const api_key = globalState.get("adminApiKey");
|
||||||
const base_url = globalState.get("baseUrl");
|
const base_url = globalState.get("baseUrl");
|
||||||
const organization_id = globalState.get("organizationId");
|
const organization_id = globalState.get("organizationId");
|
||||||
const url = `${base_url}/v2/accounts`;
|
const url = `${base_url}/v2/merchant_accounts`;
|
||||||
|
|
||||||
const merchant_name = merchantAccountCreateBody.merchant_name
|
const merchant_name = merchantAccountCreateBody.merchant_name
|
||||||
.replaceAll(" ", "")
|
.replaceAll(" ", "")
|
||||||
@ -221,7 +221,7 @@ Cypress.Commands.add("merchantAccountRetrieveCall", (globalState) => {
|
|||||||
const api_key = globalState.get("adminApiKey");
|
const api_key = globalState.get("adminApiKey");
|
||||||
const base_url = globalState.get("baseUrl");
|
const base_url = globalState.get("baseUrl");
|
||||||
const merchant_id = globalState.get("merchantId");
|
const merchant_id = globalState.get("merchantId");
|
||||||
const url = `${base_url}/v2/accounts/${merchant_id}`;
|
const url = `${base_url}/v2/merchant_accounts/${merchant_id}`;
|
||||||
|
|
||||||
cy.request({
|
cy.request({
|
||||||
method: "GET",
|
method: "GET",
|
||||||
@ -255,7 +255,7 @@ Cypress.Commands.add("merchantAccountRetrieveCall", (globalState) => {
|
|||||||
} else {
|
} else {
|
||||||
// to be updated
|
// to be updated
|
||||||
throw new Error(
|
throw new Error(
|
||||||
`Merchant retrieve call failed with status ${response.status} and message ${response.body.message}`
|
`Merchant account retrieve call failed with status ${response.status} and message ${response.body.message}`
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -267,7 +267,7 @@ Cypress.Commands.add(
|
|||||||
const api_key = globalState.get("adminApiKey");
|
const api_key = globalState.get("adminApiKey");
|
||||||
const base_url = globalState.get("baseUrl");
|
const base_url = globalState.get("baseUrl");
|
||||||
const merchant_id = globalState.get("merchantId");
|
const merchant_id = globalState.get("merchantId");
|
||||||
const url = `${base_url}/v2/accounts/${merchant_id}`;
|
const url = `${base_url}/v2/merchant_accounts/${merchant_id}`;
|
||||||
|
|
||||||
const merchant_name = merchantAccountUpdateBody.merchant_name;
|
const merchant_name = merchantAccountUpdateBody.merchant_name;
|
||||||
|
|
||||||
@ -304,7 +304,7 @@ Cypress.Commands.add(
|
|||||||
} else {
|
} else {
|
||||||
// to be updated
|
// to be updated
|
||||||
throw new Error(
|
throw new Error(
|
||||||
`Merchant update call failed with status ${response.status} and message ${response.body.message}`
|
`Merchant account update call failed with status ${response.status} and message ${response.body.message}`
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -351,7 +351,7 @@ Cypress.Commands.add(
|
|||||||
} else {
|
} else {
|
||||||
// to be updated
|
// to be updated
|
||||||
throw new Error(
|
throw new Error(
|
||||||
`Merchant update call failed with status ${response.status} and message ${response.body.message}`
|
`Business profile create call failed with status ${response.status} and message ${response.body.message}`
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -392,7 +392,7 @@ Cypress.Commands.add("businessProfileRetrieveCall", (globalState) => {
|
|||||||
} else {
|
} else {
|
||||||
// to be updated
|
// to be updated
|
||||||
throw new Error(
|
throw new Error(
|
||||||
`Merchant update call failed with status ${response.status} and message ${response.body.message}`
|
`Business profile retrieve call failed with status ${response.status} and message ${response.body.message}`
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -438,7 +438,7 @@ Cypress.Commands.add(
|
|||||||
} else {
|
} else {
|
||||||
// to be updated
|
// to be updated
|
||||||
throw new Error(
|
throw new Error(
|
||||||
`Merchant update call failed with status ${response.status} and message ${response.body.message}`
|
`Business profile update call failed with status ${response.status} and message ${response.body.message}`
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -475,6 +475,12 @@ Cypress.Commands.add(
|
|||||||
mcaCreateBody.connector_type = connectorType;
|
mcaCreateBody.connector_type = connectorType;
|
||||||
mcaCreateBody.payment_methods_enabled = paymentMethodsEnabled;
|
mcaCreateBody.payment_methods_enabled = paymentMethodsEnabled;
|
||||||
|
|
||||||
|
if (connectorName === undefined) {
|
||||||
|
throw new Error(
|
||||||
|
`Connector name is a mandatory field to create merchant connector account but is undefined.`
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
// readFile is used to read the contents of the file and it always returns a promise ([Object Object]) due to its asynchronous nature
|
// readFile is used to read the contents of the file and it always returns a promise ([Object Object]) due to its asynchronous nature
|
||||||
// it is best to use then() to handle the response within the same block of code
|
// it is best to use then() to handle the response within the same block of code
|
||||||
cy.readFile(globalState.get("connectorAuthFilePath")).then(
|
cy.readFile(globalState.get("connectorAuthFilePath")).then(
|
||||||
@ -521,7 +527,7 @@ Cypress.Commands.add(
|
|||||||
} else {
|
} else {
|
||||||
// to be updated
|
// to be updated
|
||||||
throw new Error(
|
throw new Error(
|
||||||
`MCA create call failed with status ${response.status} and message ${response.body.message}`
|
`Merchant connector account create call failed with status ${response.status} and message ${response.body.message}`
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -569,7 +575,7 @@ Cypress.Commands.add("mcaRetrieveCall", (globalState) => {
|
|||||||
} else {
|
} else {
|
||||||
// to be updated
|
// to be updated
|
||||||
throw new Error(
|
throw new Error(
|
||||||
`MCA create call failed with status ${response.status} and message ${response.body.message}`
|
`Merchant connector account retrieve call failed with status ${response.status} and message ${response.body.message}`
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -634,7 +640,7 @@ Cypress.Commands.add(
|
|||||||
} else {
|
} else {
|
||||||
// to be updated
|
// to be updated
|
||||||
throw new Error(
|
throw new Error(
|
||||||
`MCA create call failed with status ${response.status} and message ${response.body.message}`
|
`Merchant connector account update call failed with status ${response.status} and message ${response.body.message}`
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -741,7 +747,7 @@ Cypress.Commands.add("apiKeyRetrieveCall", (globalState) => {
|
|||||||
} else {
|
} else {
|
||||||
// to be updated
|
// to be updated
|
||||||
throw new Error(
|
throw new Error(
|
||||||
`API Key create call failed with status ${response.status} and message ${response.body.message}`
|
`API Key retrieve call failed with status ${response.status} and message ${response.body.message}`
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -797,7 +803,7 @@ Cypress.Commands.add("apiKeyUpdateCall", (apiKeyUpdateBody, globalState) => {
|
|||||||
} else {
|
} else {
|
||||||
// to be updated
|
// to be updated
|
||||||
throw new Error(
|
throw new Error(
|
||||||
`API Key create call failed with status ${response.status} and message ${response.body.message}`
|
`API Key update call failed with status ${response.status} and message ${response.body.message}`
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -1169,12 +1175,56 @@ Cypress.Commands.add("userInfo", (globalState) => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
// List API calls
|
// List API calls
|
||||||
Cypress.Commands.add("listMcaCall", (globalState) => {
|
Cypress.Commands.add("merchantAccountsListCall", (globalState) => {
|
||||||
|
// Define the necessary variables and constants
|
||||||
|
const api_key = globalState.get("adminApiKey");
|
||||||
|
const base_url = globalState.get("baseUrl");
|
||||||
|
const organization_id = globalState.get("organizationId");
|
||||||
|
const url = `${base_url}/v2/organization/${organization_id}/merchant_accounts`;
|
||||||
|
|
||||||
|
cy.request({
|
||||||
|
method: "GET",
|
||||||
|
url: url,
|
||||||
|
headers: {
|
||||||
|
"api-key": api_key,
|
||||||
|
"Content-Type": "application/json",
|
||||||
|
},
|
||||||
|
failOnStatusCode: false,
|
||||||
|
}).then((response) => {
|
||||||
|
logRequestId(response.headers["x-request-id"]);
|
||||||
|
|
||||||
|
if (response.status === 200) {
|
||||||
|
expect(response.body).to.be.an("array").and.to.not.be.empty;
|
||||||
|
for (const key in response.body) {
|
||||||
|
expect(response.body[key]).to.have.property("id").and.to.not.be.empty;
|
||||||
|
expect(response.body[key])
|
||||||
|
.to.have.property("organization_id")
|
||||||
|
.and.to.equal(organization_id);
|
||||||
|
if (base_url.includes("integ") || base_url.includes("sandbox")) {
|
||||||
|
expect(response.body[key])
|
||||||
|
.to.have.property("publishable_key")
|
||||||
|
.and.include("pk_snd_").and.to.not.be.empty;
|
||||||
|
} else if (base_url.includes("localhost")) {
|
||||||
|
expect(response.body[key])
|
||||||
|
.to.have.property("publishable_key")
|
||||||
|
.and.include("pk_dev_").and.to.not.be.empty;
|
||||||
|
}
|
||||||
|
expect(response.body[key]).to.have.property("id").and.to.not.be.empty;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
// to be updated
|
||||||
|
throw new Error(
|
||||||
|
`API Keys list call failed with status ${response.status} and message ${response.body.message}`
|
||||||
|
);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
Cypress.Commands.add("businessProfilesListCall", (globalState) => {
|
||||||
// Define the necessary variables and constants
|
// Define the necessary variables and constants
|
||||||
const api_key = globalState.get("adminApiKey");
|
const api_key = globalState.get("adminApiKey");
|
||||||
const base_url = globalState.get("baseUrl");
|
const base_url = globalState.get("baseUrl");
|
||||||
const merchant_id = globalState.get("merchantId");
|
const merchant_id = globalState.get("merchantId");
|
||||||
const url = `${base_url}/v2/account/${merchant_id}/connectors`;
|
const url = `${base_url}/v2/merchant_accounts/${merchant_id}/profiles`;
|
||||||
|
|
||||||
const customHeaders = {
|
const customHeaders = {
|
||||||
"x-merchant-id": merchant_id,
|
"x-merchant-id": merchant_id,
|
||||||
@ -1193,55 +1243,120 @@ Cypress.Commands.add("listMcaCall", (globalState) => {
|
|||||||
logRequestId(response.headers["x-request-id"]);
|
logRequestId(response.headers["x-request-id"]);
|
||||||
|
|
||||||
if (response.status === 200) {
|
if (response.status === 200) {
|
||||||
// Control never comes here until the API endpoints are introduced
|
expect(response.body).to.be.an("array").and.to.not.be.empty;
|
||||||
console.log("List MCA call successful");
|
for (const key in response.body) {
|
||||||
globalState.set(
|
expect(response.body[key]).to.have.property("id").and.to.not.be.empty;
|
||||||
"adyenMerchantConnectorId",
|
expect(response.body[key])
|
||||||
response.body[2].merchant_connector_id
|
.to.have.property("merchant_id")
|
||||||
);
|
.and.to.equal(merchant_id);
|
||||||
globalState.set(
|
expect(response.body[key]).to.have.property("payment_response_hash_key")
|
||||||
"bluesnapMerchantConnectorId",
|
.and.to.not.be.empty;
|
||||||
response.body[0].merchant_connector_id
|
|
||||||
);
|
|
||||||
globalState.set(
|
|
||||||
"stripeMerchantConnectorId",
|
|
||||||
response.body[1].merchant_connector_id
|
|
||||||
);
|
|
||||||
} else if (response.status === 404) {
|
|
||||||
expect(response.body.error)
|
|
||||||
.to.have.property("message")
|
|
||||||
.and.to.equal("Unrecognized request URL");
|
|
||||||
expect(response.body.error)
|
|
||||||
.to.have.property("type")
|
|
||||||
.and.to.equal("invalid_request");
|
|
||||||
|
|
||||||
// hard code MCA values for now
|
|
||||||
if (base_url.includes("integ")) {
|
|
||||||
globalState.set("adyenMerchantConnectorId", "mca_YOGOW6CdrjudsT9Mvg7w");
|
|
||||||
globalState.set(
|
|
||||||
"bluesnapMerchantConnectorId",
|
|
||||||
"mca_cdKJoouwpmkHqwVJ1bzV"
|
|
||||||
);
|
|
||||||
globalState.set(
|
|
||||||
"stripeMerchantConnectorId",
|
|
||||||
"mca_KyxoOnfLXWE1hzPSsl9H"
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// to be updated
|
// to be updated
|
||||||
throw new Error(
|
throw new Error(
|
||||||
`MCA list call failed with status ${response.status} and message ${response.body.message}`
|
`API Keys list call failed with status ${response.status} and message ${response.body.message}`
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
Cypress.Commands.add("mcaListCall", (globalState, service_type) => {
|
||||||
|
// Define the necessary variables and constants
|
||||||
|
const api_key = globalState.get("adminApiKey");
|
||||||
|
const base_url = globalState.get("baseUrl");
|
||||||
|
const merchant_id = globalState.get("merchantId");
|
||||||
|
const profile_id = globalState.get("profileId");
|
||||||
|
const url = `${base_url}/v2/profiles/${profile_id}/connector_accounts`;
|
||||||
|
|
||||||
|
const customHeaders = {
|
||||||
|
"x-merchant-id": merchant_id,
|
||||||
|
};
|
||||||
|
|
||||||
|
cy.request({
|
||||||
|
method: "GET",
|
||||||
|
url: url,
|
||||||
|
headers: {
|
||||||
|
"api-key": api_key,
|
||||||
|
"Content-Type": "application/json",
|
||||||
|
...customHeaders,
|
||||||
|
},
|
||||||
|
failOnStatusCode: false,
|
||||||
|
}).then((response) => {
|
||||||
|
logRequestId(response.headers["x-request-id"]);
|
||||||
|
|
||||||
|
if (response.status === 200) {
|
||||||
|
// TODO: Update List MCA such that it should handle cases for both routing as well normal calls
|
||||||
|
// TODO: Present implementation looks a bit hacky
|
||||||
|
if (service_type === "routing") {
|
||||||
|
if (response.body[0].connector_name === "stripe")
|
||||||
|
globalState.set("stripeMerchantConnectorId", response.body[0].id);
|
||||||
|
if (response.body[1].connector_name === "adyen")
|
||||||
|
globalState.set("adyenMerchantConnectorId", response.body[1].id);
|
||||||
|
if (response.body[2].connector_name === "bluesnap")
|
||||||
|
globalState.set("bluesnapMerchantConnectorId", response.body[2].id);
|
||||||
|
} else {
|
||||||
|
expect(response.body).to.be.an("array").and.to.not.be.empty;
|
||||||
|
for (const key in response.body) {
|
||||||
|
expect(response.body[key]).to.have.property("connector_name").and.to
|
||||||
|
.not.be.empty;
|
||||||
|
expect(response.body[key]).to.have.property("connector_label").and.to
|
||||||
|
.not.be.empty;
|
||||||
|
expect(response.body[key]).to.have.property("id").and.to.not.be.empty;
|
||||||
|
expect(response.body[key])
|
||||||
|
.to.have.property("payment_methods_enabled")
|
||||||
|
.and.to.be.an("array").and.to.not.be.empty;
|
||||||
|
expect(response.body[key])
|
||||||
|
.to.have.property("profile_id")
|
||||||
|
.and.to.equal(profile_id);
|
||||||
|
expect(response.body[key])
|
||||||
|
.to.have.property("status")
|
||||||
|
.and.to.equal("active");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
// to be updated
|
||||||
|
throw new Error(
|
||||||
|
`Merchant connector account list call failed with status ${response.status} and message ${response.body.message}`
|
||||||
|
);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
Cypress.Commands.add("apiKeysListCall", (globalState) => {
|
||||||
|
// Define the necessary variables and constants
|
||||||
|
const api_key = globalState.get("adminApiKey");
|
||||||
|
const base_url = globalState.get("baseUrl");
|
||||||
|
const merchant_id = globalState.get("merchantId");
|
||||||
|
const url = `${base_url}/v2/api_keys/list`;
|
||||||
|
|
||||||
|
const customHeaders = {
|
||||||
|
"x-merchant-id": merchant_id,
|
||||||
|
};
|
||||||
|
|
||||||
|
cy.request({
|
||||||
|
method: "GET",
|
||||||
|
url: url,
|
||||||
|
headers: {
|
||||||
|
"api-key": api_key,
|
||||||
|
"Content-Type": "application/json",
|
||||||
|
...customHeaders,
|
||||||
|
},
|
||||||
|
failOnStatusCode: false,
|
||||||
|
}).then((response) => {
|
||||||
|
logRequestId(response.headers["x-request-id"]);
|
||||||
|
|
||||||
|
if (response.status === 200) {
|
||||||
|
// This end point does not work
|
||||||
|
expect(response.body).to.be.an("array").and.to.not.be.empty;
|
||||||
|
} else {
|
||||||
|
// to be updated
|
||||||
|
throw new Error(
|
||||||
|
`API Keys list call failed with status ${response.status} and message ${response.body.message}`
|
||||||
|
);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
// templates
|
// templates
|
||||||
Cypress.Commands.add("", () => {
|
Cypress.Commands.add("", () => {
|
||||||
cy.request({}).then((response) => {});
|
cy.request({}).then((response) => {});
|
||||||
});
|
});
|
||||||
Cypress.Commands.add("", () => {
|
|
||||||
cy.request({}).then((response) => {});
|
|
||||||
});
|
|
||||||
Cypress.Commands.add("", () => {
|
|
||||||
cy.request({}).then((response) => {});
|
|
||||||
});
|
|
||||||
|
|||||||
Reference in New Issue
Block a user