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")} + `${record.cost_center} ${record.mod_lbr_ty}`} pagination={false} diff --git a/client/src/components/time-ticket-modal/time-ticket-modal.component.jsx b/client/src/components/time-ticket-modal/time-ticket-modal.component.jsx index 6df9f2b9f..8cbe446c0 100644 --- a/client/src/components/time-ticket-modal/time-ticket-modal.component.jsx +++ b/client/src/components/time-ticket-modal/time-ticket-modal.component.jsx @@ -113,7 +113,7 @@ export function TimeTicketModalComponent({ }, ]} > - + - + ); }} @@ -235,7 +241,10 @@ export function TimeTicketModalComponent({ }, ]} > - + )} @@ -262,7 +271,11 @@ export function TimeTicketModalComponent({ }), ]} > - + { <> @@ -320,7 +333,7 @@ export function TimeTicketModalComponent({ } - + {() => ( diff --git a/client/src/components/time-ticket-modal/time-ticket-modal.container.jsx b/client/src/components/time-ticket-modal/time-ticket-modal.container.jsx index 463b2a80c..2f202e524 100644 --- a/client/src/components/time-ticket-modal/time-ticket-modal.container.jsx +++ b/client/src/components/time-ticket-modal/time-ticket-modal.container.jsx @@ -174,7 +174,11 @@ export function TimeTicketModalContainer({ footer={ - {timeTicketModal.context && timeTicketModal.context.id ? null : ( @@ -196,6 +200,7 @@ export function TimeTicketModalContainer({ onFinish={handleFinish} layout="vertical" autoComplete={"off"} + data-cy="form-timeticket" form={form} onFinishFailed={() => setEnterAgain(false)} initialValues={ @@ -221,7 +226,11 @@ export function TimeTicketModalContainer({ - {timeTicketModal.context && timeTicketModal.context.id ? null : ( diff --git a/client/yarn.lock b/client/yarn.lock index 658548af2..c374f6d4f 100644 --- a/client/yarn.lock +++ b/client/yarn.lock @@ -13075,6 +13075,11 @@ unicode-property-aliases-ecmascript@^2.0.0: resolved "https://registry.yarnpkg.com/unicode-property-aliases-ecmascript/-/unicode-property-aliases-ecmascript-2.0.0.tgz#0a36cb9a585c4f6abd51ad1deddb285c165297c8" integrity sha512-5Zfuy9q/DFr4tfO7ZPeVXb1aPoeQSdeFMLpYuFebehDAhbuevLs5yxSZmIFN1tP5F9Wl4IpJrYojg85/zgyZHQ== +uniqid@^5.4.0: + version "5.4.0" + resolved "https://registry.yarnpkg.com/uniqid/-/uniqid-5.4.0.tgz#4e17bfcab66dfe33563411ae0c801f46ef964e66" + integrity sha512-38JRbJ4Fj94VmnC7G/J/5n5SC7Ab46OM5iNtSstB/ko3l1b5g7ALt4qzHFgGciFkyiRNtDXtLNb+VsxtMSE77A== + unique-string@^2.0.0: version "2.0.0" resolved "https://registry.yarnpkg.com/unique-string/-/unique-string-2.0.0.tgz#39c6451f81afb2749de2b233e3f7c5e8843bd89d"