Skip to content

Commit

Permalink
#789: add DEPLOY tests for mobileMessage
Browse files Browse the repository at this point in the history
  • Loading branch information
JoernBerkefeld committed Mar 28, 2023
1 parent 1360c10 commit 45e5100
Show file tree
Hide file tree
Showing 13 changed files with 531 additions and 40 deletions.
6 changes: 3 additions & 3 deletions lib/metadataTypes/MobileMessage.js
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ class MobileMessage extends MetadataType {
return super.updateREST(
metadata,
'/legacy/v1/beta/mobile/message/' + metadata[this.definition.keyField],
'post'
'post' // upsert API, post for insert and update!
);
}

Expand Down Expand Up @@ -322,7 +322,7 @@ class MobileMessage extends MetadataType {
// extract text/code
const codeArr = [];
// keep between tags
const { fileExt, code } = this.prepExtractedCode(metadata.text, metadata.name);
const { fileExt, code } = this.prepExtractedCode(metadata.text);
delete metadata.text;
codeArr.push({
subFolder: null,
Expand Down Expand Up @@ -498,7 +498,7 @@ class MobileMessage extends MetadataType {
// get code from filesystem
let code = await this._mergeCode(metadata, templateDir, templateName);
// try to remove script tags and decide on file extension (html/ssjs)
const file = this.prepExtractedCode(code, metadata.name);
const file = this.prepExtractedCode(code);
const fileExt = file.fileExt;
code = file.code;
// apply templating
Expand Down
80 changes: 43 additions & 37 deletions test/mobileMessage.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,45 +45,51 @@ describe('mobileMessage', () => {
return;
});
});
// describe('Deploy ================', () => {
// beforeEach(() => {
// testUtils.mockSetup(true);
// });
// it('Should create & upsert a mobileMessage', async () => {
// // WHEN
// await handler.deploy('testInstance/testBU', ['mobileMessage']);
// // THEN
// assert.equal(!!process.exitCode, false, 'deploy should not have thrown an error');
// // get results from cache
// const result = cache.getCache();
// assert.equal(
// result.mobileMessage ? Object.keys(result.mobileMessage).length : 0,
// 3,
// '3 mobileMessages expected'
// );
// // confirm created item
// assert.deepEqual(
// await testUtils.getActualJson('testNew_mobileMessage', 'mobileMessage'),
// await testUtils.getExpectedJson('9999999', 'mobileMessage', 'post'),
// 'returned JSON was not equal expected for insert mobileMessage'
// );
describe('Deploy ================', () => {
beforeEach(() => {
testUtils.mockSetup(true);
});
it('Should create & upsert a mobileMessage', async () => {
// WHEN
await handler.deploy('testInstance/testBU', ['mobileMessage']);
// THEN
assert.equal(!!process.exitCode, false, 'deploy should not have thrown an error');
// get results from cache
const result = cache.getCache();
assert.equal(
result.mobileMessage ? Object.keys(result.mobileMessage).length : 0,
2,
'2 mobileMessages expected'
);
// confirm created item
assert.deepEqual(
await testUtils.getActualJson('NTQ3Ojc4OjA', 'mobileMessage'),
await testUtils.getExpectedJson('9999999', 'mobileMessage', 'post-create'),
'returned JSON was not equal expected for insert mobileMessage'
);
expect(file(testUtils.getActualFile('NTQ3Ojc4OjA', 'mobileMessage', 'amp'))).to.equal(
file(testUtils.getExpectedFile('9999999', 'mobileMessage', 'post-create', 'amp'))
);

// // confirm updated item
// assert.deepEqual(
// await testUtils.getActualJson('testExisting_mobileMessage', 'mobileMessage'),
// await testUtils.getExpectedJson('9999999', 'mobileMessage', 'put'), // watch out - mobileMessage api wants put instead of patch for updates
// 'returned JSON was not equal expected for update mobileMessage'
// );
// confirm updated item
assert.deepEqual(
await testUtils.getActualJson('NTIzOjc4OjA', 'mobileMessage'),
await testUtils.getExpectedJson('9999999', 'mobileMessage', 'post-update'), // watch out - mobileMessage api wants put instead of patch for updates
'returned JSON was not equal expected for update mobileMessage'
);
expect(file(testUtils.getActualFile('NTIzOjc4OjA', 'mobileMessage', 'amp'))).to.equal(
file(testUtils.getExpectedFile('9999999', 'mobileMessage', 'post-update', 'amp'))
);

// // check number of API calls
// assert.equal(
// testUtils.getAPIHistoryLength(),
// 7,
// 'Unexpected number of requests made. Run testUtils.logAPIHistoryDebug() to see the requests'
// );
// return;
// });
// });
// check number of API calls
assert.equal(
testUtils.getAPIHistoryLength(),
7,
'Unexpected number of requests made. Run testUtils.logAPIHistoryDebug() to see the requests'
);
return;
});
});
// describe('Templating ================', () => {
// it('Should create a mobileMessage template via buildTemplate and build it', async () => {
// // download first before we test buildTemplate
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
test message jb new
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
{
"id": "NTIzOjc4OjA",
"lastUpdated": "2023-03-08T16:30:00Z",
"type": "ExactTarget.Mobile.Sms.Core.Entities.SmsMessageEntity",
"name": "testExisting_mobileMessage",
"origin": "SMS Send",
"code": {
"code": "4912312345678"
},
"c__campaignNames": ["testExisting_campaign"],

"mtSendDate": "2020-07-16T22:46:00Z",
"template": {
"id": "Mzo4MDow",
"name": "Outbound"
},
"status": "Active/Scheduled",
"invalidMessage": "",
"responseMessage": "",
"publishedMessage": "Text '<keyword>' to 4912312345678.",
"isTest": false,
"moTimezone": {
"offset": 1,
"name": "(GMT+01:00) Amsterdam, Berlin, Bern, Rome, Stockholm, Vienna *"
},
"optinType": "NO_OPTIN",
"doubleOptinInitialMessage": "",
"doubleOptinConfirmMessage": "",
"optinMinimumAge": 0,
"optinInvalidAgeMessage": "",
"numberMessagesPerPeriod": 0,
"periodType": "NO_PERIOD",
"optinErrorMessage": "",
"isDuplicationAllowed": true,
"triggeredSendName": "DEV_InformUserAboutProposal - 267",
"isTimeZoneBased": false,
"surveyType": "NO_SURVEY",
"surveyCorrectResponseMessage": "",
"surveyTooManyEntriesMessage": "",
"isExpireSet": false,
"expireHours": 0,
"surveyIncorrectResponseMessage": "",
"statusId": 2,
"doubleOptinValidResponses": "y|yes",
"messagesPerPeriod": 0,
"minutesPerPeriod": 0,
"subscriberResponseMessage": "",
"isSubscriberResponseToAnySubscriptionForShortCode": false,
"sendMethod": "API",
"messageObjectId": "MzN3MUV5YVpmRVMtV1R1UXJUR3NzUTo2MjU6MA",
"allowSingleOptin": false,
"isSentImmediately": true,
"isSuppressMt": false,
"smsTriggeredSendDefinitionId": "39d0e022-b6c7-ea11-a2e9-1402ec938719",
"fromName": "4912312345678",
"concatenateMessage": true,
"isFromNameCertificationAccepted": false,
"isCertified": false,
"outboundSendTypeFlag": "Audience",
"outboundSendBehaviorFlag": "AutoAddSubscribers"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
New Task Available
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
{
"id": "new",
"lastUpdated": "2020-07-03T06:39:00Z",
"type": "ExactTarget.Mobile.Sms.Core.Entities.SmsMessageEntity",
"name": "testNew_mobileMessage",
"origin": "SMS Send",
"code": {
"code": "4912312345678"
},
"c__campaignNames": ["testExisting_campaign"],
"mtSendDate": "2017-07-03T14:03:00Z",
"template": {
"id": "Mzo4MDow",
"name": "Outbound"
},
"status": "Active/Scheduled",
"invalidMessage": "",
"responseMessage": "",
"publishedMessage": "Text '<keyword>' to 4912312345678.",
"isTest": false,
"moTimezone": {
"offset": 1,
"name": "(GMT+01:00) Amsterdam, Berlin, Bern, Rome, Stockholm, Vienna *"
},
"optinType": "NO_OPTIN",
"doubleOptinInitialMessage": "",
"doubleOptinConfirmMessage": "",
"optinMinimumAge": 0,
"optinInvalidAgeMessage": "",
"numberMessagesPerPeriod": 0,
"periodType": "NO_PERIOD",
"optinErrorMessage": "",
"isDuplicationAllowed": true,
"triggeredSendName": "OneUserOneDevice_DEV - 93",
"isTimeZoneBased": false,
"surveyType": "NO_SURVEY",
"surveyCorrectResponseMessage": "",
"surveyTooManyEntriesMessage": "",
"isExpireSet": false,
"expireHours": 0,
"surveyIncorrectResponseMessage": "",
"statusId": 2,
"doubleOptinValidResponses": "y|yes",
"messagesPerPeriod": 0,
"minutesPerPeriod": 0,
"subscriberResponseMessage": "",
"isSubscriberResponseToAnySubscriptionForShortCode": false,
"sendMethod": "API",
"messageObjectId": "M09MU3o1YnRMVS1GNHppZTdCRDVCdzo2MjU6MA",
"allowSingleOptin": false,
"isSentImmediately": true,
"isSuppressMt": false,
"smsTriggeredSendDefinitionId": "58d59e53-f85f-e711-80cc-1402ec7222b4",
"fromName": "PMI_DEV",
"concatenateMessage": false,
"isFromNameCertificationAccepted": false,
"isCertified": false,
"outboundSendTypeFlag": "Audience",
"outboundSendBehaviorFlag": "AutoAddSubscribers"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
{
"id": "NTIzOjc4OjA",
"lastUpdated": "2023-03-08T16:30:00Z",
"type": "ExactTarget.Mobile.Sms.Core.Entities.SmsMessageEntity",
"name": "testExisting_mobileMessage",
"text": "test message jb new",
"origin": "SMS Send",
"code": {
"id": "RXBwc0JoNk9jVTY0YWJNWFZDaGxvdzo4MTow",
"code": "4912312345678",
"codeType": "PRIVATE",
"isShortCode": false,
"isGsmCharacterSetOnly": false,
"isMms": false,
"isStackIndependant": false,
"dipSwitches": 0,
"moEngineVersion": 0,
"sendableCountries": [{ "countryCode": "HK", "vendor": "CLX", "fromNameSupported": true }],
"supportsConcatenation": true,
"isClientOwned": false,
"isOwner": false
},
"campaigns": [
{
"id": "MjMxOjQ2OjA",
"name": "testExisting_campaign",
"display": {
"name": "color",
"value": "f6efb6"
}
}
],

"mtSendDate": "2020-07-16T22:46:00Z",
"template": {
"id": "Mzo4MDow",
"name": "Outbound"
},
"status": "Active/Scheduled",
"invalidMessage": "",
"responseMessage": "",
"publishedMessage": "Text '<keyword>' to 4912312345678.",
"nextJob": {
"id": "MjY3Ojc5OjA",
"type": "ExactTarget.Mobile.Sms.Core.Entities.SmsJobEntity",
"isTest": false,
"sendDate": "2020-07-16T22:46:00Z"
},
"isTest": false,
"currentEditStep": 13,
"moTimezone": {
"offset": 1,
"name": "(GMT+01:00) Amsterdam, Berlin, Bern, Rome, Stockholm, Vienna *"
},
"optinType": "NO_OPTIN",
"doubleOptinInitialMessage": "",
"doubleOptinConfirmMessage": "",
"optinMinimumAge": 0,
"optinInvalidAgeMessage": "",
"numberMessagesPerPeriod": 0,
"periodType": "NO_PERIOD",
"optinErrorMessage": "",
"triggeredSendId": "00000000-0000-0000-0000-000000000000",
"isDuplicationAllowed": true,
"triggeredSendName": "DEV_InformUserAboutProposal - 267",
"isTimeZoneBased": false,
"surveyType": "NO_SURVEY",
"surveyCorrectResponseMessage": "",
"surveyTooManyEntriesMessage": "",
"isExpireSet": false,
"expireHours": 0,
"surveyIncorrectResponseMessage": "",
"statistics": {
"outbound": {
"sent": 45,
"delivered": 33,
"undelivered": 0,
"unknown": 0
}
},
"statusId": 2,
"doubleOptinValidResponses": "y|yes",
"messagesPerPeriod": 0,
"minutesPerPeriod": 0,
"subscriberResponseMessage": "",
"isSubscriberResponseToAnySubscriptionForShortCode": false,
"sendMethod": "API",
"messageObjectId": "MzN3MUV5YVpmRVMtV1R1UXJUR3NzUTo2MjU6MA",
"allowSingleOptin": false,
"isSentImmediately": true,
"nextKeyword": {
"id": "cTVJaG5oSDJPVUNHcUh6Z3pQT2tVdzo4Njow",
"keyword": "testExisting_keyword",
"restriction": "NONE",
"isInherited": false
},
"isSuppressMt": false,
"smsTriggeredSendDefinitionId": "39d0e022-b6c7-ea11-a2e9-1402ec938719",
"fromName": "4912312345678",
"concatenateMessage": true,
"isFromNameCertificationAccepted": false,
"isCertified": false,
"outboundSendTypeFlag": "Audience",
"programId": "00000000-0000-0000-0000-000000000000",
"outboundSendBehaviorFlag": "AutoAddSubscribers"
}
Loading

0 comments on commit 45e5100

Please sign in to comment.