Skip to content

Commit ced6295

Browse files
Feat: Onboarding flexcard on report framework. (#290)
1 parent 9f9e32b commit ced6295

File tree

3 files changed

+136
-81
lines changed

3 files changed

+136
-81
lines changed

src/commands/omnistudio/migration/__tests__/assess.test.ts

Lines changed: 16 additions & 74 deletions
Original file line numberDiff line numberDiff line change
@@ -255,24 +255,10 @@ describe('omnistudio:migration:assess', () => {
255255
expect(dataRaptorContent).to.include('DR_Test_Extract');
256256
expect(dataRaptorContent).to.include('DR_Test_Transform');
257257

258-
const flexCardContent = fs.readFileSync(
259-
path.join(process.cwd(), 'assessment_reports/flexcard_assessment.html'),
260-
'utf8'
261-
);
262-
expect(flexCardContent).to.not.include('FC_Test_Card');
263-
expect(flexCardContent).to.not.include('FC_Test_Form');
264-
265-
const omniScriptContent = fs.readFileSync(
266-
path.join(process.cwd(), 'assessment_reports/omniscript_assessment.html'),
267-
'utf8'
268-
);
269-
expect(omniScriptContent).to.not.include('OS_Test_Script');
270-
271-
const ipContent = fs.readFileSync(
272-
path.join(process.cwd(), 'assessment_reports/integration_procedure_assessment.html'),
273-
'utf8'
274-
);
275-
expect(ipContent).to.not.include('IP_Test_Procedure');
258+
void expect(fs.existsSync(path.join(process.cwd(), 'assessment_reports/flexcard_assessment.html'))).to.be.false;
259+
void expect(fs.existsSync(path.join(process.cwd(), 'assessment_reports/omniscript_assessment.html'))).to.be.false;
260+
void expect(fs.existsSync(path.join(process.cwd(), 'assessment_reports/integration_procedure_assessment.html')))
261+
.to.be.false;
276262
});
277263

278264
test
@@ -281,31 +267,18 @@ describe('omnistudio:migration:assess', () => {
281267
.stderr()
282268
.command(['omnistudio:migration:assess', '-o', Constants.Flexcard])
283269
.it('generates assessment files with content only for FlexCard components', () => {
284-
const dataRaptorContent = fs.readFileSync(
285-
path.join(process.cwd(), 'assessment_reports/datamapper_assessment.html'),
286-
'utf8'
287-
);
288-
expect(dataRaptorContent).to.not.include('DR_Test_Extract');
289-
expect(dataRaptorContent).to.not.include('DR_Test_Transform');
270+
void expect(fs.existsSync(path.join(process.cwd(), 'assessment_reports/datamapper_assessment.html'))).to.be.false;
290271

291272
const flexCardContent = fs.readFileSync(
292273
path.join(process.cwd(), 'assessment_reports/flexcard_assessment.html'),
293274
'utf8'
294275
);
276+
295277
expect(flexCardContent).to.include('FC_Test_Card');
296278
expect(flexCardContent).to.include('FC_Test_Form');
297-
298-
const omniScriptContent = fs.readFileSync(
299-
path.join(process.cwd(), 'assessment_reports/omniscript_assessment.html'),
300-
'utf8'
301-
);
302-
expect(omniScriptContent).to.not.include('OS_Test_Script');
303-
304-
const ipContent = fs.readFileSync(
305-
path.join(process.cwd(), 'assessment_reports/integration_procedure_assessment.html'),
306-
'utf8'
307-
);
308-
expect(ipContent).to.not.include('IP_Test_Procedure');
279+
void expect(fs.existsSync(path.join(process.cwd(), 'assessment_reports/omniscript_assessment.html'))).to.be.false;
280+
void expect(fs.existsSync(path.join(process.cwd(), 'assessment_reports/integration_procedure_assessment.html')))
281+
.to.be.false;
309282
});
310283

311284
test
@@ -314,31 +287,16 @@ describe('omnistudio:migration:assess', () => {
314287
.stderr()
315288
.command(['omnistudio:migration:assess', '-o', Constants.Omniscript])
316289
.it('generates assessment files with content only for OmniScript components', () => {
317-
const dataRaptorContent = fs.readFileSync(
318-
path.join(process.cwd(), 'assessment_reports/datamapper_assessment.html'),
319-
'utf8'
320-
);
321-
expect(dataRaptorContent).to.not.include('DR_Test_Extract');
322-
expect(dataRaptorContent).to.not.include('DR_Test_Transform');
323-
324-
const flexCardContent = fs.readFileSync(
325-
path.join(process.cwd(), 'assessment_reports/flexcard_assessment.html'),
326-
'utf8'
327-
);
328-
expect(flexCardContent).to.not.include('FC_Test_Card');
329-
expect(flexCardContent).to.not.include('FC_Test_Form');
290+
void expect(fs.existsSync(path.join(process.cwd(), 'assessment_reports/datamapper_assessment.html'))).to.be.false;
291+
void expect(fs.existsSync(path.join(process.cwd(), 'assessment_reports/flexcard_assessment.html'))).to.be.false;
292+
void expect(fs.existsSync(path.join(process.cwd(), 'assessment_reports/integration_procedure_assessment.html')))
293+
.to.be.false;
330294

331295
const omniScriptContent = fs.readFileSync(
332296
path.join(process.cwd(), 'assessment_reports/omniscript_assessment.html'),
333297
'utf8'
334298
);
335299
expect(omniScriptContent).to.include('OS_Test_Script');
336-
337-
const ipContent = fs.readFileSync(
338-
path.join(process.cwd(), 'assessment_reports/integration_procedure_assessment.html'),
339-
'utf8'
340-
);
341-
expect(ipContent).to.include('IP_Test_Procedure');
342300
});
343301

344302
test
@@ -347,25 +305,9 @@ describe('omnistudio:migration:assess', () => {
347305
.stderr()
348306
.command(['omnistudio:migration:assess', '-o', Constants.IntegrationProcedure])
349307
.it('generates assessment files with content only for Integration Procedure components', () => {
350-
const dataRaptorContent = fs.readFileSync(
351-
path.join(process.cwd(), 'assessment_reports/datamapper_assessment.html'),
352-
'utf8'
353-
);
354-
expect(dataRaptorContent).to.not.include('DR_Test_Extract');
355-
expect(dataRaptorContent).to.not.include('DR_Test_Transform');
356-
357-
const flexCardContent = fs.readFileSync(
358-
path.join(process.cwd(), 'assessment_reports/flexcard_assessment.html'),
359-
'utf8'
360-
);
361-
expect(flexCardContent).to.not.include('FC_Test_Card');
362-
expect(flexCardContent).to.not.include('FC_Test_Form');
363-
364-
const omniScriptContent = fs.readFileSync(
365-
path.join(process.cwd(), 'assessment_reports/omniscript_assessment.html'),
366-
'utf8'
367-
);
368-
expect(omniScriptContent).to.include('OS_Test_Script');
308+
void expect(fs.existsSync(path.join(process.cwd(), 'assessment_reports/datamapper_assessment.html'))).to.be.false;
309+
void expect(fs.existsSync(path.join(process.cwd(), 'assessment_reports/flexcard_assessment.html'))).to.be.false;
310+
void expect(fs.existsSync(path.join(process.cwd(), 'assessment_reports/omniscript_assessment.html'))).to.be.false;
369311

370312
const ipContent = fs.readFileSync(
371313
path.join(process.cwd(), 'assessment_reports/integration_procedure_assessment.html'),
Lines changed: 112 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,112 @@
1+
import { FlexCardAssessmentInfo } from '../interfaces';
2+
import { generateHtmlTable } from '../reportGenerator/reportGenerator';
3+
import {
4+
HeaderColumn,
5+
ReportFrameworkParameters,
6+
ReportHeaderFormat,
7+
TableColumn,
8+
} from '../reportGenerator/reportInterfaces';
9+
10+
export class FlexcardAssessmentReporter {
11+
public static generateFlexcardAssesment(
12+
flexcardAssessmentInfos: FlexCardAssessmentInfo[],
13+
instanceUrl: string,
14+
org: ReportHeaderFormat[]
15+
): string {
16+
// Define multi-row headers
17+
const headerColumn: HeaderColumn[] = [
18+
{
19+
label: 'In Package',
20+
colspan: 2,
21+
subColumn: [
22+
{
23+
label: 'Name',
24+
key: 'oldName',
25+
},
26+
{
27+
label: 'Record ID',
28+
key: 'id',
29+
},
30+
],
31+
},
32+
{
33+
label: 'In Core',
34+
colspan: 1,
35+
subColumn: [
36+
{
37+
label: 'Name',
38+
key: 'name',
39+
},
40+
],
41+
},
42+
{
43+
label: 'Omniscript Dependencies',
44+
rowspan: 2,
45+
subColumn: [],
46+
},
47+
{
48+
label: 'Integration Procedures Dependencies',
49+
rowspan: 2,
50+
subColumn: [],
51+
},
52+
{
53+
label: 'Data Mapper dependencies',
54+
rowspan: 2,
55+
subColumn: [],
56+
},
57+
];
58+
59+
// Define columns
60+
const columns: Array<TableColumn<FlexCardAssessmentInfo>> = [
61+
{
62+
key: 'oldName',
63+
cell: (row: FlexCardAssessmentInfo): string => row.name || '',
64+
filterValue: (row: FlexCardAssessmentInfo): string => row.name,
65+
title: (row: FlexCardAssessmentInfo): string => row.name,
66+
},
67+
{
68+
key: 'id',
69+
cell: (row: FlexCardAssessmentInfo): string =>
70+
row.id ? `<a href="${instanceUrl}/${row.id}">${row.id}</a>` : '',
71+
filterValue: (row: FlexCardAssessmentInfo): string => row.id,
72+
title: (row: FlexCardAssessmentInfo): string => row.id,
73+
},
74+
{
75+
key: 'name',
76+
cell: (row: FlexCardAssessmentInfo): string => row.name || '',
77+
filterValue: (row: FlexCardAssessmentInfo): string => row.name,
78+
title: (row: FlexCardAssessmentInfo): string => row.name,
79+
},
80+
{
81+
key: 'dependenciesOS',
82+
cell: (row: FlexCardAssessmentInfo): string => (row.dependenciesOS ? row.dependenciesOS.join(', ') : ''),
83+
filterValue: (row: FlexCardAssessmentInfo): string => (row.dependenciesOS ? row.dependenciesOS.join(', ') : ''),
84+
},
85+
{
86+
key: 'dependenciesIP',
87+
cell: (row: FlexCardAssessmentInfo): string => (row.dependenciesIP ? row.dependenciesIP.join(', ') : ''),
88+
filterValue: (row: FlexCardAssessmentInfo): string => (row.dependenciesIP ? row.dependenciesIP.join(', ') : ''),
89+
},
90+
{
91+
key: 'dependenciesDR',
92+
cell: (row: FlexCardAssessmentInfo): string => (row.dependenciesDR ? row.dependenciesDR.join(', ') : ''),
93+
filterValue: (row: FlexCardAssessmentInfo): string => (row.dependenciesDR ? row.dependenciesDR.join(', ') : ''),
94+
},
95+
];
96+
97+
const reportFrameworkParameters: ReportFrameworkParameters<FlexCardAssessmentInfo> = {
98+
headerColumns: headerColumn,
99+
columns,
100+
rows: flexcardAssessmentInfos,
101+
orgDetails: org,
102+
filters: [],
103+
ctaSummary: [],
104+
reportHeaderLabel: 'Flexcard Components Assessment',
105+
showMigrationBanner: true,
106+
};
107+
108+
// Render table
109+
const tableHtml = generateHtmlTable(reportFrameworkParameters);
110+
return `${tableHtml}`;
111+
}
112+
}

src/utils/resultsbuilder/assessmentReporter.ts

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import { OSAssessmentReporter } from './OSAssessmentReporter';
1111
import { ApexAssessmentReporter } from './ApexAssessmentReporter';
1212
import { IPAssessmentReporter } from './IPAssessmentReporter';
1313
import { DRAssessmentReporter } from './DRAssessmentReporter';
14+
import { FlexcardAssessmentReporter } from './FlexcardAssessmentReporter';
1415

1516
export class AssessmentReporter {
1617
public static async generate(
@@ -39,17 +40,17 @@ export class AssessmentReporter {
3940

4041
this.createDocument(
4142
flexcardAssessmentFilePath,
42-
this.generateCardAssesment(result.flexCardAssessmentInfos, instanceUrl)
43+
FlexcardAssessmentReporter.generateFlexcardAssesment(result.flexCardAssessmentInfos, instanceUrl, orgDetails)
4344
);
4445
this.createDocument(
45-
apexAssessmentFilePath,
46+
apexAssessmentFilePath,
4647
ApexAssessmentReporter.generateApexAssesment(result.apexAssessmentInfos, instanceUrl, orgDetails)
4748
);
48-
49-
// this.createDocument(
50-
// lwcAssessmentFilePath,
51-
// LWCAssessmentReporter.generateLwcAssesment(result.lwcAssessmentInfos, instanceUrl, orgDetails)
52-
// );
49+
50+
// this.createDocument(
51+
// lwcAssessmentFilePath,
52+
// LWCAssessmentReporter.generateLwcAssesment(result.lwcAssessmentInfos, instanceUrl, orgDetails)
53+
// );
5354

5455
this.createDocument(
5556
integrationProcedureAssessmentFilePath,

0 commit comments

Comments
 (0)