Skip to content

Commit

Permalink
#1270: add test for multi-type rcb run
Browse files Browse the repository at this point in the history
  • Loading branch information
JoernBerkefeld committed Jun 7, 2024
1 parent 448865a commit 229e1db
Show file tree
Hide file tree
Showing 4 changed files with 140 additions and 6 deletions.
140 changes: 140 additions & 0 deletions test/general.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 () => {
Expand Down
2 changes: 0 additions & 2 deletions test/type.journey.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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'),
Expand Down Expand Up @@ -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'),
Expand Down
2 changes: 0 additions & 2 deletions test/type.senderProfile.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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'),
Expand Down Expand Up @@ -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'),
Expand Down
2 changes: 0 additions & 2 deletions test/type.triggeredSend.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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'),
Expand Down Expand Up @@ -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'),
Expand Down

0 comments on commit 229e1db

Please sign in to comment.