diff --git a/src/routes/dossiers/_post/creation.spec.ts b/src/routes/dossiers/_post/creation.spec.ts index b48a3eab8..b8ba68957 100644 --- a/src/routes/dossiers/_post/creation.spec.ts +++ b/src/routes/dossiers/_post/creation.spec.ts @@ -229,7 +229,7 @@ describe("Route POST /dossiers", () => { .where({ id }) .first(); - expect(campaign).toHaveProperty("start_date", "2021-08-24T14:15:22Z"); + expect(campaign).toHaveProperty("start_date", "2021-08-24 14:15:22"); }); it("Should create a campaign with the specified end date ", async () => { @@ -250,7 +250,7 @@ describe("Route POST /dossiers", () => { .where({ id }) .first(); - expect(campaign).toHaveProperty("end_date", "2021-08-20T14:15:22Z"); + expect(campaign).toHaveProperty("end_date", "2021-08-20 14:15:22"); }); it("Should create a campaign with the specified close date ", async () => { @@ -271,7 +271,7 @@ describe("Route POST /dossiers", () => { .where({ id }) .first(); - expect(campaign).toHaveProperty("close_date", "2021-08-20T14:15:22Z"); + expect(campaign).toHaveProperty("close_date", "2021-08-20 14:15:22"); }); it("Should create a campaign with the end date as start date + 7 if left unspecified", async () => { @@ -292,7 +292,7 @@ describe("Route POST /dossiers", () => { .where({ id }) .first(); - expect(campaign).toHaveProperty("end_date", "2021-08-27T14:15:22Z"); + expect(campaign).toHaveProperty("end_date", "2021-08-27 14:15:22"); }); it("Should create a campaign with the close date as start date + 14 if left unspecified", async () => { @@ -313,7 +313,7 @@ describe("Route POST /dossiers", () => { .where({ id }) .first(); - expect(campaign).toHaveProperty("close_date", "2021-09-03T14:15:22Z"); + expect(campaign).toHaveProperty("close_date", "2021-09-03 14:15:22"); }); it("Should create a campaign with current user as pm_id if left unspecified", async () => { diff --git a/src/routes/dossiers/_post/index.ts b/src/routes/dossiers/_post/index.ts index 30877bbed..88359a00d 100644 --- a/src/routes/dossiers/_post/index.ts +++ b/src/routes/dossiers/_post/index.ts @@ -246,16 +246,13 @@ export default class RouteItem extends UserRoute<{ .insert({ title: this.getBody().title.tester, platform_id: 0, - /* start_date: + start_date: this.getBody().startDate?.toString().slice(0, 19).replace("T", " ") || "", end_date: this.getEndDate()?.toString().slice(0, 19).replace("T", " ") || "", close_date: - this.getCloseDate()?.toString().slice(0, 19).replace("T", " ") || "",*/ - start_date: this.getBody().startDate, - end_date: this.getEndDate(), - close_date: this.getCloseDate(), + this.getCloseDate()?.toString().slice(0, 19).replace("T", " ") || "", page_preview_id: 0, page_manual_id: 0, customer_id: 0, diff --git a/src/routes/dossiers/campaignId/_put/index.ts b/src/routes/dossiers/campaignId/_put/index.ts index b0719ce90..1a0723670 100644 --- a/src/routes/dossiers/campaignId/_put/index.ts +++ b/src/routes/dossiers/campaignId/_put/index.ts @@ -116,13 +116,16 @@ export default class RouteItem extends UserRoute<{ private async updateCampaign() { const { os, form_factor } = await this.getDevices(); - console.log(typeof this.getBody().target?.cap); await tryber.tables.WpAppqEvdCampaign.do() .update({ title: this.getBody().title.tester, - start_date: this.getBody().startDate, - end_date: this.getEndDate(), - close_date: this.getCloseDate(), + start_date: + this.getBody().startDate?.toString().slice(0, 19).replace("T", " ") || + "", + end_date: + this.getEndDate()?.toString().slice(0, 19).replace("T", " ") || "", + close_date: + this.getCloseDate()?.toString().slice(0, 19).replace("T", " ") || "", pm_id: this.getBody().csm ?? this.getTesterId(), project_id: this.getBody().project, campaign_type_id: this.getBody().testType, diff --git a/src/routes/dossiers/campaignId/_put/update.spec.ts b/src/routes/dossiers/campaignId/_put/update.spec.ts index be9f9d4d5..7a73983ac 100644 --- a/src/routes/dossiers/campaignId/_put/update.spec.ts +++ b/src/routes/dossiers/campaignId/_put/update.spec.ts @@ -265,7 +265,7 @@ describe("Route POST /dossiers", () => { .where({ id }) .first(); - expect(campaign).toHaveProperty("start_date", "2021-08-24T14:15:22Z"); + expect(campaign).toHaveProperty("start_date", "2021-08-24 14:15:22"); }); it("Should update the campaign with the specified end date ", async () => { @@ -286,7 +286,7 @@ describe("Route POST /dossiers", () => { .where({ id }) .first(); - expect(campaign).toHaveProperty("end_date", "2021-08-20T14:15:22Z"); + expect(campaign).toHaveProperty("end_date", "2021-08-20 14:15:22"); }); it("Should update the campaign with the specified close date ", async () => { @@ -307,7 +307,7 @@ describe("Route POST /dossiers", () => { .where({ id }) .first(); - expect(campaign).toHaveProperty("close_date", "2021-08-20T14:15:22Z"); + expect(campaign).toHaveProperty("close_date", "2021-08-20 14:15:22"); }); it("Should leave the end date of the campaign unedited if left unspecified", async () => { @@ -328,7 +328,7 @@ describe("Route POST /dossiers", () => { .where({ id }) .first(); - expect(campaign).toHaveProperty("end_date", "2019-08-24T14:15:22Z"); + expect(campaign).toHaveProperty("end_date", "2019-08-24 14:15:22"); }); it("Should leave the close date of the campaign unedited if left unspecified", async () => { @@ -349,7 +349,7 @@ describe("Route POST /dossiers", () => { .where({ id }) .first(); - expect(campaign).toHaveProperty("close_date", "2019-08-25T14:15:22Z"); + expect(campaign).toHaveProperty("close_date", "2019-08-25 14:15:22"); }); it("Should update the campaign with current user as pm_id", async () => { @@ -614,7 +614,6 @@ describe("Route POST /dossiers", () => { const responseGet = await request(app) .get("/dossiers/1") .set("authorization", "Bearer admin"); - console.log(responseGet.body); expect(responseGet.status).toBe(200); expect(responseGet.body).toHaveProperty("countries", ["DE", "FR"]); }); @@ -630,7 +629,6 @@ describe("Route POST /dossiers", () => { const responseGet = await request(app) .get("/dossiers/1") .set("authorization", "Bearer admin"); - console.log(responseGet.body); expect(responseGet.status).toBe(200); expect(responseGet.body).toHaveProperty("languages"); expect(responseGet.body.languages).toHaveLength(1);