Open source, composable payments platform | PCI compliant | SaaS and Self-host options | Enables connectivity to multiple payment, payout, fraud, vault and tokenization providers | Uplifts authorization with intelligent routing and revenue recovery | Reduce payment processing costs with cost observability | Reduces payment ops with reconciliation
Rust adyenbeginner-friendlyfeaturedfinancefintechhacktoberfesthigh-performanceopen-sourceorchestrationpaymentpayment-gatewaypayment-integrationpayment-processingpaymentspayments-platformrestful-apirustsdkstripeworks-with-react
test(cypress): Add dispute test cases for Stripe (#11926)
HS-QUALIBOT3476a0eb854f
diff --git a/cypress-tests/cypress/e2e/configs/Payment/Commons.js b/cypress-tests/cypress/e2e/configs/Payment/Commons.jsindex e67833a7ad..2c5967d62f 100644--- a/cypress-tests/cypress/e2e/configs/Payment/Commons.js+++ b/cypress-tests/cypress/e2e/configs/Payment/Commons.js@@ -2583,6 +2583,124 @@ export const connectorDetails = {},}),},+ Dispute: {+ ListDisputes: {+ Response: {+ status: 200,+ },+ },+ ListDisputesWithConnectorFilter: {+ Response: {+ status: 200,+ },+ },+ ListDisputesWithTimeRange: {+ Response: {+ status: 200,+ },+ },+ ListDisputesWithInvalidStatusFilter: {+ Response: {+ status: 400,+ },+ },+ ListDisputesWithInvalidStageFilter: {+ Response: {+ status: 400,+ },+ },+ ListDisputesWithLimit: {+ Response: {+ status: 200,+ },+ },+ ListDisputesWithLargeTimeRange: {+ Response: {+ status: 200,+ },+ },+ RetrieveDispute: {+ Response: {+ status: 200,+ },+ },+ RetrieveNonExistentDispute: {+ Response: {+ status: 404,+ body: {+ error: {+ code: "HE_04",+ },+ },+ },+ },+ AcceptDispute: {+ Response: {+ status: 200,+ },+ },+ AcceptNonExistentDispute: {+ Response: {+ status: 404,+ body: {+ error: {+ code: "HE_04",+ },+ },+ },+ },+ SubmitEvidence: {+ Response: {+ status: 200,+ },+ },+ SubmitEvidenceNonExistentDispute: {+ Response: {+ status: 404,+ body: {+ error: {+ code: "HE_04",+ },+ },+ },+ },+ SubmitEvidenceEmptyBody: {+ Response: {+ status: 400,+ },+ },+ RetrieveEvidence: {+ Response: {+ status: 200,+ },+ },+ AttachEvidenceFileMissingType: {+ Response: {+ status: 400,+ body: {+ error: {+ code: "IR_04",+ },+ },+ },+ },+ FetchDisputes: {+ Response: {},+ },+ FetchDisputesWithTimeRange: {+ Response: {},+ },+ FetchDisputesMissingParams: {+ Response: {+ status: 400,+ },+ },+ FetchDisputesInvalidConnector: {+ Response: {+ status: 400,+ },+ },+ },mandate_id_too_long: getCustomExchange({Request: {mandate_id: "mnd_" + "a".repeat(63),diff --git a/cypress-tests/cypress/e2e/spec/Payment/47-DisputeTests.cy.js b/cypress-tests/cypress/e2e/spec/Payment/47-DisputeTests.cy.jsnew file mode 100644index 0000000000..491fe4c39c--- /dev/null+++ b/cypress-tests/cypress/e2e/spec/Payment/47-DisputeTests.cy.js@@ -0,0 +1,351 @@+import * as fixtures from "../../../fixtures/imports";+import State from "../../../utils/State";+import getConnectorDetails from "../../configs/Payment/Utils";++let globalState;++describe("Dispute Tests", () => {+ before("seed global state", function () {+ cy.task("getGlobalState")+ .then((state) => {+ globalState = new State(state);+ })+ .then(() => {+ if (!globalState.get("connectorId")) {+ this.skip();+ }+ });+ });++ after("flush global state", () => {+ cy.task("setGlobalState", globalState.data);+ });++ context("List Disputes - Happy Path", () => {+ it("list-all-disputes", () => {+ const data = getConnectorDetails(globalState.get("connectorId"))[+ "Dispute"+ ]["ListDisputes"];++ cy.listDisputesCallTest(data, globalState);++ cy.step("Store Dispute ID if Found", () => {+ const disputeId = globalState.get("disputeId");+ if (disputeId) {+ cy.task("cli_log", `Found dispute ID: ${disputeId}`);+ } else {+ cy.task(+ "cli_log",+ "No disputes found - subsequent dispute tests may be skipped"+ );+ }+ });+ });+ });++ context("List Disputes - With Filters", () => {+ it("list-disputes-with-connector-filter", () => {+ const connectorId = globalState.get("connectorId");+ if (!connectorId) {+ cy.task("cli_log", "No connectorId found, skipping filter test");+ return;+ }++ const data =+ getConnectorDetails(connectorId)["Dispute"][+ "ListDisputesWithConnectorFilter"+ ];++ cy.listDisputesWithFilterCallTest(+ { connector: connectorId },+ data,+ globalState+ );+ });++ it("list-disputes-with-time-range-filter", () => {+ const now = new Date();+ const oneWeekAgo = new Date(now.getTime() - 7 * 24 * 60 * 60 * 1000);+ const startTime = oneWeekAgo.toISOString();+ const endTime = now.toISOString();++ const data = getConnectorDetails(globalState.get("connectorId"))[+ "Dispute"+ ]["ListDisputesWithTimeRange"];++ cy.listDisputesWithFilterCallTest(+ { start_time: startTime, end_time: endTime },+ data,+ globalState+ );+ });+ });++ context("List Disputes - Negative Cases", () => {+ it("list-disputes-with-invalid-status-filter-error", () => {+ const data = getConnectorDetails(globalState.get("connectorId"))[+ "Dispute"+ ]["ListDisputesWithInvalidStatusFilter"];++ cy.listDisputesWithFilterCallTest(+ { dispute_status: "DisputeOpened" },+ data,+ globalState+ );+ });++ it("list-disputes-with-invalid-stage-filter-error", () => {+ const data = getConnectorDetails(globalState.get("connectorId"))[+ "Dispute"+ ]["ListDisputesWithInvalidStageFilter"];++ cy.listDisputesWithFilterCallTest(+ { dispute_stage: "Dispute" },+ data,+ globalState+ );+ });+ });++ context("Retrieve Dispute - Conditional on Existing Dispute", () => {+ before(function () {+ if (!globalState.get("disputeId")) {+ this.skip();+ }+ });++ it("retrieve-existing-dispute", () => {+ const data = getConnectorDetails(globalState.get("connectorId"))[+ "Dispute"+ ]["RetrieveDispute"];++ cy.retrieveDisputeCallTest(data, globalState);+ });+ });++ context("Retrieve Dispute - Negative Cases", () => {+ it("retrieve-non-existent-dispute-error", () => {+ const nonExistentDisputeId = "dis_123456789";+ const data = getConnectorDetails(globalState.get("connectorId"))[+ "Dispute"+ ]["RetrieveNonExistentDispute"];++ cy.retrieveDisputeByIdCallTest(nonExistentDisputeId, data, globalState);+ });++ it("retrieve-dispute-with-invalid-id-format", () => {+ const invalidDisputeIds = ["invalid_id_format", "dispute_123", "123"];++ const data = getConnectorDetails(globalState.get("connectorId"))[+ "Dispute"+ ]["RetrieveNonExistentDispute"];++ invalidDisputeIds.forEach((invalidId) => {+ cy.retrieveDisputeByIdCallTest(invalidId, data, globalState);+ });+ });+ });++ context("Accept Dispute - Conditional on Existing Dispute", () => {+ before(function () {+ if (!globalState.get("disputeId")) {+ this.skip();+ }+ });++ it("accept-existing-dispute", () => {+ const data = getConnectorDetails(globalState.get("connectorId"))[+ "Dispute"+ ]["AcceptDispute"];++ cy.acceptDisputeCallTest(data, globalState);++ cy.step("Verify Dispute Status After Acceptance", () => {+ const disputeStatus = globalState.get("disputeStatus");+ cy.task("cli_log", `Dispute status after acceptance: ${disputeStatus}`);+ });+ });+ });++ context("Accept Dispute - Negative Cases", () => {+ it("accept-non-existent-dispute-error", () => {+ const nonExistentDisputeId = "dis_123456789";+ const data = getConnectorDetails(globalState.get("connectorId"))[+ "Dispute"+ ]["AcceptNonExistentDispute"];++ cy.acceptDisputeByIdCallTest(nonExistentDisputeId, data, globalState);+ });+ });++ context("Submit Dispute Evidence - Conditional on Existing Dispute", () => {+ before(function () {+ if (!globalState.get("disputeId")) {+ this.skip();+ }+ });++ it("submit-evidence-for-dispute", () => {+ const data = getConnectorDetails(globalState.get("connectorId"))[+ "Dispute"+ ]["SubmitEvidence"];++ cy.submitEvidenceCallTest(+ fixtures.disputeEvidenceBody,+ data,+ globalState+ );++ cy.step("Verify Dispute Status After Evidence Submission", () => {+ const disputeStatus = globalState.get("disputeStatus");+ cy.task(+ "cli_log",+ `Dispute status after evidence submission: ${disputeStatus}`+ );+ });+ });+ });++ context("Submit Dispute Evidence - Negative Cases", () => {+ it("submit-evidence-for-non-existent-dispute-error", () => {+ const data = getConnectorDetails(globalState.get("connectorId"))[+ "Dispute"+ ]["SubmitEvidenceNonExistentDispute"];++ cy.submitDisputeEvidenceByIdCallTest(+ {+ dispute_id: "dis_nonexistent",+ evidence: {+ cancellation_policy: "file_123",+ },+ },+ data,+ globalState+ );+ });++ it("submit-evidence-with-empty-body-error", () => {+ const data = getConnectorDetails(globalState.get("connectorId"))[+ "Dispute"+ ]["SubmitEvidenceEmptyBody"];++ cy.submitDisputeEvidenceByIdCallTest({}, data, globalState);+ });+ });++ context("Retrieve Dispute Evidence - Conditional on Existing Dispute", () => {+ before(function () {+ if (!globalState.get("disputeId")) {+ this.skip();+ }+ });++ it("retrieve-evidence-for-dispute", () => {+ const data = getConnectorDetails(globalState.get("connectorId"))[+ "Dispute"+ ]["RetrieveEvidence"];++ cy.retrieveDisputeEvidenceCallTest(data, globalState);+ });+ });++ context("Attach Evidence File - Edge Cases", () => {+ it("attach-evidence-file-without-evidence-type-error", () => {+ const data = getConnectorDetails(globalState.get("connectorId"))[+ "Dispute"+ ]["AttachEvidenceFileMissingType"];++ cy.attachDisputeEvidenceFileCallTest(data, globalState);+ });+ });++ context("Fetch Disputes from Connector", () => {+ it("fetch-disputes-from-connector-happy-path", () => {+ const connectorId = globalState.get("connectorId");+ const now = Math.floor(Date.now() / 1000);+ const oneDayAgo = now - 24 * 60 * 60;++ const data = getConnectorDetails(globalState.get("connectorId"))[+ "Dispute"+ ]["FetchDisputes"];++ cy.fetchDisputesFromConnectorCallTest(+ connectorId,+ { fetch_from: oneDayAgo, fetch_till: now },+ data,+ globalState+ );+ });++ it("fetch-disputes-with-query-params", () => {+ const connectorId = globalState.get("connectorId");+ const now = Math.floor(Date.now() / 1000);+ const oneDayAgo = now - 24 * 60 * 60;++ const data = getConnectorDetails(globalState.get("connectorId"))[+ "Dispute"+ ]["FetchDisputesWithTimeRange"];++ cy.fetchDisputesFromConnectorCallTest(+ connectorId,+ { fetch_from: oneDayAgo, fetch_till: now },+ data,+ globalState+ );+ });+ });++ context("Fetch Disputes - Negative Cases", () => {+ it("fetch-disputes-missing-required-params-error", () => {+ const connectorId = globalState.get("connectorId");+ const data = getConnectorDetails(globalState.get("connectorId"))[+ "Dispute"+ ]["FetchDisputesMissingParams"];++ cy.fetchDisputesFromConnectorCallTest(+ connectorId,+ { fetch_from: "true" },+ data,+ globalState+ );+ });++ it("fetch-disputes-invalid-connector-id", () => {+ const data = getConnectorDetails(globalState.get("connectorId"))[+ "Dispute"+ ]["FetchDisputesInvalidConnector"];++ cy.fetchDisputesFromConnectorCallTest(+ "invalid_connector",+ {},+ data,+ globalState+ );+ });+ });++ context("Edge Cases and Boundary Tests", () => {+ it("list-disputes-pagination-edge-case", () => {+ const data = getConnectorDetails(globalState.get("connectorId"))[+ "Dispute"+ ]["ListDisputesWithLimit"];++ cy.listDisputesWithFilterCallTest({ limit: "1" }, data, globalState);+ });++ it("list-disputes-large-time-range", () => {+ const startTime = new Date("2020-01-01").toISOString();+ const endTime = new Date().toISOString();++ const data = getConnectorDetails(globalState.get("connectorId"))[+ "Dispute"+ ]["ListDisputesWithLargeTimeRange"];++ cy.listDisputesWithFilterCallTest(+ { start_time: startTime, end_time: endTime },+ data,+ globalState+ );+ });+ });+});diff --git a/cypress-tests/cypress/fixtures/dispute-evidence-body.json b/cypress-tests/cypress/fixtures/dispute-evidence-body.jsonnew file mode 100644index 0000000000..63883133ab--- /dev/null+++ b/cypress-tests/cypress/fixtures/dispute-evidence-body.json@@ -0,0 +1,22 @@+{+ "dispute_id": "",+ "evidence": {+ "product_description": "Test product description for dispute evidence",+ "customer_name": "Test Customer",+ "customer_email_address": "[email protected]",+ "billing_address": {+ "line1": "1467 Harrison Street",+ "city": "San Francisco",+ "state": "CA",+ "zip": "94122",+ "country": "US"+ },+ "shipping_address": {+ "line1": "1467 Harrison Street",+ "city": "San Francisco",+ "state": "CA",+ "zip": "94122",+ "country": "US"+ }+ }+}diff --git a/cypress-tests/cypress/fixtures/imports.js b/cypress-tests/cypress/fixtures/imports.jsindex 99b262795d..dd1d70fe27 100644--- a/cypress-tests/cypress/fixtures/imports.js+++ b/cypress-tests/cypress/fixtures/imports.js@@ -25,6 +25,7 @@ import customerUpdateBody from "./update-customer-body.json";import voidBody from "./void-payment-body.json";import ntidConfirmBody from "./create-ntid-mit.json";import blocklistCreateBody from "./blocklist-create-body.json";+import disputeEvidenceBody from "./dispute-evidence-body.json";import eligibilityCheckBody from "./eligibility-check-body.json";import * as IncomingWebhookBody from "./webhooks/import";import customerCreate from "./modularPmService/modularPmServiceCustomerCreate.json";@@ -49,6 +50,7 @@ export {createPayoutBody,customerCreateBody,customerUpdateBody,+ disputeEvidenceBody,eligibilityCheckBody,gsmBody,listRefundCall,diff --git a/cypress-tests/cypress/support/commands.js b/cypress-tests/cypress/support/commands.jsindex ae83fd3e09..6fd46ab713 100644--- a/cypress-tests/cypress/support/commands.js+++ b/cypress-tests/cypress/support/commands.js@@ -6510,6 +6510,513 @@ Cypress.Commands.add(});+Cypress.Commands.add("listDisputesCallTest", (data, globalState) => {+ const { Response: resData } = data || {};++ cy.request({+ method: "GET",+ url: `${globalState.get("baseUrl")}/disputes/list`,+ headers: {+ "Content-Type": "application/json",+ "api-key": globalState.get("apiKey"),+ },+ failOnStatusCode: false,+ }).then((response) => {+ logRequestId(response.headers["x-request-id"]);++ cy.wrap(response).then(() => {+ expect(response.headers["content-type"]).to.include("application/json");+ if (response.status === 200) {+ globalState.set("disputesList", response.body.data || response.body);+ if (Array.isArray(response.body) && response.body.length > 0) {+ globalState.set("disputeId", response.body[0].dispute_id);+ } else if (response.body.data && response.body.data.length > 0) {+ globalState.set("disputeId", response.body.data[0].dispute_id);+ }+ }+ if (resData && resData.body) {+ for (const key in resData.body) {+ // Only assert if expected value is defined+ if (resData.body[key] !== undefined) {+ expect(+ response.body[key],+ `"${key}" in response body`+ ).to.deep.equal(resData.body[key]);+ }+ }+ }+ });+ });+});++Cypress.Commands.add("retrieveDisputeCallTest", (data, globalState) => {+ const { Response: resData } = data || {};+ const disputeId = globalState.get("disputeId");++ if (!disputeId) {+ cy.log("No disputeId found in globalState, skipping retrieve dispute");+ return;+ }++ cy.request({+ method: "GET",+ url: `${globalState.get("baseUrl")}/disputes/${disputeId}`,+ headers: {+ "Content-Type": "application/json",+ "api-key": globalState.get("apiKey"),+ },+ failOnStatusCode: false,+ }).then((response) => {+ logRequestId(response.headers["x-request-id"]);++ cy.wrap(response).then(() => {+ expect(response.headers["content-type"]).to.include("application/json");+ if (response.status === 200) {+ expect(response.body.dispute_id).to.equal(disputeId);+ globalState.set("disputeStage", response.body.dispute_stage);+ globalState.set("disputeStatus", response.body.dispute_status);+ }+ if (resData && resData.body) {+ for (const key in resData.body) {+ expect(resData.body[key]).to.equal(response.body[key]);+ }+ }+ });+ });+});++Cypress.Commands.add("acceptDisputeCallTest", (data, globalState) => {+ const { Response: resData } = data || {};+ const disputeId = globalState.get("disputeId");++ if (!disputeId) {+ cy.log("No disputeId found in globalState, skipping accept dispute");+ return;+ }++ cy.request({+ method: "POST",+ url: `${globalState.get("baseUrl")}/disputes/accept/${disputeId}`,+ headers: {+ "Content-Type": "application/json",+ "api-key": globalState.get("apiKey"),+ },+ failOnStatusCode: false,+ }).then((response) => {+ logRequestId(response.headers["x-request-id"]);++ cy.wrap(response).then(() => {+ expect(response.headers["content-type"]).to.include("application/json");+ if (response.status === 200) {+ globalState.set("disputeStatus", response.body.dispute_status);+ globalState.set("disputeStage", response.body.dispute_stage);+ }+ if (resData && resData.body) {+ for (const key in resData.body) {+ expect(resData.body[key]).to.equal(response.body[key]);+ }+ }+ });+ });+});++Cypress.Commands.add(+ "submitEvidenceCallTest",+ (requestBody, data, globalState) => {+ const {+ Configs: configs = {},+ Request: reqData,+ Response: resData,+ } = data || {};++ const disputeId = globalState.get("disputeId");++ if (!disputeId) {+ cy.log("No disputeId found in globalState, skipping submit evidence");+ return;+ }++ execConfig(validateConfig(configs));++ for (const key in reqData) {+ requestBody[key] = reqData[key];+ }+ requestBody.dispute_id = disputeId;++ cy.request({+ method: "POST",+ url: `${globalState.get("baseUrl")}/disputes/evidence`,+ headers: {+ "Content-Type": "application/json",+ "api-key": globalState.get("apiKey"),+ },+ failOnStatusCode: false,+ body: requestBody,+ }).then((response) => {+ logRequestId(response.headers["x-request-id"]);++ cy.wrap(response).then(() => {+ expect(response.headers["content-type"]).to.include("application/json");+ if (response.status === 200) {+ globalState.set("disputeStatus", response.body.dispute_status);+ globalState.set("disputeStage", response.body.dispute_stage);+ }+ if (resData && resData.body) {+ for (const key in resData.body) {+ expect(resData.body[key]).to.equal(response.body[key]);+ }+ }+ });+ });+ }+);++Cypress.Commands.add("retrieveDisputeEvidenceCallTest", (data, globalState) => {+ const { Response: resData } = data || {};+ const disputeId = globalState.get("disputeId");++ if (!disputeId) {+ cy.log(+ "No disputeId found in globalState, skipping retrieve dispute evidence"+ );+ return;+ }++ cy.request({+ method: "GET",+ url: `${globalState.get("baseUrl")}/disputes/evidence/${disputeId}`,+ headers: {+ "Content-Type": "application/json",+ "api-key": globalState.get("apiKey"),+ },+ failOnStatusCode: false,+ }).then((response) => {+ logRequestId(response.headers["x-request-id"]);++ cy.wrap(response).then(() => {+ expect(response.headers["content-type"]).to.include("application/json");+ if (resData && resData.body) {+ for (const key in resData.body) {+ expect(resData.body[key]).to.equal(response.body[key]);+ }+ }+ });+ });+});++Cypress.Commands.add("fetchDisputesCallTest", (data, globalState) => {+ const { Response: resData } = data || {};+ const connectorId = globalState.get("connectorId");++ if (!connectorId) {+ cy.log("No connectorId found in globalState, skipping fetch disputes");+ return;+ }++ cy.request({+ method: "GET",+ url: `${globalState.get("baseUrl")}/disputes/${connectorId}/fetch`,+ headers: {+ "Content-Type": "application/json",+ "api-key": globalState.get("apiKey"),+ },+ failOnStatusCode: false,+ }).then((response) => {+ logRequestId(response.headers["x-request-id"]);++ cy.wrap(response).then(() => {+ // fetch-disputes endpoint may return text/plain content type+ if (resData && resData.body) {+ for (const key in resData.body) {+ expect(resData.body[key]).to.deep.equal(response.body[key]);+ }+ }+ });+ });+});++Cypress.Commands.add(+ "listDisputesWithFilterCallTest",+ (queryParams, data, globalState) => {+ const { Response: resData } = data || {};++ const queryString = Object.entries(queryParams || {})+ .filter(([, v]) => v !== undefined && v !== null)+ .map(([k, v]) => `${k}=${encodeURIComponent(v)}`)+ .join("&");++ const url = `${globalState.get("baseUrl")}/disputes/list${queryString ? `?${queryString}` : ""}`;++ cy.request({+ method: "GET",+ url,+ headers: {+ "Content-Type": "application/json",+ "api-key": globalState.get("apiKey"),+ },+ failOnStatusCode: false,+ }).then((response) => {+ logRequestId(response.headers["x-request-id"]);++ cy.wrap(response).then(() => {+ if (response.status === 200) {+ if (+ response.headers["content-type"] &&+ response.headers["content-type"].includes("application/json")+ ) {+ const disputes = Array.isArray(response.body)+ ? response.body+ : response.body.data || [];+ globalState.set("disputesList", disputes);+ if (disputes.length > 0) {+ globalState.set("disputeId", disputes[0].dispute_id);+ }+ }+ if (resData && resData.body) {+ for (const key in resData.body) {+ if (resData.body[key] !== undefined) {+ expect(response.body[key]).to.deep.equal(resData.body[key]);+ }+ }+ }+ } else {+ if (resData && resData.status) {+ expect(response.status).to.equal(resData.status);+ }+ if (+ response.headers["content-type"] &&+ response.headers["content-type"].includes("application/json") &&+ response.body &&+ response.body.error+ ) {+ defaultErrorHandler(response, resData);+ }+ }+ });+ });+ }+);++Cypress.Commands.add(+ "retrieveDisputeByIdCallTest",+ (disputeId, data, globalState) => {+ const { Response: resData } = data || {};++ cy.request({+ method: "GET",+ url: `${globalState.get("baseUrl")}/disputes/${disputeId}`,+ headers: {+ "Content-Type": "application/json",+ "api-key": globalState.get("apiKey"),+ },+ failOnStatusCode: false,+ }).then((response) => {+ logRequestId(response.headers["x-request-id"]);++ cy.wrap(response).then(() => {+ if (response.status === 200) {+ expect(response.headers["content-type"]).to.include(+ "application/json"+ );+ expect(response.body.dispute_id).to.equal(disputeId);+ globalState.set("disputeStage", response.body.dispute_stage);+ globalState.set("disputeStatus", response.body.dispute_status);+ }+ if (resData && resData.status) {+ expect(response.status).to.equal(resData.status);+ }+ if (resData && resData.body) {+ if (response.body.error) {+ for (const key in resData.body.error) {+ expect(response.body.error[key]).to.equal(+ resData.body.error[key]+ );+ }+ }+ }+ });+ });+ }+);++Cypress.Commands.add(+ "acceptDisputeByIdCallTest",+ (disputeId, data, globalState) => {+ const { Response: resData } = data || {};++ cy.request({+ method: "POST",+ url: `${globalState.get("baseUrl")}/disputes/accept/${disputeId}`,+ headers: {+ "Content-Type": "application/json",+ "api-key": globalState.get("apiKey"),+ },+ failOnStatusCode: false,+ }).then((response) => {+ logRequestId(response.headers["x-request-id"]);++ cy.wrap(response).then(() => {+ if (response.status === 200) {+ expect(response.headers["content-type"]).to.include(+ "application/json"+ );+ globalState.set("disputeStatus", response.body.dispute_status);+ globalState.set("disputeStage", response.body.dispute_stage);+ }+ if (resData && resData.status) {+ expect(response.status).to.equal(resData.status);+ }+ if (resData && resData.body) {+ if (response.body.error) {+ for (const key in resData.body.error) {+ expect(response.body.error[key]).to.equal(+ resData.body.error[key]+ );+ }+ }+ }+ });+ });+ }+);++Cypress.Commands.add(+ "submitDisputeEvidenceByIdCallTest",+ (requestBody, data, globalState) => {+ const {+ Configs: configs = {},+ Request: reqData,+ Response: resData,+ } = data || {};++ execConfig(validateConfig(configs));++ for (const key in reqData) {+ requestBody[key] = reqData[key];+ }++ cy.request({+ method: "POST",+ url: `${globalState.get("baseUrl")}/disputes/evidence`,+ headers: {+ "Content-Type": "application/json",+ "api-key": globalState.get("apiKey"),+ },+ failOnStatusCode: false,+ body: requestBody,+ }).then((response) => {+ logRequestId(response.headers["x-request-id"]);++ cy.wrap(response).then(() => {+ if (response.status === 200) {+ expect(response.headers["content-type"]).to.include(+ "application/json"+ );+ globalState.set("disputeStatus", response.body.dispute_status);+ globalState.set("disputeStage", response.body.dispute_stage);+ }+ if (resData && resData.status) {+ expect(response.status).to.equal(resData.status);+ }+ if (resData && resData.body) {+ if (response.body.error) {+ for (const key in resData.body.error) {+ expect(response.body.error[key]).to.equal(+ resData.body.error[key]+ );+ }+ }+ }+ });+ });+ }+);++Cypress.Commands.add(+ "attachDisputeEvidenceFileCallTest",+ (data, globalState) => {+ const { Response: resData } = data || {};++ cy.request({+ method: "PUT",+ url: `${globalState.get("baseUrl")}/disputes/evidence`,+ headers: {+ "api-key": globalState.get("apiKey"),+ "Content-Type": "multipart/form-data",+ },+ body: {+ purpose: "dispute_evidence",+ file: "@/dev/null;filename=empty.pdf",+ },+ failOnStatusCode: false,+ }).then((response) => {+ logRequestId(response.headers["x-request-id"]);++ cy.wrap(response).then(() => {+ if (resData && resData.status) {+ expect(response.status).to.equal(resData.status);+ }+ if (resData && resData.body) {+ if (response.body.error) {+ for (const key in resData.body.error) {+ expect(response.body.error[key]).to.equal(+ resData.body.error[key]+ );+ }+ }+ }+ });+ });+ }+);++Cypress.Commands.add(+ "fetchDisputesFromConnectorCallTest",+ (connectorId, queryParams, data, globalState) => {+ const { Response: resData } = data || {};++ const queryString = Object.entries(queryParams || {})+ .filter(([, v]) => v !== undefined && v !== null)+ .map(([k, v]) => `${k}=${encodeURIComponent(v)}`)+ .join("&");++ const url = `${globalState.get("baseUrl")}/disputes/${connectorId}/fetch${queryString ? `?${queryString}` : ""}`;++ cy.request({+ method: "GET",+ url,+ headers: {+ "Content-Type": "application/json",+ "api-key": globalState.get("apiKey"),+ },+ failOnStatusCode: false,+ }).then((response) => {+ logRequestId(response.headers["x-request-id"]);++ cy.wrap(response).then(() => {+ if (response.status === 200) {+ cy.task(+ "cli_log",+ `Fetched disputes from connector ${connectorId}: ${JSON.stringify(response.body)}`+ );+ }+ if (resData && resData.status) {+ expect(response.status).to.equal(resData.status);+ }+ if (resData && resData.body) {+ if (response.body.error) {+ for (const key in resData.body.error) {+ expect(response.body.error[key]).to.deep.equal(+ resData.body.error[key]+ );+ }+ }+ }+ });+ });+ }+);+Cypress.Commands.add("blocklistToggle", (status, globalState) => {const apiKey = globalState.get("apiKey");const baseUrl = globalState.get("baseUrl");