From 5939c3a0adf73e7b64ef30633afa0220f9364aed Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rn=20Berkefeld?= Date: Fri, 2 Jun 2023 14:20:53 +0200 Subject: [PATCH] #844: add DEPLOY tests for type automation --- ...stExisting_automation.automation-meta.json | 46 ++++++++++ .../testNew_automation.automation-meta.json | 46 ++++++++++ .../9999999/automation/create-expected.json | 46 ++++++++++ ...rieve-testExisting_automation-expected.md} | 0 .../9999999/automation/update-expected.json | 46 ++++++++++ .../patch-response.json | 84 ++++++++++++++++++ .../get-response.json | 85 +++++++++++++++++++ .../v1/automations/post-response.json | 84 ++++++++++++++++++ .../9999999/program/retrieve-response.xml | 2 + test/type.automation.test.js | 71 +++++++++------- 10 files changed, 478 insertions(+), 32 deletions(-) create mode 100644 test/mockRoot/deploy/testInstance/testBU/automation/testExisting_automation.automation-meta.json create mode 100644 test/mockRoot/deploy/testInstance/testBU/automation/testNew_automation.automation-meta.json create mode 100644 test/resources/9999999/automation/create-expected.json rename test/resources/9999999/automation/{retrieve-expected.md => retrieve-testExisting_automation-expected.md} (100%) create mode 100644 test/resources/9999999/automation/update-expected.json create mode 100644 test/resources/9999999/automation/v1/automations/08afb0e2-b00a-4c88-ad2e-1f7f8788c560/patch-response.json create mode 100644 test/resources/9999999/automation/v1/automations/a8afb0e2-b00a-4c88-ad2e-1f7f8788c560/get-response.json create mode 100644 test/resources/9999999/automation/v1/automations/post-response.json diff --git a/test/mockRoot/deploy/testInstance/testBU/automation/testExisting_automation.automation-meta.json b/test/mockRoot/deploy/testInstance/testBU/automation/testExisting_automation.automation-meta.json new file mode 100644 index 000000000..47860e944 --- /dev/null +++ b/test/mockRoot/deploy/testInstance/testBU/automation/testExisting_automation.automation-meta.json @@ -0,0 +1,46 @@ +{ + "description": "updated on deploy", + "key": "testExisting_automation", + "name": "testExisting_automation", + "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", + "typeId": 3 + }, + "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" +} diff --git a/test/mockRoot/deploy/testInstance/testBU/automation/testNew_automation.automation-meta.json b/test/mockRoot/deploy/testInstance/testBU/automation/testNew_automation.automation-meta.json new file mode 100644 index 000000000..2a1caee12 --- /dev/null +++ b/test/mockRoot/deploy/testInstance/testBU/automation/testNew_automation.automation-meta.json @@ -0,0 +1,46 @@ +{ + "description": "created on deploy", + "key": "testNew_automation", + "name": "testNew_automation", + "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", + "typeId": 3 + }, + "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" +} diff --git a/test/resources/9999999/automation/create-expected.json b/test/resources/9999999/automation/create-expected.json new file mode 100644 index 000000000..2a1caee12 --- /dev/null +++ b/test/resources/9999999/automation/create-expected.json @@ -0,0 +1,46 @@ +{ + "description": "created on deploy", + "key": "testNew_automation", + "name": "testNew_automation", + "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", + "typeId": 3 + }, + "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" +} diff --git a/test/resources/9999999/automation/retrieve-expected.md b/test/resources/9999999/automation/retrieve-testExisting_automation-expected.md similarity index 100% rename from test/resources/9999999/automation/retrieve-expected.md rename to test/resources/9999999/automation/retrieve-testExisting_automation-expected.md diff --git a/test/resources/9999999/automation/update-expected.json b/test/resources/9999999/automation/update-expected.json new file mode 100644 index 000000000..d9f835037 --- /dev/null +++ b/test/resources/9999999/automation/update-expected.json @@ -0,0 +1,46 @@ +{ + "description": "bla bla", + "key": "testExisting_automation", + "name": "testExisting_automation", + "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", + "typeId": 3 + }, + "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" +} diff --git a/test/resources/9999999/automation/v1/automations/08afb0e2-b00a-4c88-ad2e-1f7f8788c560/patch-response.json b/test/resources/9999999/automation/v1/automations/08afb0e2-b00a-4c88-ad2e-1f7f8788c560/patch-response.json new file mode 100644 index 000000000..edd818bd1 --- /dev/null +++ b/test/resources/9999999/automation/v1/automations/08afb0e2-b00a-4c88-ad2e-1f7f8788c560/patch-response.json @@ -0,0 +1,84 @@ +{ + "name": "testExisting_automation", + "description": "updated on deploy", + "key": "testExisting_automation", + "typeId": 1, + "type": "scheduled", + "statusId": 4, + "status": "PausedSchedule", + "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": "paused", + "timezoneId": 5 + }, + "steps": [ + { + "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 + } + ], + "annotation": "", + "stepNumber": 0 + } + ], + "categoryId": 290937, + "id": "08afb0e2-b00a-4c88-ad2e-1f7f8788c560" +} diff --git a/test/resources/9999999/automation/v1/automations/a8afb0e2-b00a-4c88-ad2e-1f7f8788c560/get-response.json b/test/resources/9999999/automation/v1/automations/a8afb0e2-b00a-4c88-ad2e-1f7f8788c560/get-response.json new file mode 100644 index 000000000..b58d358fb --- /dev/null +++ b/test/resources/9999999/automation/v1/automations/a8afb0e2-b00a-4c88-ad2e-1f7f8788c560/get-response.json @@ -0,0 +1,85 @@ +{ + "id": "a8afb0e2-b00a-4c88-ad2e-1f7f8788c560", + "name": "testNew_automation", + "description": "created on deploy", + "key": "testNew_automation", + "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": "paused", + "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/post-response.json b/test/resources/9999999/automation/v1/automations/post-response.json new file mode 100644 index 000000000..9053199c9 --- /dev/null +++ b/test/resources/9999999/automation/v1/automations/post-response.json @@ -0,0 +1,84 @@ +{ + "name": "testNew_automation", + "description": "created on deploy", + "key": "testNew_automation", + "typeId": 1, + "type": "scheduled", + "statusId": 4, + "status": "PausedSchedule", + "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": "paused", + "timezoneId": 5 + }, + "steps": [ + { + "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 + } + ], + "annotation": "", + "stepNumber": 0 + } + ], + "categoryId": 290937, + "id": "a8afb0e2-b00a-4c88-ad2e-1f7f8788c560" +} diff --git a/test/resources/9999999/program/retrieve-response.xml b/test/resources/9999999/program/retrieve-response.xml index 16ba379bd..67ede7785 100644 --- a/test/resources/9999999/program/retrieve-response.xml +++ b/test/resources/9999999/program/retrieve-response.xml @@ -24,6 +24,8 @@ 08afb0e2-b00a-4c88-ad2e-1f7f8788c560 + testExisting_automation + testExisting_automation diff --git a/test/type.automation.test.js b/test/type.automation.test.js index 1fd54617b..422f6c3bf 100644 --- a/test/type.automation.test.js +++ b/test/type.automation.test.js @@ -38,7 +38,14 @@ describe('type: automation', () => { ); // check if MD file was created and equals expectations expect(file(testUtils.getActualDoc('testExisting_automation', 'automation'))).to.equal( - file(testUtils.getExpectedFile('9999999', 'automation', 'retrieve', 'md')) + file( + testUtils.getExpectedFile( + '9999999', + 'automation', + 'retrieve-testExisting_automation', + 'md' + ) + ) ); assert.equal( @@ -53,38 +60,38 @@ describe('type: automation', () => { beforeEach(() => { testUtils.mockSetup(true); }); - it('Should create & update a automation'); // , async () => { - // // WHEN - // await handler.deploy('testInstance/testBU', ['automation']); - // // THEN - // assert.equal(process.exitCode, false, 'deploy should not have thrown an error'); + it('Should create & update a automation', async () => { + // WHEN + await handler.deploy('testInstance/testBU', ['automation']); + // THEN + assert.equal(process.exitCode, false, 'deploy should not have thrown an error'); - // // get results from cache - // const result = cache.getCache(); - // assert.equal( - // result.automation ? Object.keys(result.automation).length : 0, - // 2, - // 'two automations expected' - // ); - // // insert - // assert.deepEqual( - // await testUtils.getActualJson('testNew_automation', 'automation'), - // await testUtils.getExpectedJson('9999999', 'automation', 'create'), - // 'returned metadata was not equal expected for create' - // ); - // // update - // assert.deepEqual( - // await testUtils.getActualJson('testExisting_automation', 'automation'), - // await testUtils.getExpectedJson('9999999', 'automation', 'update'), - // 'returned metadata was not equal expected for update' - // ); - // assert.equal( - // testUtils.getAPIHistoryLength(), - // 11, - // 'Unexpected number of requests made. Run testUtils.logAPIHistoryDebug() to see the requests' - // ); - // return; - // }); + // get results from cache + const result = cache.getCache(); + assert.equal( + result.automation ? Object.keys(result.automation).length : 0, + 2, + 'two automations expected' + ); + // insert + assert.deepEqual( + await testUtils.getActualJson('testNew_automation', 'automation'), + await testUtils.getExpectedJson('9999999', 'automation', 'create'), + 'returned metadata was not equal expected for create' + ); + // update + assert.deepEqual( + await testUtils.getActualJson('testExisting_automation', 'automation'), + await testUtils.getExpectedJson('9999999', 'automation', 'update'), + '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 change the key during update via --changeKeyValue'); }); describe('Templating ================', () => {