From b5ade2217f11015110ca4ccb234008a6611692e6 Mon Sep 17 00:00:00 2001 From: Anudeep Date: Sat, 17 Aug 2024 17:35:44 +0530 Subject: [PATCH] chore: update smart analysis block (#234) --- src/extensions/smart-analysis.extension.js | 24 ++++++++++++++++++++-- test/mocks/teams.mock.js | 19 +++++++++-------- 2 files changed, 32 insertions(+), 11 deletions(-) diff --git a/src/extensions/smart-analysis.extension.js b/src/extensions/smart-analysis.extension.js index c6d1b3a..f8f99e8 100644 --- a/src/extensions/smart-analysis.extension.js +++ b/src/extensions/smart-analysis.extension.js @@ -1,5 +1,6 @@ const { BaseExtension } = require('./base.extension'); const { STATUS, HOOK } = require("../helpers/constants"); +const logger = require('../utils/logger'); class SmartAnalysisExtension extends BaseExtension { @@ -21,7 +22,7 @@ class SmartAnalysisExtension extends BaseExtension { } #setDefaultInputs() { - this.default_inputs.title = 'Smart Analysis'; + this.default_inputs.title = ''; this.default_inputs.title_link = ''; } @@ -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}`); @@ -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); } } diff --git a/test/mocks/teams.mock.js b/test/mocks/teams.mock.js index 2f986a4..acb893f 100644 --- a/test/mocks/teams.mock.js +++ b/test/mocks/teams.mock.js @@ -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": []