IO-2327 timetickets test cases
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
import moment from "moment";
|
||||
import job2 from "../../fixtures/jobs/job-4.json";
|
||||
import Dinero from "dinero.js";
|
||||
|
||||
const uuid = () => Cypress._.random(0, 1e6);
|
||||
|
||||
@@ -10,6 +11,8 @@ describe(
|
||||
},
|
||||
() => {
|
||||
const today = moment().format("YYYY-MM-DD");
|
||||
const LABOR_HOURS = 1;
|
||||
const COST_CENTER = "Body";
|
||||
|
||||
beforeEach(() => {
|
||||
cy.intercept("POST", Cypress.env("graphql_dev_endpoint"), (req) => {
|
||||
@@ -115,9 +118,9 @@ describe(
|
||||
.invoke("text")
|
||||
.as("bodyDiff")
|
||||
.then((diff) => {
|
||||
cy.get('[data-cy="form-timeticket-productivehrs"]').type(1);
|
||||
cy.get('[data-cy="form-timeticket-productivehrs"]').type(LABOR_HOURS);
|
||||
|
||||
cy.get('[data-cy="form-timeticket-actualhrs"]').type(1);
|
||||
cy.get('[data-cy="form-timeticket-actualhrs"]').type(LABOR_HOURS);
|
||||
});
|
||||
|
||||
cy.wait("@employees").then(({ response }) => {
|
||||
@@ -126,13 +129,17 @@ describe(
|
||||
const employee_name = `${employee.first_name} ${employee.last_name}`;
|
||||
|
||||
cy.antdSelectValue("timeticket-employee", employee_name);
|
||||
});
|
||||
|
||||
cy.antdSelect("cost-center");
|
||||
cy.antdSelectValue("cost-center", COST_CENTER);
|
||||
});
|
||||
|
||||
cy.get('[data-cy="form-timeticket-memo"]').type(uuid());
|
||||
|
||||
cy.get('[data-cy="timeticket-save-button"]').first().click();
|
||||
|
||||
cy.get(".ant-notification-notice-message").contains(
|
||||
"Time ticket entered successfully."
|
||||
);
|
||||
});
|
||||
|
||||
it("adds new time ticket to a job with straight rate", () => {
|
||||
@@ -161,9 +168,9 @@ describe(
|
||||
.invoke("text")
|
||||
.as("bodyDiff")
|
||||
.then((diff) => {
|
||||
cy.get('[data-cy="form-timeticket-productivehrs"]').type(1);
|
||||
cy.get('[data-cy="form-timeticket-productivehrs"]').type(LABOR_HOURS);
|
||||
|
||||
cy.get('[data-cy="form-timeticket-actualhrs"]').type(1);
|
||||
cy.get('[data-cy="form-timeticket-actualhrs"]').type(LABOR_HOURS);
|
||||
});
|
||||
|
||||
cy.wait("@employees").then(({ response }) => {
|
||||
@@ -172,13 +179,17 @@ describe(
|
||||
const employee_name = `${employee.first_name} ${employee.last_name}`;
|
||||
|
||||
cy.antdSelectValue("timeticket-employee", employee_name);
|
||||
});
|
||||
|
||||
cy.antdSelect("cost-center");
|
||||
cy.antdSelectValue("cost-center", COST_CENTER);
|
||||
});
|
||||
|
||||
cy.get('[data-cy="form-timeticket-memo"]').type(uuid());
|
||||
|
||||
cy.get('[data-cy="timeticket-save-button"]').first().click();
|
||||
|
||||
cy.get(".ant-notification-notice-message").contains(
|
||||
"Time ticket entered successfully."
|
||||
);
|
||||
});
|
||||
|
||||
it("checks hours calculated to the allocations table", () => {
|
||||
@@ -197,7 +208,7 @@ describe(
|
||||
});
|
||||
});
|
||||
|
||||
it.only("checks the job costing calculations", () => {
|
||||
it("checks the job costing calculations", () => {
|
||||
cy.get('[data-cy="job-actions-button"]').click();
|
||||
|
||||
cy.get('[data-cy="actions-jobcosting"]')
|
||||
@@ -237,19 +248,38 @@ describe(
|
||||
query,
|
||||
},
|
||||
}).then((response) => {
|
||||
cy.log(response);
|
||||
});
|
||||
const cost_center = COST_CENTER;
|
||||
const employees = response.body.employees;
|
||||
const total_cost = employees.reduce((prev, employee) => {
|
||||
const rate =
|
||||
employee.rates.find((rate) => rate.cost_center === cost_center)
|
||||
.rate ?? 0;
|
||||
|
||||
// cy.get('[data-cy="responsibilitycenter"]')
|
||||
// .contains("Body")
|
||||
// .parent()
|
||||
// .parent()
|
||||
// .find('[data-cy="cost"]');
|
||||
return prev + rate * LABOR_HOURS;
|
||||
}, 0);
|
||||
|
||||
cy.get('[data-cy="responsibilitycenter"]')
|
||||
.contains(cost_center)
|
||||
.parent()
|
||||
.parent()
|
||||
.find('[data-cy="cost"]')
|
||||
.should(
|
||||
"have.text",
|
||||
Dinero({
|
||||
amount: total_cost,
|
||||
precision: 0,
|
||||
}).toFormat()
|
||||
);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
it("clocks in and out of the tech page for the timeticket", () => {
|
||||
it.only("clocks in and out of the tech page for the timeticket", () => {
|
||||
// TODO go to tech page for the clock in and out
|
||||
cy.visit("/tech");
|
||||
|
||||
cy.get('[data-cy="tech-employee-id"]').type("a");
|
||||
cy.get('[data-cy="tech-employee-password"]').type("a{enter}");
|
||||
});
|
||||
}
|
||||
);
|
||||
|
||||
@@ -53,7 +53,11 @@ export function TechLogin({
|
||||
},
|
||||
]}
|
||||
>
|
||||
<Input size="large" autoComplete="new-password" />
|
||||
<Input
|
||||
data-cy="tech-employee-id"
|
||||
size="large"
|
||||
autoComplete="new-password"
|
||||
/>
|
||||
</Form.Item>
|
||||
<Form.Item
|
||||
label={t("tech.fields.pin")}
|
||||
@@ -65,7 +69,11 @@ export function TechLogin({
|
||||
},
|
||||
]}
|
||||
>
|
||||
<Input.Password size="large" autoComplete="new-password" />
|
||||
<Input.Password
|
||||
data-cy="tech-employee-password"
|
||||
size="large"
|
||||
autoComplete="new-password"
|
||||
/>
|
||||
</Form.Item>
|
||||
<Button htmlType="submit" loading={loginLoading} className="login-btn">
|
||||
{t("general.actions.login")}
|
||||
|
||||
Reference in New Issue
Block a user