diff --git a/client/cypress/e2e/posting-bills/posting-bills.cy.js b/client/cypress/e2e/posting-bills/posting-bills.cy.js index 5df985be3..bae034d08 100644 --- a/client/cypress/e2e/posting-bills/posting-bills.cy.js +++ b/client/cypress/e2e/posting-bills/posting-bills.cy.js @@ -52,10 +52,10 @@ describe( // fill out form // data-cy="bill-form-invoice" - cy.get('[data-cy="bill-form-invoice"]').type(uniqueId("QBD246-00-")); + cy.get('[data-cy="bill-form-invoice"]').type(uniqueId("1QBD246-00-")); cy.get("#bill-form-date").click(); - cy.get('[title="2023-06-30"]').should("be.visible").click(); + cy.get('[title="2023-07-06"]').should("be.visible").click(); // get table cy.get('[data-cy="bill-line-table"]').each(($row) => { @@ -94,10 +94,10 @@ describe( // Select Line cy.antdSelect("bill-line", "-- Not On Estimate --"); // Fill the Form - cy.get('[data-cy="bill-form-invoice"]').type(uniqueId("QBD246-01-")); + cy.get('[data-cy="bill-form-invoice"]').type(uniqueId("1QBD246-01-")); cy.get("#bill-form-date").click(); - cy.get('[title="2023-06-30"]').should("be.visible").click(); + cy.get('[title="2023-07-06"]').should("be.visible").click(); // get table cy.get('[data-cy="bill-line-table"]').each(($row) => { @@ -136,10 +136,10 @@ describe( // Select Line cy.antdSelect("bill-line", "-- Not On Estimate --"); // Fill the Form - cy.get('[data-cy="bill-form-invoice"]').type(uniqueId("QBD246-02-")); + cy.get('[data-cy="bill-form-invoice"]').type(uniqueId("1QBD246-02-")); cy.get("#bill-form-date").click(); - cy.get('[title="2023-06-30"]').should("be.visible").click(); + cy.get('[title="2023-07-06"]').should("be.visible").click(); // get table cy.get('[data-cy="bill-line-table"]').each(($row) => { @@ -287,10 +287,10 @@ describe( .click(); // fill out form - cy.get('[data-cy="bill-form-invoice"]').type(uniqueId("QBD261-0")); + cy.get('[data-cy="bill-form-invoice"]').type(uniqueId("1QBD261-0")); cy.get("#bill-form-date").click(); - cy.get('[title="2023-06-30"]').should("be.visible").click(); + cy.get('[title="2023-07-06"]').should("be.visible").click(); cy.get('[data-cy="bill-form-bill-total"]').type("70.46"); cy.get('[data-cy="bill-line-actual-cost"]').type("67.10"); @@ -358,10 +358,10 @@ describe( .click(); // fill out form - cy.get('[data-cy="bill-form-invoice"]').type(uniqueId("QBD261-01-")); + cy.get('[data-cy="bill-form-invoice"]').type(uniqueId("1QBD261-01-")); cy.get("#bill-form-date").click(); - cy.get('[title="2023-06-30"]').should("be.visible").click(); + cy.get('[title="2023-07-06"]').should("be.visible").click(); cy.get('[data-cy="bill-form-bill-total"]').type("70.46"); cy.get('[data-cy="bill-line-actual-cost"]').type("67.10"); @@ -396,10 +396,10 @@ describe( .click(); // fill out form - cy.get('[data-cy="bill-form-invoice"]').type(uniqueId("QBD261-02-")); + cy.get('[data-cy="bill-form-invoice"]').type(uniqueId("1QBD261-02-")); cy.get("#bill-form-date").click(); - cy.get('[title="2023-06-30"]').should("be.visible").click(); + cy.get('[title="2023-07-06"]').should("be.visible").click(); cy.get('[data-cy="bill-form-bill-total"]').type("70.46"); cy.get('[data-cy="bill-line-actual-cost"]').type("67.10"); diff --git a/client/cypress/e2e/time-tickets/time-tickets.cy.js b/client/cypress/e2e/time-tickets/time-tickets.cy.js new file mode 100644 index 000000000..e7a3272a1 --- /dev/null +++ b/client/cypress/e2e/time-tickets/time-tickets.cy.js @@ -0,0 +1,137 @@ +import random from "lodash/random"; +import uniqid from "uniqid"; +import moment from "moment"; + +describe( + "Entering payment for the job", + { + defaultCommandTimeout: 5000, + }, + () => { + const today = moment().format("YYYY-MM-DD"); + + 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("N/A")') + .first() + .find("a") + .first() + .click(); + + cy.url().should("include", "/manage/jobs"); + }); + }); + + it("checks input validations", () => { + cy.get('[data-cy="job-actions-button"]').click(); + + cy.get('[data-cy="actions-timetickets"]') + .should("be.visible") + .and("not.be.disabled") + .click(); + + cy.get('[data-cy="timeticket-save-button"]').first().click(); + + cy.get('[data-cy="form-timeticket"]') + .find(".ant-form-item-explain-error") + .should("have.length", 4); + + cy.get('[data-cy="form-timeticket-date"]').click(); + cy.get(`[title="${today}"]`).should("be.visible").click({ force: true }); + + cy.antdSelect("timeticket-employee"); + cy.get('[data-cy="form-timeticket-employee"]').contains( + "bb Emily Appleseed" + ); + cy.antdSelect("cost-center"); + + cy.get('[data-cy="labor-allocations-table"]') + .find(".ant-table-tbody") + .find("> tr:not(.ant-table-measure-row)") + .as("orders-table") + .should("not.have.class", "ant-table-placeholder"); + + cy.get("@orders-table") + .eq(0) + .find("td:not(.ant-table-selection-column)") + .eq(4) + .find("strong") + .invoke("text") + .as("bodyDiff") + .then((diff) => { + cy.get('[data-cy="form-timeticket-productivehrs"]').type( + Number(diff) + 1 + ); + + cy.get(".ant-form-item-explain-error").should( + "have.text", + "The number of hours entered is more than what is available for this cost center." + ); + }); + }); + + it.skip("adds new time ticket to a job", () => { + cy.get('[data-cy="job-actions-button"]').click(); + + cy.get('[data-cy="actions-timetickets"]') + .should("be.visible") + .and("not.be.disabled") + .click(); + + cy.get('[data-cy="labor-allocations-table"]') + .find(".ant-table-tbody") + .find("> tr:not(.ant-table-measure-row)") + .as("orders-table") + .should("not.have.class", "ant-table-placeholder"); + + // Get Difference for Body + cy.get('[data-cy="form-timeticket-date"]').click(); + cy.get(`[title="${today}"]`).should("be.visible").click(); + + cy.get("@orders-table") + .eq(0) + .find("td:not(.ant-table-selection-column)") + .eq(4) + .find("strong") + .invoke("text") + .as("bodyDiff") + .then((diff) => { + const hours = random(diff); + const actualHrs = random(hours); + + cy.get('[data-cy="form-timeticket-productivehrs"]').type( + hours.toFixed(1) + ); + + cy.get('[data-cy="form-timeticket-actualhrs"]').type( + actualHrs.toFixed(1) + ); + }); + + cy.antdSelect("timeticket-employee"); + cy.get('[data-cy="form-timeticket-employee"]').contains( + "bb Emily Appleseed" + ); + cy.antdSelect("cost-center"); + // cy.get('@bodyDiff').then(diff => {}) + cy.get('[data-cy="form-timeticket-memo"]').type(uniqid()); + + cy.get('[data-cy="timeticket-save-button"]').first().click(); + }); + } +); diff --git a/client/cypress/support/commands.js b/client/cypress/support/commands.js index ad0a364b5..5a28da167 100644 --- a/client/cypress/support/commands.js +++ b/client/cypress/support/commands.js @@ -56,12 +56,21 @@ Cypress.Commands.add("antdSelect", (selector, filter) => { .invoke("attr", "id") .then((selElm) => { const dropDownSelector = `#${selElm}_list`; - cy.get(dropDownSelector) - .next() - .find(".ant-select-item-option-content") - .not(`:contains("${filter}")`) - .first() - .click(); + + if (filter) { + cy.get(dropDownSelector) + .next() + .find(".ant-select-item-option-content") + .not(`:contains("${filter}")`) + .first() + .click({ force: true }); + } else { + cy.get(dropDownSelector) + .next() + .find(".ant-select-item-option-content") + .first() + .click({ force: true }); + } }); }); diff --git a/client/package.json b/client/package.json index b086a4596..42bb10291 100644 --- a/client/package.json +++ b/client/package.json @@ -70,6 +70,7 @@ "socket.io-client": "^4.6.1", "styled-components": "^5.3.6", "subscriptions-transport-ws": "^0.11.0", + "uniqid": "^5.4.0", "web-vitals": "^2.1.4", "workbox-background-sync": "^6.5.3", "workbox-broadcast-update": "^6.5.3", diff --git a/client/src/components/jobs-detail-header-actions/jobs-detail-header-actions.component.jsx b/client/src/components/jobs-detail-header-actions/jobs-detail-header-actions.component.jsx index cd53ef4ea..987fa2c3c 100644 --- a/client/src/components/jobs-detail-header-actions/jobs-detail-header-actions.component.jsx +++ b/client/src/components/jobs-detail-header-actions/jobs-detail-header-actions.component.jsx @@ -244,7 +244,9 @@ export function JobsDetailHeaderActions({ }); }} > - {t("timetickets.actions.enter")} + + {t("timetickets.actions.enter")} +