From 4bb8af11ee63de3aa85e73b76e7d1d6a7fd32654 Mon Sep 17 00:00:00 2001 From: Adam Alfredsson Date: Wed, 19 Jul 2023 15:04:23 +0200 Subject: [PATCH 1/2] Add e2e existing donor donation test --- cypress/e2e/widget.js | 50 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) diff --git a/cypress/e2e/widget.js b/cypress/e2e/widget.js index 80f1198f..5bd2220b 100644 --- a/cypress/e2e/widget.js +++ b/cypress/e2e/widget.js @@ -1,3 +1,5 @@ +import mockDonor from "../fixtures/donor.json"; + describe("Widget", () => { beforeEach(() => { cy.fixture("organizations") @@ -292,4 +294,52 @@ describe("Widget", () => { cy.get("[data-cy=referral-button-10]").click(); cy.get("[data-cy=referral-text-input]").type("Referral text"); }); + + it("End-2-End for existing donor", () => { + cy.login(); + + cy.intercept("GET", "/donors/*/", { + statusCode: 200, + body: { + status: 200, + content: mockDonor, + }, + }); + + cy.visit("/min-side"); + cy.wait(500); + cy.get("[data-cy=send-donation-button]").click(); + + const randomSum = Math.floor(Math.random() * 1000) + 100; + cy.pickSingleDonation(); + cy.get("[data-cy=donation-sum-input]").type(randomSum.toString()); + cy.nextWidgetPane(); + + cy.get("[data-cy=name-input]").should("have.value", mockDonor.name); + cy.get("[data-cy=email-input]").should("have.value", mockDonor.email); + + cy.get("[data-cy=bank-method]").click({ force: true }); + cy.wait(500); + + cy.intercept("POST", "/donations/register", (req) => { + expect(req.body).to.have.property("donor"); + expect(req.body.donor).to.have.property("email", mockDonor.email); + expect(req.body.donor).to.have.property("name", mockDonor.name); + + req.reply({ + statusCode: 200, + body: { + status: 200, + content: { + KID: "87397824", + donorID: mockDonor.id, + hasAnsweredReferral: false, + paymentProviderUrl: "", + }, + }, + }); + }).as("registerDonation"); + + cy.nextWidgetPane(); + }); }); From 5fb1dcfdb4c6ff57f661bc69237ecfa051ea8e03 Mon Sep 17 00:00:00 2001 From: Adam Alfredsson Date: Wed, 19 Jul 2023 15:11:51 +0200 Subject: [PATCH 2/2] Add failing test --- cypress/e2e/widget.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/cypress/e2e/widget.js b/cypress/e2e/widget.js index 5bd2220b..95953e4d 100644 --- a/cypress/e2e/widget.js +++ b/cypress/e2e/widget.js @@ -318,6 +318,9 @@ describe("Widget", () => { cy.get("[data-cy=name-input]").should("have.value", mockDonor.name); cy.get("[data-cy=email-input]").should("have.value", mockDonor.email); + cy.get("[data-cy=tax-deduction-checkbox]").click("left"); + cy.get("[data-cy=ssn-input]").should("have.value", mockDonor.ssn); + cy.get("[data-cy=bank-method]").click({ force: true }); cy.wait(500);