Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/develop' into feature/1852-add-o…
Browse files Browse the repository at this point in the history
…ption-deploy-ignoresffields-isf

# Conflicts:
#	@types/lib/index.d.ts.map
#	@types/lib/metadataTypes/Journey.d.ts.map
  • Loading branch information
JoernBerkefeld committed Nov 11, 2024
2 parents 79b4d97 + b7643fa commit f7b3d75
Show file tree
Hide file tree
Showing 10 changed files with 197 additions and 24 deletions.
2 changes: 1 addition & 1 deletion @types/lib/metadataTypes/Journey.d.ts.map

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

5 changes: 0 additions & 5 deletions lib/cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -870,11 +870,6 @@ yargs(hideBin(process.argv))
group: 'Options for validate:',
describe:
'filter metadata components (can include % as wildcard or _ for a single character)',
})
.option('skipStatusCheck', {
group: 'Options for validate:',
describe:
'if you don not care if validating actually worked you can skip the checks',
}),

(argv) => {
Expand Down
31 changes: 13 additions & 18 deletions lib/metadataTypes/Journey.js
Original file line number Diff line number Diff line change
Expand Up @@ -2270,24 +2270,19 @@ class Journey extends MetadataType {
} else {
throw new Error(response);
}
if (!Util.OPTIONS.skipStatusCheck && statusUrl) {
const spinner = yoctoSpinner({
text: `Validating journey…`,
}).start();

await Util.sleep(1000);
executedKeyArr.push(
await this._checkPublishStatus(
statusUrl,
journey[this.definition.keyField],
journey[this.definition.nameField],
spinner
)
);
} else {
// no guarantees if the journey was actually published
executedKeyArr.push(key);
}
const spinner = yoctoSpinner({
text: `Validating journey…`,
}).start();

await Util.sleep(1000);
executedKeyArr.push(
await this._checkPublishStatus(
statusUrl,
journey[this.definition.keyField],
journey[this.definition.nameField],
spinner
)
);
} catch (ex) {
switch (ex.message) {
case 'Cannot validate interaction in Published status.': {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"statusUrl": "/interaction/v1/interactions/validateStatus/45f06c0a-3ed2-48b2-a6a8-b5119253f01c",
"statusId": "45f06c0a-3ed2-48b2-a6a8-b5119253f01c"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
{
"status": "Error",
"errors": [
{
"errorDetail": "The default email or mobile address in Journey Settings is invalid. Select a different one.",
"errorCode": "121226",
"errorType": "Error",
"additionalInfo": {}
},
{
"errorDetail": "Email Activity: CCE OpsIssue Satisfaction Email -- The email specified for the job did not pass validation. EmailID: 72604 An unverified from email address was detected. ",
"errorCode": "121008",
"errorType": "Error",
"additionalInfo": {
"activityKey": "EMAILV2-1",
"activityId": "620dbe27-665a-49a3-ad61-ceea5aab720f",
"activityType": "EMAILV2",
"definitionId": "2d5f37b8-7acf-4ac4-b76a-74690255600c"
}
}
],
"warnings": [
{
"errorDetail": "Last modified date for email activity is more then 6 months ago. Please review the content or use path optimizer to test it.",
"errorCode": "121546",
"errorType": "Warning",
"additionalInfo": {
"activityKey": "EMAILV2-1",
"activityId": "620dbe27-665a-49a3-ad61-ceea5aab720f",
"activityType": "EMAILV2"
}
}
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"status": "ValidateCompleted",
"errors": [],
"warnings": []
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
{
"status": "ValidateCompleted",
"errors": [],
"warnings": [
{
"errorDetail": "The journey has a long wait (1 days), please consider reducing wait to under 4 minutes.",
"errorCode": "121547",
"errorType": "Warning",
"additionalInfo": {
"activityKey": "WAITBYDURATION-5",
"activityId": "2d0b5dbf-14cc-4635-acee-64071c8e1022",
"activityType": "WAIT"
}
},
{
"errorDetail": "The journey has a long wait (1 days), please consider reducing wait to under 4 minutes.",
"errorCode": "121547",
"errorType": "Warning",
"additionalInfo": {
"activityKey": "WAITBYDURATION-4",
"activityId": "26298616-e89b-4166-8e7e-8417031f276b",
"activityType": "WAIT"
}
},
{
"errorDetail": "Last modified date for email activity is more then 6 months ago. Please review the content or use path optimizer to test it.",
"errorCode": "121546",
"errorType": "Warning",
"additionalInfo": {
"activityKey": "EMAILV2-1",
"activityId": "966651f8-e1b6-4261-849c-e95589001c75",
"activityType": "EMAILV2"
}
}
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{}
103 changes: 103 additions & 0 deletions test/type.journey.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -823,4 +823,107 @@ describe('type: journey', () => {
return;
});
});

describe('Validate ================', () => {
it('Should not validate a transactional journey by key', async () => {
handler.setOptions({ skipStatusCheck: true });
// WHEN
await handler.validate(
'testInstance/testBU',
['journey'],
['testExisting_temail_notPublished']
);
// THEN
assert.equal(process.exitCode, 1, 'validate should not have thrown an error');

assert.equal(
testUtils.getAPIHistoryLength(),
1,
'Unexpected number of requests made. Run testUtils.logAPIHistoryDebug() to see the requests'
);
return;
});

it('Should validate a journey by id but w/o version (auto-picks latest version)', async () => {
await testUtils.copyFile(
'interaction/v1/interactions/validateStatus/45f06c0a-3ed2-48b2-a6a8-b5119253f01c/get-response-success.json',
'interaction/v1/interactions/validateStatus/45f06c0a-3ed2-48b2-a6a8-b5119253f01c/get-response.json'
);
// WHEN
const validate = await handler.validate(
'testInstance/testBU',
['journey'],
['id:0175b971-71a3-4d8e-98ac-48121f3fbf4f']
);
// THEN
assert.equal(process.exitCode, 0, 'validate should not have thrown an error');
// retrieve result
assert.deepEqual(
validate['testInstance/testBU']?.journey,
['testExisting_journey_Multistep'],
'should have validateed the right journey'
);

// get callouts
const validateCallout = testUtils.getRestCallout(
'post',
'/interaction/v1/interactions/validateAsync/%'
);
// confirm created item
assert.deepEqual(
validateCallout,
await testUtils.getExpectedJson('9999999', 'journey', 'validate-callout'),
'validate-payload JSON was not equal expected'
);

assert.equal(
testUtils.getAPIHistoryLength(),
3,
'Unexpected number of requests made. Run testUtils.logAPIHistoryDebug() to see the requests'
);
return;
});

it('Should validate a journey by id w/ version with failing status check', async () => {
await testUtils.copyFile(
'interaction/v1/interactions/publishStatus/45f06c0a-3ed2-48b2-a6a8-b5119253f01c/get-response-failed.json',
'interaction/v1/interactions/validateStatus/45f06c0a-3ed2-48b2-a6a8-b5119253f01c/get-response.json'
);

handler.setOptions({ _runningTest: true });
// WHEN
const validate = await handler.validate(
'testInstance/testBU',
['journey'],
['id:0175b971-71a3-4d8e-98ac-48121f3fbf4f/1']
);
// THEN
assert.equal(process.exitCode, 1, 'validate should have thrown an error');
// retrieve result
assert.equal(
validate['testInstance/testBU']?.journey.length,
0,
'should have not validated the journey'
);

// get callouts
const validateCallout = testUtils.getRestCallout(
'post',
'/interaction/v1/interactions/validateAsync/%'
);
// confirm created item
assert.deepEqual(
validateCallout,
await testUtils.getExpectedJson('9999999', 'journey', 'validate-callout'),
'validate-payload JSON was not equal expected'
);

assert.equal(
testUtils.getAPIHistoryLength(),
3,
'Unexpected number of requests made. Run testUtils.logAPIHistoryDebug() to see the requests'
);
return;
});
});
});

0 comments on commit f7b3d75

Please sign in to comment.