Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bug/1856 ensure upserted senderProfiles are saved with CreatedDate, ModifiedDate, createdBy and modifiedBy #1964

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions @types/lib/metadataTypes/SenderProfile.d.ts

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion @types/lib/metadataTypes/SenderProfile.d.ts.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

20 changes: 20 additions & 0 deletions lib/metadataTypes/SenderProfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,26 @@ class SenderProfile extends MetadataType {
return metadata;
}

/**
* Gets executed after deployment of metadata type
*
* @param {MetadataTypeMap} upsertResults metadata mapped by their keyField as returned by update/create
* @returns {Promise.<void>} -
*/
static async postDeployTasks(upsertResults) {
// re-retrieve all upserted items to ensure we have all fields (createdDate and modifiedDate are otherwise not present)
Util.logger.debug(
`Caching all ${this.definition.type} post-deploy to ensure we have all fields`
);
const typeCache = await this.retrieveForCache();
// update values in upsertResults with retrieved values before saving to disk
for (const key of Object.keys(upsertResults)) {
if (typeCache.metadata[key]) {
upsertResults[key] = typeCache.metadata[key];
}
}
}

/**
*
* @param {MetadataTypeItem} item single metadata item
Expand Down
10 changes: 5 additions & 5 deletions test/general.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -569,7 +569,7 @@ describe('GENERAL', () => {
);
assert.equal(
testUtils.getAPIHistoryLength(),
16,
17,
'Unexpected number of requests made. Run testUtils.logAPIHistoryDebug() to see the requests'
);
});
Expand Down Expand Up @@ -632,7 +632,7 @@ describe('GENERAL', () => {
);
assert.equal(
testUtils.getAPIHistoryLength(),
17,
18,
'Unexpected number of requests made. Run testUtils.logAPIHistoryDebug() to see the requests'
);
});
Expand Down Expand Up @@ -697,7 +697,7 @@ describe('GENERAL', () => {
);
assert.equal(
testUtils.getAPIHistoryLength(),
14,
15,
'Unexpected number of requests made. Run testUtils.logAPIHistoryDebug() to see the requests'
);
});
Expand Down Expand Up @@ -2249,7 +2249,7 @@ describe('GENERAL', () => {
);
assert.equal(
testUtils.getAPIHistoryLength(),
16,
17,
'Unexpected number of requests made. Run testUtils.logAPIHistoryDebug() to see the requests'
);
});
Expand Down Expand Up @@ -2298,7 +2298,7 @@ describe('GENERAL', () => {
);
assert.equal(
testUtils.getAPIHistoryLength(),
11,
12,
'Unexpected number of requests made. Run testUtils.logAPIHistoryDebug() to see the requests'
);
});
Expand Down
20 changes: 12 additions & 8 deletions test/resources/9999999/senderProfile/patch-expected.json
Original file line number Diff line number Diff line change
@@ -1,15 +1,19 @@
{
"FallbackFromAddress": "",
"AutoForwardToEmailAddress": "[email protected]",
"AutoForwardToName": "Jörn Berkefeld",
"AutoReply": false,
"CreatedDate": "2021-08-03T11:14:00",
"ModifiedDate": "2021-08-03T11:14:00",
"CustomerKey": "testExisting_senderProfile",
"Description": "updated via deploy",
"DirectForward": false,
"FromAddress": "[email protected]",
"FromName": "Jörn Berkefeld",
"Name": "testExisting_senderProfile",
"Description": "Send from [email protected]",
"FromName": "Jörn Berkefeld",
"FromAddress": "[email protected]",
"UseDefaultRMMRules": true,
"AutoForwardToEmailAddress": "",
"AutoForwardToName": "",
"DirectForward": false,
"AutoReply": false,
"SenderHeaderEmailAddress": "",
"SenderHeaderName": "",
"UseDefaultRMMRules": false
"createdBy": "Jörn Berkefeld",
"modifiedBy": "Jörn Berkefeld"
}
2 changes: 1 addition & 1 deletion test/type.senderProfile.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ describe('type: senderProfile', () => {
// check number of API calls
assert.equal(
testUtils.getAPIHistoryLength(),
6,
7,
'Unexpected number of requests made. Run testUtils.logAPIHistoryDebug() to see the requests'
);
return;
Expand Down
Loading