Skip to content

Commit 00ea266

Browse files
committed
Fix notification format
1 parent db2c140 commit 00ea266

File tree

2 files changed

+18
-4
lines changed

2 files changed

+18
-4
lines changed

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "sfdx-notify",
3-
"version": "0.0.15",
3+
"version": "0.0.16",
44
"author": "Gil Avignon",
55
"bugs": "https://github.com/gavignon/sfdx-notify/issues",
66
"dependencies": {

src/commands/notify/tests/teams.ts

+17-3
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,10 @@ export default class Teams extends SfdxCommand {
6464
}
6565

6666
private formatMilliseconds(milliseconds){
67+
if(milliseconds == 0){
68+
return '0s';
69+
}
70+
6771
let seconds = Math.floor((milliseconds / 1000) % 60);
6872
let minutes = Math.floor((milliseconds / (1000 * 60)) % 60);
6973
let hours = Math.floor((milliseconds / (1000 * 60 * 60)) % 24);
@@ -146,13 +150,23 @@ export default class Teams extends SfdxCommand {
146150
coverageApexClasses.push(currentClass);
147151
}
148152
let globalCoverage = Math.round((1 - (globalNumLinesNotCovered / globalNumLines)) * 100);
153+
if(globalNumLines == 0){
154+
globalCoverage = 0;
155+
}
156+
149157
this.ux.stopSpinner('done');
150158

159+
let formattedDate = new Date(testResult.result.startDate).toLocaleString('fr-FR', { timeZone: 'CET' });
160+
let createdDate = new Date(testResult.result.createdDate);
161+
let completedDate = new Date(testResult.result.completedDate);
162+
let executionTime = this.formatMilliseconds(completedDate.getTime() - createdDate.getTime());
163+
164+
151165
// Generate Global information
152166
let status = testResult.result.numberTestErrors > 0 ? 'Failed' : 'Passed';
153167
let statusColor = status == 'Passed' ? 'green' : 'red';
154-
let summaryTitle = 'Test Execution in ' + this.flags.env + ' - ' + testResult.result.startDate;
155-
let summaryContent = '<strong>TestRunId: </strong>' + testResult.result.id + ' (Execution Time: ' + this.formatMilliseconds(testResult.result.details.runTestResult.totalTime) + ')'
168+
let summaryTitle = 'Test Execution in ' + this.flags.env + ' - ' + formattedDate;
169+
let summaryContent = '<strong>DeploymentId: </strong>' + testResult.result.id + ' (Execution Time: ' + executionTime + ')'
156170
+ '\n\n' + '<strong>Status: </strong><span style="color:' + statusColor + ';">' + status + '</span>'
157171
+ '\n\n' + '<strong>Code Coverage: </strong>' + globalCoverage + '%'
158172
+ '\n\n' + '<strong>Tests Ran: </strong>' + testResult.result.numberTestsTotal
@@ -252,7 +266,7 @@ export default class Teams extends SfdxCommand {
252266

253267
this.ux.startSpinner('Notify deployment status on Microsoft Teams');
254268
await HttpClient.sendRequest(this.flags.url.toString(), data);
255-
this.ux.stopSpinner('Done!');
269+
this.ux.stopSpinner('done');
256270
}catch(error){
257271
throw error;
258272
}

0 commit comments

Comments
 (0)