IO-2327 job import test cases
This commit is contained in:
4
client/cypress.env.json
Normal file
4
client/cypress.env.json
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
{
|
||||||
|
"graphql_dev_endpoint": "https://db.dev.bodyshop.app/v1/graphql",
|
||||||
|
"uploaded_by_email": "john@imex.dev"
|
||||||
|
}
|
||||||
@@ -11,6 +11,25 @@ const query = `mutation INSERT_AVAILABLE_JOB($job: available_jobs_insert_input!)
|
|||||||
}
|
}
|
||||||
}`;
|
}`;
|
||||||
|
|
||||||
|
const createJobEstimate = (job, bodyshopid) => {
|
||||||
|
return {
|
||||||
|
owner: {
|
||||||
|
data: {
|
||||||
|
shopid: bodyshopid,
|
||||||
|
...job.owner.data,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
vehicle: {
|
||||||
|
data: {
|
||||||
|
shopid: bodyshopid,
|
||||||
|
...job.vehicle.data,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
shopid: bodyshopid,
|
||||||
|
...job,
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
describe(
|
describe(
|
||||||
"Importing an available job",
|
"Importing an available job",
|
||||||
{
|
{
|
||||||
@@ -23,7 +42,7 @@ describe(
|
|||||||
cy.visit("/manage/available");
|
cy.visit("/manage/available");
|
||||||
// intercept bodyshop query for id
|
// intercept bodyshop query for id
|
||||||
|
|
||||||
cy.intercept("POST", "https://db.dev.bodyshop.app/v1/graphql", (req) => {
|
cy.intercept("POST", Cypress.env("graphql_dev_endpoint"), (req) => {
|
||||||
if (req.body.operationName === "QUERY_BODYSHOP") {
|
if (req.body.operationName === "QUERY_BODYSHOP") {
|
||||||
req.alias = "bodyshop";
|
req.alias = "bodyshop";
|
||||||
}
|
}
|
||||||
@@ -36,8 +55,8 @@ describe(
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
it.only("Enters a job programatically", () => {
|
it("Enters a job programatically", () => {
|
||||||
cy.intercept("POST", "https://db.dev.bodyshop.app/v1/graphql", (req) => {
|
cy.intercept("POST", Cypress.env("graphql_dev_endpoint"), (req) => {
|
||||||
if (req.body.operationName === "QUERY_AVAILABLE_JOBS") {
|
if (req.body.operationName === "QUERY_AVAILABLE_JOBS") {
|
||||||
req.alias = "availableJobs";
|
req.alias = "availableJobs";
|
||||||
}
|
}
|
||||||
@@ -47,53 +66,20 @@ describe(
|
|||||||
const token = request.headers.authorization;
|
const token = request.headers.authorization;
|
||||||
|
|
||||||
cy.get("@bodyshopid").then((bodyshopid) => {
|
cy.get("@bodyshopid").then((bodyshopid) => {
|
||||||
const job_est_data = {
|
const job_est_data = createJobEstimate(job, bodyshopid);
|
||||||
owner: {
|
|
||||||
data: {
|
|
||||||
shopid: bodyshopid,
|
|
||||||
...job.owner.data,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
vehicle: {
|
|
||||||
data: {
|
|
||||||
shopid: bodyshopid,
|
|
||||||
...job.vehicle.data,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
shopid: bodyshopid,
|
|
||||||
...job,
|
|
||||||
};
|
|
||||||
|
|
||||||
cy.request({
|
cy.insertAvailableJob({
|
||||||
url: "http://localhost:4000/test/query",
|
bodyshopid,
|
||||||
method: "POST",
|
job,
|
||||||
headers: {
|
token,
|
||||||
"Content-Type": "application/json",
|
job_est_data,
|
||||||
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", () => {
|
it("creates a new owner record for the job", () => {
|
||||||
cy.intercept("POST", "https://db.dev.bodyshop.app/v1/graphql", (req) => {
|
cy.intercept("POST", Cypress.env("graphql_dev_endpoint"), (req) => {
|
||||||
if (req.body.operationName === "QUERY_AVAILABLE_JOBS") {
|
if (req.body.operationName === "QUERY_AVAILABLE_JOBS") {
|
||||||
req.alias = "availableJobs";
|
req.alias = "availableJobs";
|
||||||
}
|
}
|
||||||
@@ -108,14 +94,17 @@ describe(
|
|||||||
.parent()
|
.parent()
|
||||||
.as("row");
|
.as("row");
|
||||||
|
|
||||||
cy.get('[data-cy="add-job-as-new-button"]').should("be.enabled").click();
|
cy.get("@row")
|
||||||
|
.find('[data-cy="add-job-as-new-button"]')
|
||||||
|
.should("be.enabled")
|
||||||
|
.click();
|
||||||
|
|
||||||
cy.get('[data-cy="new_owner_checkbox"]').should("be.checked");
|
cy.get('[data-cy="new_owner_checkbox"]').should("be.checked");
|
||||||
cy.get('[data-cy="existing-owners-ok-button"]')
|
cy.get('[data-cy="existing-owners-ok-button"]')
|
||||||
.should("be.enabled")
|
.should("be.enabled")
|
||||||
.click();
|
.click();
|
||||||
|
|
||||||
cy.intercept("POST", "https://db.dev.bodyshop.app/v1/graphql", (req) => {
|
cy.intercept("POST", Cypress.env("graphql_dev_endpoint"), (req) => {
|
||||||
if (req.body.operationName === "INSERT_JOB") {
|
if (req.body.operationName === "INSERT_JOB") {
|
||||||
req.alias = "insertJob";
|
req.alias = "insertJob";
|
||||||
}
|
}
|
||||||
@@ -153,7 +142,7 @@ describe(
|
|||||||
});
|
});
|
||||||
|
|
||||||
it("imports a supplement for an existing job", () => {
|
it("imports a supplement for an existing job", () => {
|
||||||
cy.intercept("POST", "https://db.dev.bodyshop.app/v1/graphql", (req) => {
|
cy.intercept("POST", Cypress.env("graphql_dev_endpoint"), (req) => {
|
||||||
if (req.body.operationName === "QUERY_AVAILABLE_JOBS") {
|
if (req.body.operationName === "QUERY_AVAILABLE_JOBS") {
|
||||||
req.alias = "availableJobs";
|
req.alias = "availableJobs";
|
||||||
}
|
}
|
||||||
@@ -162,30 +151,16 @@ describe(
|
|||||||
cy.wait("@availableJobs").then(({ request }) => {
|
cy.wait("@availableJobs").then(({ request }) => {
|
||||||
const token = request.headers.authorization;
|
const token = request.headers.authorization;
|
||||||
|
|
||||||
cy.request({
|
cy.get("@bodyshopid").then((bodyshopid) => {
|
||||||
url: "http://localhost:4000/test/query",
|
const job_est_data = createJobEstimate(jobSupplement, bodyshopid);
|
||||||
method: "POST",
|
|
||||||
headers: {
|
cy.insertAvailableJob({
|
||||||
"Content-Type": "application/json",
|
bodyshopid,
|
||||||
Authorization: token,
|
job: jobSupplement,
|
||||||
},
|
token,
|
||||||
body: {
|
job_est_data,
|
||||||
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"]')
|
cy.get('[data-cy="refetch-available-jobs-button"]')
|
||||||
@@ -239,7 +214,7 @@ describe(
|
|||||||
});
|
});
|
||||||
|
|
||||||
it("imports a supplement and override estimate header", () => {
|
it("imports a supplement and override estimate header", () => {
|
||||||
cy.intercept("POST", "https://db.dev.bodyshop.app/v1/graphql", (req) => {
|
cy.intercept("POST", Cypress.env("graphql_dev_endpoint"), (req) => {
|
||||||
if (req.body.operationName === "QUERY_AVAILABLE_JOBS") {
|
if (req.body.operationName === "QUERY_AVAILABLE_JOBS") {
|
||||||
req.alias = "availableJobs";
|
req.alias = "availableJobs";
|
||||||
}
|
}
|
||||||
@@ -248,30 +223,16 @@ describe(
|
|||||||
cy.wait("@availableJobs").then(({ request }) => {
|
cy.wait("@availableJobs").then(({ request }) => {
|
||||||
const token = request.headers.authorization;
|
const token = request.headers.authorization;
|
||||||
|
|
||||||
cy.request({
|
cy.get("@bodyshopid").then((bodyshopid) => {
|
||||||
url: "http://localhost:4000/test/query",
|
const job_est_data = createJobEstimate(jobSupplement, bodyshopid);
|
||||||
method: "POST",
|
|
||||||
headers: {
|
cy.insertAvailableJob({
|
||||||
"Content-Type": "application/json",
|
bodyshopid,
|
||||||
Authorization: token,
|
job: jobSupplement,
|
||||||
},
|
token,
|
||||||
body: {
|
job_est_data,
|
||||||
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"]')
|
cy.get('[data-cy="refetch-available-jobs-button"]')
|
||||||
@@ -327,8 +288,8 @@ describe(
|
|||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
it.skip("imports a job with an existing owner", () => {
|
it("imports a job with an existing owner", () => {
|
||||||
cy.intercept("POST", "https://db.dev.bodyshop.app/v1/graphql", (req) => {
|
cy.intercept("POST", Cypress.env("graphql_dev_endpoint"), (req) => {
|
||||||
if (req.body.operationName === "QUERY_AVAILABLE_JOBS") {
|
if (req.body.operationName === "QUERY_AVAILABLE_JOBS") {
|
||||||
req.alias = "availableJobs";
|
req.alias = "availableJobs";
|
||||||
}
|
}
|
||||||
@@ -337,30 +298,16 @@ describe(
|
|||||||
cy.wait("@availableJobs").then(({ request }) => {
|
cy.wait("@availableJobs").then(({ request }) => {
|
||||||
const token = request.headers.authorization;
|
const token = request.headers.authorization;
|
||||||
|
|
||||||
cy.request({
|
cy.get("@bodyshopid").then((bodyshopid) => {
|
||||||
url: "http://localhost:4000/test/query",
|
const job_est_data = createJobEstimate(job2, bodyshopid);
|
||||||
method: "POST",
|
|
||||||
headers: {
|
cy.insertAvailableJob({
|
||||||
"Content-Type": "application/json",
|
bodyshopid,
|
||||||
Authorization: token,
|
job: job2,
|
||||||
},
|
token,
|
||||||
body: {
|
job_est_data,
|
||||||
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"]')
|
cy.get('[data-cy="refetch-available-jobs-button"]')
|
||||||
@@ -386,8 +333,24 @@ describe(
|
|||||||
|
|
||||||
cy.visit("/manage/owners");
|
cy.visit("/manage/owners");
|
||||||
// Navigate to owner records
|
// Navigate to owner records
|
||||||
|
cy.get('[data-cy="owners-table"]')
|
||||||
|
.find(".ant-table-tbody")
|
||||||
|
.find("> tr:not(.ant-table-measure-row)")
|
||||||
|
.as("owners-table")
|
||||||
|
.should("not.have.class", "ant-table-placeholder");
|
||||||
// Get owner name
|
// Get owner name
|
||||||
|
cy.get("@owners-table")
|
||||||
|
.contains(`${job2.owner.data.ownr_fn} ${job2.owner.data.ownr_ln}`)
|
||||||
|
.click();
|
||||||
|
|
||||||
// check list if claim number is there
|
// check list if claim number is there
|
||||||
|
cy.get('[data-cy="owner-jobs-table"]')
|
||||||
|
.find(".ant-table-tbody")
|
||||||
|
.find("> tr:not(.ant-table-measure-row)")
|
||||||
|
.as("owner-jobs-table")
|
||||||
|
.should("not.have.class", "ant-table-placeholder");
|
||||||
|
// Get owner name
|
||||||
|
cy.get("@owner-jobs-table").contains(job2.clm_no).should("exist");
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -82,3 +82,39 @@ Cypress.Commands.add("antdFormSelect", (name, text, cb) => {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
Cypress.Commands.add(
|
||||||
|
"insertAvailableJob",
|
||||||
|
({ bodyshopid, job, job_est_data, token }) => {
|
||||||
|
const query = `mutation INSERT_AVAILABLE_JOB($job: available_jobs_insert_input!) {
|
||||||
|
insert_available_jobs_one(object: $job) {
|
||||||
|
id
|
||||||
|
}
|
||||||
|
}`;
|
||||||
|
|
||||||
|
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: Cypress.env("uploaded_by_email"),
|
||||||
|
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");
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|||||||
@@ -75,6 +75,7 @@ function OwnerDetailJobsComponent({ bodyshop, owner }) {
|
|||||||
}
|
}
|
||||||
>
|
>
|
||||||
<Table
|
<Table
|
||||||
|
data-cy="owner-jobs-table"
|
||||||
pagination={{ position: "bottom" }}
|
pagination={{ position: "bottom" }}
|
||||||
columns={columns}
|
columns={columns}
|
||||||
scroll={{ x: true }}
|
scroll={{ x: true }}
|
||||||
|
|||||||
@@ -115,6 +115,7 @@ export default function OwnersListComponent({
|
|||||||
}
|
}
|
||||||
>
|
>
|
||||||
<Table
|
<Table
|
||||||
|
data-cy="owners-table"
|
||||||
loading={loading}
|
loading={loading}
|
||||||
pagination={{
|
pagination={{
|
||||||
position: "top",
|
position: "top",
|
||||||
|
|||||||
Reference in New Issue
Block a user