Skip to content

Commit 2f55375

Browse files
Merge master into feature/flare-mega
2 parents eb75bc0 + 2a1242d commit 2f55375

File tree

3 files changed

+35
-5
lines changed

3 files changed

+35
-5
lines changed
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"type": "Bug Fix",
3+
"description": "/transform: only show lines of code statistic in plan"
4+
}

packages/core/src/codewhisperer/service/transformByQ/transformApiHandler.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -595,9 +595,11 @@ export function getJobStatisticsHtml(jobStatistics: any) {
595595
htmlString += `<div style="flex: 1; margin-left: 20px; border: 1px solid #424750; border-radius: 8px; padding: 10px;">`
596596
// eslint-disable-next-line unicorn/no-array-for-each
597597
jobStatistics.forEach((stat: { name: string; value: string }) => {
598-
htmlString += `<p style="margin-bottom: 4px"><img src="${getTransformationIcon(
599-
stat.name
600-
)}" style="vertical-align: middle;"> ${getFormattedString(stat.name)}: ${stat.value}</p>`
598+
if (stat.name === 'linesOfCode') {
599+
htmlString += `<p style="margin-bottom: 4px"><img src="${getTransformationIcon(
600+
stat.name
601+
)}" style="vertical-align: middle;"> ${getFormattedString(stat.name)}: ${stat.value}</p>`
602+
}
601603
})
602604
htmlString += `</div>`
603605
return htmlString
@@ -647,8 +649,6 @@ export async function getTransformationPlan(jobId: string, profile: RegionProfil
647649
plan += `</div><br>`
648650
}
649651
plan += `</div><br>`
650-
plan += `<p style="font-size: 18px; margin-bottom: 4px;"><b>Appendix</b><br><a href="#top" style="float: right; font-size: 14px;">Scroll to top <img src="${arrowIcon}" style="vertical-align: middle;"></a></p><br>`
651-
plan = addTableMarkdown(plan, '-1', tableMapping) // ID of '-1' reserved for appendix table; only 1 table there
652652
return plan
653653
} catch (e: any) {
654654
const errorMessage = (e as Error).message

packages/core/src/test/codewhisperer/commands/transformByQ.test.ts

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ import {
2828
zipCode,
2929
getTableMapping,
3030
getFilesRecursively,
31+
getJobStatisticsHtml,
3132
} from '../../../codewhisperer/service/transformByQ/transformApiHandler'
3233
import {
3334
validateOpenProjects,
@@ -312,6 +313,31 @@ dependencyManagement:
312313
assert.deepStrictEqual(actual, expected)
313314
})
314315

316+
it('WHEN showing plan statistics THEN correct labels appear', () => {
317+
const mockJobStatistics = [
318+
{
319+
name: 'linesOfCode',
320+
value: '1234',
321+
},
322+
{
323+
name: 'plannedDependencyChanges',
324+
value: '0',
325+
},
326+
{
327+
name: 'plannedDeprecatedApiChanges',
328+
value: '0',
329+
},
330+
{
331+
name: 'plannedFileChanges',
332+
value: '0',
333+
},
334+
]
335+
const result = getJobStatisticsHtml(mockJobStatistics)
336+
assert.strictEqual(result.includes('Lines of code in your application'), true)
337+
assert.strictEqual(result.includes('to be replaced'), false)
338+
assert.strictEqual(result.includes('to be changed'), false)
339+
})
340+
315341
it(`WHEN transforming a project with a Windows Maven executable THEN mavenName set correctly`, async function () {
316342
sinon.stub(env, 'isWin').returns(true)
317343
const tempFileName = 'mvnw.cmd'

0 commit comments

Comments
 (0)