IO-2327 job importing test cases
This commit is contained in:
@@ -1,49 +1,206 @@
|
||||
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 Dinero from "dinero.js";
|
||||
|
||||
const query = `mutation INSERT_AVAILABLE_JOB($job: available_jobs_insert_input!) {
|
||||
insert_available_jobs_one(object: $job) {
|
||||
id
|
||||
}
|
||||
}`;
|
||||
|
||||
describe(
|
||||
"Importing an available job",
|
||||
{
|
||||
defaultCommandTimeout: 5000,
|
||||
defaultCommandTimeout: 10000,
|
||||
requestTimeout: 10000,
|
||||
},
|
||||
() => {
|
||||
// assuming that user is logged in
|
||||
beforeEach(() => {
|
||||
cy.visit("/manage/available");
|
||||
// intercept bodyshop query for id
|
||||
|
||||
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", "https://db.dev.bodyshop.app/v1/graphql", (req) => {
|
||||
if (req.body.operationName === "QUERY_BODYSHOP") {
|
||||
req.alias = "bodyshop";
|
||||
}
|
||||
});
|
||||
|
||||
cy.get('[data-cy="available-jobs-table"]')
|
||||
.find("tr")
|
||||
.should("not.have.class", "ant-table-placeholder");
|
||||
cy.wait("@bodyshop").then(({ response }) => {
|
||||
const id = response.body.data.bodyshops[0].id;
|
||||
|
||||
cy.wrap(id).as("bodyshopid");
|
||||
});
|
||||
});
|
||||
|
||||
it.only("Enters a job programatically", () => {
|
||||
cy.intercept("POST", "https://db.dev.bodyshop.app/v1/graphql", (req) => {
|
||||
if (req.body.operationName === "QUERY_AVAILABLE_JOBS") {
|
||||
req.alias = "availableJobs";
|
||||
}
|
||||
});
|
||||
|
||||
cy.wait("@availableJobs").then(({ request }) => {
|
||||
const token = request.headers.authorization;
|
||||
|
||||
cy.get("@bodyshopid").then((bodyshopid) => {
|
||||
const job_est_data = {
|
||||
owner: {
|
||||
data: {
|
||||
shopid: bodyshopid,
|
||||
...job.owner.data,
|
||||
},
|
||||
},
|
||||
vehicle: {
|
||||
data: {
|
||||
shopid: bodyshopid,
|
||||
...job.vehicle.data,
|
||||
},
|
||||
},
|
||||
shopid: bodyshopid,
|
||||
...job,
|
||||
};
|
||||
|
||||
cy.request({
|
||||
url: "http://localhost:4000/test/query",
|
||||
method: "POST",
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
Authorization: token,
|
||||
},
|
||||
body: {
|
||||
query,
|
||||
job: {
|
||||
est_data: job_est_data,
|
||||
uploaded_by: "john@imex.dev",
|
||||
cieca_id: job.ciecaid,
|
||||
bodyshopid,
|
||||
clm_amt: job.clm_total,
|
||||
clm_no: job.clm_no,
|
||||
ins_co_nm: job.ins_co_nm,
|
||||
ownr_name: `${job.owner.data.ownr_fn} ${job.owner.data.ownr_ln}`,
|
||||
vehicle_info: `${job.v_model_yr} ${job.v_make_desc} ${job.v_model_desc}`,
|
||||
},
|
||||
},
|
||||
})
|
||||
.its("body.insert_available_jobs_one")
|
||||
.should("have.property", "id");
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
it("creates a new owner record for the job", () => {
|
||||
cy.get('[data-cy="add-job-as-new-button"]')
|
||||
.filter(":enabled")
|
||||
.first()
|
||||
.click();
|
||||
cy.intercept("POST", "https://db.dev.bodyshop.app/v1/graphql", (req) => {
|
||||
if (req.body.operationName === "QUERY_AVAILABLE_JOBS") {
|
||||
req.alias = "availableJobs";
|
||||
}
|
||||
});
|
||||
|
||||
cy.wait("@availableJobs");
|
||||
|
||||
cy.get('[data-cy="available-jobs-table"]')
|
||||
.find(".ant-table-tbody")
|
||||
.find("> tr:not(.ant-table-measure-row)")
|
||||
.contains(job.clm_no)
|
||||
.parent()
|
||||
.as("row");
|
||||
|
||||
cy.get('[data-cy="add-job-as-new-button"]').should("be.enabled").click();
|
||||
|
||||
cy.get('[data-cy="new_owner_checkbox"]').should("be.checked");
|
||||
|
||||
cy.get(".ant-modal-content").find("button").contains("OK").click();
|
||||
|
||||
cy.get(".ant-notification-notice-message")
|
||||
.contains("Job created successfully. Click to view.")
|
||||
cy.get('[data-cy="existing-owners-ok-button"]')
|
||||
.should("be.enabled")
|
||||
.click();
|
||||
|
||||
cy.url().should("include", "/manage/jobs");
|
||||
cy.intercept("POST", "https://db.dev.bodyshop.app/v1/graphql", (req) => {
|
||||
if (req.body.operationName === "INSERT_JOB") {
|
||||
req.alias = "insertJob";
|
||||
}
|
||||
});
|
||||
|
||||
cy.wait("@insertJob").then(({ response }) => {
|
||||
const id = response.body.data.insert_jobs.returning[0].id;
|
||||
|
||||
cy.get(".ant-notification-notice-message")
|
||||
.contains("Job created successfully. Click to view.")
|
||||
.click();
|
||||
|
||||
cy.url().should("include", `/manage/jobs/${id}`);
|
||||
});
|
||||
|
||||
cy.get('[data-cy="tab-totals"]').should("be.visible").click();
|
||||
|
||||
cy.get('[data-cy="job-totals-table"]')
|
||||
.find(".ant-table-tbody")
|
||||
.find("> tr:not(.ant-table-measure-row)")
|
||||
.as("totals-table")
|
||||
.should("not.have.class", "ant-table-placeholder");
|
||||
|
||||
cy.get("@totals-table")
|
||||
.eq(0)
|
||||
.find("td:not(.ant-table-selection-column)")
|
||||
.eq(1)
|
||||
.invoke("text")
|
||||
.should(
|
||||
"be.equal",
|
||||
Dinero({
|
||||
amount: jobMetadata.totals.subtotal.amount,
|
||||
}).toFormat()
|
||||
);
|
||||
});
|
||||
|
||||
it("imports a supplement for an existing job", () => {
|
||||
cy.get('[data-cy="add-job-as-supplement"]')
|
||||
.filter(":enabled")
|
||||
.first()
|
||||
cy.intercept("POST", "https://db.dev.bodyshop.app/v1/graphql", (req) => {
|
||||
if (req.body.operationName === "QUERY_AVAILABLE_JOBS") {
|
||||
req.alias = "availableJobs";
|
||||
}
|
||||
});
|
||||
|
||||
cy.wait("@availableJobs").then(({ request }) => {
|
||||
const token = request.headers.authorization;
|
||||
|
||||
cy.request({
|
||||
url: "http://localhost:4000/test/query",
|
||||
method: "POST",
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
Authorization: token,
|
||||
},
|
||||
body: {
|
||||
query,
|
||||
job: {
|
||||
est_data: jobSupplement,
|
||||
uploaded_by: "john@imex.dev",
|
||||
cieca_id: jobSupplement.ciecaid,
|
||||
bodyshopid: jobSupplement.owner.data.shopid,
|
||||
clm_amt: jobSupplement.clm_total,
|
||||
clm_no: jobSupplement.clm_no,
|
||||
ins_co_nm: jobSupplement.ins_co_nm,
|
||||
ownr_name: `${jobSupplement.owner.data.ownr_fn} ${jobSupplement.owner.data.ownr_ln}`,
|
||||
vehicle_info: `${jobSupplement.v_model_yr} ${jobSupplement.v_make_desc} ${jobSupplement.v_model_desc}`,
|
||||
},
|
||||
},
|
||||
})
|
||||
.its("body.insert_available_jobs_one")
|
||||
.should("have.property", "id");
|
||||
});
|
||||
|
||||
cy.get('[data-cy="refetch-available-jobs-button"]')
|
||||
.should("not.be.disabled")
|
||||
.click();
|
||||
|
||||
cy.get('[data-cy="available-jobs-table"]')
|
||||
.find(".ant-table-tbody")
|
||||
.find("> tr:not(.ant-table-measure-row)")
|
||||
.contains(jobSupplement.clm_no)
|
||||
.parent()
|
||||
.as("row");
|
||||
|
||||
cy.get('[data-cy="add-job-as-supplement"]').should("be.enabled").click();
|
||||
|
||||
cy.get('[data-cy="existing-jobs-table"]')
|
||||
.find(".ant-table-tbody tr")
|
||||
.should("not.have.class", "ant-table-placeholder")
|
||||
@@ -59,47 +216,178 @@ describe(
|
||||
.click();
|
||||
|
||||
cy.url().should("include", "/manage/jobs");
|
||||
|
||||
cy.get('[data-cy="tab-totals"]').should("be.visible").click();
|
||||
|
||||
cy.get('[data-cy="job-totals-table"]')
|
||||
.find(".ant-table-tbody")
|
||||
.find("> tr:not(.ant-table-measure-row)")
|
||||
.as("totals-table")
|
||||
.should("not.have.class", "ant-table-placeholder");
|
||||
|
||||
cy.get("@totals-table")
|
||||
.eq(0)
|
||||
.find("td:not(.ant-table-selection-column)")
|
||||
.eq(1)
|
||||
.invoke("text")
|
||||
.should(
|
||||
"be.equal",
|
||||
Dinero({
|
||||
amount: jobSupplementMetadata.totals.subtotal.amount,
|
||||
}).toFormat()
|
||||
);
|
||||
});
|
||||
|
||||
it("imports a job with an existing owner", () => {
|
||||
let hasOwner = false;
|
||||
it("imports a supplement and override estimate header", () => {
|
||||
cy.intercept("POST", "https://db.dev.bodyshop.app/v1/graphql", (req) => {
|
||||
if (req.body.operationName === "QUERY_AVAILABLE_JOBS") {
|
||||
req.alias = "availableJobs";
|
||||
}
|
||||
});
|
||||
|
||||
cy.get('[data-cy="add-job-as-new-button"]')
|
||||
.filter(":enabled")
|
||||
.each(($el) => {
|
||||
cy.then(() => {
|
||||
if (hasOwner) return false;
|
||||
cy.wait("@availableJobs").then(({ request }) => {
|
||||
const token = request.headers.authorization;
|
||||
|
||||
cy.wrap($el).click();
|
||||
cy.request({
|
||||
url: "http://localhost:4000/test/query",
|
||||
method: "POST",
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
Authorization: token,
|
||||
},
|
||||
body: {
|
||||
query,
|
||||
job: {
|
||||
est_data: jobSupplement,
|
||||
uploaded_by: "john@imex.dev",
|
||||
cieca_id: jobSupplement.ciecaid,
|
||||
bodyshopid: jobSupplement.owner.data.shopid,
|
||||
clm_amt: jobSupplement.clm_total,
|
||||
clm_no: jobSupplement.clm_no,
|
||||
ins_co_nm: jobSupplement.ins_co_nm,
|
||||
ownr_name: `${jobSupplement.owner.data.ownr_fn} ${jobSupplement.owner.data.ownr_ln}`,
|
||||
vehicle_info: `${jobSupplement.v_model_yr} ${jobSupplement.v_make_desc} ${jobSupplement.v_model_desc}`,
|
||||
},
|
||||
},
|
||||
})
|
||||
.its("body.insert_available_jobs_one")
|
||||
.should("have.property", "id");
|
||||
});
|
||||
|
||||
// check if table is not empty
|
||||
cy.get('[data-cy="existing-owner-table"]', { timeout: 20000 })
|
||||
.find(".ant-table-tbody tr")
|
||||
.should("not.have.class", "ant-table-placeholder")
|
||||
.then(($table) => {
|
||||
if ($table.length === 0) {
|
||||
cy.get('[data-cy="existing-owners-cancel-button"]').click();
|
||||
}
|
||||
cy.get('[data-cy="refetch-available-jobs-button"]')
|
||||
.should("not.be.disabled")
|
||||
.click();
|
||||
|
||||
cy.wrap($table).first().click();
|
||||
cy.get('[data-cy="available-jobs-table"]')
|
||||
.find(".ant-table-tbody")
|
||||
.find("> tr:not(.ant-table-measure-row)")
|
||||
.contains(jobSupplement.clm_no)
|
||||
.parent()
|
||||
.as("row");
|
||||
|
||||
cy.get('[data-cy="new_owner_checkbox"]').should(
|
||||
"not.be",
|
||||
"checked"
|
||||
);
|
||||
cy.get('[data-cy="add-job-as-supplement"]').should("be.enabled").click();
|
||||
|
||||
hasOwner = true;
|
||||
});
|
||||
});
|
||||
cy.get('[data-cy="existing-jobs-table"]')
|
||||
.find(".ant-table-tbody tr")
|
||||
.should("not.have.class", "ant-table-placeholder")
|
||||
.first()
|
||||
.click();
|
||||
|
||||
// click override
|
||||
cy.get('[data-cy="override-header-checkbox"]').check();
|
||||
|
||||
cy.get('[data-cy="existing-jobs-ok-button"]')
|
||||
.should("not.be", "disabled")
|
||||
.click();
|
||||
|
||||
cy.get(".ant-notification-notice-message")
|
||||
.contains("Job supplemented successfully.")
|
||||
.click();
|
||||
|
||||
cy.url().should("include", "/manage/jobs");
|
||||
|
||||
cy.get('[data-cy="tab-totals"]').should("be.visible").click();
|
||||
|
||||
cy.get('[data-cy="job-totals-table"]')
|
||||
.find(".ant-table-tbody")
|
||||
.find("> tr:not(.ant-table-measure-row)")
|
||||
.as("totals-table")
|
||||
.should("not.have.class", "ant-table-placeholder");
|
||||
|
||||
cy.get("@totals-table")
|
||||
.eq(0)
|
||||
.find("td:not(.ant-table-selection-column)")
|
||||
.eq(1)
|
||||
.invoke("text")
|
||||
.should(
|
||||
"be.equal",
|
||||
Dinero({
|
||||
amount: jobSupplementMetadata.totals.subtotal.amount,
|
||||
}).toFormat()
|
||||
);
|
||||
});
|
||||
|
||||
it.skip("imports a job with an existing owner", () => {
|
||||
cy.intercept("POST", "https://db.dev.bodyshop.app/v1/graphql", (req) => {
|
||||
if (req.body.operationName === "QUERY_AVAILABLE_JOBS") {
|
||||
req.alias = "availableJobs";
|
||||
}
|
||||
});
|
||||
|
||||
cy.wait("@availableJobs").then(({ request }) => {
|
||||
const token = request.headers.authorization;
|
||||
|
||||
cy.request({
|
||||
url: "http://localhost:4000/test/query",
|
||||
method: "POST",
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
Authorization: token,
|
||||
},
|
||||
body: {
|
||||
query,
|
||||
job: {
|
||||
est_data: job2,
|
||||
uploaded_by: "john@imex.dev",
|
||||
cieca_id: job2.ciecaid,
|
||||
bodyshopid: job2.owner.data.shopid,
|
||||
clm_amt: job2.clm_total,
|
||||
clm_no: job2.clm_no,
|
||||
ins_co_nm: job2.ins_co_nm,
|
||||
ownr_name: `${job2.owner.data.ownr_fn} ${job2.owner.data.ownr_ln}`,
|
||||
vehicle_info: `${job2.v_model_yr} ${job2.v_make_desc} ${job2.v_model_desc}`,
|
||||
},
|
||||
},
|
||||
})
|
||||
.its("body.insert_available_jobs_one")
|
||||
.should("have.property", "id");
|
||||
});
|
||||
|
||||
cy.get('[data-cy="refetch-available-jobs-button"]')
|
||||
.should("not.be.disabled")
|
||||
.click();
|
||||
|
||||
cy.get('[data-cy="add-job-as-new-button"]').should("be.enabled").click();
|
||||
|
||||
cy.get('[data-cy="existing-owner-table"]', { timeout: 20000 })
|
||||
.find(".ant-table-tbody tr")
|
||||
.should("not.have.class", "ant-table-placeholder")
|
||||
.then(($table) => {
|
||||
cy.wrap($table).first().click();
|
||||
|
||||
cy.get('[data-cy="new_owner_checkbox"]').should("not.be", "checked");
|
||||
});
|
||||
|
||||
cy.get('[data-cy="existing-owners-ok-button"]').click();
|
||||
|
||||
cy.get(".ant-notification-notice-message")
|
||||
.contains("Job created successfully. Click to view.")
|
||||
.click();
|
||||
cy.get(".ant-notification-notice-message").contains(
|
||||
"Job created successfully. Click to view."
|
||||
);
|
||||
|
||||
cy.url().should("include", "/manage/jobs");
|
||||
cy.visit("/manage/owners");
|
||||
// Navigate to owner records
|
||||
// Get owner name
|
||||
// check list if claim number is there
|
||||
});
|
||||
}
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user