IO-2327 Intake checklist tests
This commit is contained in:
161
client/cypress/e2e/intake/intake-checklist.cy.js
Normal file
161
client/cypress/e2e/intake/intake-checklist.cy.js
Normal file
@@ -0,0 +1,161 @@
|
|||||||
|
describe(
|
||||||
|
"Adding job to checklist",
|
||||||
|
{
|
||||||
|
defaultCommandTimeout: 5000,
|
||||||
|
},
|
||||||
|
() => {
|
||||||
|
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");
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
it("adds checklists to the job and set the job to production", () => {
|
||||||
|
// Go to a scheduled job
|
||||||
|
cy.get(".ant-table-row")
|
||||||
|
.contains("Scheduled")
|
||||||
|
.first()
|
||||||
|
.siblings()
|
||||||
|
.find("a")
|
||||||
|
.first()
|
||||||
|
.click();
|
||||||
|
// Click actions button
|
||||||
|
cy.get('[data-cy="job-actions-button"]').click();
|
||||||
|
// Go to intake
|
||||||
|
cy.get('[data-cy="job-intake-button"]').should("not.be.disabled").click();
|
||||||
|
cy.url().should("include", "/intake");
|
||||||
|
// Fill out the form
|
||||||
|
cy.get('[data-cy="checklist-form"]').should("be.visible");
|
||||||
|
// Check if form items are not disabled
|
||||||
|
cy.get(".ant-form-item").should("not.be.disabled");
|
||||||
|
// Checks all the required checklist item
|
||||||
|
cy.get('[data-cy="checklist-item-checkbox"]').each((el) => {
|
||||||
|
cy.wrap(el).check().as("checkbox");
|
||||||
|
cy.get("@checkbox").should("be.checked");
|
||||||
|
});
|
||||||
|
// Check if `Add Job to Production` is switched to on
|
||||||
|
cy.get('[data-cy="add-to-production-switch"]').should(
|
||||||
|
"have.attr",
|
||||||
|
"aria-checked",
|
||||||
|
"true"
|
||||||
|
);
|
||||||
|
// Select dates for completion and delivery
|
||||||
|
cy.get("#scheduled_completion").find(".ant-picker-input").first().click();
|
||||||
|
cy.get('[title="2023-06-20"]').should("be.visible").click();
|
||||||
|
// Add time selection
|
||||||
|
cy.get("#scheduled_delivery").find(".ant-picker-input").first().click();
|
||||||
|
cy.get('[title="2023-06-20"]')
|
||||||
|
.should("be.visible")
|
||||||
|
.click({ multiple: true, force: true });
|
||||||
|
// Add time selection
|
||||||
|
// Add note
|
||||||
|
cy.get('[data-cy="checklist-production-note"]').type("automated testing");
|
||||||
|
// Submit the form
|
||||||
|
cy.get('[data-cy="checklist-submit-button"]').click();
|
||||||
|
|
||||||
|
// Job checklist completed.
|
||||||
|
cy.url().should("include", "/manage/jobs");
|
||||||
|
cy.contains("In Production");
|
||||||
|
});
|
||||||
|
|
||||||
|
it("renders and check the checklist correctly", () => {
|
||||||
|
// Go to a job in production
|
||||||
|
cy.get(".ant-table-row")
|
||||||
|
.contains("Arrived")
|
||||||
|
.first()
|
||||||
|
.siblings()
|
||||||
|
.find("a")
|
||||||
|
.first()
|
||||||
|
.click();
|
||||||
|
// Click the actions button
|
||||||
|
cy.get('[data-cy="job-actions-button"]').click();
|
||||||
|
// Go to checklists
|
||||||
|
cy.get('[data-cy="job-checklist"]').should("not.be.disabled").click();
|
||||||
|
// Check if the checklist renders in the page
|
||||||
|
cy.get('[data-cy="intake-checklist"]')
|
||||||
|
.should("be.visible")
|
||||||
|
.find("input")
|
||||||
|
.should("be.disabled");
|
||||||
|
});
|
||||||
|
|
||||||
|
it("completes delivery and updates the status", () => {
|
||||||
|
// Go to a job in production
|
||||||
|
cy.get(".ant-table-row")
|
||||||
|
.contains("Arrived")
|
||||||
|
.first()
|
||||||
|
.siblings()
|
||||||
|
.find("a")
|
||||||
|
.first()
|
||||||
|
.click();
|
||||||
|
// Click the actions button
|
||||||
|
cy.get('[data-cy="job-actions-button"]').click();
|
||||||
|
// Go to checklists
|
||||||
|
cy.get('[data-cy="job-deliver"]').should("not.be.disabled").click();
|
||||||
|
// Check if the checklist renders in the page
|
||||||
|
cy.get('[data-cy="checklist-form"]')
|
||||||
|
.should("be.visible")
|
||||||
|
.find("input")
|
||||||
|
.should("not.be.disabled");
|
||||||
|
|
||||||
|
cy.get('[data-cy="checklist-item-checkbox"]').each((el) => {
|
||||||
|
cy.wrap(el).check().as("checkbox");
|
||||||
|
cy.get("@checkbox").should("be.checked");
|
||||||
|
});
|
||||||
|
|
||||||
|
// Select dates for completion and delivery
|
||||||
|
cy.get("#actual_completion").find(".ant-picker-input").first().click();
|
||||||
|
cy.get('[title="2023-06-20"]').should("be.visible").click();
|
||||||
|
// Add time selection
|
||||||
|
cy.get("#actual_delivery").find(".ant-picker-input").first().click();
|
||||||
|
cy.get('[title="2023-06-20"]')
|
||||||
|
.should("be.visible")
|
||||||
|
.click({ multiple: true, force: true });
|
||||||
|
// Add time selection
|
||||||
|
|
||||||
|
cy.get('[data-cy="remove-from-production"]').should(
|
||||||
|
"have.attr",
|
||||||
|
"aria-checked",
|
||||||
|
"true"
|
||||||
|
);
|
||||||
|
// Submit the form
|
||||||
|
cy.get('[data-cy="checklist-submit-button"]').click();
|
||||||
|
// Job checklist completed.
|
||||||
|
cy.url().should("include", "/manage/jobs");
|
||||||
|
cy.contains("Delivered");
|
||||||
|
|
||||||
|
cy.get('[data-cy="job-actions-button"]').click();
|
||||||
|
// Go to checklists
|
||||||
|
cy.get('[data-cy="job-checklist"]').should("not.be.disabled").click();
|
||||||
|
|
||||||
|
cy.get('[data-cy="intake-checklist"]')
|
||||||
|
.should("be.visible")
|
||||||
|
.find("input")
|
||||||
|
.should("be.disabled");
|
||||||
|
|
||||||
|
cy.get('[data-cy="deliver-checklist"]')
|
||||||
|
.should("be.visible")
|
||||||
|
.find("input")
|
||||||
|
.should("be.disabled");
|
||||||
|
});
|
||||||
|
|
||||||
|
// it("speedprint the checklists", () => {
|
||||||
|
// // FIXME print button is not working
|
||||||
|
// // Go to a job in production
|
||||||
|
// // Click the actions button
|
||||||
|
// // Go to checklists
|
||||||
|
// // Print all the necessary documents for the job
|
||||||
|
// });
|
||||||
|
}
|
||||||
|
);
|
||||||
@@ -16,7 +16,7 @@ export default function JobIntakeFormCheckboxComponent({ formItem, readOnly }) {
|
|||||||
},
|
},
|
||||||
]}
|
]}
|
||||||
>
|
>
|
||||||
<Checkbox disabled={readOnly} />
|
<Checkbox data-cy="checklist-item-checkbox" disabled={readOnly} />
|
||||||
</Form.Item>
|
</Form.Item>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -199,6 +199,7 @@ export function JobChecklistForm({
|
|||||||
extra={
|
extra={
|
||||||
!readOnly && (
|
!readOnly && (
|
||||||
<Button
|
<Button
|
||||||
|
data-cy="checklist-submit-button"
|
||||||
loading={loading}
|
loading={loading}
|
||||||
type="primary"
|
type="primary"
|
||||||
onClick={() => form.submit()}
|
onClick={() => form.submit()}
|
||||||
@@ -209,6 +210,7 @@ export function JobChecklistForm({
|
|||||||
}
|
}
|
||||||
>
|
>
|
||||||
<Form
|
<Form
|
||||||
|
data-cy="checklist-form"
|
||||||
form={form}
|
form={form}
|
||||||
onFinish={handleFinish}
|
onFinish={handleFinish}
|
||||||
initialValues={{
|
initialValues={{
|
||||||
@@ -256,7 +258,7 @@ export function JobChecklistForm({
|
|||||||
label={t("checklist.labels.addtoproduction")}
|
label={t("checklist.labels.addtoproduction")}
|
||||||
disabled={readOnly}
|
disabled={readOnly}
|
||||||
>
|
>
|
||||||
<Switch disabled={readOnly} />
|
<Switch data-cy="add-to-production-switch" disabled={readOnly} />
|
||||||
</Form.Item>
|
</Form.Item>
|
||||||
<Form.Item
|
<Form.Item
|
||||||
name="allow_text_message"
|
name="allow_text_message"
|
||||||
@@ -292,7 +294,11 @@ export function JobChecklistForm({
|
|||||||
disabled={readOnly}
|
disabled={readOnly}
|
||||||
trigger="onChange"
|
trigger="onChange"
|
||||||
>
|
>
|
||||||
<Input.TextArea rows={3} disabled={readOnly} />
|
<Input.TextArea
|
||||||
|
data-cy="checklist-production-note"
|
||||||
|
rows={3}
|
||||||
|
disabled={readOnly}
|
||||||
|
/>
|
||||||
</Form.Item>
|
</Form.Item>
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
@@ -324,7 +330,11 @@ export function JobChecklistForm({
|
|||||||
label={t("checklist.labels.removefromproduction")}
|
label={t("checklist.labels.removefromproduction")}
|
||||||
disabled={readOnly}
|
disabled={readOnly}
|
||||||
>
|
>
|
||||||
<Switch disabled={readOnly} defaultChecked={true} />
|
<Switch
|
||||||
|
data-cy="remove-from-production"
|
||||||
|
disabled={readOnly}
|
||||||
|
defaultChecked={true}
|
||||||
|
/>
|
||||||
</Form.Item>
|
</Form.Item>
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
|
|||||||
@@ -196,6 +196,7 @@ export function JobsDetailHeaderActions({
|
|||||||
</Popover>
|
</Popover>
|
||||||
</Menu.Item>
|
</Menu.Item>
|
||||||
<Menu.Item
|
<Menu.Item
|
||||||
|
data-cy="job-intake-button"
|
||||||
disabled={
|
disabled={
|
||||||
!!job.intakechecklist ||
|
!!job.intakechecklist ||
|
||||||
!jobInPreProduction ||
|
!jobInPreProduction ||
|
||||||
@@ -214,7 +215,7 @@ export function JobsDetailHeaderActions({
|
|||||||
</Link>
|
</Link>
|
||||||
)}
|
)}
|
||||||
</Menu.Item>
|
</Menu.Item>
|
||||||
<Menu.Item disabled={!jobInProduction || jobRO}>
|
<Menu.Item data-cy="job-deliver" disabled={!jobInProduction || jobRO}>
|
||||||
{!jobInProduction ? (
|
{!jobInProduction ? (
|
||||||
t("jobs.actions.deliver")
|
t("jobs.actions.deliver")
|
||||||
) : (
|
) : (
|
||||||
@@ -223,7 +224,7 @@ export function JobsDetailHeaderActions({
|
|||||||
</Link>
|
</Link>
|
||||||
)}
|
)}
|
||||||
</Menu.Item>
|
</Menu.Item>
|
||||||
<Menu.Item disabled={!job.converted}>
|
<Menu.Item data-cy="job-checklist" disabled={!job.converted}>
|
||||||
<Link to={`/manage/jobs/${job.id}/checklist`}>
|
<Link to={`/manage/jobs/${job.id}/checklist`}>
|
||||||
{t("jobs.actions.viewchecklist")}
|
{t("jobs.actions.viewchecklist")}
|
||||||
</Link>
|
</Link>
|
||||||
@@ -517,7 +518,7 @@ export function JobsDetailHeaderActions({
|
|||||||
);
|
);
|
||||||
return (
|
return (
|
||||||
<Dropdown overlay={statusmenu} trigger={["click"]} key="changestatus">
|
<Dropdown overlay={statusmenu} trigger={["click"]} key="changestatus">
|
||||||
<Button>
|
<Button data-cy="job-actions-button">
|
||||||
<span>{t("general.labels.actions")}</span>
|
<span>{t("general.labels.actions")}</span>
|
||||||
|
|
||||||
<DownCircleFilled />
|
<DownCircleFilled />
|
||||||
|
|||||||
@@ -81,7 +81,7 @@ export function JobsChecklistViewContainer({
|
|||||||
</Typography.Title>
|
</Typography.Title>
|
||||||
{data.jobs_by_pk.intakechecklist &&
|
{data.jobs_by_pk.intakechecklist &&
|
||||||
data.jobs_by_pk.intakechecklist.form && (
|
data.jobs_by_pk.intakechecklist.form && (
|
||||||
<>
|
<span data-cy="intake-checklist">
|
||||||
<JobChecklistForm
|
<JobChecklistForm
|
||||||
formItems={
|
formItems={
|
||||||
data.jobs_by_pk.intakechecklist &&
|
data.jobs_by_pk.intakechecklist &&
|
||||||
@@ -92,7 +92,7 @@ export function JobsChecklistViewContainer({
|
|||||||
readOnly
|
readOnly
|
||||||
/>
|
/>
|
||||||
<CompletedBy checklist={data.jobs_by_pk.intakechecklist} />
|
<CompletedBy checklist={data.jobs_by_pk.intakechecklist} />
|
||||||
</>
|
</span>
|
||||||
)}
|
)}
|
||||||
</Col>
|
</Col>
|
||||||
<Col span={12}>
|
<Col span={12}>
|
||||||
@@ -101,7 +101,7 @@ export function JobsChecklistViewContainer({
|
|||||||
</Typography.Title>
|
</Typography.Title>
|
||||||
{data.jobs_by_pk.deliverchecklist &&
|
{data.jobs_by_pk.deliverchecklist &&
|
||||||
data.jobs_by_pk.deliverchecklist.form && (
|
data.jobs_by_pk.deliverchecklist.form && (
|
||||||
<>
|
<span data-cy="deliver-checklist">
|
||||||
<JobChecklistForm
|
<JobChecklistForm
|
||||||
formItems={
|
formItems={
|
||||||
data.jobs_by_pk.deliverchecklist &&
|
data.jobs_by_pk.deliverchecklist &&
|
||||||
@@ -112,7 +112,7 @@ export function JobsChecklistViewContainer({
|
|||||||
readOnly
|
readOnly
|
||||||
/>
|
/>
|
||||||
<CompletedBy checklist={data.jobs_by_pk.deliverchecklist} />
|
<CompletedBy checklist={data.jobs_by_pk.deliverchecklist} />
|
||||||
</>
|
</span>
|
||||||
)}
|
)}
|
||||||
</Col>
|
</Col>
|
||||||
</Row>
|
</Row>
|
||||||
|
|||||||
Reference in New Issue
Block a user