From 8d35cb69cbae0f1bb49b568421cfbf2dad325308 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rn=20Berkefeld?= Date: Fri, 26 May 2023 14:07:32 +0200 Subject: [PATCH] Revert "#889: fix mobileKeyword test cases after switching keyField to "id"" This reverts commit a5d2337b6957e23bea012a85029680896bf2a0ce. # Conflicts: # lib/metadataTypes/definitions/MobileKeyword.definition.js --- .../testNew_keyword.mobileKeyword-meta.json | 1 - ...ew_keyword_blocked.mobileKeyword-meta.json | 1 - .../9999999/mobileKeyword/build-expected.json | 1 - .../9999999/mobileKeyword/get-expected.json | 1 - .../mobileKeyword/post-create-expected.json | 1 - .../mobileKeyword/template-expected.json | 1 - test/type.mobileKeyword.test.js | 96 ++++++++++--------- 7 files changed, 50 insertions(+), 52 deletions(-) diff --git a/test/mockRoot/deploy/testInstance/testBU/mobileKeyword/testNew_keyword.mobileKeyword-meta.json b/test/mockRoot/deploy/testInstance/testBU/mobileKeyword/testNew_keyword.mobileKeyword-meta.json index 0daf6b944..0e3525320 100644 --- a/test/mockRoot/deploy/testInstance/testBU/mobileKeyword/testNew_keyword.mobileKeyword-meta.json +++ b/test/mockRoot/deploy/testInstance/testBU/mobileKeyword/testNew_keyword.mobileKeyword-meta.json @@ -2,7 +2,6 @@ "code": { "code": "4912312345678" }, - "id": "testNew_keyword", "keyword": "testNew_keyword", "status": "Active", "restriction": "NONE", diff --git a/test/mockRoot/deploy/testInstance/testBU/mobileKeyword/testNew_keyword_blocked.mobileKeyword-meta.json b/test/mockRoot/deploy/testInstance/testBU/mobileKeyword/testNew_keyword_blocked.mobileKeyword-meta.json index 982b8d2d2..ba94f5392 100644 --- a/test/mockRoot/deploy/testInstance/testBU/mobileKeyword/testNew_keyword_blocked.mobileKeyword-meta.json +++ b/test/mockRoot/deploy/testInstance/testBU/mobileKeyword/testNew_keyword_blocked.mobileKeyword-meta.json @@ -2,7 +2,6 @@ "code": { "code": "4912312345678" }, - "id": "testNew_keyword_blocked", "keyword": "testNew_keyword_blocked", "status": "Active", "restriction": "NONE", diff --git a/test/resources/9999999/mobileKeyword/build-expected.json b/test/resources/9999999/mobileKeyword/build-expected.json index bfef5a1f9..75331b6b2 100644 --- a/test/resources/9999999/mobileKeyword/build-expected.json +++ b/test/resources/9999999/mobileKeyword/build-expected.json @@ -1,5 +1,4 @@ { - "id": "cTVJaG5oSDJPVUNHcUh6Z3pQT2tVdzo4Njow", "code": { "code": "4912312345678" }, diff --git a/test/resources/9999999/mobileKeyword/get-expected.json b/test/resources/9999999/mobileKeyword/get-expected.json index b4e0bfe33..398d759cf 100644 --- a/test/resources/9999999/mobileKeyword/get-expected.json +++ b/test/resources/9999999/mobileKeyword/get-expected.json @@ -1,5 +1,4 @@ { - "id": "cTVJaG5oSDJPVUNHcUh6Z3pQT2tVdzo4Njow", "createdDate": "2018-03-27T12:37:18.12Z", "lastUpdated": "2018-03-27T12:37:18.167Z", "code": { diff --git a/test/resources/9999999/mobileKeyword/post-create-expected.json b/test/resources/9999999/mobileKeyword/post-create-expected.json index c33ef6c2a..0c3f1b7d4 100644 --- a/test/resources/9999999/mobileKeyword/post-create-expected.json +++ b/test/resources/9999999/mobileKeyword/post-create-expected.json @@ -1,5 +1,4 @@ { - "id": "NXV4ZFMwTEFwRVczd3RaLUF5X3p5dzo4Njow", "code": { "code": "4912312345678" }, diff --git a/test/resources/9999999/mobileKeyword/template-expected.json b/test/resources/9999999/mobileKeyword/template-expected.json index 8a07c052e..a79e3f458 100644 --- a/test/resources/9999999/mobileKeyword/template-expected.json +++ b/test/resources/9999999/mobileKeyword/template-expected.json @@ -1,5 +1,4 @@ { - "id": "cTVJaG5oSDJPVUNHcUh6Z3pQT2tVdzo4Njow", "code": { "code": "4912312345678" }, diff --git a/test/type.mobileKeyword.test.js b/test/type.mobileKeyword.test.js index 52ef4cefe..bac8e0ee1 100644 --- a/test/type.mobileKeyword.test.js +++ b/test/type.mobileKeyword.test.js @@ -30,21 +30,12 @@ describe('type: mobileKeyword', () => { 'only 1 mobileKeywords expected' ); assert.deepEqual( - await testUtils.getActualJson( - 'cTVJaG5oSDJPVUNHcUh6Z3pQT2tVdzo4Njow', - 'mobileKeyword' - ), + await testUtils.getActualJson('testExisting_keyword', 'mobileKeyword'), await testUtils.getExpectedJson('9999999', 'mobileKeyword', 'get'), 'saved JSON was not equal expected' ); expect( - file( - testUtils.getActualFile( - 'cTVJaG5oSDJPVUNHcUh6Z3pQT2tVdzo4Njow', - 'mobileKeyword', - 'amp' - ) - ) + file(testUtils.getActualFile('testExisting_keyword', 'mobileKeyword', 'amp')) ).to.equal(file(testUtils.getExpectedFile('9999999', 'mobileKeyword', 'get', 'amp'))); assert.equal( testUtils.getAPIHistoryLength(), @@ -60,7 +51,7 @@ describe('type: mobileKeyword', () => { }); it('Should create (but not update) a mobileKeyword', async () => { // WHEN - await handler.deploy('testInstance/testBU', ['mobileKeyword'], ['testNew_keyword']); // the key is not actually send to the server because key==id and the id is auto-generated + await handler.deploy('testInstance/testBU', ['mobileKeyword'], ['testNew_keyword']); // THEN assert.equal(process.exitCode, false, 'deploy should not have thrown an error'); // get results from cache @@ -72,21 +63,12 @@ describe('type: mobileKeyword', () => { ); // confirm created item assert.deepEqual( - await testUtils.getActualJson( - 'NXV4ZFMwTEFwRVczd3RaLUF5X3p5dzo4Njow', - 'mobileKeyword' - ), + await testUtils.getActualJson('testNew_keyword', 'mobileKeyword'), await testUtils.getExpectedJson('9999999', 'mobileKeyword', 'post-create'), 'returned JSON was not equal expected for insert mobileKeyword' ); expect( - file( - testUtils.getActualFile( - 'NXV4ZFMwTEFwRVczd3RaLUF5X3p5dzo4Njow', - 'mobileKeyword', - 'amp' - ) - ) + file(testUtils.getActualFile('testNew_keyword', 'mobileKeyword', 'amp')) ).to.equal( file(testUtils.getExpectedFile('9999999', 'mobileKeyword', 'post-create', 'amp')) ); @@ -126,6 +108,44 @@ describe('type: mobileKeyword', () => { it('Should change the key during update via --changeKeyValue'); }); describe('Templating ================', () => { + it('Should create a mobileKeyword template via retrieveAsTemplate and build it', async () => { + // GIVEN there is a template + const result = await handler.retrieveAsTemplate( + 'testInstance/testBU', + 'mobileKeyword', + ['testExisting_keyword'], + 'testSourceMarket' + ); + // WHEN + assert.equal( + process.exitCode, + false, + 'retrieveAsTemplate should not have thrown an error' + ); + assert.equal( + result.mobileKeyword ? Object.keys(result.mobileKeyword).length : 0, + 1, + 'only one item expected' + ); + assert.deepEqual( + await testUtils.getActualTemplateJson('testExisting_keyword', 'mobileKeyword'), + await testUtils.getExpectedJson('9999999', 'mobileKeyword', 'template'), + 'returned template JSON was not equal expected' + ); + expect( + file( + testUtils.getActualTemplateFile('testExisting_keyword', 'mobileKeyword', 'amp') + ) + ).to.equal( + file(testUtils.getExpectedFile('9999999', 'mobileKeyword', 'template', 'amp')) + ); + assert.equal( + testUtils.getAPIHistoryLength(), + 2, + 'Unexpected number of requests made. Run testUtils.logAPIHistoryDebug() to see the requests' + ); + return; + }); it('Should create a mobileKeyword template via buildTemplate and build it', async () => { // download first before we test buildTemplate await handler.retrieve('testInstance/testBU', ['mobileKeyword']); @@ -133,7 +153,7 @@ describe('type: mobileKeyword', () => { const result = await handler.buildTemplate( 'testInstance/testBU', 'mobileKeyword', - ['cTVJaG5oSDJPVUNHcUh6Z3pQT2tVdzo4Njow'], + ['testExisting_keyword'], 'testSourceMarket' ); assert.equal(process.exitCode, false, 'buildTemplate should not have thrown an error'); @@ -144,20 +164,13 @@ describe('type: mobileKeyword', () => { 'only one mobileKeyword expected' ); assert.deepEqual( - await testUtils.getActualTemplateJson( - 'cTVJaG5oSDJPVUNHcUh6Z3pQT2tVdzo4Njow', - 'mobileKeyword' - ), + await testUtils.getActualTemplateJson('testExisting_keyword', 'mobileKeyword'), await testUtils.getExpectedJson('9999999', 'mobileKeyword', 'template'), 'returned template JSON was not equal expected' ); expect( file( - testUtils.getActualTemplateFile( - 'cTVJaG5oSDJPVUNHcUh6Z3pQT2tVdzo4Njow', - 'mobileKeyword', - 'amp' - ) + testUtils.getActualTemplateFile('testExisting_keyword', 'mobileKeyword', 'amp') ) ).to.equal( file(testUtils.getExpectedFile('9999999', 'mobileKeyword', 'template', 'amp')) @@ -167,7 +180,7 @@ describe('type: mobileKeyword', () => { await handler.buildDefinition( 'testInstance/testBU', 'mobileKeyword', - 'cTVJaG5oSDJPVUNHcUh6Z3pQT2tVdzo4Njow', + 'testExisting_keyword', 'testTargetMarket' ); assert.equal( @@ -176,21 +189,12 @@ describe('type: mobileKeyword', () => { 'buildDefinition should not have thrown an error' ); assert.deepEqual( - await testUtils.getActualDeployJson( - 'cTVJaG5oSDJPVUNHcUh6Z3pQT2tVdzo4Njow', - 'mobileKeyword' - ), + await testUtils.getActualDeployJson('testTemplated_keyword', 'mobileKeyword'), await testUtils.getExpectedJson('9999999', 'mobileKeyword', 'build'), 'returned deployment JSON was not equal expected' ); expect( - file( - testUtils.getActualDeployFile( - 'cTVJaG5oSDJPVUNHcUh6Z3pQT2tVdzo4Njow', - 'mobileKeyword', - 'amp' - ) - ) + file(testUtils.getActualDeployFile('testTemplated_keyword', 'mobileKeyword', 'amp')) ).to.equal(file(testUtils.getExpectedFile('9999999', 'mobileKeyword', 'build', 'amp'))); assert.equal( @@ -205,7 +209,7 @@ describe('type: mobileKeyword', () => { it('Should delete the item', async () => { // WHEN const result = await handler.deleteByKey('testInstance/testBU', 'mobileKeyword', [ - 'cTVJaG5oSDJPVUNHcUh6Z3pQT2tVdzo4Njow', + 'testExisting_keyword', ]); // THEN assert.equal(process.exitCode, false, 'delete should not have thrown an error');