From 0a8c2bf3850737753c16b0eb27bf4e39e28fbf4a Mon Sep 17 00:00:00 2001 From: swtmply Date: Wed, 5 Jul 2023 07:32:46 +0800 Subject: [PATCH] IO-2327 payments test cases --- .../e2e/payments/entering-payments.cy.js | 89 +++++++++++++++++++ .../job-payments/job-payments.component.jsx | 3 + .../payment-form/payment-form.component.jsx | 26 +++--- .../payment-mark-export-button-component.jsx | 1 + .../payment-modal/payment-modal.container.jsx | 6 +- .../payment-reexport-button.component.jsx | 1 + .../jobs-detail.page.component.jsx | 2 +- 7 files changed, 115 insertions(+), 13 deletions(-) create mode 100644 client/cypress/e2e/payments/entering-payments.cy.js diff --git a/client/cypress/e2e/payments/entering-payments.cy.js b/client/cypress/e2e/payments/entering-payments.cy.js new file mode 100644 index 000000000..c3994103e --- /dev/null +++ b/client/cypress/e2e/payments/entering-payments.cy.js @@ -0,0 +1,89 @@ +describe( + "Entering payment for the job", + { + defaultCommandTimeout: 5000, + }, + () => { + beforeEach(() => { + cy.visit("/manage"); + + cy.get("body").then(($body) => { + if ($body.text().includes("Login")) { + // Log in + cy.get('[data-cy="username"]').type("john@imex.dev"); + cy.get('[data-cy="password"]').type("john123"); + cy.get('[data-cy="sign-in-button"]').click(); + } + + cy.get(".ant-table-tbody") + .should("be.visible") + .find("tr") + .should("not.have.class", "ant-table-placeholder"); + + cy.get(".ant-table-row") + .not(':contains("Open")') + .first() + .find("a") + .first() + .click(); + + cy.url().should("include", "/manage/jobs"); + + // Go to totals data tab + cy.get('[data-cy="tab-totals"]').should("be.visible").click(); + }); + }); + + it("enters a payment manually", () => { + cy.get('[data-cy="job-payment-button"]').should("be.visible").click(); + + // fill out form + cy.get('[data-cy="payment-amount"]').type(100); + cy.get('[data-cy="payment-transactionid"]').type("QBD-P-03"); + cy.get('[data-cy="payment-memo"]').type("e2e testing"); + cy.get('[data-cy="payment-date"]').click(); + cy.get('[title="2023-07-03"]').should("be.visible").click(); + + cy.antdSelect("payer"); + cy.antdSelect("type"); + + cy.get('[data-cy="payment-form-save"]').click(); + }); + + // TODO Add payment using intellipay + + it("marks payment as exported", () => { + cy.get('[data-cy="payments-table"]') + .find(".ant-table-tbody") + .find("> tr:not(.ant-table-measure-row)") + .as("payments-table") + .should("not.have.class", "ant-table-placeholder"); + + cy.get("@payments-table") + .first() + .find('[data-cy="edit-payment-button"]') + .click(); + + cy.get('[data-cy="payment-markexported"]') + .should("not.be.disabled") + .click(); + }); + + it("marks payment for re-export", () => { + cy.get('[data-cy="payments-table"]') + .find(".ant-table-tbody") + .find("> tr:not(.ant-table-measure-row)") + .as("payments-table") + .should("not.have.class", "ant-table-placeholder"); + + cy.get("@payments-table") + .last() + .find('[data-cy="edit-payment-button"]') + .click(); + + cy.get('[data-cy="payment-markforreexport"]') + .should("not.be.disabled") + .click(); + }); + } +); diff --git a/client/src/components/job-payments/job-payments.component.jsx b/client/src/components/job-payments/job-payments.component.jsx index f13d57bbe..6c0b25645 100644 --- a/client/src/components/job-payments/job-payments.component.jsx +++ b/client/src/components/job-payments/job-payments.component.jsx @@ -100,6 +100,7 @@ export function JobPayments({