IO-2327 timetickets test cases

This commit is contained in:
swtmply
2023-08-24 12:03:36 +08:00
parent eb075d732a
commit c4a961fc03
3 changed files with 53 additions and 36 deletions

View File

@@ -1,6 +1,8 @@
import random from "lodash/random";
import uniqid from "uniqid";
import moment from "moment";
import job2 from "../../fixtures/jobs/job-4.json";
const uuid = () => Cypress._.random(0, 1e6);
describe(
"Entering payment for the job",
@@ -13,28 +15,27 @@ describe(
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();
// TODO add bodyshop query to get the employees data for labor
cy.intercept("POST", Cypress.env("graphql_dev_endpoint"), (req) => {
if (req.body.operationName === "QUERY_BODYSHOP") {
req.alias = "bodyshop";
}
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");
});
cy.get('[data-cy="active-jobs-table"]')
.find(".ant-table-tbody")
.find("> tr:not(.ant-table-measure-row)")
.as("active-jobs-table")
.should("not.have.class", "ant-table-placeholder");
cy.get("@active-jobs-table")
.contains(job2.clm_no)
.first()
.parent()
.find('[data-cy="active-job-link"]')
.click();
cy.url().should("include", "/manage/jobs");
});
it("checks input validations", () => {
@@ -54,19 +55,18 @@ describe(
cy.get('[data-cy="form-timeticket-date"]').click();
cy.get(`[title="${today}"]`).should("be.visible").click({ force: true });
// TODO select employee from the bodyshop
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")
.as("labor-allocations")
.should("not.have.class", "ant-table-placeholder");
cy.get("@orders-table")
cy.get("@labor-allocations")
.eq(0)
.find("td:not(.ant-table-selection-column)")
.eq(4)
@@ -74,6 +74,7 @@ describe(
.invoke("text")
.as("bodyDiff")
.then((diff) => {
// TODO dynamically select the employee prior to what is the labor and cost
cy.get('[data-cy="form-timeticket-productivehrs"]').type(
Number(diff) + 1
);
@@ -85,7 +86,7 @@ describe(
});
});
it.skip("adds new time ticket to a job", () => {
it("adds new time ticket to a job", () => {
cy.get('[data-cy="job-actions-button"]').click();
cy.get('[data-cy="actions-timetickets"]')
@@ -96,14 +97,14 @@ describe(
cy.get('[data-cy="labor-allocations-table"]')
.find(".ant-table-tbody")
.find("> tr:not(.ant-table-measure-row)")
.as("orders-table")
.as("labor-allocations")
.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")
cy.get("@labor-allocations")
.eq(0)
.find("td:not(.ant-table-selection-column)")
.eq(4)
@@ -124,14 +125,30 @@ describe(
});
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="form-timeticket-memo"]').type(uuid());
cy.get('[data-cy="timeticket-save-button"]').first().click();
// TODO check if hours are calculated to the allocations table
// cy.get('[data-cy="tab-labor"]').should("be.visible").click();
});
it("checks the job costing calculations", () => {
cy.get('[data-cy="job-actions-button"]').click();
cy.get('[data-cy="actions-timetickets"]')
.should("be.visible")
.and("not.be.disabled")
.click();
// TODO check if labors are calculated correctly
});
it("clocks in and out of the tech page for the timeticket", () => {
// TODO go to tech page for the clock in and out
});
}
);

View File

@@ -430,7 +430,7 @@ export function JobsDetailHeaderActions({
});
}}
>
{t("jobs.labels.jobcosting")}
<span data-cy="actions-jobcosting">{t("jobs.labels.jobcosting")}</span>
</Menu.Item>
{job && !job.converted && (
<Menu.Item>

View File

@@ -323,7 +323,7 @@ export function JobsDetailPage({
</Tabs.TabPane>
<Tabs.TabPane
tab={
<span>
<span data-cy="tab-labor">
<Icon component={FaHardHat} />
{t("menus.jobsdetail.labor")}
</span>