Skip to content

Commit

Permalink
fix: Allow changing csm
Browse files Browse the repository at this point in the history
  • Loading branch information
d-beezee committed May 20, 2024
1 parent c09f3a6 commit a1899b1
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 18 deletions.
2 changes: 1 addition & 1 deletion src/routes/dossiers/campaignId/_put/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ export default class RouteItem extends UserRoute<{
start_date: this.getBody().startDate,
end_date: this.getEndDate(),
close_date: this.getCloseDate(),
pm_id: this.getTesterId(),
pm_id: this.getBody().csm ?? this.getTesterId(),
project_id: this.getBody().project,
campaign_type_id: this.getBody().testType,
customer_title: this.getBody().title.customer,
Expand Down
59 changes: 42 additions & 17 deletions src/routes/dossiers/campaignId/_put/update.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,14 +70,26 @@ describe("Route POST /dossiers", () => {
},
]);

await tryber.tables.WpAppqEvdProfile.do().insert({
id: 1,
wp_user_id: 1,
name: "Test User",
const user = {
email: "",
education_id: 1,
employment_id: 1,
});
};
await tryber.tables.WpAppqEvdProfile.do().insert([
{
...user,
id: 1,
wp_user_id: 1,
name: "Test User",
},
{
...user,
id: 2,
wp_user_id: 2,
name: "Other",
surname: "User",
},
]);

await tryber.tables.WpAppqLang.do().insert([
{ id: 1, display_name: "Test Language", lang_code: "TL" },
Expand Down Expand Up @@ -168,6 +180,31 @@ describe("Route POST /dossiers", () => {
expect(campaign).toHaveProperty("campaign_type_id", 11);
});

it("Should update the campaign with the specified csm", async () => {
const response = await request(app)
.put("/dossiers/1")
.set("authorization", "Bearer admin")
.send({
...baseRequest,
csm: 2,
});

expect(response.status).toBe(200);
expect(response.body).toHaveProperty("id");
const id = response.body.id;

const responseGet = await request(app)
.get("/dossiers/1")
.set("authorization", "Bearer admin");

expect(responseGet.status).toBe(200);
expect(responseGet.body).toHaveProperty("csm");
expect(responseGet.body.csm).toEqual({
id: 2,
name: "Other User",
});
});

it("Should update the campaign with the specified title", async () => {
const response = await request(app)
.put("/dossiers/1")
Expand Down Expand Up @@ -640,16 +677,6 @@ describe("Route POST /dossiers", () => {

describe("Role handling", () => {
beforeAll(async () => {
await tryber.tables.WpAppqEvdProfile.do().insert({
id: 2,
wp_user_id: 2,
name: "Test User",
surname: "Test Surname",
education_id: 1,
employment_id: 1,
email: "",
});

await tryber.tables.CustomRoles.do().insert([
{
id: 1,
Expand All @@ -664,9 +691,7 @@ describe("Route POST /dossiers", () => {
]);
});
afterAll(async () => {
await tryber.tables.WpAppqEvdProfile.do().delete();
await tryber.tables.CustomRoles.do().delete();
await tryber.tables.WpAppqEvdProfile.do().delete();
});
afterEach(async () => {
await tryber.tables.CampaignCustomRoles.do().delete();
Expand Down

0 comments on commit a1899b1

Please sign in to comment.