job converting and importing test cases

This commit is contained in:
swtmply
2023-07-28 10:08:26 +08:00
parent 72c9b5a11e
commit e4890c5fb8
8 changed files with 281 additions and 53 deletions

View File

@@ -1,16 +1,10 @@
import job from "../../downloads/jobs/job-3.json";
import job2 from "../../downloads/jobs/job-4.json";
import jobSupplement from "../../downloads/jobs/job-3-supplement.json";
import jobMetadata from "../../downloads/jobs/job-3-jobmetadata.json";
import jobSupplementMetadata from "../../downloads/jobs/job-3-supplment-jobmetadata.json";
import job from "../../fixtures/jobs/job-3.json";
import job2 from "../../fixtures/jobs/job-4.json";
import jobSupplement from "../../fixtures/jobs/job-3-supplement.json";
import jobMetadata from "../../fixtures/jobs/job-3-jobmetadata.json";
import jobSupplementMetadata from "../../fixtures/jobs/job-3-supplment-jobmetadata.json";
import Dinero from "dinero.js";
const query = `mutation INSERT_AVAILABLE_JOB($job: available_jobs_insert_input!) {
insert_available_jobs_one(object: $job) {
id
}
}`;
const createJobEstimate = (job, bodyshopid) => {
return {
owner: {
@@ -354,3 +348,151 @@ describe(
});
}
);
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 an active job",
{
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");
});
});
}
);