Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@
"ts-node-dev": "^2.0.0",
"tsconfig-paths": "^3.14.1",
"tscpaths": "^0.0.9",
"typescript": "^4.6.3"
"typescript": "^4.6.3",
"yaml-sort": "2"
}
}
5 changes: 4 additions & 1 deletion src/reference/openapi.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6332,6 +6332,10 @@ paths:
type: array
deviceRequirements:
type: string

hasPlan:
default: false
type: boolean
endDate:
format: date-time
type: string
Expand Down Expand Up @@ -13132,4 +13136,3 @@ tags:
- name: Projects
- name: Task
- name: User
- name: Admin
46 changes: 46 additions & 0 deletions src/routes/dossiers/campaignId/_get/index.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -284,6 +284,52 @@ describe("Route GET /dossiers/:id", () => {
expect(response.body.phase).toHaveProperty("name", "Active");
});

describe("Campaign Plan", () => {
beforeEach(async () => {
await tryber.tables.CpReqPlans.do().insert({
id: 1,
name: "Standard Plan",
config: "config",
});
await tryber.tables.WpAppqEvdCampaign.do().insert({
id: 2,
project_id: 1,
campaign_type_id: 1,
title: "Test Campaign",
customer_title: "Test Customer Campaign",
start_date: "2019-08-24T14:15:22Z",
end_date: "2019-08-24T14:15:22Z",
close_date: "2019-08-27T14:15:22Z",
platform_id: 0,
os: "1",
page_manual_id: 0,
page_preview_id: 0,
pm_id: 1,
customer_id: 0,
desired_number_of_testers: 100,
auto_apply: 1,
plan_id: 1,
});
});
afterEach(async () => {
await tryber.tables.WpAppqEvdCampaign.do().delete().where("id", 2);
await tryber.tables.CpReqPlans.do().delete();
});
it("Should return whether the campaign has a plan or not", async () => {
const response = await request(app)
.get("/dossiers/1")
.set("authorization", "Bearer admin");
expect(response.status).toBe(200);
expect(response.body).toHaveProperty("hasPlan", false);

const responseWithPlan = await request(app)
.get("/dossiers/2")
.set("authorization", "Bearer admin");
expect(responseWithPlan.status).toBe(200);
expect(responseWithPlan.body).toHaveProperty("hasPlan", true);
});
});

describe("With dossier data", () => {
beforeAll(async () => {
await tryber.tables.CampaignDossierData.do().insert({
Expand Down
4 changes: 3 additions & 1 deletion src/routes/dossiers/campaignId/_get/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,8 @@ export default class RouteItem extends UserRoute<{
.as("phase_id"),
tryber.ref("name").withSchema("campaign_phase").as("phase_name"),
tryber.ref("auto_apply").withSchema("wp_appq_evd_campaign"),
tryber.ref("auto_approve").withSchema("wp_appq_evd_campaign")
tryber.ref("auto_approve").withSchema("wp_appq_evd_campaign"),
tryber.ref("plan_id").withSchema("wp_appq_evd_campaign")
)
.join(
"wp_appq_project",
Expand Down Expand Up @@ -226,6 +227,7 @@ export default class RouteItem extends UserRoute<{
try {
this.setSuccess(200, {
id: this.campaign.id,
hasPlan: this.campaign.plan_id != null,
title: {
customer: this.campaign.customer_title,
tester: this.campaign.title,
Expand Down
1 change: 1 addition & 0 deletions src/schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3020,6 +3020,7 @@ export interface operations {
name: string;
}[];
deviceRequirements?: string;
hasPlan?: boolean;
/** Format: date-time */
endDate: string;
goal?: string;
Expand Down
42 changes: 42 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2711,6 +2711,15 @@ cliui@^7.0.2:
strip-ansi "^6.0.0"
wrap-ansi "^7.0.0"

cliui@^8.0.1:
version "8.0.1"
resolved "https://registry.yarnpkg.com/cliui/-/cliui-8.0.1.tgz#0c04b075db02cbfe60dc8e6cf2f5486b1a3608aa"
integrity sha512-BSeNnyus75C4//NQ9gQt1/csTXyo/8Sb+afLAkzAptFuMsod9HFokGNudZpi/oQV73hnVK+sR+5PVRMd+Dr7YQ==
dependencies:
string-width "^4.2.0"
strip-ansi "^6.0.1"
wrap-ansi "^7.0.0"

co@^4.6.0:
version "4.6.0"
resolved "https://registry.npmjs.org/co/-/co-4.6.0.tgz"
Expand Down Expand Up @@ -4607,6 +4616,13 @@ js-yaml@^3.13.1:
argparse "^1.0.7"
esprima "^4.0.0"

js-yaml@^4.0.0:
version "4.1.1"
resolved "https://registry.yarnpkg.com/js-yaml/-/js-yaml-4.1.1.tgz#854c292467705b699476e1a2decc0c8a3458806b"
integrity sha512-qQKT4zQxXl8lLwBtHMWwaTcGfFOZviOJet3Oy/xmGk2gZH677CJM9EvtfdSkgWcATZhj/55JZ0rmy3myCT5lsA==
dependencies:
argparse "^2.0.1"

js-yaml@^4.1.0:
version "4.1.0"
resolved "https://registry.npmjs.org/js-yaml/-/js-yaml-4.1.0.tgz"
Expand Down Expand Up @@ -6970,6 +6986,14 @@ yallist@^5.0.0:
resolved "https://registry.npmjs.org/yallist/-/yallist-5.0.0.tgz#00e2de443639ed0d78fd87de0d27469fbcffb533"
integrity sha512-YgvUTfwqyc7UXVMrB+SImsVYSmTS8X/tSrtdNZMImM+n7+QTriRXyXim0mBrTXNeqzVF0KWGgHPeiyViFFrNDw==

yaml-sort@2:
version "2.1.0"
resolved "https://registry.yarnpkg.com/yaml-sort/-/yaml-sort-2.1.0.tgz#ee27132a446d359c26e4e67a02bd16d1d230e279"
integrity sha512-iiGmT3MvzfHYY7hepMdx1a2tCG6ltHRF8fSGGE4zwxPLNo2tD0KHjwLRtWThBYT71F5qTWObo6pKdZ9UYHHD5A==
dependencies:
js-yaml "^4.0.0"
yargs "^17.0.0"

yargs-parser@^20.2.2, yargs-parser@^20.x:
version "20.2.9"
resolved "https://registry.npmjs.org/yargs-parser/-/yargs-parser-20.2.9.tgz"
Expand All @@ -6980,6 +7004,11 @@ yargs-parser@^21.0.0:
resolved "https://registry.npmjs.org/yargs-parser/-/yargs-parser-21.0.1.tgz"
integrity sha512-9BK1jFpLzJROCI5TzwZL/TU4gqjK5xiHV/RfWLOahrjAko/e4DJkRDZQXfvqAsiZzzYhgAzbgz6lg48jcm4GLg==

yargs-parser@^21.1.1:
version "21.1.1"
resolved "https://registry.yarnpkg.com/yargs-parser/-/yargs-parser-21.1.1.tgz#9096bceebf990d21bb31fa9516e0ede294a77d35"
integrity sha512-tVpsJW7DdjecAiFpbIB1e3qxIQsE6NoPc5/eTdrbbIC4h0LVsWhnoa3g+m2HclBIujHzsxZ4VJVA+GUuc2/LBw==

yargs@^16.1.0:
version "16.2.0"
resolved "https://registry.npmjs.org/yargs/-/yargs-16.2.0.tgz"
Expand All @@ -6993,6 +7022,19 @@ yargs@^16.1.0:
y18n "^5.0.5"
yargs-parser "^20.2.2"

yargs@^17.0.0:
version "17.7.2"
resolved "https://registry.yarnpkg.com/yargs/-/yargs-17.7.2.tgz#991df39aca675a192b816e1e0363f9d75d2aa269"
integrity sha512-7dSzzRQ++CKnNI/krKnYRV7JKKPUXMEh61soaHKg9mrWEhzFWhFnxPxGl+69cD1Ou63C13NUPCnmIcrvqCuM6w==
dependencies:
cliui "^8.0.1"
escalade "^3.1.1"
get-caller-file "^2.0.5"
require-directory "^2.1.1"
string-width "^4.2.3"
y18n "^5.0.5"
yargs-parser "^21.1.1"

yargs@^17.3.1:
version "17.5.1"
resolved "https://registry.npmjs.org/yargs/-/yargs-17.5.1.tgz"
Expand Down
Loading