Skip to content

Commit

Permalink
Revert "#889: fix mobileKeyword test cases after switching keyField t…
Browse files Browse the repository at this point in the history
…o "id""

This reverts commit a5d2337.

# Conflicts:
#	lib/metadataTypes/definitions/MobileKeyword.definition.js
  • Loading branch information
JoernBerkefeld committed May 26, 2023
1 parent 89959fb commit 8d35cb6
Show file tree
Hide file tree
Showing 7 changed files with 50 additions and 52 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
"code": {
"code": "4912312345678"
},
"id": "testNew_keyword",
"keyword": "testNew_keyword",
"status": "Active",
"restriction": "NONE",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
"code": {
"code": "4912312345678"
},
"id": "testNew_keyword_blocked",
"keyword": "testNew_keyword_blocked",
"status": "Active",
"restriction": "NONE",
Expand Down
1 change: 0 additions & 1 deletion test/resources/9999999/mobileKeyword/build-expected.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
{
"id": "cTVJaG5oSDJPVUNHcUh6Z3pQT2tVdzo4Njow",
"code": {
"code": "4912312345678"
},
Expand Down
1 change: 0 additions & 1 deletion test/resources/9999999/mobileKeyword/get-expected.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
{
"id": "cTVJaG5oSDJPVUNHcUh6Z3pQT2tVdzo4Njow",
"createdDate": "2018-03-27T12:37:18.12Z",
"lastUpdated": "2018-03-27T12:37:18.167Z",
"code": {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
{
"id": "NXV4ZFMwTEFwRVczd3RaLUF5X3p5dzo4Njow",
"code": {
"code": "4912312345678"
},
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
{
"id": "cTVJaG5oSDJPVUNHcUh6Z3pQT2tVdzo4Njow",
"code": {
"code": "4912312345678"
},
Expand Down
96 changes: 50 additions & 46 deletions test/type.mobileKeyword.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
Expand All @@ -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
Expand All @@ -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'))
);
Expand Down Expand Up @@ -126,14 +108,52 @@ 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']);
// buildTemplate
const result = await handler.buildTemplate(
'testInstance/testBU',
'mobileKeyword',
['cTVJaG5oSDJPVUNHcUh6Z3pQT2tVdzo4Njow'],
['testExisting_keyword'],
'testSourceMarket'
);
assert.equal(process.exitCode, false, 'buildTemplate should not have thrown an error');
Expand All @@ -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'))
Expand All @@ -167,7 +180,7 @@ describe('type: mobileKeyword', () => {
await handler.buildDefinition(
'testInstance/testBU',
'mobileKeyword',
'cTVJaG5oSDJPVUNHcUh6Z3pQT2tVdzo4Njow',
'testExisting_keyword',
'testTargetMarket'
);
assert.equal(
Expand All @@ -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(
Expand All @@ -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');
Expand Down

0 comments on commit 8d35cb6

Please sign in to comment.