IO-2327 timetickets validation
This commit is contained in:
137
client/cypress/e2e/time-tickets/time-tickets.cy.js
Normal file
137
client/cypress/e2e/time-tickets/time-tickets.cy.js
Normal file
@@ -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();
|
||||
});
|
||||
}
|
||||
);
|
||||
Reference in New Issue
Block a user