150 lines
4.6 KiB
JavaScript
150 lines
4.6 KiB
JavaScript
import job from "../../fixtures/jobs/job-3.json";
|
|
|
|
const errorMessages = {
|
|
class: "Class is required. ",
|
|
referral_source: "Referral Source is required. ",
|
|
employee_csr: "Customer Service Rep. is required. ",
|
|
category: "Category is required. ",
|
|
};
|
|
|
|
describe(
|
|
"Converting a job with ",
|
|
{
|
|
defaultCommandTimeout: 10000,
|
|
},
|
|
() => {
|
|
beforeEach(() => {
|
|
cy.visit("/manage/jobs");
|
|
|
|
cy.intercept("POST", Cypress.env("graphql_dev_endpoint"), (req) => {
|
|
if (req.body.operationName === "QUERY_BODYSHOP") {
|
|
req.alias = "bodyshop";
|
|
}
|
|
});
|
|
|
|
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(job.clm_no)
|
|
.first()
|
|
.parent()
|
|
.find('[data-cy="active-job-link"]')
|
|
.click();
|
|
|
|
cy.get('[data-cy="job-convert-button"]').click();
|
|
});
|
|
|
|
it("shows the error messages of required fields", () => {
|
|
cy.wait("@bodyshop").then(({ response }) => {
|
|
const bodyshop = response.body.data.bodyshops[0];
|
|
|
|
const data = {
|
|
ins_cos: bodyshop.md_ins_cos,
|
|
config: {
|
|
class: bodyshop.enforce_class,
|
|
referral_source: bodyshop.enforce_referral,
|
|
employee_csr: bodyshop.enforce_conversion_csr,
|
|
category: bodyshop.enforce_conversion_category,
|
|
},
|
|
};
|
|
|
|
cy.get('[data-cy="convert-button"]').click();
|
|
|
|
cy.get("#ins_co_nm_help")
|
|
.find(".ant-form-item-explain-error")
|
|
.should("have.text", "Insurance Company Name is required. ");
|
|
|
|
for (const id in data.config) {
|
|
if (data.config[id]) {
|
|
cy.get(`#${id}_help`)
|
|
.find(".ant-form-item-explain-error")
|
|
.should("have.text", errorMessages[id]);
|
|
}
|
|
}
|
|
});
|
|
});
|
|
|
|
it("shows error of required fields when insurance company is selected", () => {
|
|
cy.wait("@bodyshop").then(({ response }) => {
|
|
const bodyshop = response.body.data.bodyshops[0];
|
|
|
|
const data = {
|
|
ins_cos: bodyshop.md_ins_cos,
|
|
config: {
|
|
class: bodyshop.enforce_class,
|
|
referral_source: bodyshop.enforce_referral,
|
|
employee_csr: bodyshop.enforce_conversion_csr,
|
|
category: bodyshop.enforce_conversion_category,
|
|
},
|
|
};
|
|
|
|
cy.get(".ant-select-selection-search").find("#ins_co_nm").click();
|
|
cy.get("#ins_co_nm_list")
|
|
.next()
|
|
.find(".ant-select-item-option-content")
|
|
.first()
|
|
.click();
|
|
|
|
cy.get("#ca_gst_registrant").should("have.class", "ant-switch").click();
|
|
cy.get("#driveable").should("have.class", "ant-switch").click();
|
|
cy.get("#towin").should("have.class", "ant-switch").click();
|
|
|
|
cy.get('[data-cy="convert-button"]').click();
|
|
|
|
for (const id in data.config) {
|
|
if (data.config[id]) {
|
|
cy.get(`#${id}_help`)
|
|
.find(".ant-form-item-explain-error")
|
|
.should("have.text", errorMessages[id]);
|
|
}
|
|
}
|
|
});
|
|
});
|
|
|
|
it("checks for the job to convert", () => {
|
|
cy.wait("@bodyshop").then(({ response }) => {
|
|
const bodyshop = response.body.data.bodyshops[0];
|
|
|
|
const data = {
|
|
ins_cos: bodyshop.md_ins_cos,
|
|
config: {
|
|
class: bodyshop.enforce_class,
|
|
referral_source: bodyshop.enforce_referral,
|
|
employee_csr: bodyshop.enforce_conversion_csr,
|
|
category: bodyshop.enforce_conversion_category,
|
|
},
|
|
};
|
|
|
|
cy.get(".ant-select-selection-search").find("#ins_co_nm").click();
|
|
cy.get("#ins_co_nm_list")
|
|
.next()
|
|
.find(".ant-select-item-option-content")
|
|
.first()
|
|
.click();
|
|
|
|
for (const id in data.config) {
|
|
if (data.config[id]) {
|
|
cy.get(".ant-select-selection-search").find(`#${id}`).click();
|
|
cy.get(`#${id}_list`)
|
|
.next()
|
|
.find(".ant-select-item-option-content")
|
|
.first()
|
|
.click();
|
|
}
|
|
}
|
|
|
|
cy.get("#ca_gst_registrant").should("have.class", "ant-switch").click();
|
|
cy.get("#driveable").should("have.class", "ant-switch").click();
|
|
cy.get("#towin").should("have.class", "ant-switch").click();
|
|
|
|
// cy.get('[data-cy="convert-button"]').click();
|
|
// cy.get(".ant-notification-notice-message").contains("successfully");
|
|
});
|
|
});
|
|
}
|
|
);
|