From 229e1db5c494fe318e1890877074152c82d7751f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rn=20Berkefeld?= Date: Fri, 7 Jun 2024 07:53:40 +0200 Subject: [PATCH] #1270: add test for multi-type rcb run --- test/general.test.js | 140 ++++++++++++++++++++++++++++++++ test/type.journey.test.js | 2 - test/type.senderProfile.test.js | 2 - test/type.triggeredSend.test.js | 2 - 4 files changed, 140 insertions(+), 6 deletions(-) diff --git a/test/general.test.js b/test/general.test.js index 3569b8b45..cb1c42a66 100644 --- a/test/general.test.js +++ b/test/general.test.js @@ -16,6 +16,146 @@ describe('GENERAL', () => { testUtils.mockReset(); }); + describe('ReplaceContentBlockByX ================', () => { + it('Should replace references with ContentBlockByName w/o deploy', async () => { + handler.setOptions({ skipDeploy: true }); + + // WHEN + const replace = await handler.replaceCbReference( + 'testInstance/testBU', + { + journey: null, + senderProfile: null, + }, + 'name' + ); + // THEN + assert.equal(process.exitCode, 0, 'retrieve should not have thrown an error'); + // retrieve result + assert.deepEqual( + replace['testInstance/testBU'].journey, + ['testExisting_journey_Quicksend'], + 'should have found the right journeys that need updating' + ); + assert.deepEqual( + replace['testInstance/testBU'].senderProfile, + ['testExisting_senderProfile_rcb'], + 'should have found the right senderProfiles that need updating' + ); + + // check if conversions happened + assert.deepEqual( + await testUtils.getActualJson('testExisting_journey_Quicksend', 'journey'), + await testUtils.getExpectedJson('9999999', 'journey', 'get-quicksend-rcb-name'), + 'returned JSON was not equal expected' + ); + assert.deepEqual( + await testUtils.getActualJson('testExisting_senderProfile_rcb', 'senderProfile'), + await testUtils.getExpectedJson('9999999', 'senderProfile', 'get-rcb-name'), + 'returned JSON was not equal expected' + ); + + assert.equal( + testUtils.getAPIHistoryLength(), + 51, + 'Unexpected number of requests made. Run testUtils.logAPIHistoryDebug() to see the requests' + ); + return; + }); + + it('Should replace references with ContentBlockById w/o deploy', async () => { + handler.setOptions({ skipDeploy: true }); + + // WHEN + const replace = await handler.replaceCbReference( + 'testInstance/testBU', + { + journey: null, + senderProfile: null, + }, + 'id' + ); + // THEN + assert.equal(process.exitCode, 0, 'retrieve should not have thrown an error'); + // retrieve result + assert.deepEqual( + replace['testInstance/testBU'].journey, + ['testExisting_journey_Quicksend'], + 'should have found the right journeys that need updating' + ); + assert.deepEqual( + replace['testInstance/testBU'].senderProfile, + ['testExisting_senderProfile_rcb'], + 'should have found the right senderProfiles that need updating' + ); + + // check if conversions happened + assert.deepEqual( + await testUtils.getActualJson('testExisting_journey_Quicksend', 'journey'), + await testUtils.getExpectedJson('9999999', 'journey', 'get-quicksend-rcb-id'), + 'returned JSON was not equal expected' + ); + assert.deepEqual( + await testUtils.getActualJson('testExisting_senderProfile_rcb', 'senderProfile'), + await testUtils.getExpectedJson('9999999', 'senderProfile', 'get-rcb-id'), + 'returned JSON was not equal expected' + ); + + assert.equal( + testUtils.getAPIHistoryLength(), + 51, + 'Unexpected number of requests made. Run testUtils.logAPIHistoryDebug() to see the requests' + ); + return; + }); + + it('Should replace references with ContentBlockByKey w/o deploy', async () => { + handler.setOptions({ skipDeploy: true }); + + // WHEN + const replace = await handler.replaceCbReference( + 'testInstance/testBU', + { + journey: null, + senderProfile: null, + }, + 'key' + ); + // THEN + assert.equal(process.exitCode, 0, 'retrieve should not have thrown an error'); + // retrieve result + assert.deepEqual( + replace['testInstance/testBU'].journey, + ['testExisting_journey_Quicksend'], + 'should have found the right assets that need updating' + ); + assert.deepEqual( + replace['testInstance/testBU'].senderProfile, + ['testExisting_senderProfile_rcb'], + 'should have found the right senderProfiles that need updating' + ); + + // check if conversions happened + assert.deepEqual( + await testUtils.getActualJson('testExisting_journey_Quicksend', 'journey'), + await testUtils.getExpectedJson('9999999', 'journey', 'get-quicksend-rcb-key'), + 'returned JSON was not equal expected' + ); + assert.deepEqual( + await testUtils.getActualJson('testExisting_senderProfile_rcb', 'senderProfile'), + await testUtils.getExpectedJson('9999999', 'senderProfile', 'get-rcb-key'), + 'returned JSON was not equal expected' + ); + + assert.equal( + testUtils.getAPIHistoryLength(), + 51, + 'Unexpected number of requests made. Run testUtils.logAPIHistoryDebug() to see the requests' + ); + return; + }); + }); + describe('with --metadata ================', () => { describe('retrieve --metadata ~~~', () => { it('retrieve single type without keys', async () => { diff --git a/test/type.journey.test.js b/test/type.journey.test.js index 89ccecbff..ef459b0bd 100644 --- a/test/type.journey.test.js +++ b/test/type.journey.test.js @@ -301,7 +301,6 @@ describe('type: journey', () => { 'should have found the right journeys that need updating' ); - // check if conversions happened // check if conversions happened assert.deepEqual( await testUtils.getActualJson('testExisting_journey_Quicksend', 'journey'), @@ -337,7 +336,6 @@ describe('type: journey', () => { 'should have found the right journeys that need updating' ); - // check if conversions happened // check if conversions happened assert.deepEqual( await testUtils.getActualJson('testExisting_journey_Quicksend', 'journey'), diff --git a/test/type.senderProfile.test.js b/test/type.senderProfile.test.js index 4c32e1777..cdb01a7ee 100644 --- a/test/type.senderProfile.test.js +++ b/test/type.senderProfile.test.js @@ -166,7 +166,6 @@ describe('type: senderProfile', () => { 'should have found the right senderProfiles that need updating' ); - // check if conversions happened // check if conversions happened assert.deepEqual( await testUtils.getActualJson('testExisting_senderProfile_rcb', 'senderProfile'), @@ -202,7 +201,6 @@ describe('type: senderProfile', () => { 'should have found the right senderProfiles that need updating' ); - // check if conversions happened // check if conversions happened assert.deepEqual( await testUtils.getActualJson('testExisting_senderProfile_rcb', 'senderProfile'), diff --git a/test/type.triggeredSend.test.js b/test/type.triggeredSend.test.js index 543bf2672..d93beec54 100644 --- a/test/type.triggeredSend.test.js +++ b/test/type.triggeredSend.test.js @@ -178,7 +178,6 @@ describe('type: triggeredSend', () => { 'should have found the right triggeredSends that need updating' ); - // check if conversions happened // check if conversions happened assert.deepEqual( await testUtils.getActualJson('testExisting_triggeredSend_rcb', 'triggeredSend'), @@ -214,7 +213,6 @@ describe('type: triggeredSend', () => { 'should have found the right triggeredSends that need updating' ); - // check if conversions happened // check if conversions happened assert.deepEqual( await testUtils.getActualJson('testExisting_triggeredSend_rcb', 'triggeredSend'),