Skip to content

Commit 8824285

Browse files
authored
Merge pull request #422 from AppQuality/develop
Release 20250630
2 parents 72aa07d + 22e183a commit 8824285

2 files changed

Lines changed: 126 additions & 0 deletions

File tree

src/routes/dossiers/campaignId/_put/index.ts

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,32 @@ export default class RouteItem extends UserRoute<{
152152
await this.updateCampaignDossierData();
153153

154154
await this.updateTesterVisibilityCriteria();
155+
156+
await this.updatePlanData();
157+
}
158+
159+
private async updatePlanData() {
160+
const plan = await tryber.tables.WpAppqEvdCampaign.do()
161+
.select("plan_id")
162+
.where({
163+
id: this.campaignId,
164+
})
165+
.first();
166+
if (!plan || !plan.plan_id) return;
167+
168+
const project = await tryber.tables.WpAppqProject.do()
169+
.select("id", "customer_id")
170+
.where({
171+
id: this.getBody().project,
172+
})
173+
.first();
174+
175+
if (!project || !project.customer_id) return;
176+
177+
await tryber.tables.CpReqPlans.do().update({
178+
workspace_id: project.customer_id,
179+
project_id: project.id,
180+
});
155181
}
156182

157183
private async updateTesterVisibilityCriteria() {
Lines changed: 100 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,100 @@
1+
import app from "@src/app";
2+
import { tryber } from "@src/features/database";
3+
import request from "supertest";
4+
5+
const baseRequest = {
6+
project: 10,
7+
testType: 10,
8+
title: {
9+
customer: "Campaign Title for Customer",
10+
tester: "Campaign Title for Tester",
11+
},
12+
startDate: "2019-08-24T14:15:22Z",
13+
deviceList: [],
14+
};
15+
16+
describe("Route POST /dossiers - plan", () => {
17+
beforeEach(async () => {
18+
await tryber.tables.WpAppqCampaignType.do().insert({
19+
id: 10,
20+
category_id: 1,
21+
name: "Test Campaign Type",
22+
description: "Test Description",
23+
});
24+
await tryber.tables.WpAppqProject.do().insert([
25+
{
26+
id: 1,
27+
display_name: "Test Project",
28+
customer_id: 1,
29+
edited_by: 1,
30+
},
31+
{
32+
id: 10,
33+
display_name: "New Project",
34+
customer_id: 10,
35+
edited_by: 1,
36+
},
37+
]);
38+
await tryber.tables.WpAppqCustomer.do().insert([
39+
{
40+
id: 1,
41+
company: "Test Customer",
42+
pm_id: 1,
43+
},
44+
{
45+
id: 10,
46+
company: "New Customer",
47+
pm_id: 1,
48+
},
49+
]);
50+
await tryber.tables.CpReqPlans.do().insert({
51+
id: 1,
52+
name: "Test Plan",
53+
config: "{}",
54+
project_id: 1,
55+
workspace_id: 1,
56+
});
57+
await tryber.tables.WpAppqEvdCampaign.do().insert({
58+
id: 1,
59+
project_id: 1,
60+
campaign_type_id: 1,
61+
title: "Test Campaign",
62+
customer_title: "Test Customer Campaign",
63+
start_date: "2019-08-24T14:15:22Z",
64+
end_date: "2019-08-24T14:15:22Z",
65+
platform_id: 0,
66+
os: "1",
67+
page_manual_id: 0,
68+
page_preview_id: 0,
69+
pm_id: 1,
70+
customer_id: 0,
71+
plan_id: 1,
72+
});
73+
await tryber.tables.CampaignDossierData.do().insert({
74+
id: 1,
75+
campaign_id: 1,
76+
link: "https://example.com",
77+
created_by: 1,
78+
updated_by: 1,
79+
});
80+
});
81+
82+
it("should update the plan project and workspace", async () => {
83+
const response = await request(app)
84+
.put("/dossiers/1")
85+
.send({
86+
...baseRequest,
87+
})
88+
.set("Authorization", "Bearer admin");
89+
90+
const plan = await tryber.tables.CpReqPlans.do()
91+
.select("project_id", "workspace_id")
92+
.where({ id: 1 })
93+
.first();
94+
95+
if (!plan) throw new Error("Plan not found");
96+
97+
expect(plan.project_id).toBe(10);
98+
expect(plan.workspace_id).toBe(10);
99+
});
100+
});

0 commit comments

Comments
 (0)