diff --git a/lib/cli.js b/lib/cli.js index efd21f2ec..61da5bcf6 100644 --- a/lib/cli.js +++ b/lib/cli.js @@ -602,7 +602,8 @@ yargs .option('clear', { type: 'string', group: 'Options for updateNotifications:', - describe: 'remove notification email addresses and/or notes', + describe: + "remove notification email addresses and/or notes. Possible options: 'all', 'errorEmail', 'completionEmail', 'notes'", }) .option('like', { type: 'string', diff --git a/lib/index.js b/lib/index.js index 972b84c11..5f7bdbb90 100644 --- a/lib/index.js +++ b/lib/index.js @@ -1004,23 +1004,19 @@ class Mcdev { } } case 'updateNotifications': { - { - if ( - Object.prototype.hasOwnProperty.call(MetadataTypeInfo[type], methodName) - ) { - resultArr.push(...(await MetadataTypeInfo[type][methodName](keyArr))); - if (resultArr.length > 0) { - Util.logger.info(`Retrieving ${type} to have most recent changes`); - const retriever = new Retriever(properties, buObject); - await retriever.retrieve([type], resultArr, null, false); - } - } else { - resultArr.push( - ...(await this.#updateNotificationsGeneric(type, keyArr, buObject)) - ); + if (Object.prototype.hasOwnProperty.call(MetadataTypeInfo[type], methodName)) { + resultArr.push(...(await MetadataTypeInfo[type][methodName](keyArr))); + if (resultArr.length > 0) { + Util.logger.info(`Retrieving ${type} to have most recent changes`); + const retriever = new Retriever(properties, buObject); + await retriever.retrieve([type], resultArr, null, false); } - break; + } else { + resultArr.push( + ...(await this.#updateNotificationsGeneric(type, keyArr, buObject)) + ); } + break; } default: { if (Util.OPTIONS.like && Object.keys(Util.OPTIONS.like).length) { diff --git a/lib/metadataTypes/Automation.js b/lib/metadataTypes/Automation.js index 80d9ff295..d284997c0 100644 --- a/lib/metadataTypes/Automation.js +++ b/lib/metadataTypes/Automation.js @@ -981,9 +981,7 @@ class Automation extends MetadataType { // should be empty if all OK throw new Error(result); } else { - Util.logger.info( - Util.getGrayMsg(` - updated notifications for automation '${key}'`) - ); + Util.logger.info(`updated notifications for automation '${key}'`); return 'OK'; } } catch (ex) { diff --git a/test/resources/9999999/automation/clearNotifications-expected.json b/test/resources/9999999/automation/clearNotificationsAll-expected.json similarity index 91% rename from test/resources/9999999/automation/clearNotifications-expected.json rename to test/resources/9999999/automation/clearNotificationsAll-expected.json index c7597dbb8..7ee326e5c 100644 --- a/test/resources/9999999/automation/clearNotifications-expected.json +++ b/test/resources/9999999/automation/clearNotificationsAll-expected.json @@ -1,7 +1,7 @@ { "description": "bla bla", - "key": "testExisting_automation_clearNotifications", - "name": "testExisting_automation_clearNotifications", + "key": "testExisting_automation_clearNotificationsAll", + "name": "testExisting_automation_clearNotificationsAll", "r__folder_Path": "my automations", "schedule": { "endDate": "2022-07-30T00:00:00", diff --git a/test/resources/9999999/automation/clearNotificationsCompletionEmail-expected.json b/test/resources/9999999/automation/clearNotificationsCompletionEmail-expected.json new file mode 100644 index 000000000..11f0eaab0 --- /dev/null +++ b/test/resources/9999999/automation/clearNotificationsCompletionEmail-expected.json @@ -0,0 +1,52 @@ +{ + "description": "bla bla", + "key": "testExisting_automation_clearNotificationsCompletionEmail", + "name": "testExisting_automation_clearNotificationsCompletionEmail", + "r__folder_Path": "my automations", + "schedule": { + "endDate": "2022-07-30T00:00:00", + "icalRecur": "FREQ=DAILY;COUNT=1;INTERVAL=1", + "startDate": "2022-07-30T00:00:00", + "timezoneName": "W. Europe Standard Time" + }, + "status": "PausedSchedule", + "steps": [ + { + "activities": [ + { + "name": "testExisting_dataExtract", + "r__type": "dataExtract" + }, + { + "name": "testExisting_emailSend", + "r__type": "emailSend" + }, + { + "name": "testExisting_fileTransfer", + "r__type": "fileTransfer" + }, + { + "name": "testExisting_importFile", + "r__type": "importFile" + }, + { + "name": "testExisting_query", + "r__type": "query" + }, + { + "name": "testExisting_script", + "r__type": "script" + } + ], + "name": "" + } + ], + "type": "scheduled", + "notifications": [ + { + "email": ["test@test.com"], + "message": "test", + "type": "Error" + } + ] +} diff --git a/test/resources/9999999/automation/clearNotificationsErrorEmail-expected.json b/test/resources/9999999/automation/clearNotificationsErrorEmail-expected.json new file mode 100644 index 000000000..11141755c --- /dev/null +++ b/test/resources/9999999/automation/clearNotificationsErrorEmail-expected.json @@ -0,0 +1,52 @@ +{ + "description": "bla bla", + "key": "testExisting_automation_clearNotificationsErrorEmail", + "name": "testExisting_automation_clearNotificationsErrorEmail", + "r__folder_Path": "my automations", + "schedule": { + "endDate": "2022-07-30T00:00:00", + "icalRecur": "FREQ=DAILY;COUNT=1;INTERVAL=1", + "startDate": "2022-07-30T00:00:00", + "timezoneName": "W. Europe Standard Time" + }, + "status": "PausedSchedule", + "steps": [ + { + "activities": [ + { + "name": "testExisting_dataExtract", + "r__type": "dataExtract" + }, + { + "name": "testExisting_emailSend", + "r__type": "emailSend" + }, + { + "name": "testExisting_fileTransfer", + "r__type": "fileTransfer" + }, + { + "name": "testExisting_importFile", + "r__type": "importFile" + }, + { + "name": "testExisting_query", + "r__type": "query" + }, + { + "name": "testExisting_script", + "r__type": "script" + } + ], + "name": "" + } + ], + "type": "scheduled", + "notifications": [ + { + "email": ["test@test.com"], + "message": "test", + "type": "Complete" + } + ] +} diff --git a/test/resources/9999999/automation/clearNotificationsNotes-expected.json b/test/resources/9999999/automation/clearNotificationsNotes-expected.json new file mode 100644 index 000000000..52b46bc9a --- /dev/null +++ b/test/resources/9999999/automation/clearNotificationsNotes-expected.json @@ -0,0 +1,57 @@ +{ + "description": "bla bla", + "key": "testExisting_automation_clearNotificationsNotes", + "name": "testExisting_automation_clearNotificationsNotes", + "r__folder_Path": "my automations", + "schedule": { + "endDate": "2022-07-30T00:00:00", + "icalRecur": "FREQ=DAILY;COUNT=1;INTERVAL=1", + "startDate": "2022-07-30T00:00:00", + "timezoneName": "W. Europe Standard Time" + }, + "status": "PausedSchedule", + "steps": [ + { + "activities": [ + { + "name": "testExisting_dataExtract", + "r__type": "dataExtract" + }, + { + "name": "testExisting_emailSend", + "r__type": "emailSend" + }, + { + "name": "testExisting_fileTransfer", + "r__type": "fileTransfer" + }, + { + "name": "testExisting_importFile", + "r__type": "importFile" + }, + { + "name": "testExisting_query", + "r__type": "query" + }, + { + "name": "testExisting_script", + "r__type": "script" + } + ], + "name": "" + } + ], + "type": "scheduled", + "notifications": [ + { + "email": ["test@test.com"], + "message": "", + "type": "Complete" + }, + { + "email": ["test@test.com"], + "message": "", + "type": "Error" + } + ] +} diff --git a/test/resources/9999999/automation/v1/automations/08afb0e2-b00a-4c88-ad2e-clearNotifications/get-response.json b/test/resources/9999999/automation/v1/automations/08afb0e2-b00a-4c88-ad2e-clear/get-response.json similarity index 94% rename from test/resources/9999999/automation/v1/automations/08afb0e2-b00a-4c88-ad2e-clearNotifications/get-response.json rename to test/resources/9999999/automation/v1/automations/08afb0e2-b00a-4c88-ad2e-clear/get-response.json index e2977d662..949d7ebbe 100644 --- a/test/resources/9999999/automation/v1/automations/08afb0e2-b00a-4c88-ad2e-clearNotifications/get-response.json +++ b/test/resources/9999999/automation/v1/automations/08afb0e2-b00a-4c88-ad2e-clear/get-response.json @@ -1,8 +1,8 @@ { - "id": "08afb0e2-b00a-4c88-ad2e-updateNotifications", - "name": "testExisting_automation_clearNotifications", + "id": "08afb0e2-b00a-4c88-ad2e-clear", + "name": "testExisting_automation_clear", "description": "bla bla", - "key": "testExisting_automation_clearNotifications", + "key": "testExisting_automation_clear", "typeId": 1, "type": "scheduled", "statusId": 4, diff --git a/test/resources/9999999/automation/v1/automations/08afb0e2-b00a-4c88-ad2e-clearNotificationsAll/get-response.json b/test/resources/9999999/automation/v1/automations/08afb0e2-b00a-4c88-ad2e-clearNotificationsAll/get-response.json new file mode 100644 index 000000000..2bab6cea0 --- /dev/null +++ b/test/resources/9999999/automation/v1/automations/08afb0e2-b00a-4c88-ad2e-clearNotificationsAll/get-response.json @@ -0,0 +1,85 @@ +{ + "id": "08afb0e2-b00a-4c88-ad2e-clearNotificationsAll", + "name": "testExisting_automation_clearNotificationsAll", + "description": "bla bla", + "key": "testExisting_automation_clearNotificationsAll", + "typeId": 1, + "type": "scheduled", + "statusId": 4, + "status": "PausedSchedule", + "categoryId": 290937, + "schedule": { + "id": "b393aa6c-a4a8-4c0f-a148-9250258a7339", + "typeId": 3, + "startDate": "2022-07-30T00:00:00", + "endDate": "2022-07-30T00:00:00", + "scheduledTime": "0001-01-01T07:00:00", + "rangeTypeId": 0, + "occurrences": 1, + "pattern": "01", + "icalRecur": "FREQ=DAILY;COUNT=1;INTERVAL=1", + "timezoneName": "W. Europe Standard Time", + "scheduleStatus": "scheduled", + "timezoneId": 5 + }, + "steps": [ + { + "id": "13fda077-0e82-4936-b936-a36b0997fc44", + "name": "", + "step": 1, + "activities": [ + { + "id": "8081a992-a27d-4a43-984a-d60114ea1025", + "name": "testExisting_dataExtract", + "activityObjectId": "56c5370a-f988-4f36-b0ee-0f876573f6d7", + "objectTypeId": 73, + "displayOrder": 1 + }, + { + "id": "d3774dc2-a271-4a44-8cbe-f630a6d6545e", + "name": "testExisting_emailSend", + "activityObjectId": "9b1c7bf9-4964-ed11-b849-48df37d1de8b", + "objectTypeId": 42, + "displayOrder": 2 + }, + { + "id": "2c77fc42-85eb-4611-98f9-223d29d89d72", + "name": "testExisting_fileTransfer", + "activityObjectId": "72c328ac-f5b0-4e37-91d3-a775666f15a6", + "objectTypeId": 53, + "displayOrder": 3 + }, + { + "id": "298b2794-28cb-4c70-b7ad-58b2c8cf48f7", + "name": "testExisting_importFile", + "activityObjectId": "9d16f42c-2260-ed11-b849-48df37d1de8b", + "objectTypeId": 43, + "displayOrder": 4, + "targetDataExtensions": [ + { + "id": "21711373-72c1-ec11-b83b-48df37d1deb7", + "name": "testExisting_dataExtension", + "key": "testExisting_dataExtension", + "description": "bla bla", + "rowCount": 0 + } + ] + }, + { + "id": "e3774dc2-a271-4a44-8cbe-f630a6d6545e", + "name": "testExisting_query_WRONG_NAME", + "activityObjectId": "549f0568-607c-4940-afef-437965094dat", + "objectTypeId": 300, + "displayOrder": 5 + }, + { + "id": "g3774dc2-a271-4a44-8cbe-f630a6d6545e", + "name": "testExisting_script", + "activityObjectId": "39f6a488-20eb-4ba0-b0b9-023725b574e4", + "objectTypeId": 423, + "displayOrder": 6 + } + ] + } + ] +} diff --git a/test/resources/9999999/automation/v1/automations/08afb0e2-b00a-4c88-ad2e-clearNotificationsCompletionEmail/get-response.json b/test/resources/9999999/automation/v1/automations/08afb0e2-b00a-4c88-ad2e-clearNotificationsCompletionEmail/get-response.json new file mode 100644 index 000000000..71156d9ce --- /dev/null +++ b/test/resources/9999999/automation/v1/automations/08afb0e2-b00a-4c88-ad2e-clearNotificationsCompletionEmail/get-response.json @@ -0,0 +1,92 @@ +{ + "id": "08afb0e2-b00a-4c88-ad2e-clearNotificationsCompletionEmail", + "name": "testExisting_automation_clearNotificationsCompletionEmail", + "description": "bla bla", + "key": "testExisting_automation_clearNotificationsCompletionEmail", + "typeId": 1, + "type": "scheduled", + "statusId": 4, + "status": "PausedSchedule", + "categoryId": 290937, + "schedule": { + "id": "b393aa6c-a4a8-4c0f-a148-9250258a7339", + "typeId": 3, + "startDate": "2022-07-30T00:00:00", + "endDate": "2022-07-30T00:00:00", + "scheduledTime": "0001-01-01T07:00:00", + "rangeTypeId": 0, + "occurrences": 1, + "pattern": "01", + "icalRecur": "FREQ=DAILY;COUNT=1;INTERVAL=1", + "timezoneName": "W. Europe Standard Time", + "scheduleStatus": "scheduled", + "timezoneId": 5 + }, + "steps": [ + { + "id": "13fda077-0e82-4936-b936-a36b0997fc44", + "name": "", + "step": 1, + "activities": [ + { + "id": "8081a992-a27d-4a43-984a-d60114ea1025", + "name": "testExisting_dataExtract", + "activityObjectId": "56c5370a-f988-4f36-b0ee-0f876573f6d7", + "objectTypeId": 73, + "displayOrder": 1 + }, + { + "id": "d3774dc2-a271-4a44-8cbe-f630a6d6545e", + "name": "testExisting_emailSend", + "activityObjectId": "9b1c7bf9-4964-ed11-b849-48df37d1de8b", + "objectTypeId": 42, + "displayOrder": 2 + }, + { + "id": "2c77fc42-85eb-4611-98f9-223d29d89d72", + "name": "testExisting_fileTransfer", + "activityObjectId": "72c328ac-f5b0-4e37-91d3-a775666f15a6", + "objectTypeId": 53, + "displayOrder": 3 + }, + { + "id": "298b2794-28cb-4c70-b7ad-58b2c8cf48f7", + "name": "testExisting_importFile", + "activityObjectId": "9d16f42c-2260-ed11-b849-48df37d1de8b", + "objectTypeId": 43, + "displayOrder": 4, + "targetDataExtensions": [ + { + "id": "21711373-72c1-ec11-b83b-48df37d1deb7", + "name": "testExisting_dataExtension", + "key": "testExisting_dataExtension", + "description": "bla bla", + "rowCount": 0 + } + ] + }, + { + "id": "e3774dc2-a271-4a44-8cbe-f630a6d6545e", + "name": "testExisting_query_WRONG_NAME", + "activityObjectId": "549f0568-607c-4940-afef-437965094dat", + "objectTypeId": 300, + "displayOrder": 5 + }, + { + "id": "g3774dc2-a271-4a44-8cbe-f630a6d6545e", + "name": "testExisting_script", + "activityObjectId": "39f6a488-20eb-4ba0-b0b9-023725b574e4", + "objectTypeId": 423, + "displayOrder": 6 + } + ] + } + ], + "notifications": [ + { + "email": ["test@test.com"], + "message": "test", + "type": "Error" + } + ] +} diff --git a/test/resources/9999999/automation/v1/automations/08afb0e2-b00a-4c88-ad2e-clearNotificationsErrorEmail/get-response.json b/test/resources/9999999/automation/v1/automations/08afb0e2-b00a-4c88-ad2e-clearNotificationsErrorEmail/get-response.json new file mode 100644 index 000000000..134103842 --- /dev/null +++ b/test/resources/9999999/automation/v1/automations/08afb0e2-b00a-4c88-ad2e-clearNotificationsErrorEmail/get-response.json @@ -0,0 +1,92 @@ +{ + "id": "08afb0e2-b00a-4c88-ad2e-clearNotificationsErrorEmail", + "name": "testExisting_automation_clearNotificationsErrorEmail", + "description": "bla bla", + "key": "testExisting_automation_clearNotificationsErrorEmail", + "typeId": 1, + "type": "scheduled", + "statusId": 4, + "status": "PausedSchedule", + "categoryId": 290937, + "schedule": { + "id": "b393aa6c-a4a8-4c0f-a148-9250258a7339", + "typeId": 3, + "startDate": "2022-07-30T00:00:00", + "endDate": "2022-07-30T00:00:00", + "scheduledTime": "0001-01-01T07:00:00", + "rangeTypeId": 0, + "occurrences": 1, + "pattern": "01", + "icalRecur": "FREQ=DAILY;COUNT=1;INTERVAL=1", + "timezoneName": "W. Europe Standard Time", + "scheduleStatus": "scheduled", + "timezoneId": 5 + }, + "steps": [ + { + "id": "13fda077-0e82-4936-b936-a36b0997fc44", + "name": "", + "step": 1, + "activities": [ + { + "id": "8081a992-a27d-4a43-984a-d60114ea1025", + "name": "testExisting_dataExtract", + "activityObjectId": "56c5370a-f988-4f36-b0ee-0f876573f6d7", + "objectTypeId": 73, + "displayOrder": 1 + }, + { + "id": "d3774dc2-a271-4a44-8cbe-f630a6d6545e", + "name": "testExisting_emailSend", + "activityObjectId": "9b1c7bf9-4964-ed11-b849-48df37d1de8b", + "objectTypeId": 42, + "displayOrder": 2 + }, + { + "id": "2c77fc42-85eb-4611-98f9-223d29d89d72", + "name": "testExisting_fileTransfer", + "activityObjectId": "72c328ac-f5b0-4e37-91d3-a775666f15a6", + "objectTypeId": 53, + "displayOrder": 3 + }, + { + "id": "298b2794-28cb-4c70-b7ad-58b2c8cf48f7", + "name": "testExisting_importFile", + "activityObjectId": "9d16f42c-2260-ed11-b849-48df37d1de8b", + "objectTypeId": 43, + "displayOrder": 4, + "targetDataExtensions": [ + { + "id": "21711373-72c1-ec11-b83b-48df37d1deb7", + "name": "testExisting_dataExtension", + "key": "testExisting_dataExtension", + "description": "bla bla", + "rowCount": 0 + } + ] + }, + { + "id": "e3774dc2-a271-4a44-8cbe-f630a6d6545e", + "name": "testExisting_query_WRONG_NAME", + "activityObjectId": "549f0568-607c-4940-afef-437965094dat", + "objectTypeId": 300, + "displayOrder": 5 + }, + { + "id": "g3774dc2-a271-4a44-8cbe-f630a6d6545e", + "name": "testExisting_script", + "activityObjectId": "39f6a488-20eb-4ba0-b0b9-023725b574e4", + "objectTypeId": 423, + "displayOrder": 6 + } + ] + } + ], + "notifications": [ + { + "email": ["test@test.com"], + "message": "test", + "type": "Complete" + } + ] +} diff --git a/test/resources/9999999/automation/v1/automations/08afb0e2-b00a-4c88-ad2e-clearNotificationsNotes/get-response.json b/test/resources/9999999/automation/v1/automations/08afb0e2-b00a-4c88-ad2e-clearNotificationsNotes/get-response.json new file mode 100644 index 000000000..b7fa1f011 --- /dev/null +++ b/test/resources/9999999/automation/v1/automations/08afb0e2-b00a-4c88-ad2e-clearNotificationsNotes/get-response.json @@ -0,0 +1,97 @@ +{ + "id": "08afb0e2-b00a-4c88-ad2e-clearNotificationsNotes", + "name": "testExisting_automation_clearNotificationsNotes", + "description": "bla bla", + "key": "testExisting_automation_clearNotificationsNotes", + "typeId": 1, + "type": "scheduled", + "statusId": 4, + "status": "PausedSchedule", + "categoryId": 290937, + "schedule": { + "id": "b393aa6c-a4a8-4c0f-a148-9250258a7339", + "typeId": 3, + "startDate": "2022-07-30T00:00:00", + "endDate": "2022-07-30T00:00:00", + "scheduledTime": "0001-01-01T07:00:00", + "rangeTypeId": 0, + "occurrences": 1, + "pattern": "01", + "icalRecur": "FREQ=DAILY;COUNT=1;INTERVAL=1", + "timezoneName": "W. Europe Standard Time", + "scheduleStatus": "scheduled", + "timezoneId": 5 + }, + "steps": [ + { + "id": "13fda077-0e82-4936-b936-a36b0997fc44", + "name": "", + "step": 1, + "activities": [ + { + "id": "8081a992-a27d-4a43-984a-d60114ea1025", + "name": "testExisting_dataExtract", + "activityObjectId": "56c5370a-f988-4f36-b0ee-0f876573f6d7", + "objectTypeId": 73, + "displayOrder": 1 + }, + { + "id": "d3774dc2-a271-4a44-8cbe-f630a6d6545e", + "name": "testExisting_emailSend", + "activityObjectId": "9b1c7bf9-4964-ed11-b849-48df37d1de8b", + "objectTypeId": 42, + "displayOrder": 2 + }, + { + "id": "2c77fc42-85eb-4611-98f9-223d29d89d72", + "name": "testExisting_fileTransfer", + "activityObjectId": "72c328ac-f5b0-4e37-91d3-a775666f15a6", + "objectTypeId": 53, + "displayOrder": 3 + }, + { + "id": "298b2794-28cb-4c70-b7ad-58b2c8cf48f7", + "name": "testExisting_importFile", + "activityObjectId": "9d16f42c-2260-ed11-b849-48df37d1de8b", + "objectTypeId": 43, + "displayOrder": 4, + "targetDataExtensions": [ + { + "id": "21711373-72c1-ec11-b83b-48df37d1deb7", + "name": "testExisting_dataExtension", + "key": "testExisting_dataExtension", + "description": "bla bla", + "rowCount": 0 + } + ] + }, + { + "id": "e3774dc2-a271-4a44-8cbe-f630a6d6545e", + "name": "testExisting_query_WRONG_NAME", + "activityObjectId": "549f0568-607c-4940-afef-437965094dat", + "objectTypeId": 300, + "displayOrder": 5 + }, + { + "id": "g3774dc2-a271-4a44-8cbe-f630a6d6545e", + "name": "testExisting_script", + "activityObjectId": "39f6a488-20eb-4ba0-b0b9-023725b574e4", + "objectTypeId": 423, + "displayOrder": 6 + } + ] + } + ], + "notifications": [ + { + "email": ["test@test.com"], + "message": "", + "type": "Complete" + }, + { + "email": ["test@test.com"], + "message": "", + "type": "Error" + } + ] +} diff --git a/test/resources/9999999/legacy/v1/beta/automations/notifications/RkpOcE9qSVh2VUdnYTVJbWFfWW14dzoyNTow_clearNotifications/get-response.json b/test/resources/9999999/legacy/v1/beta/automations/notifications/RkpOcE9qSVh2VUdnYTVJbWFfWW14dzoyNTow_clearNotifications/get-response.json deleted file mode 100644 index 59095924e..000000000 --- a/test/resources/9999999/legacy/v1/beta/automations/notifications/RkpOcE9qSVh2VUdnYTVJbWFfWW14dzoyNTow_clearNotifications/get-response.json +++ /dev/null @@ -1,9 +0,0 @@ -{ - "programId": "ZGQ4N2M2ZjEtYjJlZi00MDljLTg3MDctYzYwNWQ0MzdiYWI4OjI1OjA_clearNotifications", - "workers": [ - { - "programId": "ZGQ4N2M2ZjEtYjJlZi00MDljLTg3MDctYzYwNWQ0MzdiYWI4OjI1OjA_clearNotifications", - "id": "NGIzZGQ5N2EtMDI0ZS00MzFiLTg5ZWYtNTdjYTI4ODVjMjQ0OjEyOjA" - } - ] -} diff --git a/test/resources/9999999/legacy/v1/beta/automations/notifications/RkpOcE9qSVh2VUdnYTVJbWFfWW14dzoyNTow_clearNotificationsAll/get-response.json b/test/resources/9999999/legacy/v1/beta/automations/notifications/RkpOcE9qSVh2VUdnYTVJbWFfWW14dzoyNTow_clearNotificationsAll/get-response.json new file mode 100644 index 000000000..8306cab4f --- /dev/null +++ b/test/resources/9999999/legacy/v1/beta/automations/notifications/RkpOcE9qSVh2VUdnYTVJbWFfWW14dzoyNTow_clearNotificationsAll/get-response.json @@ -0,0 +1,13 @@ +{ + "programId": "ZGQ4N2M2ZjEtYjJlZi00MDljLTg3MDctYzYwNWQ0MzdiYWI4OjI1OjA_clearNotificationsAll", + "workers": [ + { + "programId": "ZGQ4N2M2ZjEtYjJlZi00MDljLTg3MDctYzYwNWQ0MzdiYWI4OjI1OjA_clearNotificationsAll", + "id": "YjA2NmVlODEtODllOS00NTE4LTkwYzYtMTY4Mzg2ZTk3MGE4OjEyOjA" + }, + { + "programId": "ZGQ4N2M2ZjEtYjJlZi00MDljLTg3MDctYzYwNWQ0MzdiYWI4OjI1OjA_clearNotificationsAll", + "id": "NGIzZGQ5N2EtMDI0ZS00MzFiLTg5ZWYtNTdjYTI4ODVjMjQ0OjEyOjA" + } + ] +} diff --git a/test/resources/9999999/legacy/v1/beta/automations/notifications/RkpOcE9qSVh2VUdnYTVJbWFfWW14dzoyNTow_clearNotifications/post-response.json b/test/resources/9999999/legacy/v1/beta/automations/notifications/RkpOcE9qSVh2VUdnYTVJbWFfWW14dzoyNTow_clearNotificationsAll/post-response.json similarity index 100% rename from test/resources/9999999/legacy/v1/beta/automations/notifications/RkpOcE9qSVh2VUdnYTVJbWFfWW14dzoyNTow_clearNotifications/post-response.json rename to test/resources/9999999/legacy/v1/beta/automations/notifications/RkpOcE9qSVh2VUdnYTVJbWFfWW14dzoyNTow_clearNotificationsAll/post-response.json diff --git a/test/resources/9999999/legacy/v1/beta/automations/notifications/RkpOcE9qSVh2VUdnYTVJbWFfWW14dzoyNTow_clearNotificationsCompletionEmail/get-response.json b/test/resources/9999999/legacy/v1/beta/automations/notifications/RkpOcE9qSVh2VUdnYTVJbWFfWW14dzoyNTow_clearNotificationsCompletionEmail/get-response.json new file mode 100644 index 000000000..4cf622609 --- /dev/null +++ b/test/resources/9999999/legacy/v1/beta/automations/notifications/RkpOcE9qSVh2VUdnYTVJbWFfWW14dzoyNTow_clearNotificationsCompletionEmail/get-response.json @@ -0,0 +1,17 @@ +{ + "programId": "ZGQ4N2M2ZjEtYjJlZi00MDljLTg3MDctYzYwNWQ0MzdiYWI4OjI1OjA_clearNotificationsCompletionEmail", + "workers": [ + { + "programId": "ZGQ4N2M2ZjEtYjJlZi00MDljLTg3MDctYzYwNWQ0MzdiYWI4OjI1OjA_clearNotificationsCompletionEmail", + "id": "NGIzZGQ5N2EtMDI0ZS00MzFiLTg5ZWYtNTdjYTI4ODVjMjQ0OjEyOjA" + }, + { + "programId": "ZGQ4N2M2ZjEtYjJlZi00MDljLTg3MDctYzYwNWQ0MzdiYWI4OjI1OjA_clearNotificationsCompletionEmail", + "id": "NGIzZGQ5N2EtMDI0ZS00MzFiLTg5ZWYtNTdjYTI4ODVjMjQ0OjEyOjA", + "notificationType": "Error", + "definition": "test@test.com", + "body": "test", + "channelType": "Account" + } + ] +} diff --git a/test/resources/9999999/legacy/v1/beta/automations/notifications/RkpOcE9qSVh2VUdnYTVJbWFfWW14dzoyNTow_clearNotificationsCompletionEmail/post-response.json b/test/resources/9999999/legacy/v1/beta/automations/notifications/RkpOcE9qSVh2VUdnYTVJbWFfWW14dzoyNTow_clearNotificationsCompletionEmail/post-response.json new file mode 100644 index 000000000..e69de29bb diff --git a/test/resources/9999999/legacy/v1/beta/automations/notifications/RkpOcE9qSVh2VUdnYTVJbWFfWW14dzoyNTow_clearNotificationsErrorEmail/get-response.json b/test/resources/9999999/legacy/v1/beta/automations/notifications/RkpOcE9qSVh2VUdnYTVJbWFfWW14dzoyNTow_clearNotificationsErrorEmail/get-response.json new file mode 100644 index 000000000..8198ec9f7 --- /dev/null +++ b/test/resources/9999999/legacy/v1/beta/automations/notifications/RkpOcE9qSVh2VUdnYTVJbWFfWW14dzoyNTow_clearNotificationsErrorEmail/get-response.json @@ -0,0 +1,17 @@ +{ + "programId": "ZGQ4N2M2ZjEtYjJlZi00MDljLTg3MDctYzYwNWQ0MzdiYWI4OjI1OjA_clearNotificationsErrorEmail", + "workers": [ + { + "programId": "ZGQ4N2M2ZjEtYjJlZi00MDljLTg3MDctYzYwNWQ0MzdiYWI4OjI1OjA_clearNotificationsErrorEmail", + "id": "NGIzZGQ5N2EtMDI0ZS00MzFiLTg5ZWYtNTdjYTI4ODVjMjQ0OjEyOjA", + "notificationType": "Complete", + "definition": "test@test.com", + "body": "test", + "channelType": "Account" + }, + { + "programId": "ZGQ4N2M2ZjEtYjJlZi00MDljLTg3MDctYzYwNWQ0MzdiYWI4OjI1OjA_clearNotificationsErrorEmail", + "id": "NGIzZGQ5N2EtMDI0ZS00MzFiLTg5ZWYtNTdjYTI4ODVjMjQ0OjEyOjA" + } + ] +} diff --git a/test/resources/9999999/legacy/v1/beta/automations/notifications/RkpOcE9qSVh2VUdnYTVJbWFfWW14dzoyNTow_clearNotificationsErrorEmail/post-response.json b/test/resources/9999999/legacy/v1/beta/automations/notifications/RkpOcE9qSVh2VUdnYTVJbWFfWW14dzoyNTow_clearNotificationsErrorEmail/post-response.json new file mode 100644 index 000000000..e69de29bb diff --git a/test/resources/9999999/legacy/v1/beta/automations/notifications/RkpOcE9qSVh2VUdnYTVJbWFfWW14dzoyNTow_clearNotificationsNotes/get-response.json b/test/resources/9999999/legacy/v1/beta/automations/notifications/RkpOcE9qSVh2VUdnYTVJbWFfWW14dzoyNTow_clearNotificationsNotes/get-response.json new file mode 100644 index 000000000..b09f2a715 --- /dev/null +++ b/test/resources/9999999/legacy/v1/beta/automations/notifications/RkpOcE9qSVh2VUdnYTVJbWFfWW14dzoyNTow_clearNotificationsNotes/get-response.json @@ -0,0 +1,21 @@ +{ + "programId": "ZGQ4N2M2ZjEtYjJlZi00MDljLTg3MDctYzYwNWQ0MzdiYWI4OjI1OjA_clearNotificationsNotes", + "workers": [ + { + "programId": "ZGQ4N2M2ZjEtYjJlZi00MDljLTg3MDctYzYwNWQ0MzdiYWI4OjI1OjA_clearNotificationsNotes", + "id": "NGIzZGQ5N2EtMDI0ZS00MzFiLTg5ZWYtNTdjYTI4ODVjMjQ0OjEyOjA", + "notificationType": "Complete", + "definition": "test@test.com", + "body": "", + "channelType": "Account" + }, + { + "programId": "ZGQ4N2M2ZjEtYjJlZi00MDljLTg3MDctYzYwNWQ0MzdiYWI4OjI1OjA_clearNotificationsNotes", + "id": "NGIzZGQ5N2EtMDI0ZS00MzFiLTg5ZWYtNTdjYTI4ODVjMjQ0OjEyOjA", + "notificationType": "Error", + "definition": "test@test.com", + "body": "", + "channelType": "Account" + } + ] +} diff --git a/test/resources/9999999/legacy/v1/beta/automations/notifications/RkpOcE9qSVh2VUdnYTVJbWFfWW14dzoyNTow_clearNotificationsNotes/post-response.json b/test/resources/9999999/legacy/v1/beta/automations/notifications/RkpOcE9qSVh2VUdnYTVJbWFfWW14dzoyNTow_clearNotificationsNotes/post-response.json new file mode 100644 index 000000000..e69de29bb diff --git a/test/resources/9999999/legacy/v1/beta/bulk/automations/automation/definition/get-response.json b/test/resources/9999999/legacy/v1/beta/bulk/automations/automation/definition/get-response.json index 66832b7ac..abef3f25c 100644 --- a/test/resources/9999999/legacy/v1/beta/bulk/automations/automation/definition/get-response.json +++ b/test/resources/9999999/legacy/v1/beta/bulk/automations/automation/definition/get-response.json @@ -50,10 +50,10 @@ "automationType": "scheduled" }, { - "id": "RkpOcE9qSVh2VUdnYTVJbWFfWW14dzoyNTow_clearNotifications", - "key": "testExisting_automation_clearNotifications", + "id": "RkpOcE9qSVh2VUdnYTVJbWFfWW14dzoyNTow_clear", + "key": "testExisting_automation_clear", "createdDate": "2022-01-12T08:41:35.773Z", - "name": "testExisting_automation_clearNotifications", + "name": "testExisting_automation_clear", "description": "bla bla", "clientId": 9999999, "status": "Building", @@ -69,7 +69,99 @@ "email": "tom.tester@accenture.com" }, "isPlatformObject": false, - "notifications": "https://mcxxxxx.rest.marketingcloudapis.com/legacy/v1/beta/hub/notifications/RkpOcE9qSVh2VUdnYTVJbWFfWW14dzoxMjow_updateNotifications_errorEmailCompletionEmail", + "notifications": "https://mcxxxxx.rest.marketingcloudapis.com/legacy/v1/beta/hub/notifications/RkpOcE9qSVh2VUdnYTVJbWFfWW14dzoxMjow_clear", + "automationType": "scheduled" + }, + { + "id": "RkpOcE9qSVh2VUdnYTVJbWFfWW14dzoyNTow_clearNotificationsAll", + "key": "testExisting_automation_clearNotificationsAll", + "createdDate": "2022-01-12T08:41:35.773Z", + "name": "testExisting_automation_clearNotificationsAll", + "description": "bla bla", + "clientId": 9999999, + "status": "Building", + "createdBy": { + "id": "NzE3MzUzNDA1OjQ6MA", + "name": "Tom Tester", + "email": "tom.tester@accenture.com" + }, + "modifiedDate": "2022-11-11T16:42:36.513Z", + "modifiedBy": { + "id": "NzE3MzUzNDA1OjQ6MA", + "name": "Tom Tester", + "email": "tom.tester@accenture.com" + }, + "isPlatformObject": false, + "notifications": "https://mcxxxxx.rest.marketingcloudapis.com/legacy/v1/beta/hub/notifications/RkpOcE9qSVh2VUdnYTVJbWFfWW14dzoxMjow_clearNotificationsAll", + "automationType": "scheduled" + }, + { + "id": "RkpOcE9qSVh2VUdnYTVJbWFfWW14dzoyNTow_clearNotificationsCompletionEmail", + "key": "testExisting_automation_clearNotificationsCompletionEmail", + "createdDate": "2022-01-12T08:41:35.773Z", + "name": "testExisting_automation_clearNotificationsCompletionEmail", + "description": "bla bla", + "clientId": 9999999, + "status": "Building", + "createdBy": { + "id": "NzE3MzUzNDA1OjQ6MA", + "name": "Tom Tester", + "email": "tom.tester@accenture.com" + }, + "modifiedDate": "2022-11-11T16:42:36.513Z", + "modifiedBy": { + "id": "NzE3MzUzNDA1OjQ6MA", + "name": "Tom Tester", + "email": "tom.tester@accenture.com" + }, + "isPlatformObject": false, + "notifications": "https://mcxxxxx.rest.marketingcloudapis.com/legacy/v1/beta/hub/notifications/RkpOcE9qSVh2VUdnYTVJbWFfWW14dzoxMjow_clearNotificationsCompletionEmail", + "automationType": "scheduled" + }, + { + "id": "RkpOcE9qSVh2VUdnYTVJbWFfWW14dzoyNTow_clearNotificationsErrorEmail", + "key": "testExisting_automation_clearNotificationsErrorEmail", + "createdDate": "2022-01-12T08:41:35.773Z", + "name": "testExisting_automation_clearNotificationsErrorEmail", + "description": "bla bla", + "clientId": 9999999, + "status": "Building", + "createdBy": { + "id": "NzE3MzUzNDA1OjQ6MA", + "name": "Tom Tester", + "email": "tom.tester@accenture.com" + }, + "modifiedDate": "2022-11-11T16:42:36.513Z", + "modifiedBy": { + "id": "NzE3MzUzNDA1OjQ6MA", + "name": "Tom Tester", + "email": "tom.tester@accenture.com" + }, + "isPlatformObject": false, + "notifications": "https://mcxxxxx.rest.marketingcloudapis.com/legacy/v1/beta/hub/notifications/RkpOcE9qSVh2VUdnYTVJbWFfWW14dzoxMjow_clearNotificationsErrorEmail", + "automationType": "scheduled" + }, + { + "id": "RkpOcE9qSVh2VUdnYTVJbWFfWW14dzoyNTow_clearNotificationsNotes", + "key": "testExisting_automation_clearNotificationsNotes", + "createdDate": "2022-01-12T08:41:35.773Z", + "name": "testExisting_automation_clearNotificationsNotes", + "description": "bla bla", + "clientId": 9999999, + "status": "Building", + "createdBy": { + "id": "NzE3MzUzNDA1OjQ6MA", + "name": "Tom Tester", + "email": "tom.tester@accenture.com" + }, + "modifiedDate": "2022-11-11T16:42:36.513Z", + "modifiedBy": { + "id": "NzE3MzUzNDA1OjQ6MA", + "name": "Tom Tester", + "email": "tom.tester@accenture.com" + }, + "isPlatformObject": false, + "notifications": "https://mcxxxxx.rest.marketingcloudapis.com/legacy/v1/beta/hub/notifications/RkpOcE9qSVh2VUdnYTVJbWFfWW14dzoxMjow_clearNotificationsNotes", "automationType": "scheduled" }, { @@ -92,7 +184,7 @@ "email": "tom.tester@accenture.com" }, "isPlatformObject": false, - "notifications": "https://mcxxxxx.rest.marketingcloudapis.com/legacy/v1/beta/hub/notifications/RkpOcE9qSVh2VUdnYTVJbWFfWW14dzoxMjow_updateNotifications_errorEmailErrorNote", + "notifications": "https://mcxxxxx.rest.marketingcloudapis.com/legacy/v1/beta/hub/notifications/RkpOcE9qSVh2VUdnYTVJbWFfWW14dzoxMjow_errorEmailErrorNote", "automationType": "scheduled" }, { diff --git a/test/resources/9999999/program/retrieve-CustomerKey=testExisting_automation_clearNotificationsAll-response.xml b/test/resources/9999999/program/retrieve-CustomerKey=testExisting_automation_clearNotificationsAll-response.xml new file mode 100644 index 000000000..0292c0933 --- /dev/null +++ b/test/resources/9999999/program/retrieve-CustomerKey=testExisting_automation_clearNotificationsAll-response.xml @@ -0,0 +1,32 @@ + + + + RetrieveResponse + urn:uuid:60a72d4a-847e-4d9b-a4eb-a42951078298 + urn:uuid:0b59ed53-72ec-4481-ae06-4ee78912aef2 + http://schemas.xmlsoap.org/ws/2004/08/addressing/role/anonymous + + + 2023-06-01T12:04:20Z + 2023-06-01T12:09:20Z + + + + + + OK + 3b1c8cee-b270-49cb-b77b-e7b33934d1b6 + + + + 08afb0e2-b00a-4c88-ad2e-clearNotificationsAll + + + + + diff --git a/test/resources/9999999/program/retrieve-CustomerKey=testExisting_automation_clearNotificationsCompletionEmail-response.xml b/test/resources/9999999/program/retrieve-CustomerKey=testExisting_automation_clearNotificationsCompletionEmail-response.xml new file mode 100644 index 000000000..3b828b574 --- /dev/null +++ b/test/resources/9999999/program/retrieve-CustomerKey=testExisting_automation_clearNotificationsCompletionEmail-response.xml @@ -0,0 +1,30 @@ + + + + RetrieveResponse + urn:uuid:60a72d4a-847e-4d9b-a4eb-a42951078298 + urn:uuid:0b59ed53-72ec-4481-ae06-4ee78912aef2 + http://schemas.xmlsoap.org/ws/2004/08/addressing/role/anonymous + + + 2023-06-01T12:04:20Z + 2023-06-01T12:09:20Z + + + + + + OK + 3b1c8cee-b270-49cb-b77b-e7b33934d1b6 + + + 08afb0e2-b00a-4c88-ad2e-clearNotificationsCompletionEmail + + + + diff --git a/test/resources/9999999/program/retrieve-CustomerKey=testExisting_automation_clearNotificationsErrorEmail-response.xml b/test/resources/9999999/program/retrieve-CustomerKey=testExisting_automation_clearNotificationsErrorEmail-response.xml new file mode 100644 index 000000000..76ea00e58 --- /dev/null +++ b/test/resources/9999999/program/retrieve-CustomerKey=testExisting_automation_clearNotificationsErrorEmail-response.xml @@ -0,0 +1,30 @@ + + + + RetrieveResponse + urn:uuid:60a72d4a-847e-4d9b-a4eb-a42951078298 + urn:uuid:0b59ed53-72ec-4481-ae06-4ee78912aef2 + http://schemas.xmlsoap.org/ws/2004/08/addressing/role/anonymous + + + 2023-06-01T12:04:20Z + 2023-06-01T12:09:20Z + + + + + + OK + 3b1c8cee-b270-49cb-b77b-e7b33934d1b6 + + + 08afb0e2-b00a-4c88-ad2e-clearNotificationsErrorEmail + + + + diff --git a/test/resources/9999999/program/retrieve-CustomerKey=testExisting_automation_clearNotificationsNotes-response.xml b/test/resources/9999999/program/retrieve-CustomerKey=testExisting_automation_clearNotificationsNotes-response.xml new file mode 100644 index 000000000..0dce66c4b --- /dev/null +++ b/test/resources/9999999/program/retrieve-CustomerKey=testExisting_automation_clearNotificationsNotes-response.xml @@ -0,0 +1,30 @@ + + + + RetrieveResponse + urn:uuid:60a72d4a-847e-4d9b-a4eb-a42951078298 + urn:uuid:0b59ed53-72ec-4481-ae06-4ee78912aef2 + http://schemas.xmlsoap.org/ws/2004/08/addressing/role/anonymous + + + 2023-06-01T12:04:20Z + 2023-06-01T12:09:20Z + + + + + + OK + 3b1c8cee-b270-49cb-b77b-e7b33934d1b6 + + + 08afb0e2-b00a-4c88-ad2e-clearNotificationsNotes + + + + diff --git a/test/resources/9999999/program/retrieve-response.xml b/test/resources/9999999/program/retrieve-response.xml index cc6990604..12b9621ce 100644 --- a/test/resources/9999999/program/retrieve-response.xml +++ b/test/resources/9999999/program/retrieve-response.xml @@ -53,10 +53,28 @@ - 08afb0e2-b00a-4c88-ad2e-clearNotifications - testExisting_automation_clearNotifications - testExisting_automation_clearNotifications + 08afb0e2-b00a-4c88-ad2e-clearNotificationsAll + testExisting_automation_clearNotificationsAll + testExisting_automation_clearNotificationsAll + + + 08afb0e2-b00a-4c88-ad2e-clearNotificationsCompletionEmail + testExisting_automation_clearNotificationsCompletionEmail + testExisting_automation_clearNotificationsCompletionEmail + + + + 08afb0e2-b00a-4c88-ad2e-clearNotificationsErrorEmail + testExisting_automation_clearNotificationsErrorEmail + testExisting_automation_clearNotificationsErrorEmail + + + + 08afb0e2-b00a-4c88-ad2e-clearNotificationsNotes + testExisting_automation_clearNotificationsNotes + testExisting_automation_clearNotificationsNotes + 08afb0e2-b00a-4c88-ad2e-updateNotifications_errorEmailErrorNote diff --git a/test/type.automation.test.js b/test/type.automation.test.js index edf61ecf0..3c53a71f3 100644 --- a/test/type.automation.test.js +++ b/test/type.automation.test.js @@ -27,8 +27,8 @@ describe('type: automation', () => { const result = cache.getCache(); assert.equal( result.automation ? Object.keys(result.automation).length : 0, - 15, - 'only 15 automations expected' + 18, + 'only 18 automations expected' ); assert.deepEqual( await testUtils.getActualJson('testExisting_automation', 'automation'), @@ -50,7 +50,7 @@ describe('type: automation', () => { assert.equal( testUtils.getAPIHistoryLength(), - 39, + 45, 'Unexpected number of requests made. Run testUtils.logAPIHistoryDebug() to see the requests' ); return; @@ -79,7 +79,7 @@ describe('type: automation', () => { const cacheResult = cache.getCache(); assert.equal( cacheResult.automation ? Object.keys(cacheResult.automation).length : 0, - 16, + 19, '16 automations expected' ); // insert @@ -144,8 +144,8 @@ describe('type: automation', () => { const cached = cache.getCache(); assert.equal( cached.automation ? Object.keys(cached.automation).length : 0, - 16, - '16 cached automation expected' + 19, + '19 cached automation expected' ); assert.equal( deployed['testInstance/testBU'].automation @@ -213,8 +213,8 @@ describe('type: automation', () => { const cached = cache.getCache(); assert.equal( cached.automation ? Object.keys(cached.automation).length : 0, - 16, - '16 cached automation expected' + 19, + '19 cached automation expected' ); assert.equal( deployed['testInstance/testBU'].automation @@ -1325,12 +1325,82 @@ describe('type: automation', () => { ); return; }); - it('Should clear all notification email addresses', async () => { + it('Should clear all notes and all notification email addresses', async () => { handler.setOptions({ clear: 'all' }); const updatedNotifications = await handler.updateNotifications( 'testInstance/testBU', 'automation', - ['testExisting_automation_clearNotifications'] + ['testExisting_automation_clearNotificationsAll'] + ); + assert.equal( + process.exitCode, + false, + 'updateNotifications --clear should not have thrown an error' + ); + assert.equal( + updatedNotifications['testInstance/testBU'].length, + 1, + 'one automation key expected' + ); + // console.log(testUtils.logAPIHistoryDebug()); + assert.deepEqual( + await testUtils.getActualJson( + 'testExisting_automation_clearNotificationsAll', + 'automation' + ), + await testUtils.getExpectedJson('9999999', 'automation', 'clearNotificationsAll'), + 'returned metadata was not equal expected for update' + ); + + assert.equal( + testUtils.getAPIHistoryLength(), + 17, + 'Unexpected number of requests made. Run testUtils.logAPIHistoryDebug() to see the requests' + ); + return; + }); + it('Should clear all eror email addresses', async () => { + handler.setOptions({ clear: 'errorEmail' }); + const updatedNotifications = await handler.updateNotifications( + 'testInstance/testBU', + 'automation', + ['testExisting_automation_clearNotificationsErrorEmail'] + ); + assert.equal( + process.exitCode, + false, + 'updateNotifications --clear should not have thrown an error' + ); + assert.equal( + updatedNotifications['testInstance/testBU'].length, + 1, + 'one automation key expected' + ); + assert.deepEqual( + await testUtils.getActualJson( + 'testExisting_automation_clearNotificationsErrorEmail', + 'automation' + ), + await testUtils.getExpectedJson( + '9999999', + 'automation', + 'clearNotificationsErrorEmail' + ), + 'returned metadata was not equal expected for update' + ); + assert.equal( + testUtils.getAPIHistoryLength(), + 17, + 'Unexpected number of requests made. Run testUtils.logAPIHistoryDebug() to see the requests' + ); + return; + }); + it('Should clear all completion emails', async () => { + handler.setOptions({ clear: 'completionEmail' }); + const updatedNotifications = await handler.updateNotifications( + 'testInstance/testBU', + 'automation', + ['testExisting_automation_clearNotificationsCompletionEmail'] ); assert.equal( process.exitCode, @@ -1344,15 +1414,51 @@ describe('type: automation', () => { ); assert.deepEqual( await testUtils.getActualJson( - 'testExisting_automation_clearNotifications', + 'testExisting_automation_clearNotificationsCompletionEmail', 'automation' ), - await testUtils.getExpectedJson('9999999', 'automation', 'clearNotifications'), + await testUtils.getExpectedJson( + '9999999', + 'automation', + 'clearNotificationsCompletionEmail' + ), 'returned metadata was not equal expected for update' ); assert.equal( testUtils.getAPIHistoryLength(), - 42, + 17, + 'Unexpected number of requests made. Run testUtils.logAPIHistoryDebug() to see the requests' + ); + return; + }); + it('Should clear all notes', async () => { + handler.setOptions({ clear: 'notes' }); + const updatedNotifications = await handler.updateNotifications( + 'testInstance/testBU', + 'automation', + ['testExisting_automation_clearNotificationsNotes'] + ); + assert.equal( + process.exitCode, + false, + 'updateNotifications --clear should not have thrown an error' + ); + assert.equal( + updatedNotifications['testInstance/testBU'].length, + 1, + 'one automation key expected' + ); + assert.deepEqual( + await testUtils.getActualJson( + 'testExisting_automation_clearNotificationsNotes', + 'automation' + ), + await testUtils.getExpectedJson('9999999', 'automation', 'clearNotificationsNotes'), + 'returned metadata was not equal expected for update' + ); + assert.equal( + testUtils.getAPIHistoryLength(), + 17, 'Unexpected number of requests made. Run testUtils.logAPIHistoryDebug() to see the requests' ); return; diff --git a/test/type.query.test.js b/test/type.query.test.js index b7bbf0acd..9e4790f4c 100644 --- a/test/type.query.test.js +++ b/test/type.query.test.js @@ -458,7 +458,7 @@ describe('type: query', () => { // check number of API calls assert.equal( testUtils.getAPIHistoryLength(), - 55, + 61, 'Unexpected number of requests made. Run testUtils.logAPIHistoryDebug() to see the requests' ); return; @@ -498,7 +498,7 @@ describe('type: query', () => { // check number of API calls assert.equal( testUtils.getAPIHistoryLength(), - 57, + 63, 'Unexpected number of requests made. Run testUtils.logAPIHistoryDebug() to see the requests' ); return;