diff --git a/client/cypress/e2e/job-import/converting.cy.js b/client/cypress/e2e/job-import/converting.cy.js
index acf8bad25..a5bce564b 100644
--- a/client/cypress/e2e/job-import/converting.cy.js
+++ b/client/cypress/e2e/job-import/converting.cy.js
@@ -1,65 +1,149 @@
+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(
- "Check if there are job without RO number",
+ "Converting a job with ",
{
- defaultCommandTimeout: 5000,
+ defaultCommandTimeout: 10000,
},
() => {
beforeEach(() => {
- cy.visit("/manage");
+ cy.visit("/manage/jobs");
- 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.intercept("POST", Cypress.env("graphql_dev_endpoint"), (req) => {
+ if (req.body.operationName === "QUERY_BODYSHOP") {
+ req.alias = "bodyshop";
}
-
- cy.get(".ant-table-tbody")
- .find("tr")
- .should("not.have.class", "ant-table-placeholder");
-
- cy.get(".ant-table-row").find("a").contains("N/A").first().click();
});
+
+ 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", () => {
- // Check if required fields are filled
- cy.get('[data-cy="job-convert-button"]').click();
- cy.get('[data-cy="convert-button"]').click();
+ cy.wait("@bodyshop").then(({ response }) => {
+ const bodyshop = response.body.data.bodyshops[0];
- cy.antdFormSelect("", "Insurance Company Name", () => {
- cy.contains("Insurance Company Name is required.").should("exist");
- });
- cy.antdFormSelect("", "Referral Source", () => {
- cy.contains("Referral Source is required.").should("exist");
- });
- cy.antdFormSelect("", "Customer Service Rep.", () => {
- cy.contains("Customer Service Rep. is required.").should("exist");
- });
- cy.antdFormSelect("", "Category", () => {
- cy.contains("Category is required.").should("exist");
+ 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("converts a job and issue an RO number", () => {
- cy.get('[data-cy="job-convert-button"]').click();
+ it("shows error of required fields when insurance company is selected", () => {
+ cy.wait("@bodyshop").then(({ response }) => {
+ const bodyshop = response.body.data.bodyshops[0];
- // Check if fields are present
- cy.antdFormSelect("ins_co_nm", "Insurance Company Name");
- cy.antdFormSelect("referral_source", "Referral Source", () => {
- cy.get('[data-cy="referral_source_extra"]').type("Twitter");
+ 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]);
+ }
+ }
});
- cy.antdFormSelect("employee_csr", "Customer Service Rep.");
- cy.antdFormSelect("category", "Category");
+ });
- 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();
+ it("checks for the job to convert", () => {
+ cy.wait("@bodyshop").then(({ response }) => {
+ const bodyshop = response.body.data.bodyshops[0];
- cy.get('[data-cy="convert-button"]').click();
+ 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-notification-notice-message").contains("successfully");
+ 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");
+ });
});
}
);
diff --git a/client/cypress/e2e/job-import/job-import.cy.js b/client/cypress/e2e/job-import/job-import.cy.js
index b3bc2aa46..155183026 100644
--- a/client/cypress/e2e/job-import/job-import.cy.js
+++ b/client/cypress/e2e/job-import/job-import.cy.js
@@ -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");
+ });
+ });
+ }
+);
diff --git a/client/cypress/downloads/jobs/job-3-jobmetadata.json b/client/cypress/fixtures/jobs/job-3-jobmetadata.json
similarity index 100%
rename from client/cypress/downloads/jobs/job-3-jobmetadata.json
rename to client/cypress/fixtures/jobs/job-3-jobmetadata.json
diff --git a/client/cypress/downloads/jobs/job-3-supplement.json b/client/cypress/fixtures/jobs/job-3-supplement.json
similarity index 100%
rename from client/cypress/downloads/jobs/job-3-supplement.json
rename to client/cypress/fixtures/jobs/job-3-supplement.json
diff --git a/client/cypress/downloads/jobs/job-3-supplment-jobmetadata.json b/client/cypress/fixtures/jobs/job-3-supplment-jobmetadata.json
similarity index 100%
rename from client/cypress/downloads/jobs/job-3-supplment-jobmetadata.json
rename to client/cypress/fixtures/jobs/job-3-supplment-jobmetadata.json
diff --git a/client/cypress/downloads/jobs/job-3.json b/client/cypress/fixtures/jobs/job-3.json
similarity index 100%
rename from client/cypress/downloads/jobs/job-3.json
rename to client/cypress/fixtures/jobs/job-3.json
diff --git a/client/cypress/downloads/jobs/job-4.json b/client/cypress/fixtures/jobs/job-4.json
similarity index 100%
rename from client/cypress/downloads/jobs/job-4.json
rename to client/cypress/fixtures/jobs/job-4.json
diff --git a/client/src/components/jobs-list/jobs-list.component.jsx b/client/src/components/jobs-list/jobs-list.component.jsx
index e28e21901..ca54ea65e 100644
--- a/client/src/components/jobs-list/jobs-list.component.jsx
+++ b/client/src/components/jobs-list/jobs-list.component.jsx
@@ -122,6 +122,7 @@ export function JobsList({ bodyshop }) {
e.stopPropagation()}
+ data-cy="active-job-link"
>
{record.ro_number || t("general.labels.na")}
@@ -364,6 +365,7 @@ export function JobsList({ bodyshop }) {
}
>