Skip to content

Commit 6b5e982

Browse files
#2035: improved test case for deploying 2 dependent assets
1 parent 54fe301 commit 6b5e982

File tree

1 file changed

+14
-19
lines changed

1 file changed

+14
-19
lines changed

test/type.asset.test.js

Lines changed: 14 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -303,7 +303,7 @@ describe('type: asset', () => {
303303
? Object.keys(deployResult['testInstance/testBU']?.asset).length
304304
: 0,
305305
1,
306-
'1 assets to be deployed'
306+
'Unexpected number of assets deployed'
307307
);
308308
const upsertCallout = testUtils.getRestCallout('post', '/asset/v1/content/assets/');
309309
assert.equal(
@@ -344,7 +344,7 @@ describe('type: asset', () => {
344344
? Object.keys(deployResult['testInstance/testBU']?.asset).length
345345
: 0,
346346
1,
347-
'1 assets to be deployed'
347+
'Unexpected number of assets deployed'
348348
);
349349
const currentCache = cache.getCache();
350350

@@ -388,7 +388,7 @@ describe('type: asset', () => {
388388
? Object.keys(deployResult['testInstance/testBU']?.asset).length
389389
: 0,
390390
0,
391-
'0 assets to be deployed'
391+
'Unexpected number of assets deployed'
392392
);
393393

394394
const upsertCallout = testUtils.getRestCallout('patch', '/asset/v1/content/assets/%');
@@ -419,7 +419,7 @@ describe('type: asset', () => {
419419
? Object.keys(deployResult['testInstance/testBU']?.asset).length
420420
: 0,
421421
1,
422-
'1 assets to be deployed'
422+
'Unexpected number of assets deployed'
423423
);
424424

425425
const upsertCallout = testUtils.getRestCallout('post', '/asset/v1/content/assets/');
@@ -459,7 +459,7 @@ describe('type: asset', () => {
459459
? Object.keys(deployResult['testInstance/testBU']?.asset).length
460460
: 0,
461461
1,
462-
'1 assets to be deployed'
462+
'Unexpected number of assets deployed'
463463
);
464464
const upsertCallout = testUtils.getRestCallout('post', '/asset/v1/content/assets/');
465465
assert.equal(
@@ -492,7 +492,7 @@ describe('type: asset', () => {
492492
? Object.keys(deployResult['testInstance/testBU']?.asset).length
493493
: 0,
494494
1,
495-
'1 assets to be deployed'
495+
'Unexpected number of assets deployed'
496496
);
497497
const upsertCallout = testUtils.getRestCallout('post', '/asset/v1/content/assets/');
498498
assert.equal(
@@ -523,7 +523,7 @@ describe('type: asset', () => {
523523
? Object.keys(deployResult['testInstance/testBU']?.asset).length
524524
: 0,
525525
1,
526-
'1 assets to be deployed'
526+
'Unexpected number of assets deployed'
527527
);
528528
const upsertCallout = testUtils.getRestCallout('post', '/asset/v1/content/assets/');
529529
assert.equal(
@@ -554,7 +554,7 @@ describe('type: asset', () => {
554554
? Object.keys(deployResult['testInstance/testBU']?.asset).length
555555
: 0,
556556
0,
557-
'0 assets deployed'
557+
'Unexpected number of assets deployed'
558558
);
559559

560560
assert.equal(
@@ -568,7 +568,7 @@ describe('type: asset', () => {
568568
it('Should create an asset that loads a content block via CBBK that is also created in the same package', async () => {
569569
// WHEN
570570
const deployResult = await handler.deploy('testInstance/testBU', {
571-
asset: ['testNew_asset_htmlblock', 'testNew_asset_withCBBK_notexisting'],
571+
asset: ['testNew_asset_withCBBK_notexisting', 'testNew_asset_htmlblock'],
572572
});
573573
// THEN
574574
assert.equal(process.exitCode, 0, 'deploy should not have thrown an error');
@@ -582,26 +582,21 @@ describe('type: asset', () => {
582582
'unexpected assets deployed'
583583
);
584584

585+
// check if we really issued callouts for those 2 blocks AND if they were run in the right order despite the key list for deploy() getting it in the wrong order
585586
const upsertCallouts = testUtils.getRestCallout(
586587
'post',
587588
'/asset/v1/content/assets/',
588589
true
589590
);
590-
const upsertCallout1 = upsertCallouts.find(
591-
(item) => item.customerKey === 'testNew_asset_htmlblock'
592-
);
593-
const upsertCallout2 = upsertCallouts.find(
594-
(item) => item.customerKey === 'testNew_asset_withCBBK_notexisting'
595-
);
596591
assert.equal(
597-
upsertCallout1?.customerKey,
592+
upsertCallouts[0]?.customerKey,
598593
'testNew_asset_htmlblock',
599-
'create callout not found'
594+
'first create callout not for expected asset'
600595
);
601596
assert.equal(
602-
upsertCallout2?.customerKey,
597+
upsertCallouts[1]?.customerKey,
603598
'testNew_asset_withCBBK_notexisting',
604-
'create callout not found'
599+
'second create callout not for expected asset'
605600
);
606601

607602
assert.equal(

0 commit comments

Comments
 (0)