From 4f35004b51ecbd01925a72c78811890cba4cb476 Mon Sep 17 00:00:00 2001 From: Yuliia Likhytska Date: Thu, 7 Sep 2023 22:23:40 +0200 Subject: [PATCH] #1084: positive tests for updatenotifications verifications --- ...eNotificationsEmail.verification-meta.json | 11 +++ .../9999999/automation/build-expected.json | 8 +++ .../9999999/automation/retrieve-expected.json | 8 +++ ...trieve-testExisting_automation-expected.md | 2 + .../9999999/automation/template-expected.json | 8 +++ .../get-response.json | 14 ++++ .../get-response.json | 2 +- .../patch-response.json | 12 ++++ .../get-response.json | 12 ++++ .../patch-response.json | 12 ++++ .../updateNotificationsEmail-expected.json | 2 +- .../updateNotificationsNote-expected.json} | 6 +- test/type.automation.test.js | 56 +++++++-------- test/type.query.test.js | 4 +- test/type.verification.test.js | 72 +++++++++++++++---- 15 files changed, 180 insertions(+), 49 deletions(-) create mode 100644 test/mockRoot/deploy/testInstance/testBU/verification/testExisting_verification_updateNotificationsEmail.verification-meta.json create mode 100644 test/resources/9999999/automation/v1/dataverifications/testExisting_verification_updateNotificationsEmail/patch-response.json create mode 100644 test/resources/9999999/automation/v1/dataverifications/testExisting_verification_updateNotificationsNote/get-response.json create mode 100644 test/resources/9999999/automation/v1/dataverifications/testExisting_verification_updateNotificationsNote/patch-response.json rename test/{mockRoot/deploy/testInstance/testBU/verification/testExisting_verification._updateNotificationsEmail.verification-meta.json => resources/9999999/verification/updateNotificationsNote-expected.json} (65%) diff --git a/test/mockRoot/deploy/testInstance/testBU/verification/testExisting_verification_updateNotificationsEmail.verification-meta.json b/test/mockRoot/deploy/testInstance/testBU/verification/testExisting_verification_updateNotificationsEmail.verification-meta.json new file mode 100644 index 000000000..929f3bc41 --- /dev/null +++ b/test/mockRoot/deploy/testInstance/testBU/verification/testExisting_verification_updateNotificationsEmail.verification-meta.json @@ -0,0 +1,11 @@ +{ + "dataVerificationDefinitionId": "testExisting_verification_updateNotificationsEmail", + "notificationEmailAddress": "", + "notificationEmailMessage": "", + "r__dataExtension_CustomerKey": "testExisting_dataExtension", + "shouldEmailOnFailure": true, + "shouldStopOnFailure": true, + "value1": 1, + "value2": 0, + "verificationType": "IsEqualTo" +} diff --git a/test/resources/9999999/automation/build-expected.json b/test/resources/9999999/automation/build-expected.json index d0e111d1e..d46d8e646 100644 --- a/test/resources/9999999/automation/build-expected.json +++ b/test/resources/9999999/automation/build-expected.json @@ -40,6 +40,14 @@ { "name": "testTemplated_39f6a488-20eb-4ba0-b0b9", "r__type": "verification" + }, + { + "name": "testTemplated_verification_updateNotificationsNote", + "r__type": "verification" + }, + { + "name": "testTemplated_verification_updateNotificationsEmail", + "r__type": "verification" } ], "name": "" diff --git a/test/resources/9999999/automation/retrieve-expected.json b/test/resources/9999999/automation/retrieve-expected.json index a598c8aff..361f9661a 100644 --- a/test/resources/9999999/automation/retrieve-expected.json +++ b/test/resources/9999999/automation/retrieve-expected.json @@ -40,6 +40,14 @@ { "name": "testExisting_39f6a488-20eb-4ba0-b0b9", "r__type": "verification" + }, + { + "name": "testExisting_verification_updateNotificationsNote", + "r__type": "verification" + }, + { + "name": "testExisting_verification_updateNotificationsEmail", + "r__type": "verification" } ], "name": "" diff --git a/test/resources/9999999/automation/retrieve-testExisting_automation-expected.md b/test/resources/9999999/automation/retrieve-testExisting_automation-expected.md index 161e31040..d34228f92 100644 --- a/test/resources/9999999/automation/retrieve-testExisting_automation-expected.md +++ b/test/resources/9999999/automation/retrieve-testExisting_automation-expected.md @@ -29,3 +29,5 @@ | _1.5: query_
testExisting_query | | _1.6: script_
testExisting_script | | _1.7: verification_
testExisting_39f6a488-20eb-4ba0-b0b9 | +| _1.8: verification_
testExisting_verification_updateNotificationsNote | +| _1.9: verification_
testExisting_verification_updateNotificationsEmail | diff --git a/test/resources/9999999/automation/template-expected.json b/test/resources/9999999/automation/template-expected.json index 9e3db99fc..6cbcaf6cf 100644 --- a/test/resources/9999999/automation/template-expected.json +++ b/test/resources/9999999/automation/template-expected.json @@ -40,6 +40,14 @@ { "name": "{{{prefix}}}39f6a488-20eb-4ba0-b0b9", "r__type": "verification" + }, + { + "name": "{{{prefix}}}verification_updateNotificationsNote", + "r__type": "verification" + }, + { + "name": "{{{prefix}}}verification_updateNotificationsEmail", + "r__type": "verification" } ], "name": "" diff --git a/test/resources/9999999/automation/v1/automations/08afb0e2-b00a-4c88-ad2e-1f7f8788c560/get-response.json b/test/resources/9999999/automation/v1/automations/08afb0e2-b00a-4c88-ad2e-1f7f8788c560/get-response.json index 3c982a924..cb6888112 100644 --- a/test/resources/9999999/automation/v1/automations/08afb0e2-b00a-4c88-ad2e-1f7f8788c560/get-response.json +++ b/test/resources/9999999/automation/v1/automations/08afb0e2-b00a-4c88-ad2e-1f7f8788c560/get-response.json @@ -85,6 +85,20 @@ "activityObjectId": "testExisting_39f6a488-20eb-4ba0-b0b9", "objectTypeId": 1000, "displayOrder": 7 + }, + { + "id": "f3774dc2-a271-4a44-8cbe-f630a6d6545e", + "name": "testExisting_dataExtension", + "activityObjectId": "testExisting_verification_updateNotificationsNote", + "objectTypeId": 1000, + "displayOrder": 8 + }, + { + "id": "f3774dc2-a271-4a44-8cbe-f630a6d6545e", + "name": "testExisting_dataExtension", + "activityObjectId": "testExisting_verification_updateNotificationsEmail", + "objectTypeId": 1000, + "displayOrder": 9 } ] } diff --git a/test/resources/9999999/automation/v1/dataverifications/testExisting_verification_updateNotificationsEmail/get-response.json b/test/resources/9999999/automation/v1/dataverifications/testExisting_verification_updateNotificationsEmail/get-response.json index 72889c32c..9029d133d 100644 --- a/test/resources/9999999/automation/v1/dataverifications/testExisting_verification_updateNotificationsEmail/get-response.json +++ b/test/resources/9999999/automation/v1/dataverifications/testExisting_verification_updateNotificationsEmail/get-response.json @@ -6,7 +6,7 @@ "value2": 0, "shouldStopOnFailure": true, "shouldEmailOnFailure": false, - "notificationEmailAddress": "test@test.com", + "notificationEmailAddress": "", "notificationEmailMessage": "", "createdBy": 700301950 } diff --git a/test/resources/9999999/automation/v1/dataverifications/testExisting_verification_updateNotificationsEmail/patch-response.json b/test/resources/9999999/automation/v1/dataverifications/testExisting_verification_updateNotificationsEmail/patch-response.json new file mode 100644 index 000000000..6d8370eff --- /dev/null +++ b/test/resources/9999999/automation/v1/dataverifications/testExisting_verification_updateNotificationsEmail/patch-response.json @@ -0,0 +1,12 @@ +{ + "dataVerificationDefinitionId": "testExisting_verification_updateNotificationsEmail", + "targetObjectId": "21711373-72c1-ec11-b83b-48df37d1deb7", + "verificationType": "IsEqualTo", + "value1": 1, + "value2": 0, + "shouldStopOnFailure": true, + "shouldEmailOnFailure": true, + "notificationEmailAddress": "test@test.com", + "notificationEmailMessage": "", + "createdBy": 700301950 +} diff --git a/test/resources/9999999/automation/v1/dataverifications/testExisting_verification_updateNotificationsNote/get-response.json b/test/resources/9999999/automation/v1/dataverifications/testExisting_verification_updateNotificationsNote/get-response.json new file mode 100644 index 000000000..e7ce8363e --- /dev/null +++ b/test/resources/9999999/automation/v1/dataverifications/testExisting_verification_updateNotificationsNote/get-response.json @@ -0,0 +1,12 @@ +{ + "dataVerificationDefinitionId": "testExisting_verification_updateNotificationsNote", + "targetObjectId": "21711373-72c1-ec11-b83b-48df37d1deb7", + "verificationType": "IsEqualTo", + "value1": 1, + "value2": 0, + "shouldStopOnFailure": true, + "shouldEmailOnFailure": false, + "notificationEmailAddress": "test@test.com", + "notificationEmailMessage": "", + "createdBy": 700301950 +} diff --git a/test/resources/9999999/automation/v1/dataverifications/testExisting_verification_updateNotificationsNote/patch-response.json b/test/resources/9999999/automation/v1/dataverifications/testExisting_verification_updateNotificationsNote/patch-response.json new file mode 100644 index 000000000..87a0707ef --- /dev/null +++ b/test/resources/9999999/automation/v1/dataverifications/testExisting_verification_updateNotificationsNote/patch-response.json @@ -0,0 +1,12 @@ +{ + "dataVerificationDefinitionId": "testExisting_verification_updateNotificationsNote", + "targetObjectId": "21711373-72c1-ec11-b83b-48df37d1deb7", + "verificationType": "IsEqualTo", + "value1": 1, + "value2": 0, + "shouldStopOnFailure": true, + "shouldEmailOnFailure": true, + "notificationEmailAddress": "test@test.com", + "notificationEmailMessage": "test", + "createdBy": 700301950 +} diff --git a/test/resources/9999999/verification/updateNotificationsEmail-expected.json b/test/resources/9999999/verification/updateNotificationsEmail-expected.json index 187c32884..b7e493f00 100644 --- a/test/resources/9999999/verification/updateNotificationsEmail-expected.json +++ b/test/resources/9999999/verification/updateNotificationsEmail-expected.json @@ -3,7 +3,7 @@ "notificationEmailAddress": "test@test.com", "notificationEmailMessage": "", "r__dataExtension_CustomerKey": "testExisting_dataExtension", - "shouldEmailOnFailure": false, + "shouldEmailOnFailure": true, "shouldStopOnFailure": true, "value1": 1, "value2": 0, diff --git a/test/mockRoot/deploy/testInstance/testBU/verification/testExisting_verification._updateNotificationsEmail.verification-meta.json b/test/resources/9999999/verification/updateNotificationsNote-expected.json similarity index 65% rename from test/mockRoot/deploy/testInstance/testBU/verification/testExisting_verification._updateNotificationsEmail.verification-meta.json rename to test/resources/9999999/verification/updateNotificationsNote-expected.json index 19814275c..bfbc84e94 100644 --- a/test/mockRoot/deploy/testInstance/testBU/verification/testExisting_verification._updateNotificationsEmail.verification-meta.json +++ b/test/resources/9999999/verification/updateNotificationsNote-expected.json @@ -1,7 +1,7 @@ -{ - "dataVerificationDefinitionId": "testExisting_verification._updateNotificationsEmail", +{ + "dataVerificationDefinitionId": "testExisting_verification_updateNotificationsNote", "notificationEmailAddress": "test@test.com", - "notificationEmailMessage": "", + "notificationEmailMessage": "test", "r__dataExtension_CustomerKey": "testExisting_dataExtension", "shouldEmailOnFailure": true, "shouldStopOnFailure": true, diff --git a/test/type.automation.test.js b/test/type.automation.test.js index bd5479b4f..1ccf9dbb9 100644 --- a/test/type.automation.test.js +++ b/test/type.automation.test.js @@ -49,7 +49,7 @@ describe('type: automation', () => { ); assert.equal( testUtils.getAPIHistoryLength(), - 48, + 50, 'Unexpected number of requests made. Run testUtils.logAPIHistoryDebug() to see the requests' ); return; @@ -122,7 +122,7 @@ describe('type: automation', () => { ); assert.equal( testUtils.getAPIHistoryLength(), - 40, + 42, 'Unexpected number of requests made. Run testUtils.logAPIHistoryDebug() to see the requests' ); return; @@ -191,7 +191,7 @@ describe('type: automation', () => { assert.equal( testUtils.getAPIHistoryLength(), - 48, + 50, 'Unexpected number of requests made. Run testUtils.logAPIHistoryDebug() to see the requests' ); return; @@ -259,7 +259,7 @@ describe('type: automation', () => { assert.equal( testUtils.getAPIHistoryLength(), - 44, + 46, 'Unexpected number of requests made. Run testUtils.logAPIHistoryDebug() to see the requests' ); return; @@ -295,7 +295,7 @@ describe('type: automation', () => { // check number of API calls assert.equal( testUtils.getAPIHistoryLength(), - 33, + 35, 'Unexpected number of requests made. Run testUtils.logAPIHistoryDebug() to see the requests' ); return; @@ -339,7 +339,7 @@ describe('type: automation', () => { // check number of API calls assert.equal( testUtils.getAPIHistoryLength(), - 70, + 74, 'Unexpected number of requests made. Run testUtils.logAPIHistoryDebug() to see the requests' ); return; @@ -383,7 +383,7 @@ describe('type: automation', () => { // check number of API calls assert.equal( testUtils.getAPIHistoryLength(), - 72, + 76, 'Unexpected number of requests made. Run testUtils.logAPIHistoryDebug() to see the requests' ); return; @@ -427,7 +427,7 @@ describe('type: automation', () => { // check number of API calls assert.equal( testUtils.getAPIHistoryLength(), - 73, + 77, 'Unexpected number of requests made. Run testUtils.logAPIHistoryDebug() to see the requests' ); return; @@ -467,7 +467,7 @@ describe('type: automation', () => { // check number of API calls assert.equal( testUtils.getAPIHistoryLength(), - 65, + 69, 'Unexpected number of requests made. Run testUtils.logAPIHistoryDebug() to see the requests' ); return; @@ -508,7 +508,7 @@ describe('type: automation', () => { // check number of API calls assert.equal( testUtils.getAPIHistoryLength(), - 71, + 75, 'Unexpected number of requests made. Run testUtils.logAPIHistoryDebug() to see the requests' ); return; @@ -549,7 +549,7 @@ describe('type: automation', () => { // check number of API calls assert.equal( testUtils.getAPIHistoryLength(), - 73, + 77, 'Unexpected number of requests made. Run testUtils.logAPIHistoryDebug() to see the requests' ); return; @@ -600,7 +600,7 @@ describe('type: automation', () => { ); assert.equal( testUtils.getAPIHistoryLength(), - 35, + 37, 'Unexpected number of requests made. Run testUtils.logAPIHistoryDebug() to see the requests' ); return; @@ -651,7 +651,7 @@ describe('type: automation', () => { ); assert.equal( testUtils.getAPIHistoryLength(), - 33, + 35, 'Unexpected number of requests made. Run testUtils.logAPIHistoryDebug() to see the requests' ); return; @@ -924,7 +924,7 @@ describe('type: automation', () => { ); assert.equal( testUtils.getAPIHistoryLength(), - 36, + 38, 'Unexpected number of requests made. Run testUtils.logAPIHistoryDebug() to see the requests' ); return; @@ -960,7 +960,7 @@ describe('type: automation', () => { ); assert.equal( testUtils.getAPIHistoryLength(), - 36, + 38, 'Unexpected number of requests made. Run testUtils.logAPIHistoryDebug() to see the requests' ); return; @@ -996,7 +996,7 @@ describe('type: automation', () => { ); assert.equal( testUtils.getAPIHistoryLength(), - 36, + 38, 'Unexpected number of requests made. Run testUtils.logAPIHistoryDebug() to see the requests' ); return; @@ -1032,7 +1032,7 @@ describe('type: automation', () => { ); assert.equal( testUtils.getAPIHistoryLength(), - 36, + 38, 'Unexpected number of requests made. Run testUtils.logAPIHistoryDebug() to see the requests' ); return; @@ -1068,7 +1068,7 @@ describe('type: automation', () => { ); assert.equal( testUtils.getAPIHistoryLength(), - 36, + 38, 'Unexpected number of requests made. Run testUtils.logAPIHistoryDebug() to see the requests' ); return; @@ -1110,7 +1110,7 @@ describe('type: automation', () => { ); assert.equal( testUtils.getAPIHistoryLength(), - 36, + 38, 'Unexpected number of requests made. Run testUtils.logAPIHistoryDebug() to see the requests' ); return; @@ -1150,7 +1150,7 @@ describe('type: automation', () => { ); assert.equal( testUtils.getAPIHistoryLength(), - 36, + 38, 'Unexpected number of requests made. Run testUtils.logAPIHistoryDebug() to see the requests' ); return; @@ -1190,7 +1190,7 @@ describe('type: automation', () => { ); assert.equal( testUtils.getAPIHistoryLength(), - 36, + 38, 'Unexpected number of requests made. Run testUtils.logAPIHistoryDebug() to see the requests' ); return; @@ -1232,7 +1232,7 @@ describe('type: automation', () => { ); assert.equal( testUtils.getAPIHistoryLength(), - 36, + 38, 'Unexpected number of requests made. Run testUtils.logAPIHistoryDebug() to see the requests' ); return; @@ -1270,7 +1270,7 @@ describe('type: automation', () => { ); assert.equal( testUtils.getAPIHistoryLength(), - 36, + 38, 'Unexpected number of requests made. Run testUtils.logAPIHistoryDebug() to see the requests' ); return; @@ -1306,7 +1306,7 @@ describe('type: automation', () => { ); assert.equal( testUtils.getAPIHistoryLength(), - 36, + 38, 'Unexpected number of requests made. Run testUtils.logAPIHistoryDebug() to see the requests' ); return; @@ -1396,7 +1396,7 @@ describe('type: automation', () => { assert.equal( testUtils.getAPIHistoryLength(), - 36, + 38, 'Unexpected number of requests made. Run testUtils.logAPIHistoryDebug() to see the requests' ); return; @@ -1432,7 +1432,7 @@ describe('type: automation', () => { ); assert.equal( testUtils.getAPIHistoryLength(), - 36, + 38, 'Unexpected number of requests made. Run testUtils.logAPIHistoryDebug() to see the requests' ); return; @@ -1468,7 +1468,7 @@ describe('type: automation', () => { ); assert.equal( testUtils.getAPIHistoryLength(), - 36, + 38, 'Unexpected number of requests made. Run testUtils.logAPIHistoryDebug() to see the requests' ); return; @@ -1500,7 +1500,7 @@ describe('type: automation', () => { ); assert.equal( testUtils.getAPIHistoryLength(), - 36, + 38, '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 31fe795c3..276e15ba1 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(), - 64, + 66, '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(), - 66, + 68, 'Unexpected number of requests made. Run testUtils.logAPIHistoryDebug() to see the requests' ); return; diff --git a/test/type.verification.test.js b/test/type.verification.test.js index 8be84b735..5b3a4537a 100644 --- a/test/type.verification.test.js +++ b/test/type.verification.test.js @@ -24,15 +24,15 @@ describe('type: verification', () => { const result = cache.getCache(); assert.equal( result.verification ? Object.keys(result.verification).length : 0, - 1, - 'only one verification expected' + 3, + 'only 3 verifications expected' ); assert.equal( retrieved['testInstance/testBU']?.verification ? Object.keys(retrieved['testInstance/testBU']?.verification).length : 0, - 1, - 'one verifications to be retrieved' + 3, + '3 verifications to be retrieved' ); assert.deepEqual( @@ -45,7 +45,7 @@ describe('type: verification', () => { ); assert.equal( testUtils.getAPIHistoryLength(), - 24, + 26, 'Unexpected number of requests made. Run testUtils.logAPIHistoryDebug() to see the requests' ); return; @@ -65,15 +65,15 @@ describe('type: verification', () => { const result = cache.getCache(); assert.equal( result.verification ? Object.keys(result.verification).length : 0, - 2, - 'two verifications expected' + 4, + '4 verifications expected' ); assert.equal( deployed['testInstance/testBU']?.verification ? Object.keys(deployed['testInstance/testBU']?.verification).length : 0, - 2, - 'two verifications to be deployed' + 3, + '3 verifications to be deployed' ); // confirm created item assert.deepEqual( @@ -93,7 +93,7 @@ describe('type: verification', () => { // check number of API calls assert.equal( testUtils.getAPIHistoryLength(), - 26, + 29, 'Unexpected number of requests made. Run testUtils.logAPIHistoryDebug() to see the requests' ); return; @@ -146,7 +146,7 @@ describe('type: verification', () => { ); assert.equal( testUtils.getAPIHistoryLength(), - 24, + 26, 'Unexpected number of requests made. Run testUtils.logAPIHistoryDebug() to see the requests' ); return; @@ -171,6 +171,9 @@ describe('type: verification', () => { }); }); describe('UpdateNotifications ================', () => { + beforeEach(() => { + testUtils.mockSetup(true); + }); it('Should update notification email', async () => { handler.setOptions({ completionEmail: 'test@test.com' }); // WHEN @@ -185,8 +188,8 @@ describe('type: verification', () => { const result = cache.getCache(); assert.equal( result.verification ? Object.keys(result.verification).length : 0, - 2, - 'only two verifications expected' + 3, + 'only one verification expected' ); assert.equal( updatedNotifications['testInstance/testBU'].length, @@ -203,11 +206,52 @@ describe('type: verification', () => { 'verification', 'updateNotificationsEmail' ), + 'returned metadata was not equal expected for update query' + ); + assert.equal( + testUtils.getAPIHistoryLength(), + 31, + 'Unexpected number of requests made. Run testUtils.logAPIHistoryDebug() to see the requests' + ); + return; + }); + it('Should update notification note', async () => { + handler.setOptions({ completionNote: 'test' }); + // WHEN + const updatedNotifications = await handler.updateNotifications( + 'testInstance/testBU', + 'verification', + ['testExisting_verification_updateNotificationsNote'] + ); + // THEN + assert.equal(process.exitCode, false, 'retrieve should not have thrown an error'); + // get results from cache + const result = cache.getCache(); + assert.equal( + result.verification ? Object.keys(result.verification).length : 0, + 3, + 'only 3 verifications expected' + ); + assert.equal( + updatedNotifications['testInstance/testBU'].length, + 1, + 'one automation key expected' + ); + assert.deepEqual( + await testUtils.getActualJson( + 'testExisting_verification_updateNotificationsNote', + 'verification' + ), + await testUtils.getExpectedJson( + '9999999', + 'verification', + 'updateNotificationsNote' + ), 'returned JSON was not equal expected' ); assert.equal( testUtils.getAPIHistoryLength(), - 29, + 31, 'Unexpected number of requests made. Run testUtils.logAPIHistoryDebug() to see the requests' ); return;