-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcampaigns.test.ts
More file actions
742 lines (636 loc) · 23.8 KB
/
campaigns.test.ts
File metadata and controls
742 lines (636 loc) · 23.8 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
import { afterAll, beforeAll, describe, expect, it } from "@jest/globals";
import { IterableClient } from "../../src/client";
import {
cleanupTestUser,
createTestIdentifiers,
retryRateLimited,
retryWithBackoff,
uniqueId,
withTimeout,
} from "../utils/test-helpers";
describe("Campaign Management Integration Tests", () => {
let client: IterableClient;
let testListId: number;
let testTemplateId: number;
let createdTestList = false;
let createdTestTemplate = false;
const { testUserEmail } = createTestIdentifiers();
const extractTemplateId = (response: { msg: string }): number => {
const templateIdMatch = response.msg.match(/IDs: (\d+)/);
if (!templateIdMatch || !templateIdMatch[1]) {
throw new Error(
`Could not extract template ID from response: ${response.msg}`
);
}
return parseInt(templateIdMatch[1]);
};
const createTestBlastCampaign = async (params: {
name: string;
templateId: number;
listIds: number[];
}) => {
const createResponse = await retryRateLimited(
() => withTimeout(client.createBlastCampaign(params)),
`Create blast campaign: ${params.name}`
);
return createResponse.campaignId;
};
const createTestTriggeredCampaign = async (params: {
name: string;
templateId: number;
}) => {
const createResponse = await retryRateLimited(
() => withTimeout(client.createTriggeredCampaign(params)),
`Create triggered campaign: ${params.name}`
);
return createResponse.campaignId;
};
const waitForCampaignState = async (
campaignId: number,
expectedState: string | ((state: string) => boolean),
description?: string
) => {
return retryWithBackoff(
async () => {
const campaign = await withTimeout(client.getCampaign({ id: campaignId }));
const isExpectedState = typeof expectedState === "function"
? expectedState(campaign.campaignState)
: campaign.campaignState === expectedState;
if (!isExpectedState) {
throw new Error(`Campaign still in ${campaign.campaignState} state`);
}
return campaign;
},
{
description: description || `Campaign state to change to ${expectedState}`,
initialIntervalMs: 1000,
maxIntervalMs: 5000,
timeoutMs: 30000,
}
);
};
const performCampaignAction = async <T>(
action: () => Promise<T>,
description: string
): Promise<T> => {
return retryWithBackoff(action, {
description,
initialIntervalMs: 1000,
maxIntervalMs: 5000,
timeoutMs: 30000,
shouldRetryOnError: (error: any) =>
error?.message?.includes("doesn't exist") ||
error?.message?.includes("Invalid campaign id") ||
error?.message?.includes("is not scheduled"),
});
};
const cleanupCampaign = async (campaignId: number) => {
try {
await client.archiveCampaigns({ campaignIds: [campaignId] });
} catch (cleanupError) {
console.warn(`Failed to cleanup test campaign ${campaignId}`, cleanupError);
}
};
beforeAll(async () => {
client = new IterableClient();
const listsResponse = await withTimeout(client.getLists());
const [existingList] = listsResponse.lists;
if (existingList) {
testListId = existingList.id;
} else {
const createResponse = await withTimeout(
client.createList({
name: `MCP Campaign Test List ${uniqueId()}`,
description: "Temporary list for campaign integration testing",
})
);
testListId = createResponse.listId;
createdTestList = true;
}
await withTimeout(
client.updateUser({
email: testUserEmail,
dataFields: { campaignTestSource: "mcp-integration-test" },
})
);
await withTimeout(
client.subscribeUserByEmail({
subscriptionGroup: "emailList",
subscriptionGroupId: testListId,
userEmail: testUserEmail,
})
);
const templatesResponse = await withTimeout(client.getTemplates({ pageSize: 1 }));
if (templatesResponse.templates.length > 0) {
testTemplateId = templatesResponse.templates[0]!.templateId;
} else {
const templateData = {
name: uniqueId("MCP-Campaign-Test-Template"),
clientTemplateId: uniqueId("mcp-campaign-test-template"),
subject: "Campaign Integration Test",
fromName: "Alex Newman",
fromEmail: "alex.newman@iterable.com",
html: "<html><body><h1>Test Campaign</h1><p>Hello {{firstName}}!</p><p><a href='{{unsubscribeUrl}}'>Unsubscribe</a></p></body></html>",
plainText: "Test Campaign\n\nHello {{firstName}}!\n\nUnsubscribe: {{unsubscribeUrl}}",
templateType: "Base" as const,
};
const createTemplateResponse = await withTimeout(
client.upsertEmailTemplate(templateData)
);
testTemplateId = extractTemplateId(createTemplateResponse as { msg: string });
createdTestTemplate = true;
}
});
afterAll(async () => {
await cleanupTestUser(client, testUserEmail);
if (createdTestList) {
try {
await withTimeout(client.deleteList({ listId: testListId }));
} catch (error) {
console.warn(`Failed to delete test list ${testListId}:`, error);
}
}
if (createdTestTemplate) {
try {
await withTimeout(client.deleteTemplates({ ids: [testTemplateId] }));
} catch (error) {
console.warn(`Failed to delete test template ${testTemplateId}:`, error);
}
}
client.destroy();
});
it("should retrieve campaigns", async () => {
const response = await retryRateLimited(
() => withTimeout(client.getCampaigns()),
"Get campaigns"
);
expect(response).toHaveProperty("campaigns");
expect(response).toHaveProperty("totalCampaignsCount");
expect(Array.isArray(response.campaigns)).toBe(true);
expect(typeof response.totalCampaignsCount).toBe("number");
// Verify campaign structure
if (response.campaigns.length > 0) {
const campaign = response.campaigns[0];
expect(campaign).toHaveProperty("id");
expect(campaign).toHaveProperty("name");
expect(campaign).toHaveProperty("type");
expect(campaign).toHaveProperty("campaignState");
if (campaign) {
expect(["Blast", "Triggered"]).toContain(campaign.type);
expect([
"Draft",
"Scheduled",
"Running",
"Finished",
"Aborted",
"Ready",
"Archived",
]).toContain(campaign.campaignState);
}
}
});
it("should retrieve campaigns with pagination", async () => {
const response = await retryRateLimited(
() => withTimeout(client.getCampaigns({ page: 1, pageSize: 5 })),
"Get campaigns with pagination"
);
expect(response).toHaveProperty("campaigns");
expect(response).toHaveProperty("totalCampaignsCount");
expect(Array.isArray(response.campaigns)).toBe(true);
expect(response.campaigns.length).toBeLessThanOrEqual(5);
// If there are more campaigns, should have nextPageUrl
if (response.totalCampaignsCount > 5) {
expect(response).toHaveProperty("nextPageUrl");
expect(typeof response.nextPageUrl).toBe("string");
}
});
it("should retrieve campaigns sorted by createdAt descending", async () => {
const response = await retryRateLimited(
() =>
withTimeout(
client.getCampaigns({
page: 1,
pageSize: 10,
sort: { field: "createdAt", direction: "desc" },
})
),
"Get campaigns sorted by createdAt descending"
);
expect(response.campaigns.length).toBeGreaterThan(1);
// Verify campaigns are sorted by createdAt in descending order
for (let i = 0; i < response.campaigns.length - 1; i++) {
expect(response.campaigns[i]!.createdAt).toBeGreaterThanOrEqual(
response.campaigns[i + 1]!.createdAt
);
}
});
it("should get campaigns using default pagination", async () => {
const response = await withTimeout(client.getCampaigns());
expect(response).toHaveProperty("campaigns");
expect(response).toHaveProperty("totalCampaignsCount");
// Should return at most 10 items (default page size)
expect(response.campaigns.length).toBeLessThanOrEqual(10);
// Verify all campaigns have valid types and states
if (response.campaigns.length > 0) {
response.campaigns.forEach((campaign) => {
expect([
"Draft",
"Scheduled",
"Running",
"Finished",
"Aborted",
"Ready",
"Archived",
]).toContain(campaign.campaignState);
expect(["Blast", "Triggered"]).toContain(campaign.type);
expect(campaign).toHaveProperty("id");
expect(campaign).toHaveProperty("name");
});
}
});
it("should get campaign metrics if campaigns exist", async () => {
const campaignsResponse = await retryRateLimited(
() => withTimeout(client.getCampaigns()),
"Get campaigns for metrics test"
);
if (campaignsResponse.campaigns.length > 0) {
const campaign = campaignsResponse.campaigns[0];
if (campaign) {
const metricsResponse = await retryRateLimited(
() =>
withTimeout(
client.getCampaignMetrics({
campaignId: campaign.id,
})
),
"Get campaign metrics"
);
expect(Array.isArray(metricsResponse)).toBe(true);
expect(metricsResponse.length).toBeGreaterThanOrEqual(0);
// If there are metrics, verify the structure
if (metricsResponse.length > 0) {
expect(typeof metricsResponse[0]).toBe("object");
}
}
}
});
it("should get individual campaign details", async () => {
// First get campaigns to find a valid campaign ID
const campaignsResponse = await retryRateLimited(
() => withTimeout(client.getCampaigns()),
"Get campaigns for individual campaign test"
);
if (campaignsResponse.campaigns.length > 0) {
const campaignId = campaignsResponse.campaigns[0]!.id;
const campaignResponse = await retryRateLimited(
() => withTimeout(client.getCampaign({ id: campaignId })),
"Get individual campaign"
);
// Verify the response structure matches our schema
expect(campaignResponse).toHaveProperty("id", campaignId);
expect(campaignResponse).toHaveProperty("name");
expect(campaignResponse).toHaveProperty("type");
expect(campaignResponse).toHaveProperty("campaignState");
expect(campaignResponse).toHaveProperty("messageMedium");
expect(campaignResponse).toHaveProperty("createdAt");
expect(campaignResponse).toHaveProperty("updatedAt");
expect(campaignResponse).toHaveProperty("createdByUserId");
// Verify enum values
expect(["Blast", "Triggered"]).toContain(campaignResponse.type);
expect([
"Draft",
"Ready",
"Scheduled",
"Running",
"Finished",
"Starting",
"Aborted",
"Recurring",
"Archived",
]).toContain(campaignResponse.campaignState);
// Verify timestamp types
expect(typeof campaignResponse.createdAt).toBe("number");
expect(typeof campaignResponse.updatedAt).toBe("number");
expect(typeof campaignResponse.createdByUserId).toBe("string");
expect(typeof campaignResponse.messageMedium).toBe("string");
}
});
it("should get child campaigns with default pagination", async () => {
// First get campaigns to find a recurring campaign
const campaignsResponse = await retryRateLimited(
() => withTimeout(client.getCampaigns()),
"Get campaigns for child campaigns test"
);
// Find a recurring campaign if one exists
const recurringCampaign = campaignsResponse.campaigns.find(
(c) => c.campaignState === "Recurring"
);
if (recurringCampaign) {
const response = await retryRateLimited(
() => withTimeout(client.getChildCampaigns({ id: recurringCampaign.id })),
"Get child campaigns with default pagination"
);
expect(response).toHaveProperty("campaigns");
expect(response).toHaveProperty("totalCampaignsCount");
expect(Array.isArray(response.campaigns)).toBe(true);
expect(typeof response.totalCampaignsCount).toBe("number");
// Should return at most 10 items (default page size)
expect(response.campaigns.length).toBeLessThanOrEqual(10);
// Verify campaign structure
if (response.campaigns.length > 0) {
const campaign = response.campaigns[0];
expect(campaign).toHaveProperty("id");
expect(campaign).toHaveProperty("name");
expect(campaign).toHaveProperty("type");
expect(campaign).toHaveProperty("campaignState");
expect(campaign).toHaveProperty("recurringCampaignId", recurringCampaign.id);
}
}
});
it("should get child campaigns with pagination parameters", async () => {
// First get campaigns to find a recurring campaign
const campaignsResponse = await retryRateLimited(
() => withTimeout(client.getCampaigns()),
"Get campaigns for child campaigns pagination test"
);
// Find a recurring campaign if one exists
const recurringCampaign = campaignsResponse.campaigns.find(
(c) => c.campaignState === "Recurring"
);
if (recurringCampaign) {
const response = await retryRateLimited(
() =>
withTimeout(
client.getChildCampaigns({
id: recurringCampaign.id,
page: 1,
pageSize: 5,
})
),
"Get child campaigns with pagination parameters"
);
expect(response).toHaveProperty("campaigns");
expect(response).toHaveProperty("totalCampaignsCount");
expect(Array.isArray(response.campaigns)).toBe(true);
expect(response.campaigns.length).toBeLessThanOrEqual(5);
// If there are more campaigns, should have nextPageUrl
if (response.totalCampaignsCount > 5) {
expect(response).toHaveProperty("nextPageUrl");
expect(typeof response.nextPageUrl).toBe("string");
}
}
});
it("should get child campaigns with sorting", async () => {
// First get campaigns to find a recurring campaign
const campaignsResponse = await retryRateLimited(
() => withTimeout(client.getCampaigns()),
"Get campaigns for child campaigns sorting test"
);
// Find a recurring campaign if one exists
const recurringCampaign = campaignsResponse.campaigns.find(
(c) => c.campaignState === "Recurring"
);
if (recurringCampaign) {
const response = await retryRateLimited(
() =>
withTimeout(
client.getChildCampaigns({
id: recurringCampaign.id,
page: 1,
pageSize: 10,
sort: { field: "createdAt", direction: "desc" },
})
),
"Get child campaigns sorted by createdAt descending"
);
expect(response).toHaveProperty("campaigns");
expect(Array.isArray(response.campaigns)).toBe(true);
// Verify campaigns are sorted by createdAt in descending order
if (response.campaigns.length > 1) {
for (let i = 0; i < response.campaigns.length - 1; i++) {
expect(response.campaigns[i]!.createdAt).toBeGreaterThanOrEqual(
response.campaigns[i + 1]!.createdAt
);
}
}
}
});
it("should create and archive a test campaign", async () => {
const campaignName = uniqueId("MCP-Test-Campaign");
const campaignId = await createTestTriggeredCampaign({
name: campaignName,
templateId: testTemplateId,
});
try {
const campaign = await retryRateLimited(
() => withTimeout(client.getCampaign({ id: campaignId })),
"Get created campaign"
);
expect(campaign).toHaveProperty("id", campaignId);
expect(campaign).toHaveProperty("name", campaignName);
const archiveResponse = await retryRateLimited(
() => withTimeout(client.archiveCampaigns({ campaignIds: [campaignId] })),
"Archive test campaign"
);
expect(archiveResponse).toHaveProperty("success");
expect(archiveResponse).toHaveProperty("failed");
expect(archiveResponse.success).toContain(campaignId);
expect(archiveResponse.failed).toHaveLength(0);
const archivedCampaign = await retryRateLimited(
() => withTimeout(client.getCampaign({ id: campaignId })),
"Get archived campaign"
);
expect(archivedCampaign.campaignState).toBe("Archived");
} catch (error) {
await cleanupCampaign(campaignId);
throw error;
}
}, 60000);
it("should create, schedule, and cancel a blast campaign", async () => {
const campaignName = uniqueId("MCP-Test-Schedule");
const campaignId = await createTestBlastCampaign({
name: campaignName,
templateId: testTemplateId,
listIds: [testListId],
});
try {
// Schedule for 24 hours in the future (ISO-8601 format)
const sendAtDate = new Date(Date.now() + 24 * 60 * 60 * 1000);
const sendAt = sendAtDate.toISOString();
await performCampaignAction(
() => withTimeout(client.scheduleCampaign({ campaignId, sendAt })),
"Schedule blast campaign"
);
const campaign = await retryRateLimited(
() => withTimeout(client.getCampaign({ id: campaignId })),
"Get scheduled blast campaign"
);
expect(campaign.type).toBe("Blast");
expect(campaign.campaignState).toBe("Scheduled");
const cancelResponse = await performCampaignAction(
() => withTimeout(client.cancelCampaign({ campaignId })),
"Cancel scheduled campaign"
);
expect(cancelResponse).toHaveProperty("msg");
expect(cancelResponse).toHaveProperty("code", "Success");
// Cancel returns campaign to "Ready" state
const cancelledCampaign = await waitForCampaignState(
campaignId,
(state) => state !== "Scheduled",
"Campaign state to change from Scheduled to Ready"
);
expect(cancelledCampaign.campaignState).toBe("Ready");
expect(cancelledCampaign.startAt).toBeUndefined();
} finally {
await cleanupCampaign(campaignId);
}
}, 60000);
it("should archive multiple campaigns at once", async () => {
const campaignId1 = await createTestTriggeredCampaign({
name: uniqueId("MCP-Test-Bulk-1"),
templateId: testTemplateId,
});
const campaignId2 = await createTestTriggeredCampaign({
name: uniqueId("MCP-Test-Bulk-2"),
templateId: testTemplateId,
});
try {
const archiveResponse = await retryRateLimited(
() =>
withTimeout(
client.archiveCampaigns({ campaignIds: [campaignId1, campaignId2] })
),
"Archive multiple campaigns"
);
expect(archiveResponse.success).toContain(campaignId1);
expect(archiveResponse.success).toContain(campaignId2);
expect(archiveResponse.failed).toHaveLength(0);
const campaign1 = await retryRateLimited(
() => withTimeout(client.getCampaign({ id: campaignId1 })),
"Get first archived campaign"
);
const campaign2 = await retryRateLimited(
() => withTimeout(client.getCampaign({ id: campaignId2 })),
"Get second archived campaign"
);
expect(campaign1.campaignState).toBe("Archived");
expect(campaign2.campaignState).toBe("Archived");
} catch (error) {
await cleanupCampaign(campaignId1);
await cleanupCampaign(campaignId2);
throw error;
}
}, 60000);
it("should abort a campaign", async () => {
const campaignId = await createTestTriggeredCampaign({
name: uniqueId("MCP-Test-Abort"),
templateId: testTemplateId,
});
try {
const abortResponse = await performCampaignAction(
() => withTimeout(client.abortCampaign({ campaignId })),
"Abort campaign"
);
expect(abortResponse).toHaveProperty("msg");
expect(abortResponse).toHaveProperty("code", "Success");
const abortedCampaign = await waitForCampaignState(campaignId, "Aborted");
expect(abortedCampaign.campaignState).toBe("Aborted");
} finally {
await cleanupCampaign(campaignId);
}
}, 60000);
it("should activate and deactivate a triggered campaign", async () => {
const campaignId = await createTestTriggeredCampaign({
name: uniqueId("MCP-Test-Triggered"),
templateId: testTemplateId,
});
try {
const campaign = await retryRateLimited(
() => withTimeout(client.getCampaign({ id: campaignId })),
"Get created triggered campaign"
);
expect(campaign.type).toBe("Triggered");
const activateResponse = await performCampaignAction(
() => withTimeout(client.activateTriggeredCampaign({ campaignId })),
"Activate triggered campaign"
);
expect(activateResponse).toHaveProperty("msg");
expect(activateResponse).toHaveProperty("code", "Success");
const activatedCampaign = await waitForCampaignState(campaignId, "Running");
expect(activatedCampaign.campaignState).toBe("Running");
const deactivateResponse = await performCampaignAction(
() => withTimeout(client.deactivateTriggeredCampaign({ campaignId })),
"Deactivate triggered campaign"
);
expect(deactivateResponse).toHaveProperty("msg");
expect(deactivateResponse).toHaveProperty("code", "Success");
// Deactivated triggered campaigns go to "Finished"
const deactivatedCampaign = await waitForCampaignState(
campaignId,
(state) => state !== "Running",
"Campaign state to change from Running"
);
expect(deactivatedCampaign.campaignState).toBe("Finished");
} finally {
await cleanupCampaign(campaignId);
}
}, 60000);
it("should trigger a campaign", async () => {
const campaignId = await createTestTriggeredCampaign({
name: uniqueId("MCP-Test-Trigger"),
templateId: testTemplateId,
});
try {
// Must activate first (campaign must be Running to trigger)
await performCampaignAction(
() => withTimeout(client.activateTriggeredCampaign({ campaignId })),
"Activate triggered campaign"
);
await waitForCampaignState(campaignId, "Running");
const triggerResponse = await performCampaignAction(
() =>
withTimeout(
client.triggerCampaign({
campaignId,
listIds: [testListId],
dataFields: { testSource: "mcp-integration-test" },
})
),
"Trigger campaign"
);
expect(triggerResponse).toHaveProperty("msg");
expect(triggerResponse).toHaveProperty("code", "Success");
} finally {
await cleanupCampaign(campaignId);
}
}, 60000);
it("should send a scheduled campaign immediately", async () => {
const campaignId = await createTestBlastCampaign({
name: uniqueId("MCP-Test-Send"),
templateId: testTemplateId,
listIds: [testListId],
});
try {
// Schedule for 24 hours in the future, then send immediately
const sendAtDate = new Date(Date.now() + 24 * 60 * 60 * 1000);
const sendAt = sendAtDate.toISOString();
await performCampaignAction(
() => withTimeout(client.scheduleCampaign({ campaignId, sendAt })),
"Schedule campaign for later"
);
const campaign = await retryRateLimited(
() => withTimeout(client.getCampaign({ id: campaignId })),
"Get scheduled campaign"
);
expect(campaign.campaignState).toBe("Scheduled");
const sendResponse = await performCampaignAction(
() => withTimeout(client.sendCampaign({ campaignId })),
"Send scheduled campaign immediately"
);
expect(sendResponse).toHaveProperty("msg");
expect(sendResponse).toHaveProperty("code", "Success");
} finally {
await cleanupCampaign(campaignId);
}
}, 60000);
});