Skip to content

Commit

Permalink
chore: update smart analysis block (#234)
Browse files Browse the repository at this point in the history
  • Loading branch information
ASaiAnudeep authored Aug 17, 2024
1 parent 0e4de0a commit b5ade22
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 11 deletions.
24 changes: 22 additions & 2 deletions src/extensions/smart-analysis.extension.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
const { BaseExtension } = require('./base.extension');
const { STATUS, HOOK } = require("../helpers/constants");
const logger = require('../utils/logger');

class SmartAnalysisExtension extends BaseExtension {

Expand All @@ -21,7 +22,7 @@ class SmartAnalysisExtension extends BaseExtension {
}

#setDefaultInputs() {
this.default_inputs.title = 'Smart Analysis';
this.default_inputs.title = '';
this.default_inputs.title_link = '';
}

Expand All @@ -37,6 +38,11 @@ class SmartAnalysisExtension extends BaseExtension {
*/
const execution_metrics = data.execution_metrics[0];

if (!execution_metrics) {
logger.warn('⚠️ No execution metrics found. Skipping.');
return;
}

const smart_analysis = [];
if (execution_metrics.newly_failed) {
smart_analysis.push(`⭕ Newly Failed: ${execution_metrics.newly_failed}`);
Expand All @@ -54,7 +60,21 @@ class SmartAnalysisExtension extends BaseExtension {
smart_analysis.push(`🟢 Recovered: ${execution_metrics.recovered}`);
}

this.text = smart_analysis.join(' | ');
const texts = [];
const rows = [];
for (const item of smart_analysis) {
rows.push(item);
if (rows.length === 3) {
texts.push(rows.join(' | '));
rows.length = 0;
}
}

if (rows.length > 0) {
texts.push(rows.join(' | '));
}

this.text = this.mergeTexts(texts);
}

}
Expand Down
19 changes: 10 additions & 9 deletions test/mocks/teams.mock.js
Original file line number Diff line number Diff line change
Expand Up @@ -1642,18 +1642,19 @@ addInteractionHandler('post test-summary with beats to teams with ai failure sum
{
"@DATA:TEMPLATE@": "TEAMS_ROOT_RESULTS_SINGLE_SUITE_FAILURES",
},
// {
// "type": "TextBlock",
// "text": "Smart Analysis",
// "isSubtle": true,
// "weight": "bolder",
// "separator": true,
// "wrap": true
// },
{
"type": "TextBlock",
"text": "Smart Analysis",
"isSubtle": true,
"weight": "bolder",
"text": "⭕ Newly Failed: 1 | 🔴 Always Failing: 1 | 🟡 Flaky: 1\n\n🟢 Recovered: 1",
"wrap": true,
"separator": true,
"wrap": true
},
{
"type": "TextBlock",
"text": "⭕ Newly Failed: 1 | 🔴 Always Failing: 1 | 🟡 Flaky: 1 | 🟢 Recovered: 1",
"wrap": true
}
],
"actions": []
Expand Down

0 comments on commit b5ade22

Please sign in to comment.