mcdev 4.2.1 → 4.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.github/ISSUE_TEMPLATE/bug.yml +3 -0
- package/.github/PULL_REQUEST_TEMPLATE.md +1 -2
- package/.github/pr-labeler.yml +3 -0
- package/.github/workflows/close_issues_on_merge.yml +18 -0
- package/.github/workflows/pr-labeler.yml +19 -0
- package/LICENSE +1 -1
- package/README.md +1 -1
- package/docs/dist/documentation.md +702 -284
- package/lib/Deployer.js +21 -15
- package/lib/Retriever.js +41 -34
- package/lib/cli.js +36 -6
- package/lib/index.js +56 -10
- package/lib/metadataTypes/AccountUser.js +17 -23
- package/lib/metadataTypes/Asset.js +36 -48
- package/lib/metadataTypes/AttributeGroup.js +1 -2
- package/lib/metadataTypes/Automation.js +75 -37
- package/lib/metadataTypes/Campaign.js +4 -3
- package/lib/metadataTypes/ContentArea.js +2 -3
- package/lib/metadataTypes/DataExtension.js +56 -47
- package/lib/metadataTypes/DataExtensionField.js +9 -12
- package/lib/metadataTypes/DataExtensionTemplate.js +2 -3
- package/lib/metadataTypes/DataExtract.js +1 -2
- package/lib/metadataTypes/DataExtractType.js +1 -2
- package/lib/metadataTypes/Discovery.js +3 -4
- package/lib/metadataTypes/Email.js +20 -6
- package/lib/metadataTypes/EmailSendDefinition.js +40 -39
- package/lib/metadataTypes/EventDefinition.js +29 -2
- package/lib/metadataTypes/FileTransfer.js +1 -2
- package/lib/metadataTypes/Filter.js +1 -2
- package/lib/metadataTypes/Folder.js +12 -14
- package/lib/metadataTypes/FtpLocation.js +1 -2
- package/lib/metadataTypes/ImportFile.js +1 -2
- package/lib/metadataTypes/Interaction.js +743 -12
- package/lib/metadataTypes/List.js +36 -33
- package/lib/metadataTypes/MetadataType.js +170 -124
- package/lib/metadataTypes/MobileCode.js +1 -2
- package/lib/metadataTypes/MobileKeyword.js +1 -2
- package/lib/metadataTypes/Query.js +15 -6
- package/lib/metadataTypes/Role.js +10 -11
- package/lib/metadataTypes/Script.js +2 -5
- package/lib/metadataTypes/SetDefinition.js +1 -2
- package/lib/metadataTypes/TransactionalMessage.js +25 -32
- package/lib/metadataTypes/TransactionalSMS.js +3 -4
- package/lib/metadataTypes/TriggeredSendDefinition.js +232 -56
- package/lib/metadataTypes/definitions/Asset.definition.js +1 -1
- package/lib/metadataTypes/definitions/Automation.definition.js +1 -1
- package/lib/metadataTypes/definitions/DataExtension.definition.js +10 -1
- package/lib/metadataTypes/definitions/Email.definition.js +1 -1
- package/lib/metadataTypes/definitions/EmailSendDefinition.definition.js +1 -1
- package/lib/metadataTypes/definitions/EventDefinition.definition.js +40 -1
- package/lib/metadataTypes/definitions/Folder.definition.js +31 -0
- package/lib/metadataTypes/definitions/ImportFile.definition.js +1 -1
- package/lib/metadataTypes/definitions/Interaction.definition.js +47 -26
- package/lib/metadataTypes/definitions/List.definition.js +1 -1
- package/lib/metadataTypes/definitions/Query.definition.js +1 -1
- package/lib/metadataTypes/definitions/Script.definition.js +1 -1
- package/lib/metadataTypes/definitions/TransactionalEmail.definition.js +4 -3
- package/lib/metadataTypes/definitions/TransactionalPush.definition.js +4 -3
- package/lib/metadataTypes/definitions/TransactionalSMS.definition.js +4 -3
- package/lib/metadataTypes/definitions/TriggeredSendDefinition.definition.js +10 -2
- package/lib/util/auth.js +15 -2
- package/lib/util/cli.js +4 -1
- package/lib/util/file.js +7 -3
- package/lib/util/init.js +62 -0
- package/lib/util/util.js +173 -11
- package/package.json +23 -9
- package/test/dataExtension.test.js +10 -10
- package/test/interaction.test.js +123 -0
- package/test/mockRoot/.mcdevrc.json +1 -1
- package/test/mockRoot/deploy/testInstance/testBU/interaction/testExisting_interaction.interaction-meta.json +266 -0
- package/test/mockRoot/deploy/testInstance/testBU/interaction/testNew_interaction.interaction-meta.json +266 -0
- package/test/mockRoot/deploy/testInstance/testBU/transactionalEmail/testExisting_temail.transactionalEmail-meta.json +0 -3
- package/test/query.test.js +8 -8
- package/test/resourceFactory.js +30 -14
- package/test/resources/1111111/dataExtension/retrieve-response.xml +26 -0
- package/test/resources/9999999/data/v1/customobjectdata/key/childBU_dataextension_test/rowset/get-response.json +13 -0
- package/test/resources/9999999/dataFolder/retrieve-response.xml +22 -0
- package/test/resources/9999999/eventDefinition/get-expected.json +34 -0
- package/test/resources/9999999/interaction/build-expected.json +260 -0
- package/test/resources/9999999/interaction/get-expected.json +264 -0
- package/test/resources/9999999/interaction/post-expected.json +264 -0
- package/test/resources/9999999/interaction/put-expected.json +264 -0
- package/test/resources/9999999/interaction/template-expected.json +260 -0
- package/test/resources/9999999/interaction/v1/EventDefinitions/get-response.json +43 -0
- package/test/resources/9999999/interaction/v1/interactions/get-response.json +222 -3
- package/test/resources/9999999/interaction/v1/interactions/key_0b76dccf-594c-b6dc-1acf-10c4493dcb84/get-response.json +219 -0
- package/test/resources/9999999/interaction/v1/interactions/key_testExisting_interaction/get-response.json +280 -0
- package/test/resources/9999999/interaction/v1/interactions/post-response.json +280 -0
- package/test/resources/9999999/interaction/v1/interactions/put-response.json +280 -0
- package/test/resources/9999999/messaging/v1/email/definitions/post-response.json +1 -1
- package/test/resources/9999999/query/post-expected.sql +1 -1
- package/test/resources/9999999/transactionalEmail/post-expected.json +1 -1
- package/test/resources/9999999/triggeredSendDefinition/retrieve-response.xml +68 -0
- package/test/transactionalEmail.test.js +7 -7
- package/test/transactionalPush.test.js +7 -7
- package/test/transactionalSMS.test.js +7 -7
- package/test/utils.js +50 -0
- package/types/mcdev.d.js +1 -0
package/lib/util/util.js
CHANGED
|
@@ -155,24 +155,46 @@ const Util = {
|
|
|
155
155
|
* helper for {@link Mcdev.retrieve}, {@link Mcdev.retrieveAsTemplate} and {@link Mcdev.deploy}
|
|
156
156
|
*
|
|
157
157
|
* @param {TYPE.SupportedMetadataTypes} selectedType type or type-subtype
|
|
158
|
+
* @param {boolean} [handleOutside] if the API reponse is irregular this allows you to handle it outside of this generic method
|
|
158
159
|
* @returns {boolean} type ok or not
|
|
159
160
|
*/
|
|
160
|
-
_isValidType(selectedType) {
|
|
161
|
-
const [type, subType] =
|
|
161
|
+
_isValidType(selectedType, handleOutside) {
|
|
162
|
+
const [type, subType] = Util.getTypeAndSubType(selectedType);
|
|
162
163
|
if (type && !MetadataDefinitions[type]) {
|
|
163
|
-
|
|
164
|
-
|
|
164
|
+
if (!handleOutside) {
|
|
165
|
+
Util.logger.error(`:: '${type}' is not a valid metadata type`);
|
|
166
|
+
}
|
|
167
|
+
return false;
|
|
165
168
|
} else if (
|
|
166
169
|
type &&
|
|
167
170
|
subType &&
|
|
168
171
|
(!MetadataDefinitions[type] || !MetadataDefinitions[type].subTypes.includes(subType))
|
|
169
172
|
) {
|
|
170
|
-
|
|
171
|
-
|
|
173
|
+
if (!handleOutside) {
|
|
174
|
+
Util.logger.error(`:: '${selectedType}' is not a valid metadata type`);
|
|
175
|
+
}
|
|
176
|
+
return false;
|
|
172
177
|
}
|
|
173
178
|
return true;
|
|
174
179
|
},
|
|
175
180
|
|
|
181
|
+
/**
|
|
182
|
+
* helper that deals with extracting type and subtype
|
|
183
|
+
*
|
|
184
|
+
* @param {string} selectedType "type" or "type-subtype"
|
|
185
|
+
* @returns {string[]} first elem is type, second elem is subType
|
|
186
|
+
*/
|
|
187
|
+
getTypeAndSubType(selectedType) {
|
|
188
|
+
if (selectedType) {
|
|
189
|
+
const temp = selectedType.split('-');
|
|
190
|
+
const type = temp.shift(); // remove first item which is the main typ
|
|
191
|
+
const subType = temp.join('-'); // subType can include "-"
|
|
192
|
+
return [type, subType];
|
|
193
|
+
} else {
|
|
194
|
+
return [];
|
|
195
|
+
}
|
|
196
|
+
},
|
|
197
|
+
|
|
176
198
|
/**
|
|
177
199
|
* helper for getDefaultProperties()
|
|
178
200
|
*
|
|
@@ -293,7 +315,7 @@ const Util = {
|
|
|
293
315
|
* Returns Order in which metadata needs to be retrieved/deployed
|
|
294
316
|
*
|
|
295
317
|
* @param {string[]} metadataTypes which should be retrieved/deployed
|
|
296
|
-
* @returns {string[]} retrieve/deploy order as array
|
|
318
|
+
* @returns {Object.<string, string[]>} retrieve/deploy order as array
|
|
297
319
|
*/
|
|
298
320
|
getMetadataHierachy(metadataTypes) {
|
|
299
321
|
const dependencies = [];
|
|
@@ -320,10 +342,11 @@ const Util = {
|
|
|
320
342
|
dependencies.push([undefined, metadataType]);
|
|
321
343
|
}
|
|
322
344
|
}
|
|
345
|
+
const allDeps = dependencies.map((dep) => dep[0]);
|
|
323
346
|
// remove subtypes if main type is in the list
|
|
324
347
|
for (const type of Object.keys(subTypeDeps)
|
|
325
|
-
// only look at subtype deps that are also supposed to be retrieved fully
|
|
326
|
-
.filter((type) => metadataTypes.includes(type))) {
|
|
348
|
+
// only look at subtype deps that are also supposed to be retrieved or cached fully
|
|
349
|
+
.filter((type) => metadataTypes.includes(type) || allDeps.includes(type))) {
|
|
327
350
|
// convert set into array to walk its elements
|
|
328
351
|
for (const subType of subTypeDeps[type]) {
|
|
329
352
|
for (const item of dependencies) {
|
|
@@ -336,7 +359,44 @@ const Util = {
|
|
|
336
359
|
}
|
|
337
360
|
|
|
338
361
|
// sort list & remove the undefined dependencies
|
|
339
|
-
|
|
362
|
+
const flatList = toposort(dependencies).filter((a) => !!a);
|
|
363
|
+
const finalList = {};
|
|
364
|
+
// group subtypes per type
|
|
365
|
+
for (const type of flatList) {
|
|
366
|
+
if (type.includes('-')) {
|
|
367
|
+
const [key, subKey] = Util.getTypeAndSubType(type);
|
|
368
|
+
if (finalList[key] === null) {
|
|
369
|
+
// if main type is already required, then don't filter by subtypes
|
|
370
|
+
continue;
|
|
371
|
+
} else if (finalList[key] && subKey) {
|
|
372
|
+
// add another subtype to the set
|
|
373
|
+
finalList[key].add(subKey);
|
|
374
|
+
continue;
|
|
375
|
+
} else {
|
|
376
|
+
// create a new set with the first subtype; subKey will be always set here
|
|
377
|
+
finalList[key] = new Set([subKey]);
|
|
378
|
+
}
|
|
379
|
+
if (subTypeDeps[key]) {
|
|
380
|
+
// check if there are depndent subtypes that need to be added
|
|
381
|
+
const temp = [...subTypeDeps[key]].map((a) => {
|
|
382
|
+
const temp = a.split('-');
|
|
383
|
+
temp.shift(); // remove first item which is the main type
|
|
384
|
+
return temp.join('-'); // subType can include "-"
|
|
385
|
+
});
|
|
386
|
+
finalList[key].add(...temp);
|
|
387
|
+
}
|
|
388
|
+
} else {
|
|
389
|
+
finalList[type] = null;
|
|
390
|
+
}
|
|
391
|
+
}
|
|
392
|
+
// convert sets into arrays
|
|
393
|
+
for (const type of Object.keys(finalList)) {
|
|
394
|
+
if (finalList[type] instanceof Set) {
|
|
395
|
+
finalList[type] = [...finalList[type]];
|
|
396
|
+
}
|
|
397
|
+
}
|
|
398
|
+
|
|
399
|
+
return finalList;
|
|
340
400
|
},
|
|
341
401
|
|
|
342
402
|
/**
|
|
@@ -430,6 +490,103 @@ const Util = {
|
|
|
430
490
|
Util.logger.debug('CLI logger set to: debug');
|
|
431
491
|
}
|
|
432
492
|
},
|
|
493
|
+
/**
|
|
494
|
+
* outputs a warning that the given type is still in beta
|
|
495
|
+
*
|
|
496
|
+
* @param {string} type api name of the type thats in beta
|
|
497
|
+
*/
|
|
498
|
+
logBeta(type) {
|
|
499
|
+
Util.logger.warn(
|
|
500
|
+
` - ${type} support is currently still in beta. Please report any issues here: https://github.com/Accenture/sfmc-devtools/issues/new/choose`
|
|
501
|
+
);
|
|
502
|
+
},
|
|
503
|
+
// defined colors for logging things in different colors
|
|
504
|
+
color: {
|
|
505
|
+
reset: '\x1B[0m',
|
|
506
|
+
dim: '\x1B[2m',
|
|
507
|
+
bright: '\x1B[1m',
|
|
508
|
+
underscore: '\x1B[4m',
|
|
509
|
+
blink: '\x1B[5m',
|
|
510
|
+
reverse: '\x1B[7m',
|
|
511
|
+
hidden: '\x1B[8m',
|
|
512
|
+
|
|
513
|
+
fgBlack: '\x1B[30m',
|
|
514
|
+
fgRed: '\x1B[31m',
|
|
515
|
+
fgGreen: '\x1B[32m',
|
|
516
|
+
fgYellow: '\x1B[33m',
|
|
517
|
+
fgBlue: '\x1B[34m',
|
|
518
|
+
fgMagenta: '\x1B[35m',
|
|
519
|
+
fgCyan: '\x1B[36m',
|
|
520
|
+
fgWhite: '\x1B[37m',
|
|
521
|
+
fgGray: '\x1B[90m',
|
|
522
|
+
|
|
523
|
+
bgBlack: '\x1B[40m',
|
|
524
|
+
bgRed: '\x1B[41m',
|
|
525
|
+
bgGreen: '\x1B[42m',
|
|
526
|
+
bgYellow: '\x1B[43m',
|
|
527
|
+
bgBlue: '\x1B[44m',
|
|
528
|
+
bgMagenta: '\x1B[45m',
|
|
529
|
+
bgCyan: '\x1B[46m',
|
|
530
|
+
bgWhite: '\x1B[47m',
|
|
531
|
+
bgGray: '\x1B[100m',
|
|
532
|
+
},
|
|
533
|
+
/**
|
|
534
|
+
* helper that wraps a message in the correct color codes to have them printed gray
|
|
535
|
+
*
|
|
536
|
+
* @param {string} msg log message that should be wrapped with color codes
|
|
537
|
+
* @returns {string} gray msg
|
|
538
|
+
*/
|
|
539
|
+
getGrayMsg(msg) {
|
|
540
|
+
return `${Util.color.dim}${msg}${Util.color.reset}`;
|
|
541
|
+
},
|
|
542
|
+
/**
|
|
543
|
+
* helper to print the subtypes we filtered by
|
|
544
|
+
*
|
|
545
|
+
* @param {string[]} subTypeArr list of subtypes to be printed
|
|
546
|
+
* @returns {void}
|
|
547
|
+
*/
|
|
548
|
+
logSubtypes(subTypeArr) {
|
|
549
|
+
if (subTypeArr && subTypeArr.length > 0) {
|
|
550
|
+
Util.logger.info(
|
|
551
|
+
Util.getGrayMsg(
|
|
552
|
+
` - Subtype${subTypeArr.length > 1 ? 's' : ''}: ${subTypeArr.join(', ')}`
|
|
553
|
+
)
|
|
554
|
+
);
|
|
555
|
+
}
|
|
556
|
+
},
|
|
557
|
+
/**
|
|
558
|
+
* helper to print the subtypes we filtered by
|
|
559
|
+
*
|
|
560
|
+
* @param {string[] | string} keyArr list of subtypes to be printed
|
|
561
|
+
* @param {boolean} [isId] optional flag to indicate if key is an id
|
|
562
|
+
* @returns {string} string to be appended to log message
|
|
563
|
+
*/
|
|
564
|
+
getKeysString(keyArr, isId) {
|
|
565
|
+
if (!keyArr) {
|
|
566
|
+
return '';
|
|
567
|
+
}
|
|
568
|
+
if (!Array.isArray(keyArr)) {
|
|
569
|
+
// if only one key, make it an array
|
|
570
|
+
keyArr = [keyArr];
|
|
571
|
+
}
|
|
572
|
+
if (keyArr.length > 0) {
|
|
573
|
+
return Util.getGrayMsg(
|
|
574
|
+
` - ${isId ? 'ID' : 'Key'}${keyArr.length > 1 ? 's' : ''}: ${keyArr.join(', ')}`
|
|
575
|
+
);
|
|
576
|
+
}
|
|
577
|
+
return '';
|
|
578
|
+
},
|
|
579
|
+
/**
|
|
580
|
+
* pause execution of code; useful when multiple server calls are dependent on each other and might not be executed right away
|
|
581
|
+
*
|
|
582
|
+
* @param {number} ms time in miliseconds to wait
|
|
583
|
+
* @returns {Promise.<void>} - promise to wait for
|
|
584
|
+
*/
|
|
585
|
+
async sleep(ms) {
|
|
586
|
+
return new Promise((resolve) => {
|
|
587
|
+
setTimeout(resolve, ms);
|
|
588
|
+
});
|
|
589
|
+
},
|
|
433
590
|
};
|
|
434
591
|
/**
|
|
435
592
|
* wrapper around our standard winston logging to console and logfile
|
|
@@ -508,7 +665,12 @@ function startLogger() {
|
|
|
508
665
|
if (message) {
|
|
509
666
|
// ! this method only sets exitCode=1 if message-param was set
|
|
510
667
|
// if not, then this method purely outputs debug information and should not change the exitCode
|
|
511
|
-
winstonError(message + ':
|
|
668
|
+
winstonError(message + ':');
|
|
669
|
+
winstonError(` ${ex.message} (${ex.code})`);
|
|
670
|
+
if (ex.endpoint) {
|
|
671
|
+
// ex.endpoint is only available if 'ex' is of type RestError
|
|
672
|
+
winstonError(' endpoint: ' + ex.endpoint);
|
|
673
|
+
}
|
|
512
674
|
Util.signalFatalError();
|
|
513
675
|
}
|
|
514
676
|
let stack;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "mcdev",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.3.1",
|
|
4
4
|
"description": "Accenture Salesforce Marketing Cloud DevTools",
|
|
5
5
|
"author": "Accenture: joern.berkefeld, douglas.midgley, robert.zimmermann, maciej.barnas",
|
|
6
6
|
"license": "MIT",
|
|
@@ -17,6 +17,19 @@
|
|
|
17
17
|
"type": "corporate",
|
|
18
18
|
"url": "https://github.com/Accenture/sfmc-devtools"
|
|
19
19
|
},
|
|
20
|
+
"keywords": [
|
|
21
|
+
"sfmc",
|
|
22
|
+
"ide",
|
|
23
|
+
"devops",
|
|
24
|
+
"developer",
|
|
25
|
+
"exacttarget",
|
|
26
|
+
"salesforce",
|
|
27
|
+
"marketing cloud",
|
|
28
|
+
"package manager",
|
|
29
|
+
"fuel",
|
|
30
|
+
"soap",
|
|
31
|
+
"rest"
|
|
32
|
+
],
|
|
20
33
|
"main": "./lib/index.js",
|
|
21
34
|
"bin": {
|
|
22
35
|
"mcdev": "./lib/cli.js"
|
|
@@ -37,6 +50,7 @@
|
|
|
37
50
|
"lint-test": "eslint test/**/*.js",
|
|
38
51
|
"upgrade": "npm-check --update",
|
|
39
52
|
"manual-prepare": "husky install",
|
|
53
|
+
"lint-and-test": "run-s lint test",
|
|
40
54
|
"test": "mocha",
|
|
41
55
|
"coverage": "nyc mocha",
|
|
42
56
|
"version:major": "npm version --no-commit-hooks major",
|
|
@@ -55,11 +69,11 @@
|
|
|
55
69
|
"json-to-table": "4.2.1",
|
|
56
70
|
"mustache": "4.2.0",
|
|
57
71
|
"p-limit": "3.1.0",
|
|
58
|
-
"prettier": "2.8.
|
|
72
|
+
"prettier": "2.8.3",
|
|
59
73
|
"prettier-plugin-sql": "0.12.1",
|
|
60
74
|
"semver": "7.3.8",
|
|
61
|
-
"sfmc-sdk": "0.6.
|
|
62
|
-
"simple-git": "3.
|
|
75
|
+
"sfmc-sdk": "0.6.3",
|
|
76
|
+
"simple-git": "3.16.0",
|
|
63
77
|
"toposort": "2.0.2",
|
|
64
78
|
"update-notifier": "5.1.0",
|
|
65
79
|
"winston": "3.8.2",
|
|
@@ -70,17 +84,17 @@
|
|
|
70
84
|
"axios-mock-adapter": "1.21.2",
|
|
71
85
|
"chai": "4.3.7",
|
|
72
86
|
"chai-files": "1.4.0",
|
|
73
|
-
"eslint": "8.
|
|
74
|
-
"eslint-config-prettier": "8.
|
|
87
|
+
"eslint": "8.32.0",
|
|
88
|
+
"eslint-config-prettier": "8.6.0",
|
|
75
89
|
"eslint-config-ssjs": "1.1.11",
|
|
76
90
|
"eslint-plugin-jsdoc": "39.6.4",
|
|
77
91
|
"eslint-plugin-mocha": "10.1.0",
|
|
78
92
|
"eslint-plugin-prettier": "4.2.1",
|
|
79
|
-
"eslint-plugin-unicorn": "45.0.
|
|
80
|
-
"husky": "8.0.
|
|
93
|
+
"eslint-plugin-unicorn": "45.0.2",
|
|
94
|
+
"husky": "8.0.3",
|
|
81
95
|
"jsdoc-to-markdown": "8.0.0",
|
|
82
96
|
"lint-staged": "13.1.0",
|
|
83
|
-
"mocha": "10.
|
|
97
|
+
"mocha": "10.2.0",
|
|
84
98
|
"mock-fs": "5.2.0",
|
|
85
99
|
"npm-check": "6.0.1",
|
|
86
100
|
"npm-run-all": "4.1.5",
|
|
@@ -29,9 +29,9 @@ describe('dataExtension', () => {
|
|
|
29
29
|
'returned metadata was not equal expected'
|
|
30
30
|
);
|
|
31
31
|
assert.equal(
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
'Unexpected number of requests made'
|
|
32
|
+
testUtils.getAPIHistoryLength(),
|
|
33
|
+
5,
|
|
34
|
+
'Unexpected number of requests made. Run testUtils.logAPIHistoryDebug() to see the requests'
|
|
35
35
|
);
|
|
36
36
|
return;
|
|
37
37
|
});
|
|
@@ -65,9 +65,9 @@ describe('dataExtension', () => {
|
|
|
65
65
|
'returned metadata was not equal expected for update'
|
|
66
66
|
);
|
|
67
67
|
assert.equal(
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
'Unexpected number of requests made'
|
|
68
|
+
testUtils.getAPIHistoryLength(),
|
|
69
|
+
11,
|
|
70
|
+
'Unexpected number of requests made. Run testUtils.logAPIHistoryDebug() to see the requests'
|
|
71
71
|
);
|
|
72
72
|
return;
|
|
73
73
|
});
|
|
@@ -112,9 +112,9 @@ describe('dataExtension', () => {
|
|
|
112
112
|
'returned deployment file was not equal expected'
|
|
113
113
|
);
|
|
114
114
|
assert.equal(
|
|
115
|
-
|
|
115
|
+
testUtils.getAPIHistoryLength(),
|
|
116
116
|
5,
|
|
117
|
-
'Unexpected number of requests made'
|
|
117
|
+
'Unexpected number of requests made. Run testUtils.logAPIHistoryDebug() to see the requests'
|
|
118
118
|
);
|
|
119
119
|
return;
|
|
120
120
|
});
|
|
@@ -159,9 +159,9 @@ describe('dataExtension', () => {
|
|
|
159
159
|
'returned deployment file was not equal expected'
|
|
160
160
|
);
|
|
161
161
|
assert.equal(
|
|
162
|
-
|
|
162
|
+
testUtils.getAPIHistoryLength(),
|
|
163
163
|
5,
|
|
164
|
-
'Unexpected number of requests made'
|
|
164
|
+
'Unexpected number of requests made. Run testUtils.logAPIHistoryDebug() to see the requests'
|
|
165
165
|
);
|
|
166
166
|
return;
|
|
167
167
|
});
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
const chai = require('chai');
|
|
2
|
+
const chaiFiles = require('chai-files');
|
|
3
|
+
const assert = chai.assert;
|
|
4
|
+
chai.use(chaiFiles);
|
|
5
|
+
const cache = require('../lib/util/cache');
|
|
6
|
+
const testUtils = require('./utils');
|
|
7
|
+
const handler = require('../lib/index');
|
|
8
|
+
|
|
9
|
+
describe('interaction', () => {
|
|
10
|
+
beforeEach(() => {
|
|
11
|
+
testUtils.mockSetup();
|
|
12
|
+
});
|
|
13
|
+
afterEach(() => {
|
|
14
|
+
testUtils.mockReset();
|
|
15
|
+
});
|
|
16
|
+
|
|
17
|
+
describe('Retrieve ================', () => {
|
|
18
|
+
it('Should retrieve a interaction', async () => {
|
|
19
|
+
// WHEN
|
|
20
|
+
await handler.retrieve('testInstance/testBU', ['interaction']);
|
|
21
|
+
// THEN
|
|
22
|
+
// get results from cache
|
|
23
|
+
const result = cache.getCache();
|
|
24
|
+
assert.equal(
|
|
25
|
+
result.interaction ? Object.keys(result.interaction).length : 0,
|
|
26
|
+
2,
|
|
27
|
+
'only 2 interactions expected'
|
|
28
|
+
);
|
|
29
|
+
assert.deepEqual(
|
|
30
|
+
await testUtils.getActualJson('testExisting_interaction', 'interaction'),
|
|
31
|
+
await testUtils.getExpectedJson('9999999', 'interaction', 'get'),
|
|
32
|
+
'returned JSON was not equal expected'
|
|
33
|
+
);
|
|
34
|
+
assert.equal(
|
|
35
|
+
testUtils.getAPIHistoryLength(),
|
|
36
|
+
9,
|
|
37
|
+
'Unexpected number of requests made. Run testUtils.logAPIHistoryDebug() to see the requests'
|
|
38
|
+
);
|
|
39
|
+
return;
|
|
40
|
+
});
|
|
41
|
+
});
|
|
42
|
+
describe('Deploy ================', () => {
|
|
43
|
+
beforeEach(() => {
|
|
44
|
+
testUtils.mockSetup(true);
|
|
45
|
+
});
|
|
46
|
+
it('Should create & upsert a interaction', async () => {
|
|
47
|
+
// WHEN
|
|
48
|
+
await handler.deploy('testInstance/testBU', ['interaction']);
|
|
49
|
+
// THEN
|
|
50
|
+
// get results from cache
|
|
51
|
+
const result = cache.getCache();
|
|
52
|
+
assert.equal(
|
|
53
|
+
result.interaction ? Object.keys(result.interaction).length : 0,
|
|
54
|
+
3,
|
|
55
|
+
'3 interactions expected'
|
|
56
|
+
);
|
|
57
|
+
// confirm created item
|
|
58
|
+
assert.deepEqual(
|
|
59
|
+
await testUtils.getActualJson('testNew_interaction', 'interaction'),
|
|
60
|
+
await testUtils.getExpectedJson('9999999', 'interaction', 'post'),
|
|
61
|
+
'returned JSON was not equal expected for insert interaction'
|
|
62
|
+
);
|
|
63
|
+
|
|
64
|
+
// confirm updated item
|
|
65
|
+
assert.deepEqual(
|
|
66
|
+
await testUtils.getActualJson('testExisting_interaction', 'interaction'),
|
|
67
|
+
await testUtils.getExpectedJson('9999999', 'interaction', 'put'), // watch out - interaction api wants put instead of patch for updates
|
|
68
|
+
'returned JSON was not equal expected for update interaction'
|
|
69
|
+
);
|
|
70
|
+
|
|
71
|
+
// check number of API calls
|
|
72
|
+
assert.equal(
|
|
73
|
+
testUtils.getAPIHistoryLength(),
|
|
74
|
+
7,
|
|
75
|
+
'Unexpected number of requests made. Run testUtils.logAPIHistoryDebug() to see the requests'
|
|
76
|
+
);
|
|
77
|
+
return;
|
|
78
|
+
});
|
|
79
|
+
});
|
|
80
|
+
describe('Templating ================', () => {
|
|
81
|
+
it('Should create a interaction template via buildTemplate and build it', async () => {
|
|
82
|
+
// download first before we test buildTemplate
|
|
83
|
+
await handler.retrieve('testInstance/testBU', ['interaction']);
|
|
84
|
+
// buildTemplate
|
|
85
|
+
const result = await handler.buildTemplate(
|
|
86
|
+
'testInstance/testBU',
|
|
87
|
+
'interaction',
|
|
88
|
+
['testExisting_interaction'],
|
|
89
|
+
'testSourceMarket'
|
|
90
|
+
);
|
|
91
|
+
assert.equal(
|
|
92
|
+
result.interaction ? Object.keys(result.interaction).length : 0,
|
|
93
|
+
1,
|
|
94
|
+
'only one interaction expected'
|
|
95
|
+
);
|
|
96
|
+
assert.deepEqual(
|
|
97
|
+
await testUtils.getActualTemplateJson('testExisting_interaction', 'interaction'),
|
|
98
|
+
await testUtils.getExpectedJson('9999999', 'interaction', 'template'),
|
|
99
|
+
'returned template JSON was not equal expected'
|
|
100
|
+
);
|
|
101
|
+
|
|
102
|
+
// buildDefinition
|
|
103
|
+
await handler.buildDefinition(
|
|
104
|
+
'testInstance/testBU',
|
|
105
|
+
'interaction',
|
|
106
|
+
'testExisting_interaction',
|
|
107
|
+
'testTargetMarket'
|
|
108
|
+
);
|
|
109
|
+
assert.deepEqual(
|
|
110
|
+
await testUtils.getActualDeployJson('testExisting_interaction', 'interaction'),
|
|
111
|
+
await testUtils.getExpectedJson('9999999', 'interaction', 'build'),
|
|
112
|
+
'returned deployment JSON was not equal expected'
|
|
113
|
+
);
|
|
114
|
+
|
|
115
|
+
assert.equal(
|
|
116
|
+
testUtils.getAPIHistoryLength(),
|
|
117
|
+
9,
|
|
118
|
+
'Unexpected number of requests made. Run testUtils.logAPIHistoryDebug() to see the requests'
|
|
119
|
+
);
|
|
120
|
+
return;
|
|
121
|
+
});
|
|
122
|
+
});
|
|
123
|
+
});
|