Skip to content

Commit

Permalink
#1943: refresh test cases for refresh updating journey and transactio…
Browse files Browse the repository at this point in the history
…nalEmail
  • Loading branch information
JoernBerkefeld committed Jan 13, 2025
1 parent 50d007b commit 2dacb7f
Showing 1 changed file with 37 additions and 57 deletions.
94 changes: 37 additions & 57 deletions test/type.journey.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -218,109 +218,77 @@ describe('type: journey', () => {
return;
});

it('Should deploy --publish a transactional journey', async () => {
it('Should not deploy --publish an already published transactional journey', async () => {
// WHEN
handler.setOptions({ skipStatusCheck: true, publish: true });
const deploy = await handler.deploy(
'testInstance/testBU',
['journey'],
['testExisting_temail_notPublished']
['testExisting_temail']
);

// THEN
assert.equal(process.exitCode, 0, 'deploy --publish should not have thrown an error');
assert.equal(process.exitCode, 1, 'deploy --publish should have thrown an error');
// retrieve result
assert.deepEqual(
Object.keys(deploy['testInstance/testBU']?.journey),
['testExisting_temail_notPublished'],
[],
'should have published the right journey'
);

// get callouts
const publishCallout = testUtils.getRestCallout(
'post',
'/interaction/v1/interactions/transactional/create'
);
// confirm callouts
assert.deepEqual(
publishCallout,
{
definitionId: 'd4a900fe-3a8f-4cc5-9a49-81286e3e2cd2',
},
'publish-payload JSON was not equal expected'
);

// confirm transactionalEmail was downloaded
assert.deepEqual(
await testUtils.getActualJson(
'testExisting_temail_notPublished',
'transactionalEmail'
),
await testUtils.getExpectedJson('9999999', 'transactionalEmail', 'get-published'),
'returned JSON was not equal expected'
);

assert.equal(
testUtils.getAPIHistoryLength(),
57,
22,
'Unexpected number of requests made. Run testUtils.logAPIHistoryDebug() to see the requests'
);
return;
});

it('Should deploy --publish an already published transactional journey and refresh it', async () => {
it('Should deploy --publish a transactional journey', async () => {
// WHEN
handler.setOptions({ skipStatusCheck: true, publish: true });
const deploy = await handler.deploy(
'testInstance/testBU',
['journey'],
['testExisting_temail']
['testExisting_temail_notPublished']
);

// THEN
assert.equal(process.exitCode, 0, 'deploy --publish should not have thrown an error');
// retrieve result
assert.deepEqual(
Object.keys(deploy['testInstance/testBU']?.journey),
['testExisting_temail'],
['testExisting_temail_notPublished'],
'should have published the right journey'
);

// get callouts
const pauseCallout = testUtils.getRestCallout(
'post',
'/interaction/v1/interactions/transactional/pause'
);
const resumeCallout = testUtils.getRestCallout(
const publishCallout = testUtils.getRestCallout(
'post',
'/interaction/v1/interactions/transactional/pause'
'/interaction/v1/interactions/transactional/create'
);
// confirm callouts
assert.deepEqual(
pauseCallout,
{
definitionId: 'dsfdsafdsa-922c-4568-85a5-e5cc77efc3be',
},
'pause-payload JSON was not equal expected'
);
assert.deepEqual(
resumeCallout,
publishCallout,
{
definitionId: 'dsfdsafdsa-922c-4568-85a5-e5cc77efc3be',
definitionId: 'd4a900fe-3a8f-4cc5-9a49-81286e3e2cd2',
},
'resume-payload JSON was not equal expected'
'publish-payload JSON was not equal expected'
);

// confirm transactionalEmail was downloaded
// assert.deepEqual(
// await testUtils.getActualJson('testExisting_temail', 'transactionalEmail'),
// await testUtils.getExpectedJson('9999999', 'transactionalEmail', 'get'),
// 'returned JSON was not equal expected'
// );
assert.deepEqual(
await testUtils.getActualJson(
'testExisting_temail_notPublished',
'transactionalEmail'
),
await testUtils.getExpectedJson('9999999', 'transactionalEmail', 'get-published'),
'returned JSON was not equal expected'
);

assert.equal(
testUtils.getAPIHistoryLength(),
26,
57,
'Unexpected number of requests made. Run testUtils.logAPIHistoryDebug() to see the requests'
);
return;
Expand Down Expand Up @@ -719,9 +687,21 @@ describe('type: journey', () => {
'resume-payload JSON was not equal expected'
);

// confirm transactionalEmail was downloaded
assert.deepEqual(
await testUtils.getActualJson('testExisting_temail', 'journey'),
await testUtils.getExpectedJson('9999999', 'journey', 'get-transactionalEmail'),
'returned JSON was not equal expected'
);
assert.deepEqual(
await testUtils.getActualJson('testExisting_temail', 'transactionalEmail'),
await testUtils.getExpectedJson('9999999', 'transactionalEmail', 'get'),
'returned JSON was not equal expected'
);

assert.equal(
testUtils.getAPIHistoryLength(),
4,
37,
'Unexpected number of requests made. Run testUtils.logAPIHistoryDebug() to see the requests'
);
return;
Expand Down Expand Up @@ -1200,7 +1180,7 @@ describe('type: journey', () => {

assert.equal(
testUtils.getAPIHistoryLength(),
3,
36,
'Unexpected number of requests made. Run testUtils.logAPIHistoryDebug() to see the requests'
);
return;
Expand All @@ -1223,7 +1203,7 @@ describe('type: journey', () => {

assert.equal(
testUtils.getAPIHistoryLength(),
8,
41,
'Unexpected number of requests made. Run testUtils.logAPIHistoryDebug() to see the requests'
);
return;
Expand Down

0 comments on commit 2dacb7f

Please sign in to comment.