mcdev 4.3.3 → 5.0.0

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.
Files changed (231) hide show
  1. package/.coverage-comment-template.md +20 -0
  2. package/.coverage-comment-template.svelte +178 -0
  3. package/.eslintrc.json +2 -0
  4. package/.fork/.prettierrc +6 -0
  5. package/.fork/custom-commands.json +13 -1
  6. package/.github/ISSUE_TEMPLATE/bug.yml +2 -0
  7. package/.github/workflows/code-test.yml +36 -0
  8. package/.github/workflows/coverage-base-update.yml +57 -0
  9. package/.github/workflows/coverage-develop-branch.yml +41 -0
  10. package/.github/workflows/coverage-main-branch.yml +41 -0
  11. package/.github/workflows/coverage.yml +77 -0
  12. package/.husky/post-checkout +1 -1
  13. package/.prettierrc +1 -1
  14. package/.vscode/extensions.json +0 -4
  15. package/boilerplate/config.json +1 -1
  16. package/boilerplate/files/.prettierrc +1 -1
  17. package/boilerplate/files/.vscode/extensions.json +1 -1
  18. package/boilerplate/files/.vscode/settings.json +1 -0
  19. package/boilerplate/forcedUpdates.json +8 -0
  20. package/docs/dist/documentation.md +1261 -433
  21. package/lib/Builder.js +6 -1
  22. package/lib/Deployer.js +34 -10
  23. package/lib/MetadataTypeDefinitions.js +8 -6
  24. package/lib/MetadataTypeInfo.js +8 -6
  25. package/lib/Retriever.js +4 -1
  26. package/lib/cli.js +54 -42
  27. package/lib/index.js +82 -8
  28. package/lib/metadataTypes/Asset.js +185 -31
  29. package/lib/metadataTypes/AttributeGroup.js +0 -1
  30. package/lib/metadataTypes/Automation.js +48 -5
  31. package/lib/metadataTypes/Campaign.js +20 -7
  32. package/lib/metadataTypes/ContentArea.js +1 -1
  33. package/lib/metadataTypes/DataExtension.js +221 -184
  34. package/lib/metadataTypes/DataExtensionField.js +12 -19
  35. package/lib/metadataTypes/DataExtensionTemplate.js +1 -1
  36. package/lib/metadataTypes/DataExtract.js +1 -1
  37. package/lib/metadataTypes/DataExtractType.js +1 -1
  38. package/lib/metadataTypes/Email.js +1 -1
  39. package/lib/metadataTypes/{EmailSendDefinition.js → EmailSend.js} +5 -5
  40. package/lib/metadataTypes/{EventDefinition.js → Event.js} +17 -35
  41. package/lib/metadataTypes/{FtpLocation.js → FileLocation.js} +2 -2
  42. package/lib/metadataTypes/FileTransfer.js +8 -7
  43. package/lib/metadataTypes/Filter.js +1 -1
  44. package/lib/metadataTypes/Folder.js +8 -3
  45. package/lib/metadataTypes/ImportFile.js +6 -6
  46. package/lib/metadataTypes/{Interaction.js → Journey.js} +311 -147
  47. package/lib/metadataTypes/List.js +2 -2
  48. package/lib/metadataTypes/MetadataType.js +318 -90
  49. package/lib/metadataTypes/MobileCode.js +0 -1
  50. package/lib/metadataTypes/MobileKeyword.js +336 -40
  51. package/lib/metadataTypes/MobileMessage.js +473 -0
  52. package/lib/metadataTypes/Query.js +114 -32
  53. package/lib/metadataTypes/Role.js +60 -21
  54. package/lib/metadataTypes/Script.js +5 -7
  55. package/lib/metadataTypes/SendClassification.js +40 -0
  56. package/lib/metadataTypes/SetDefinition.js +1 -7
  57. package/lib/metadataTypes/TransactionalEmail.js +2 -3
  58. package/lib/metadataTypes/TransactionalMessage.js +1 -2
  59. package/lib/metadataTypes/TransactionalSMS.js +8 -15
  60. package/lib/metadataTypes/{TriggeredSendDefinition.js → TriggeredSend.js} +35 -27
  61. package/lib/metadataTypes/User.js +1177 -0
  62. package/lib/metadataTypes/definitions/Asset.definition.js +2 -4
  63. package/lib/metadataTypes/definitions/AttributeGroup.definition.js +1 -0
  64. package/lib/metadataTypes/definitions/Automation.definition.js +3 -2
  65. package/lib/metadataTypes/definitions/Campaign.definition.js +79 -4
  66. package/lib/metadataTypes/definitions/ContentArea.definition.js +1 -0
  67. package/lib/metadataTypes/definitions/DataExtension.definition.js +2 -1
  68. package/lib/metadataTypes/definitions/DataExtensionField.definition.js +1 -0
  69. package/lib/metadataTypes/definitions/DataExtensionTemplate.definition.js +1 -0
  70. package/lib/metadataTypes/definitions/DataExtract.definition.js +1 -0
  71. package/lib/metadataTypes/definitions/DataExtractType.definition.js +1 -0
  72. package/lib/metadataTypes/definitions/Discovery.definition.js +1 -0
  73. package/lib/metadataTypes/definitions/Email.definition.js +1 -0
  74. package/lib/metadataTypes/definitions/{EmailSendDefinition.definition.js → EmailSend.definition.js} +4 -2
  75. package/lib/metadataTypes/definitions/{EventDefinition.definition.js → Event.definition.js} +2 -1
  76. package/lib/metadataTypes/definitions/{FtpLocation.definition.js → FileLocation.definition.js} +4 -3
  77. package/lib/metadataTypes/definitions/FileTransfer.definition.js +3 -2
  78. package/lib/metadataTypes/definitions/Filter.definition.js +1 -0
  79. package/lib/metadataTypes/definitions/Folder.definition.js +2 -0
  80. package/lib/metadataTypes/definitions/ImportFile.definition.js +4 -3
  81. package/lib/metadataTypes/definitions/{Interaction.definition.js → Journey.definition.js} +11 -2
  82. package/lib/metadataTypes/definitions/List.definition.js +1 -0
  83. package/lib/metadataTypes/definitions/MobileCode.definition.js +3 -1
  84. package/lib/metadataTypes/definitions/MobileKeyword.definition.js +27 -17
  85. package/lib/metadataTypes/definitions/MobileMessage.definition.js +743 -0
  86. package/lib/metadataTypes/definitions/Query.definition.js +3 -2
  87. package/lib/metadataTypes/definitions/Role.definition.js +5 -0
  88. package/lib/metadataTypes/definitions/Script.definition.js +1 -0
  89. package/lib/metadataTypes/definitions/SendClassification.definition.js +114 -0
  90. package/lib/metadataTypes/definitions/SetDefinition.definition.js +1 -0
  91. package/lib/metadataTypes/definitions/TransactionalEmail.definition.js +2 -1
  92. package/lib/metadataTypes/definitions/TransactionalPush.definition.js +1 -0
  93. package/lib/metadataTypes/definitions/TransactionalSMS.definition.js +1 -0
  94. package/lib/metadataTypes/definitions/{TriggeredSendDefinition.definition.js → TriggeredSend.definition.js} +5 -3
  95. package/lib/metadataTypes/definitions/User.definition.js +365 -0
  96. package/lib/retrieveChangelog.js +1 -2
  97. package/lib/util/auth.js +29 -9
  98. package/lib/util/businessUnit.js +3 -3
  99. package/lib/util/cli.js +55 -7
  100. package/lib/util/devops.js +93 -8
  101. package/lib/util/file.js +55 -13
  102. package/lib/util/init.config.js +1 -2
  103. package/lib/util/init.npm.js +3 -3
  104. package/lib/util/util.js +68 -14
  105. package/package.json +16 -15
  106. package/test/general.test.js +62 -0
  107. package/test/mockRoot/.mcdevrc.json +7 -5
  108. package/test/mockRoot/deploy/testInstance/_ParentBU_/user/testBlocked_user.user-meta.json +23 -0
  109. package/test/mockRoot/deploy/testInstance/_ParentBU_/user/testExisting_user.user-meta.json +31 -0
  110. package/test/mockRoot/deploy/testInstance/_ParentBU_/user/testNew_user.user-meta.json +27 -0
  111. package/test/mockRoot/deploy/testInstance/testBU/dataExtension/{childBU_dataextension_test.dataExtension-meta.json → testExisting_dataExtension.dataExtension-meta.json} +2 -2
  112. package/test/mockRoot/deploy/testInstance/testBU/dataExtension/{testDataExtension.dataExtension-meta.json → testNew_dataExtension.dataExtension-meta.json} +2 -2
  113. package/test/mockRoot/deploy/testInstance/testBU/journey/testExisting_interaction.interaction-meta.json +576 -0
  114. package/test/mockRoot/deploy/testInstance/testBU/mobileKeyword/testNew_keyword.mobileKeyword-meta.amp +2 -0
  115. package/test/mockRoot/deploy/testInstance/testBU/mobileKeyword/testNew_keyword.mobileKeyword-meta.json +10 -0
  116. package/test/mockRoot/deploy/testInstance/testBU/mobileKeyword/testNew_keyword_blocked.mobileKeyword-meta.amp +2 -0
  117. package/test/mockRoot/deploy/testInstance/testBU/mobileKeyword/testNew_keyword_blocked.mobileKeyword-meta.json +10 -0
  118. package/test/mockRoot/deploy/testInstance/testBU/mobileMessage/NTIzOjc4OjA.mobileMessage-meta.amp +1 -0
  119. package/test/mockRoot/deploy/testInstance/testBU/mobileMessage/NTIzOjc4OjA.mobileMessage-meta.json +61 -0
  120. package/test/mockRoot/deploy/testInstance/testBU/mobileMessage/new.mobileMessage-meta.amp +1 -0
  121. package/test/mockRoot/deploy/testInstance/testBU/mobileMessage/new.mobileMessage-meta.json +60 -0
  122. package/test/mockRoot/deploy/testInstance/testBU/query/testExistingQuery.query-meta.json +1 -1
  123. package/test/mockRoot/deploy/testInstance/testBU/query/testNewQuery.query-meta.json +1 -1
  124. package/test/mockRoot/deploy/testInstance/testBU/query/testNewQuery.query-meta.sql +1 -1
  125. package/test/mockRoot/deploy/testInstance/testBU/transactionalEmail/testExisting_temail.transactionalEmail-meta.json +1 -1
  126. package/test/mockRoot/deploy/testInstance/testBU/transactionalEmail/testNew_temail.transactionalEmail-meta.json +1 -1
  127. package/test/resourceFactory.js +13 -0
  128. package/test/resources/1111111/accountUser/configure-response.xml +70 -0
  129. package/test/resources/1111111/accountUser/create-response.xml +97 -0
  130. package/test/resources/1111111/accountUser/retrieve-response.xml +156 -0
  131. package/test/resources/1111111/accountUser/update-response.xml +111 -0
  132. package/test/resources/1111111/accountUserAccount/retrieve-response.xml +77 -0
  133. package/test/resources/1111111/platform/v1/setup/quickflow/data/get-response.json +455 -0
  134. package/test/resources/1111111/role/retrieve-response.xml +76 -0
  135. package/test/resources/1111111/user/build-expected.json +16 -0
  136. package/test/resources/1111111/user/create-expected.json +21 -0
  137. package/test/resources/1111111/user/retrieve-expected.json +24 -0
  138. package/test/resources/1111111/user/template-expected.json +16 -0
  139. package/test/resources/1111111/user/update-expected.json +21 -0
  140. package/test/resources/9999999/automation/v1/queries/549f0568-607c-4940-afef-437965094dat/delete-response.json +1 -0
  141. package/test/resources/9999999/automation/v1/queries/549f0568-607c-4940-afef-437965094dat/get-response.json +17 -0
  142. package/test/resources/9999999/automation/v1/queries/549f0568-607c-4940-afef-437965094dat/patch-response.json +3 -3
  143. package/test/resources/9999999/automation/v1/queries/get-response.json +21 -4
  144. package/test/resources/9999999/automation/v1/queries/post-response.json +4 -4
  145. package/test/resources/9999999/data/v1/customobjectdata/key/{childBU_dataextension_test → testExisting_dataExtension}/rowset/get-response.json +1 -1
  146. package/test/resources/9999999/dataExtension/build-expected.json +3 -3
  147. package/test/resources/9999999/dataExtension/create-expected.json +2 -2
  148. package/test/resources/9999999/dataExtension/create-response.xml +8 -3
  149. package/test/resources/9999999/dataExtension/retrieve-expected.json +3 -3
  150. package/test/resources/9999999/dataExtension/retrieve-response.xml +9 -4
  151. package/test/resources/9999999/dataExtension/template-expected.json +3 -3
  152. package/test/resources/9999999/dataExtension/update-expected.json +3 -3
  153. package/test/resources/9999999/dataExtension/update-response.xml +9 -4
  154. package/test/resources/9999999/dataExtensionField/retrieve-response.xml +14 -9
  155. package/test/resources/9999999/interaction/v1/interactions/get-response.json +312 -0
  156. package/test/resources/9999999/interaction/v1/interactions/key_testExisting_interaction/get-response.json +312 -0
  157. package/test/resources/9999999/interaction/v1/interactions/key_testExisting_interaction/put-response.json +592 -0
  158. package/test/resources/9999999/journey/build-expected.json +572 -0
  159. package/test/resources/9999999/journey/get-expected.json +576 -0
  160. package/test/resources/9999999/journey/put-expected.json +576 -0
  161. package/test/resources/9999999/journey/template-expected.json +572 -0
  162. package/test/resources/9999999/legacy/v1/beta/mobile/keyword/NXV4ZFMwTEFwRVczd3RaLUF5X3p5dzo4Njow/get-response.json +42 -0
  163. package/test/resources/9999999/legacy/v1/beta/mobile/keyword/cTVJaG5oSDJPVUNHcUh6Z3pQT2tVdzo4Njow/delete-response.json +0 -0
  164. package/test/resources/9999999/legacy/v1/beta/mobile/keyword/get-response.json +1 -0
  165. package/test/resources/9999999/legacy/v1/beta/mobile/keyword/post-response.json +3 -0
  166. package/test/resources/9999999/legacy/v1/beta/mobile/message/NTIzOjc4OjA/delete-response.json +0 -0
  167. package/test/resources/9999999/legacy/v1/beta/mobile/message/NTIzOjc4OjA/get-response.json +106 -0
  168. package/test/resources/9999999/legacy/v1/beta/mobile/message/NTIzOjc4OjA/post-response.json +0 -0
  169. package/test/resources/9999999/legacy/v1/beta/mobile/message/NTQ3Ojc4OjA/get-response.json +127 -0
  170. package/test/resources/9999999/legacy/v1/beta/mobile/message/get-response.json +129 -0
  171. package/test/resources/9999999/legacy/v1/beta/mobile/message/post-response.json +3 -0
  172. package/test/resources/9999999/legacy/v1/beta2/data/campaign/get-response.json +29 -0
  173. package/test/resources/9999999/messaging/v1/email/definitions/post-response.json +1 -1
  174. package/test/resources/9999999/messaging/v1/email/definitions/testExisting_temail/get-response.json +1 -1
  175. package/test/resources/9999999/messaging/v1/email/definitions/testExisting_temail/patch-response.json +1 -1
  176. package/test/resources/9999999/mobileKeyword/build-expected.amp +2 -0
  177. package/test/resources/9999999/mobileKeyword/build-expected.json +9 -0
  178. package/test/resources/9999999/mobileKeyword/get-expected.amp +2 -0
  179. package/test/resources/9999999/mobileKeyword/get-expected.json +15 -0
  180. package/test/resources/9999999/mobileKeyword/post-create-expected.amp +2 -0
  181. package/test/resources/9999999/mobileKeyword/post-create-expected.json +17 -0
  182. package/test/resources/9999999/mobileKeyword/template-expected.amp +2 -0
  183. package/test/resources/9999999/mobileKeyword/template-expected.json +9 -0
  184. package/test/resources/9999999/mobileMessage/build-expected.amp +1 -0
  185. package/test/resources/9999999/mobileMessage/build-expected.json +60 -0
  186. package/test/resources/9999999/mobileMessage/get-expected.amp +1 -0
  187. package/test/resources/9999999/mobileMessage/get-expected.json +61 -0
  188. package/test/resources/9999999/mobileMessage/post-create-expected.amp +1 -0
  189. package/test/resources/9999999/mobileMessage/post-create-expected.json +63 -0
  190. package/test/resources/9999999/mobileMessage/post-update-expected.amp +1 -0
  191. package/test/resources/9999999/mobileMessage/post-update-expected.json +61 -0
  192. package/test/resources/9999999/mobileMessage/template-expected.amp +1 -0
  193. package/test/resources/9999999/mobileMessage/template-expected.json +60 -0
  194. package/test/resources/9999999/query/build-expected.json +1 -1
  195. package/test/resources/9999999/query/get-expected.json +1 -1
  196. package/test/resources/9999999/query/get2-expected.json +11 -0
  197. package/test/resources/9999999/query/patch-expected.json +1 -1
  198. package/test/resources/9999999/query/post-expected.json +1 -1
  199. package/test/resources/9999999/query/template-expected.json +1 -1
  200. package/test/resources/9999999/queryDefinition/retrieve-response.xml +30 -0
  201. package/test/resources/9999999/transactionalEmail/build-expected.json +5 -5
  202. package/test/resources/9999999/transactionalEmail/get-expected.json +1 -1
  203. package/test/resources/9999999/transactionalEmail/patch-expected.json +1 -1
  204. package/test/resources/9999999/transactionalEmail/post-expected.json +1 -1
  205. package/test/resources/9999999/transactionalEmail/template-expected.json +5 -5
  206. package/test/resources/9999999/transactionalPush/build-expected.json +2 -2
  207. package/test/resources/9999999/transactionalPush/template-expected.json +2 -2
  208. package/test/resources/9999999/transactionalSMS/build-expected.json +3 -3
  209. package/test/resources/9999999/transactionalSMS/template-expected.json +3 -3
  210. package/test/{dataExtension.test.js → type.dataExtension.test.js} +78 -21
  211. package/test/{interaction.test.js → type.journey.test.js} +64 -30
  212. package/test/type.mobileKeyword.test.js +250 -0
  213. package/test/type.mobileMessage.test.js +205 -0
  214. package/test/{query.test.js → type.query.test.js} +102 -5
  215. package/test/{transactionalEmail.test.js → type.transactionalEmail.test.js} +40 -2
  216. package/test/{transactionalPush.test.js → type.transactionalPush.test.js} +41 -2
  217. package/test/{transactionalSMS.test.js → type.transactionalSMS.test.js} +73 -3
  218. package/test/type.user.test.js +160 -0
  219. package/test/utils.js +17 -5
  220. package/types/mcdev.d.js +48 -15
  221. package/.github/workflows/code-analysis.yml +0 -57
  222. package/lib/metadataTypes/AccountUser.js +0 -426
  223. package/lib/metadataTypes/definitions/AccountUser.definition.js +0 -227
  224. package/test/mockRoot/deploy/testInstance/testBU/interaction/testExisting_interaction.interaction-meta.json +0 -266
  225. package/test/resources/9999999/interaction/build-expected.json +0 -260
  226. package/test/resources/9999999/interaction/get-expected.json +0 -264
  227. package/test/resources/9999999/interaction/put-expected.json +0 -264
  228. package/test/resources/9999999/interaction/template-expected.json +0 -260
  229. package/test/resources/9999999/interaction/v1/interactions/put-response.json +0 -280
  230. /package/test/mockRoot/deploy/testInstance/testBU/{interaction → journey}/testNew_interaction.interaction-meta.json +0 -0
  231. /package/test/resources/9999999/{interaction → journey}/post-expected.json +0 -0
@@ -9,7 +9,7 @@ const cache = require('../lib/util/cache');
9
9
  const testUtils = require('./utils');
10
10
  const handler = require('../lib/index');
11
11
 
12
- describe('query', () => {
12
+ describe('type: query', () => {
13
13
  beforeEach(() => {
14
14
  testUtils.mockSetup();
15
15
  });
@@ -18,10 +18,46 @@ describe('query', () => {
18
18
  });
19
19
 
20
20
  describe('Retrieve ================', () => {
21
- it('Should retrieve a query', async () => {
21
+ it('Should retrieve all queries', async () => {
22
22
  // WHEN
23
23
  await handler.retrieve('testInstance/testBU', ['query']);
24
24
  // THEN
25
+ assert.equal(process.exitCode, false, 'retrieve should not have thrown an error');
26
+ // get results from cache
27
+ const result = cache.getCache();
28
+ assert.equal(
29
+ result.query ? Object.keys(result.query).length : 0,
30
+ 2,
31
+ 'only two queries expected'
32
+ );
33
+ // normal test
34
+ assert.deepEqual(
35
+ await testUtils.getActualJson('testExistingQuery', 'query'),
36
+ await testUtils.getExpectedJson('9999999', 'query', 'get'),
37
+ 'returned metadata with correct key was not equal expected'
38
+ );
39
+ expect(file(testUtils.getActualFile('testExistingQuery', 'query', 'sql'))).to.equal(
40
+ file(testUtils.getExpectedFile('9999999', 'query', 'get', 'sql'))
41
+ );
42
+ // check if targetKey was overwritten
43
+ assert.deepEqual(
44
+ await testUtils.getActualJson('testExistingQuery2', 'query'),
45
+ await testUtils.getExpectedJson('9999999', 'query', 'get2'),
46
+ 'returned metadata with wrong key was not equal expected'
47
+ );
48
+
49
+ assert.equal(
50
+ testUtils.getAPIHistoryLength(),
51
+ 6,
52
+ 'Unexpected number of requests made. Run testUtils.logAPIHistoryDebug() to see the requests'
53
+ );
54
+ return;
55
+ });
56
+ it('Should retrieve one specific query', async () => {
57
+ // WHEN
58
+ await handler.retrieve('testInstance/testBU', ['query'], ['testExistingQuery']);
59
+ // THEN
60
+ assert.equal(process.exitCode, false, 'retrieve should not have thrown an error');
25
61
  // get results from cache
26
62
  const result = cache.getCache();
27
63
  assert.equal(
@@ -39,7 +75,7 @@ describe('query', () => {
39
75
  );
40
76
  assert.equal(
41
77
  testUtils.getAPIHistoryLength(),
42
- 6,
78
+ 7,
43
79
  'Unexpected number of requests made. Run testUtils.logAPIHistoryDebug() to see the requests'
44
80
  );
45
81
  return;
@@ -53,12 +89,13 @@ describe('query', () => {
53
89
  // WHEN
54
90
  await handler.deploy('testInstance/testBU', ['query']);
55
91
  // THEN
92
+ assert.equal(process.exitCode, false, 'deploy should not have thrown an error');
56
93
  // get results from cache
57
94
  const result = cache.getCache();
58
95
  assert.equal(
59
96
  result.query ? Object.keys(result.query).length : 0,
60
- 2,
61
- 'two querys expected'
97
+ 3,
98
+ 'three queries expected'
62
99
  );
63
100
  // confirm created item
64
101
  assert.deepEqual(
@@ -86,6 +123,7 @@ describe('query', () => {
86
123
  );
87
124
  return;
88
125
  });
126
+ it('Should change the key during update with --changeKeyValue');
89
127
  });
90
128
  describe('Templating ================', () => {
91
129
  it('Should create a query template via retrieveAsTemplate and build it', async () => {
@@ -97,6 +135,11 @@ describe('query', () => {
97
135
  'testSourceMarket'
98
136
  );
99
137
  // WHEN
138
+ assert.equal(
139
+ process.exitCode,
140
+ false,
141
+ 'retrieveAsTemplate should not have thrown an error'
142
+ );
100
143
  assert.equal(
101
144
  result.query ? Object.keys(result.query).length : 0,
102
145
  1,
@@ -117,6 +160,12 @@ describe('query', () => {
117
160
  'testExistingQuery',
118
161
  'testTargetMarket'
119
162
  );
163
+ assert.equal(
164
+ process.exitCode,
165
+ false,
166
+ 'buildDefinition should not have thrown an error'
167
+ );
168
+
120
169
  assert.deepEqual(
121
170
  await testUtils.getActualDeployJson('testExistingQuery', 'query'),
122
171
  await testUtils.getExpectedJson('9999999', 'query', 'build'),
@@ -143,6 +192,8 @@ describe('query', () => {
143
192
  'testSourceMarket'
144
193
  );
145
194
  // WHEN
195
+ assert.equal(process.exitCode, false, 'buildTemplate should not have thrown an error');
196
+
146
197
  assert.equal(
147
198
  result.query ? Object.keys(result.query).length : 0,
148
199
  1,
@@ -163,6 +214,12 @@ describe('query', () => {
163
214
  'testExistingQuery',
164
215
  'testTargetMarket'
165
216
  );
217
+ assert.equal(
218
+ process.exitCode,
219
+ false,
220
+ 'buildDefinition should not have thrown an error'
221
+ );
222
+
166
223
  assert.deepEqual(
167
224
  await testUtils.getActualDeployJson('testExistingQuery', 'query'),
168
225
  await testUtils.getExpectedJson('9999999', 'query', 'build'),
@@ -180,4 +237,44 @@ describe('query', () => {
180
237
  return;
181
238
  });
182
239
  });
240
+ describe('Delete ================', () => {
241
+ it('Should delete the item', async () => {
242
+ // WHEN
243
+ const result = await handler.deleteByKey('testInstance/testBU', 'query', [
244
+ 'testExistingQuery',
245
+ ]);
246
+ // THEN
247
+ assert.equal(process.exitCode, false, 'delete should not have thrown an error');
248
+
249
+ assert.equal(result, true, 'should have deleted the item');
250
+ return;
251
+ });
252
+ });
253
+ describe('CI/CD ================', () => {
254
+ it('Should return a list of files based on their type and key', async () => {
255
+ // WHEN
256
+ const fileList = await handler.getFilesToCommit('testInstance/testBU', 'query', [
257
+ 'testExistingQuery',
258
+ ]);
259
+ // THEN
260
+ assert.equal(
261
+ process.exitCode,
262
+ false,
263
+ 'getFilesToCommit should not have thrown an error'
264
+ );
265
+ assert.equal(fileList.length, 2, 'expected only 2 file paths');
266
+
267
+ assert.equal(
268
+ fileList[0].split('\\').join('/'),
269
+ 'retrieve/testInstance/testBU/query/testExistingQuery.query-meta.json',
270
+ 'wrong JSON path'
271
+ );
272
+ assert.equal(
273
+ fileList[1].split('\\').join('/'),
274
+ 'retrieve/testInstance/testBU/query/testExistingQuery.query-meta.sql',
275
+ 'wrong JSON path'
276
+ );
277
+ return;
278
+ });
279
+ });
183
280
  });
@@ -6,7 +6,7 @@ const cache = require('../lib/util/cache');
6
6
  const testUtils = require('./utils');
7
7
  const handler = require('../lib/index');
8
8
 
9
- describe('transactionalEmail', () => {
9
+ describe('type: transactionalEmail', () => {
10
10
  beforeEach(() => {
11
11
  testUtils.mockSetup();
12
12
  });
@@ -19,6 +19,7 @@ describe('transactionalEmail', () => {
19
19
  // WHEN
20
20
  await handler.retrieve('testInstance/testBU', ['transactionalEmail']);
21
21
  // THEN
22
+ assert.equal(process.exitCode, false, 'retrieve should not have thrown an error');
22
23
  // get results from cache
23
24
  const result = cache.getCache();
24
25
  assert.equal(
@@ -47,6 +48,7 @@ describe('transactionalEmail', () => {
47
48
  // WHEN
48
49
  await handler.deploy('testInstance/testBU', ['transactionalEmail']);
49
50
  // THEN
51
+ assert.equal(process.exitCode, false, 'deploy should not have thrown an error');
50
52
  // get results from cache
51
53
  const result = cache.getCache();
52
54
  assert.equal(
@@ -74,6 +76,22 @@ describe('transactionalEmail', () => {
74
76
  );
75
77
  return;
76
78
  });
79
+ it('Should NOT change the key during update with --changeKeyValue and instead fail due to missing support', async () => {
80
+ // WHEN
81
+ handler.setOptions({ changeKeyValue: 'updatedKey' });
82
+ await handler.deploy(
83
+ 'testInstance/testBU',
84
+ ['transactionalEmail'],
85
+ ['testExisting_temail']
86
+ );
87
+ // THEN
88
+ assert.equal(
89
+ process.exitCode,
90
+ 1,
91
+ 'deploy should have thrown an error due to lack of support'
92
+ );
93
+ return;
94
+ });
77
95
  });
78
96
  describe('Templating ================', () => {
79
97
  // it.skip('Should create a transactionalEmail template via retrieveAsTemplate and build it');
@@ -87,6 +105,7 @@ describe('transactionalEmail', () => {
87
105
  ['testExisting_temail'],
88
106
  'testSourceMarket'
89
107
  );
108
+ assert.equal(process.exitCode, false, 'buildTemplate should not have thrown an error');
90
109
  assert.equal(
91
110
  result.transactionalEmail ? Object.keys(result.transactionalEmail).length : 0,
92
111
  1,
@@ -104,8 +123,13 @@ describe('transactionalEmail', () => {
104
123
  'testExisting_temail',
105
124
  'testTargetMarket'
106
125
  );
126
+ assert.equal(
127
+ process.exitCode,
128
+ false,
129
+ 'buildDefinition should not have thrown an error'
130
+ );
107
131
  assert.deepEqual(
108
- await testUtils.getActualDeployJson('testExisting_temail', 'transactionalEmail'),
132
+ await testUtils.getActualDeployJson('testTemplated_temail', 'transactionalEmail'),
109
133
  await testUtils.getExpectedJson('9999999', 'transactionalEmail', 'build'),
110
134
  'returned deployment JSON was not equal expected'
111
135
  );
@@ -117,4 +141,18 @@ describe('transactionalEmail', () => {
117
141
  return;
118
142
  });
119
143
  });
144
+ describe('Delete ================', () => {
145
+ // TODO: add this test
146
+ it('Should delete the item'); // , async () => {
147
+ // // WHEN
148
+ // const result = await handler.deleteByKey('testInstance/testBU', 'mobileKeyword', [
149
+ // 'testExisting_keyword',
150
+ // ]);
151
+ // // THEN
152
+ // assert.equal(process.exitCode, false, 'delete should not have thrown an error');
153
+
154
+ // assert.equal(result, true, 'should have deleted the item');
155
+ // return;
156
+ // });
157
+ });
120
158
  });
@@ -6,7 +6,7 @@ const cache = require('../lib/util/cache');
6
6
  const testUtils = require('./utils');
7
7
  const handler = require('../lib/index');
8
8
 
9
- describe('transactionalPush', () => {
9
+ describe('type: transactionalPush', () => {
10
10
  beforeEach(() => {
11
11
  testUtils.mockSetup();
12
12
  });
@@ -19,6 +19,7 @@ describe('transactionalPush', () => {
19
19
  // WHEN
20
20
  await handler.retrieve('testInstance/testBU', ['transactionalPush']);
21
21
  // THEN
22
+ assert.equal(process.exitCode, false, 'retrieve should not have thrown an error');
22
23
  // get results from cache
23
24
  const result = cache.getCache();
24
25
  assert.equal(
@@ -47,6 +48,7 @@ describe('transactionalPush', () => {
47
48
  // WHEN
48
49
  await handler.deploy('testInstance/testBU', ['transactionalPush']);
49
50
  // THEN
51
+ assert.equal(process.exitCode, false, 'deploy should not have thrown an error');
50
52
  // get results from cache
51
53
  const result = cache.getCache();
52
54
  assert.equal(
@@ -74,6 +76,22 @@ describe('transactionalPush', () => {
74
76
  );
75
77
  return;
76
78
  });
79
+ it('Should NOT change the key during update with --changeKeyValue and instead fail due to missing support', async () => {
80
+ // WHEN
81
+ handler.setOptions({ changeKeyValue: 'updatedKey' });
82
+ await handler.deploy(
83
+ 'testInstance/testBU',
84
+ ['transactionalPush'],
85
+ ['testExisting_tpush']
86
+ );
87
+ // THEN
88
+ assert.equal(
89
+ process.exitCode,
90
+ 1,
91
+ 'deploy should have thrown an error due to lack of support'
92
+ );
93
+ return;
94
+ });
77
95
  });
78
96
  describe('Templating ================', () => {
79
97
  // it.skip('Should create a transactionalPush template via retrieveAsTemplate and build it');
@@ -87,6 +105,7 @@ describe('transactionalPush', () => {
87
105
  ['testExisting_tpush'],
88
106
  'testSourceMarket'
89
107
  );
108
+ assert.equal(process.exitCode, false, 'buildTemplate should not have thrown an error');
90
109
  assert.equal(
91
110
  result.transactionalPush ? Object.keys(result.transactionalPush).length : 0,
92
111
  1,
@@ -104,8 +123,14 @@ describe('transactionalPush', () => {
104
123
  'testExisting_tpush',
105
124
  'testTargetMarket'
106
125
  );
126
+ assert.equal(
127
+ process.exitCode,
128
+ false,
129
+ 'buildDefinition should not have thrown an error'
130
+ );
131
+
107
132
  assert.deepEqual(
108
- await testUtils.getActualDeployJson('testExisting_tpush', 'transactionalPush'),
133
+ await testUtils.getActualDeployJson('testTemplated_tpush', 'transactionalPush'),
109
134
  await testUtils.getExpectedJson('9999999', 'transactionalPush', 'build'),
110
135
  'returned deployment JSON was not equal expected'
111
136
  );
@@ -117,4 +142,18 @@ describe('transactionalPush', () => {
117
142
  return;
118
143
  });
119
144
  });
145
+ describe('Delete ================', () => {
146
+ // TODO: add this test
147
+ it('Should delete the item'); // , async () => {
148
+ // // WHEN
149
+ // const result = await handler.deleteByKey('testInstance/testBU', 'mobileKeyword', [
150
+ // 'testExisting_keyword',
151
+ // ]);
152
+ // // THEN
153
+ // assert.equal(process.exitCode, false, 'delete should not have thrown an error');
154
+
155
+ // assert.equal(result, true, 'should have deleted the item');
156
+ // return;
157
+ // });
158
+ });
120
159
  });
@@ -8,7 +8,7 @@ const cache = require('../lib/util/cache');
8
8
  const testUtils = require('./utils');
9
9
  const handler = require('../lib/index');
10
10
 
11
- describe('transactionalSMS', () => {
11
+ describe('type: transactionalSMS', () => {
12
12
  beforeEach(() => {
13
13
  testUtils.mockSetup();
14
14
  });
@@ -21,6 +21,7 @@ describe('transactionalSMS', () => {
21
21
  // WHEN
22
22
  await handler.retrieve('testInstance/testBU', ['transactionalSMS']);
23
23
  // THEN
24
+ assert.equal(process.exitCode, false, 'retrieve should not have thrown an error');
24
25
  // get results from cache
25
26
  const result = cache.getCache();
26
27
  assert.equal(
@@ -54,6 +55,7 @@ describe('transactionalSMS', () => {
54
55
  // WHEN
55
56
  await handler.deploy('testInstance/testBU', ['transactionalSMS']);
56
57
  // THEN
58
+ assert.equal(process.exitCode, false, 'deploy should not have thrown an error');
57
59
  // get results from cache
58
60
  const result = cache.getCache();
59
61
  assert.equal(
@@ -91,6 +93,22 @@ describe('transactionalSMS', () => {
91
93
  );
92
94
  return;
93
95
  });
96
+ it('Should NOT change the key during update with --changeKeyValue and instead fail due to missing support', async () => {
97
+ // WHEN
98
+ handler.setOptions({ changeKeyValue: 'updatedKey' });
99
+ await handler.deploy(
100
+ 'testInstance/testBU',
101
+ ['transactionalSMS'],
102
+ ['testExisting_tsms']
103
+ );
104
+ // THEN
105
+ assert.equal(
106
+ process.exitCode,
107
+ 1,
108
+ 'deploy should have thrown an error due to lack of support'
109
+ );
110
+ return;
111
+ });
94
112
  });
95
113
  describe('Templating ================', () => {
96
114
  // it.skip('Should create a transactionalSMS template via retrieveAsTemplate and build it');
@@ -104,6 +122,8 @@ describe('transactionalSMS', () => {
104
122
  ['testExisting_tsms'],
105
123
  'testSourceMarket'
106
124
  );
125
+ assert.equal(process.exitCode, false, 'buildTemplate should not have thrown an error');
126
+
107
127
  assert.equal(
108
128
  result.transactionalSMS ? Object.keys(result.transactionalSMS).length : 0,
109
129
  1,
@@ -128,13 +148,19 @@ describe('transactionalSMS', () => {
128
148
  'testExisting_tsms',
129
149
  'testTargetMarket'
130
150
  );
151
+ assert.equal(
152
+ process.exitCode,
153
+ false,
154
+ 'buildDefinition should not have thrown an error'
155
+ );
156
+
131
157
  assert.deepEqual(
132
- await testUtils.getActualDeployJson('testExisting_tsms', 'transactionalSMS'),
158
+ await testUtils.getActualDeployJson('testTemplated_tsms', 'transactionalSMS'),
133
159
  await testUtils.getExpectedJson('9999999', 'transactionalSMS', 'build'),
134
160
  'returned deployment JSON was not equal expected'
135
161
  );
136
162
  expect(
137
- file(testUtils.getActualDeployFile('testExisting_tsms', 'transactionalSMS', 'amp'))
163
+ file(testUtils.getActualDeployFile('testTemplated_tsms', 'transactionalSMS', 'amp'))
138
164
  ).to.equal(
139
165
  file(testUtils.getExpectedFile('9999999', 'transactionalSMS', 'build', 'amp'))
140
166
  );
@@ -146,4 +172,48 @@ describe('transactionalSMS', () => {
146
172
  return;
147
173
  });
148
174
  });
175
+ describe('Delete ================', () => {
176
+ // TODO: add this test
177
+ it('Should delete the item'); // , async () => {
178
+ // // WHEN
179
+ // const result = await handler.deleteByKey('testInstance/testBU', 'mobileKeyword', [
180
+ // 'testExisting_keyword',
181
+ // ]);
182
+ // // THEN
183
+ // assert.equal(process.exitCode, false, 'delete should not have thrown an error');
184
+
185
+ // assert.equal(result, true, 'should have deleted the item');
186
+ // return;
187
+ // });
188
+ });
189
+ describe('CI/CD ================', () => {
190
+ // TODO: add this test
191
+ it('Should return a list of files based on their type and key'); // , async () => {
192
+ // // WHEN
193
+ // const fileList = await handler.getFilesToCommit(
194
+ // 'testInstance/testBU',
195
+ // 'mobileKeyword',
196
+ // ['testExisting_keyword']
197
+ // );
198
+ // // THEN
199
+ // assert.equal(
200
+ // process.exitCode,
201
+ // false,
202
+ // 'getFilesToCommit should not have thrown an error'
203
+ // );
204
+ // assert.equal(fileList.length, 2, 'expected only 2 file paths');
205
+
206
+ // assert.equal(
207
+ // fileList[0].split('\\').join('/'),
208
+ // 'retrieve/testInstance/testBU/mobileKeyword/testExisting_keyword.mobileKeyword-meta.json',
209
+ // 'wrong JSON path'
210
+ // );
211
+ // assert.equal(
212
+ // fileList[1].split('\\').join('/'),
213
+ // 'retrieve/testInstance/testBU/mobileKeyword/testExisting_keyword.mobileKeyword-meta.amp',
214
+ // 'wrong AMP path'
215
+ // );
216
+ // return;
217
+ // });
218
+ });
149
219
  });
@@ -0,0 +1,160 @@
1
+ const assert = require('chai').assert;
2
+ const cache = require('../lib/util/cache');
3
+ const testUtils = require('./utils');
4
+ const handler = require('../lib/index');
5
+
6
+ describe('type: user', () => {
7
+ beforeEach(() => {
8
+ testUtils.mockSetup();
9
+ });
10
+ afterEach(() => {
11
+ testUtils.mockReset();
12
+ });
13
+ describe('Retrieve ================', () => {
14
+ it('Should retrieve a user', async () => {
15
+ // WHEN
16
+ await handler.retrieve('testInstance/_ParentBU_', ['user']);
17
+ // THEN
18
+ assert.equal(process.exitCode, false, 'retrieve should not have thrown an error');
19
+ // get results from cache
20
+ const result = cache.getCache();
21
+ assert.equal(
22
+ result.user ? Object.keys(result.user).length : 0,
23
+ 1,
24
+ 'only one user expected'
25
+ );
26
+ assert.deepEqual(
27
+ await testUtils.getActualJson('testExisting_user', 'user', '_ParentBU_'),
28
+ await testUtils.getExpectedJson('1111111', 'user', 'retrieve'),
29
+
30
+ 'returned metadata was not equal expected'
31
+ );
32
+ assert.equal(
33
+ testUtils.getAPIHistoryLength(),
34
+ 6,
35
+ 'Unexpected number of requests made. Run testUtils.logAPIHistoryDebug() to see the requests'
36
+ );
37
+ return;
38
+ });
39
+ });
40
+ describe('Deploy ================', () => {
41
+ beforeEach(() => {
42
+ testUtils.mockSetup(true);
43
+ });
44
+ it('Should create & upsert a user', async () => {
45
+ // WHEN
46
+ const expectedCache = ['testNew_user', 'testExisting_user'];
47
+ await handler.deploy('testInstance/_ParentBU_', ['user'], expectedCache);
48
+ // THEN
49
+ assert.equal(process.exitCode, false, 'deploy should not have thrown an error');
50
+
51
+ // get results from cache
52
+ const result = cache.getCache();
53
+ assert.equal(
54
+ result.user ? Object.keys(result.user).length : 0,
55
+ 2,
56
+ 'two users expected'
57
+ );
58
+ // confirm if result.user only includes values from expectedCache
59
+ assert.deepEqual(
60
+ Object.keys(result.user),
61
+ expectedCache,
62
+ 'returned user keys were not equal expected'
63
+ );
64
+
65
+ // insert
66
+ assert.deepEqual(
67
+ await testUtils.getActualJson('testNew_user', 'user', '_ParentBU_'),
68
+ await testUtils.getExpectedJson('1111111', 'user', 'create'),
69
+ 'returned metadata was not equal expected for create'
70
+ );
71
+ // update
72
+ assert.deepEqual(
73
+ await testUtils.getActualJson('testExisting_user', 'user', '_ParentBU_'),
74
+ await testUtils.getExpectedJson('1111111', 'user', 'update'),
75
+ 'returned metadata was not equal expected for update'
76
+ );
77
+ assert.equal(
78
+ testUtils.getAPIHistoryLength(),
79
+ 9,
80
+ 'Unexpected number of requests made. Run testUtils.logAPIHistoryDebug() to see the requests'
81
+ );
82
+ return;
83
+ });
84
+ it('Should not deploy user with Marketing Cloud role', async () => {
85
+ // WHEN
86
+ const expectedCache = ['testExisting_user'];
87
+ await handler.deploy('testInstance/_ParentBU_', ['user'], ['testBlocked_user']);
88
+ // THEN
89
+ assert.equal(process.exitCode, 1, 'Deployment should have thrown an error');
90
+
91
+ // get results from cache
92
+ const result = cache.getCache();
93
+ assert.equal(result.user ? Object.keys(result.user).length : 0, 1, '1 user expected');
94
+ // confirm if result.user only includes values from expectedCache
95
+ assert.deepEqual(
96
+ Object.keys(result.user),
97
+ expectedCache,
98
+ 'returned user keys were not equal expected'
99
+ );
100
+
101
+ assert.equal(
102
+ testUtils.getAPIHistoryLength(),
103
+ 6,
104
+ 'Unexpected number of requests made. Run testUtils.logAPIHistoryDebug() to see the requests'
105
+ );
106
+ return;
107
+ });
108
+ it('Should change the key during update with --changeKeyValue');
109
+ });
110
+ describe('Templating ================', () => {
111
+ // it('Should create a user template via retrieveAsTemplate and build it', async () => {});
112
+ it('Should create a user template via buildTemplate and build it', async () => {
113
+ // download first before we test buildTemplate
114
+ await handler.retrieve('testInstance/_ParentBU_', ['user']);
115
+ // GIVEN there is a template
116
+ const result = await handler.buildTemplate(
117
+ 'testInstance/_ParentBU_',
118
+ 'user',
119
+ ['testExisting_user'],
120
+ 'testSourceMarket'
121
+ );
122
+ assert.equal(process.exitCode, false, 'buildTemplate should not have thrown an error');
123
+ // WHEN
124
+ assert.equal(
125
+ result.user ? Object.keys(result.user).length : 0,
126
+ 1,
127
+ 'only one user expected'
128
+ );
129
+ assert.deepEqual(
130
+ await testUtils.getActualTemplateJson('testExisting_user', 'user'),
131
+ await testUtils.getExpectedJson('1111111', 'user', 'template'),
132
+ 'returned template was not equal expected'
133
+ );
134
+ // THEN
135
+ await handler.buildDefinition(
136
+ 'testInstance/_ParentBU_',
137
+ 'user',
138
+ 'testExisting_user',
139
+ 'testTargetMarket'
140
+ );
141
+ assert.equal(
142
+ process.exitCode,
143
+ false,
144
+ 'buildDefinition should not have thrown an error'
145
+ );
146
+
147
+ assert.deepEqual(
148
+ await testUtils.getActualDeployJson('testTemplated_user', 'user', '_ParentBU_'),
149
+ await testUtils.getExpectedJson('1111111', 'user', 'build'),
150
+ 'returned deployment file was not equal expected'
151
+ );
152
+ assert.equal(
153
+ testUtils.getAPIHistoryLength(),
154
+ 6,
155
+ 'Unexpected number of requests made. Run testUtils.logAPIHistoryDebug() to see the requests'
156
+ );
157
+ return;
158
+ });
159
+ });
160
+ });