IO-2327 job importing test cases

This commit is contained in:
swtmply
2023-07-21 04:25:53 +08:00
parent 6562fd57df
commit 835b90bc4b
16 changed files with 9536 additions and 51 deletions

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,316 @@
{
"parts": {
"parts": {
"list": {
"PAE": {
"total": {
"amount": 0,
"currency": "USD",
"precision": 2
}
},
"PAN": {
"total": {
"amount": 26661,
"currency": "USD",
"precision": 2
}
}
},
"total": {
"amount": 26661,
"currency": "USD",
"precision": 2
},
"subtotal": {
"amount": 26661,
"currency": "USD",
"precision": 2
},
"prt_dsmk_total": {
"amount": 0,
"currency": "USD",
"precision": 2
}
},
"sublets": {
"total": {
"amount": 5000,
"currency": "USD",
"precision": 2
},
"subtotal": {
"amount": 5000,
"currency": "USD",
"precision": 2
}
}
},
"rates": {
"la1": {
"rate": 92.49,
"hours": 3.5,
"total": {
"amount": 32372,
"currency": "USD",
"precision": 2
}
},
"la2": {
"rate": 0,
"hours": 0,
"total": {
"amount": 0,
"currency": "USD",
"precision": 2
}
},
"la3": {
"rate": 0,
"hours": 0,
"total": {
"amount": 0,
"currency": "USD",
"precision": 2
}
},
"la4": {
"rate": 0,
"hours": 0,
"total": {
"amount": 0,
"currency": "USD",
"precision": 2
}
},
"laa": {
"rate": 0,
"hours": 0,
"total": {
"amount": 0,
"currency": "USD",
"precision": 2
}
},
"lab": {
"rate": 85.16,
"hours": 29.7,
"total": {
"amount": 252925,
"currency": "USD",
"precision": 2
}
},
"lad": {
"rate": 0,
"hours": 0,
"total": {
"amount": 0,
"currency": "USD",
"precision": 2
}
},
"lae": {
"rate": 0,
"hours": 0,
"total": {
"amount": 0,
"currency": "USD",
"precision": 2
}
},
"laf": {
"rate": 97.34,
"hours": 0,
"total": {
"amount": 0,
"currency": "USD",
"precision": 2
}
},
"lag": {
"rate": 85.16,
"hours": 0,
"total": {
"amount": 0,
"currency": "USD",
"precision": 2
}
},
"lam": {
"rate": 109.5,
"hours": 0,
"total": {
"amount": 0,
"currency": "USD",
"precision": 2
}
},
"lar": {
"rate": 85.16,
"hours": 8.500000000000002,
"total": {
"amount": 72386,
"currency": "USD",
"precision": 2
}
},
"las": {
"rate": 85.16,
"hours": 0,
"total": {
"amount": 0,
"currency": "USD",
"precision": 2
}
},
"lau": {
"rate": 0,
"hours": 0,
"total": {
"amount": 0,
"currency": "USD",
"precision": 2
}
},
"mapa": {
"rate": 55.38,
"hours": 8.500000000000002,
"total": {
"amount": 47073,
"currency": "USD",
"precision": 2
}
},
"mash": {
"rate": 6.85,
"hours": 33.199999999999996,
"total": {
"amount": 22742,
"currency": "USD",
"precision": 2
}
},
"subtotal": {
"amount": 427498,
"currency": "USD",
"precision": 2
},
"rates_subtotal": {
"amount": 357683,
"currency": "USD",
"precision": 2
}
},
"totals": {
"subtotal": {
"amount": 495355,
"currency": "USD",
"precision": 2
},
"local_tax": {
"amount": 0,
"currency": "USD",
"precision": 2
},
"state_tax": {
"amount": 34675,
"currency": "USD",
"precision": 2
},
"custPayable": {
"total": {
"amount": 30000,
"currency": "USD",
"precision": 2
},
"dep_taxes": {
"amount": 0,
"currency": "USD",
"precision": 2
},
"deductible": {
"amount": 30000,
"currency": "USD",
"precision": 2
},
"federal_tax": {
"amount": 0,
"currency": "USD",
"precision": 2
},
"other_customer_amount": {
"amount": 0,
"currency": "USD",
"precision": 2
}
},
"federal_tax": {
"amount": 24768,
"currency": "USD",
"precision": 2
},
"net_repairs": {
"amount": 524798,
"currency": "USD",
"precision": 2
},
"statePartsTax": {
"amount": 2216,
"currency": "USD",
"precision": 2
},
"total_repairs": {
"amount": 554798,
"currency": "USD",
"precision": 2
}
},
"additional": {
"pvrt": {
"amount": 0,
"currency": "USD",
"precision": 2
},
"total": {
"amount": 36196,
"currency": "USD",
"precision": 2
},
"towing": {
"amount": 0,
"currency": "USD",
"precision": 2
},
"storage": {
"amount": 0,
"currency": "USD",
"precision": 2
},
"shipping": {
"amount": 0,
"currency": "USD",
"precision": 2
},
"adjustments": {
"amount": 0,
"currency": "USD",
"precision": 2
},
"additionalCosts": {
"amount": 36196,
"currency": "USD",
"precision": 2
},
"additionalCostItems": [
{
"key": "ATS Amount",
"total": {
"amount": 36196,
"currency": "USD",
"precision": 2
}
}
]
}
}

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,316 @@
{
"parts": {
"parts": {
"list": {
"PAE": {
"total": {
"amount": 0,
"currency": "USD",
"precision": 2
}
},
"PAN": {
"total": {
"amount": 36661,
"currency": "USD",
"precision": 2
}
}
},
"total": {
"amount": 36661,
"currency": "USD",
"precision": 2
},
"subtotal": {
"amount": 36661,
"currency": "USD",
"precision": 2
},
"prt_dsmk_total": {
"amount": 0,
"currency": "USD",
"precision": 2
}
},
"sublets": {
"total": {
"amount": 5000,
"currency": "USD",
"precision": 2
},
"subtotal": {
"amount": 5000,
"currency": "USD",
"precision": 2
}
}
},
"rates": {
"la1": {
"rate": 92.49,
"hours": 3.5,
"total": {
"amount": 32372,
"currency": "USD",
"precision": 2
}
},
"la2": {
"rate": 0,
"hours": 0,
"total": {
"amount": 0,
"currency": "USD",
"precision": 2
}
},
"la3": {
"rate": 0,
"hours": 0,
"total": {
"amount": 0,
"currency": "USD",
"precision": 2
}
},
"la4": {
"rate": 0,
"hours": 0,
"total": {
"amount": 0,
"currency": "USD",
"precision": 2
}
},
"laa": {
"rate": 0,
"hours": 0,
"total": {
"amount": 0,
"currency": "USD",
"precision": 2
}
},
"lab": {
"rate": 85.16,
"hours": 29.7,
"total": {
"amount": 252925,
"currency": "USD",
"precision": 2
}
},
"lad": {
"rate": 0,
"hours": 0,
"total": {
"amount": 0,
"currency": "USD",
"precision": 2
}
},
"lae": {
"rate": 0,
"hours": 0,
"total": {
"amount": 0,
"currency": "USD",
"precision": 2
}
},
"laf": {
"rate": 97.34,
"hours": 0,
"total": {
"amount": 0,
"currency": "USD",
"precision": 2
}
},
"lag": {
"rate": 85.16,
"hours": 0,
"total": {
"amount": 0,
"currency": "USD",
"precision": 2
}
},
"lam": {
"rate": 109.5,
"hours": 0,
"total": {
"amount": 0,
"currency": "USD",
"precision": 2
}
},
"lar": {
"rate": 85.16,
"hours": 8.500000000000002,
"total": {
"amount": 72386,
"currency": "USD",
"precision": 2
}
},
"las": {
"rate": 85.16,
"hours": 0,
"total": {
"amount": 0,
"currency": "USD",
"precision": 2
}
},
"lau": {
"rate": 0,
"hours": 0,
"total": {
"amount": 0,
"currency": "USD",
"precision": 2
}
},
"mapa": {
"rate": 55.38,
"hours": 8.500000000000002,
"total": {
"amount": 47073,
"currency": "USD",
"precision": 2
}
},
"mash": {
"rate": 6.85,
"hours": 33.199999999999996,
"total": {
"amount": 22742,
"currency": "USD",
"precision": 2
}
},
"subtotal": {
"amount": 427498,
"currency": "USD",
"precision": 2
},
"rates_subtotal": {
"amount": 357683,
"currency": "USD",
"precision": 2
}
},
"totals": {
"subtotal": {
"amount": 505355,
"currency": "USD",
"precision": 2
},
"local_tax": {
"amount": 0,
"currency": "USD",
"precision": 2
},
"state_tax": {
"amount": 35375,
"currency": "USD",
"precision": 2
},
"custPayable": {
"total": {
"amount": 30000,
"currency": "USD",
"precision": 2
},
"dep_taxes": {
"amount": 0,
"currency": "USD",
"precision": 2
},
"deductible": {
"amount": 30000,
"currency": "USD",
"precision": 2
},
"federal_tax": {
"amount": 0,
"currency": "USD",
"precision": 2
},
"other_customer_amount": {
"amount": 0,
"currency": "USD",
"precision": 2
}
},
"federal_tax": {
"amount": 25268,
"currency": "USD",
"precision": 2
},
"net_repairs": {
"amount": 535998,
"currency": "USD",
"precision": 2
},
"statePartsTax": {
"amount": 2916,
"currency": "USD",
"precision": 2
},
"total_repairs": {
"amount": 565998,
"currency": "USD",
"precision": 2
}
},
"additional": {
"pvrt": {
"amount": 0,
"currency": "USD",
"precision": 2
},
"total": {
"amount": 36196,
"currency": "USD",
"precision": 2
},
"towing": {
"amount": 0,
"currency": "USD",
"precision": 2
},
"storage": {
"amount": 0,
"currency": "USD",
"precision": 2
},
"shipping": {
"amount": 0,
"currency": "USD",
"precision": 2
},
"adjustments": {
"amount": 0,
"currency": "USD",
"precision": 2
},
"additionalCosts": {
"amount": 36196,
"currency": "USD",
"precision": 2
},
"additionalCostItems": [
{
"key": "ATS Amount",
"total": {
"amount": 36196,
"currency": "USD",
"precision": 2
}
}
]
}
}

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -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
});
}
);

View File

@@ -108,6 +108,7 @@ export function JobTotalsTableTotals({ bodyshop, job }) {
return (
<Table
data-cy="job-totals-table"
columns={columns}
rowKey="key"
showHeader={false}

View File

@@ -218,6 +218,7 @@ export function JobsAvailableComponent({
extra={
<Space wrap>
<Button
data-cy="refetch-available-jobs-button"
onClick={() => {
refetch();
}}

View File

@@ -190,6 +190,7 @@ export default function JobsFindModalComponent({
/>
<Divider />
<Checkbox
data-cy="override-header-checkbox"
defaultChecked={importOptions.overrideHeader}
onChange={(e) =>
setImportOptions({

View File

@@ -172,4 +172,9 @@ const client = new ApolloClient({
},
},
});
if (window.Cypress) {
window.graphqlClient = client;
}
export default client;

View File

@@ -138,6 +138,12 @@ app.post(
);
app.post("/job/totalsssu", fb.validateFirebaseIdToken, job.totalsSsu);
app.post("/job/costing", fb.validateFirebaseIdToken, job.costing);
if (!process.env.NODE_ENV) {
const testQuery = require("./server/test/query").testQuery;
app.post("/test/query", testQuery);
}
app.post("/job/costingmulti", fb.validateFirebaseIdToken, job.costingmulti);
var partsScan = require("./server/parts-scan/parts-scan");
app.post("/job/partsscan", fb.validateFirebaseIdToken, partsScan.partsScan);

View File

@@ -12,6 +12,12 @@ query FIND_BODYSHOP_BY_MESSAGING_SERVICE_SID(
}
`;
exports.INSERT_AVAILABLE_JOB = `mutation INSERT_AVAILABLE_JOB($job: available_jobs_insert_input!) {
insert_available_jobs_one(object: $job) {
id
}
}`;
exports.UNARCHIVE_CONVERSATION = `
mutation UNARCHIVE_CONVERSATION($id: uuid!) {
update_conversations_by_pk(pk_columns: {id: $id}, _set: {archived: false}) {

24
server/test/query.js Normal file
View File

@@ -0,0 +1,24 @@
const GraphQLClient = require("graphql-request").GraphQLClient;
exports.testQuery = async function (req, res) {
const BearerToken = req.headers.authorization;
const { query, ...rest } = req.body;
const client = new GraphQLClient(process.env.GRAPHQL_ENDPOINT, {
headers: {
Authorization: BearerToken,
},
});
try {
const result = await client
.setHeaders({ Authorization: BearerToken })
.request(query, {
...rest,
});
res.status(200).json(result);
} catch (error) {
res.status(400).send(JSON.stringify(error));
}
};