Skip to content

Commit 0b906cb

Browse files
Merge pull request #455 from sf-aastha-paruthi/u/aparuthi/fileviewfix
@W-20469531 In Assessment Report - For Experience Pages, difference in changes column is not getting populated
2 parents 7a62732 + ba39c20 commit 0b906cb

File tree

5 files changed

+73
-40
lines changed

5 files changed

+73
-40
lines changed

src/migration/related/ExperienceSiteMigration.ts

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ export class ExperienceSiteMigration extends BaseRelatedObjectMigration {
103103
}
104104
try {
105105
const experienceSitePageInfo = this.processExperienceSite(file, type);
106-
if (experienceSitePageInfo?.hasOmnistudioContent === true) {
106+
if (experienceSitePageInfo?.hasOmnistudioContentWithChanges === true) {
107107
Logger.logVerbose(this.messages.getMessage('experienceSiteWithOmniWrapperSuccessfullyProcessed'));
108108
experienceSiteAssessmentInfo.experienceSiteAssessmentPageInfos.push(experienceSitePageInfo);
109109
} else {
@@ -136,7 +136,7 @@ export class ExperienceSiteMigration extends BaseRelatedObjectMigration {
136136
infos: [],
137137
path: file.location,
138138
diff: JSON.stringify([]),
139-
hasOmnistudioContent: false,
139+
hasOmnistudioContentWithChanges: false,
140140
status: type === this.ASSESS ? 'Ready for migration' : 'Successfully migrated',
141141
};
142142

@@ -150,7 +150,7 @@ export class ExperienceSiteMigration extends BaseRelatedObjectMigration {
150150
// TODO - When will it be Flexcard
151151

152152
if (regions === undefined) {
153-
experienceSiteAssessmentInfo.hasOmnistudioContent = false;
153+
experienceSiteAssessmentInfo.hasOmnistudioContentWithChanges = false;
154154
return experienceSiteAssessmentInfo;
155155
}
156156

@@ -177,6 +177,17 @@ export class ExperienceSiteMigration extends BaseRelatedObjectMigration {
177177

178178
Logger.logVerbose(this.messages.getMessage('printDifference', [JSON.stringify(difference)]));
179179

180+
// If there are no differences, mark as not having OmniStudio content to exclude from report
181+
// Only exclude if status is 'Ready for migration' or 'Successfully migrated' (no warnings/errors)
182+
if (
183+
difference.length === 0 &&
184+
(experienceSiteAssessmentInfo.status === 'Ready for migration' ||
185+
experienceSiteAssessmentInfo.status === 'Successfully migrated')
186+
) {
187+
experienceSiteAssessmentInfo.hasOmnistudioContentWithChanges = false;
188+
return experienceSiteAssessmentInfo;
189+
}
190+
180191
if (type === this.MIGRATE && normalizedOriginalFileContent !== noarmalizeUpdatedFileContent) {
181192
Logger.logVerbose(this.messages.getMessage('updatingFile'));
182193
fs.writeFileSync(file.location, noarmalizeUpdatedFileContent, 'utf8');
@@ -196,7 +207,7 @@ export class ExperienceSiteMigration extends BaseRelatedObjectMigration {
196207
infos: [],
197208
path: file.location,
198209
diff: JSON.stringify([]),
199-
hasOmnistudioContent: false,
210+
hasOmnistudioContentWithChanges: false,
200211
status: 'Failed',
201212
};
202213

@@ -242,7 +253,7 @@ export class ExperienceSiteMigration extends BaseRelatedObjectMigration {
242253
// Check for legacy wrapper component
243254
if (component.componentName === lookupComponentName) {
244255
Logger.logVerbose(this.messages.getMessage('omniWrapperFound'));
245-
experienceSiteAssessmentInfo.hasOmnistudioContent = true;
256+
experienceSiteAssessmentInfo.hasOmnistudioContentWithChanges = true;
246257

247258
this.updateComponentAndItsAttributes(
248259
component,
@@ -259,7 +270,7 @@ export class ExperienceSiteMigration extends BaseRelatedObjectMigration {
259270
// Check for new LWC components that need reference updates
260271
if (this.isOmnistudioStandardWrapper(component.componentName)) {
261272
Logger.logVerbose(`Found Omnistudio component: ${component.componentName}`);
262-
experienceSiteAssessmentInfo.hasOmnistudioContent = true;
273+
experienceSiteAssessmentInfo.hasOmnistudioContentWithChanges = true;
263274

264275
this.updateOmnistudioComponentReferences(component, experienceSiteAssessmentInfo, storage, type);
265276

src/migration/related/FlexipageMigration.ts

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -206,12 +206,22 @@ export class FlexipageMigration extends BaseRelatedObjectMigration {
206206
const diff = new FileDiffUtil().getXMLDiff(normalizedOriginal, normalizedModified);
207207
Logger.logVerbose(this.messages.getMessage('generatedDiffForFile', [fileName]));
208208

209+
const status = mode === 'assess' ? 'Ready for migration' : 'Successfully migrated';
210+
211+
// Check if there are any actual changes (where old !== new)
212+
const hasActualChanges = diff.some((d) => d.old !== d.new);
213+
214+
// Only exclude if there are no changes AND status indicates success (no warnings/errors)
215+
if (!hasActualChanges && (status === 'Ready for migration' || status === 'Successfully migrated')) {
216+
return null;
217+
}
218+
209219
return {
210220
path: filePath,
211221
name: fileName,
212222
diff: JSON.stringify(diff),
213223
errors: [],
214-
status: mode === 'assess' ? 'Ready for migration' : 'Successfully migrated',
224+
status,
215225
};
216226
}
217227
}

src/utils/interfaces.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,7 @@ export interface FileParser {
204204
export interface ExperienceSiteAssessmentPageInfo extends FileChangeInfo {
205205
warnings: string[];
206206
infos: string[];
207-
hasOmnistudioContent: boolean;
207+
hasOmnistudioContentWithChanges: boolean;
208208
errors: string[];
209209
status: 'Ready for migration' | 'Failed' | 'Successfully migrated' | 'Needs manual intervention' | 'Skipped';
210210
}

test/migration/related/ExperienceSiteMigration.test.ts

Lines changed: 40 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,7 @@ describe('ExperienceSiteMigration', () => {
183183

184184
processFileStub.onCall(0).returns({
185185
name: 'site1.json',
186-
hasOmnistudioContent: true,
186+
hasOmnistudioContentWithChanges: true,
187187
warnings: [],
188188
infos: [],
189189
path: '/test/path/site1.json',
@@ -193,7 +193,7 @@ describe('ExperienceSiteMigration', () => {
193193
});
194194
processFileStub.onCall(1).returns({
195195
name: 'site3.json',
196-
hasOmnistudioContent: false,
196+
hasOmnistudioContentWithChanges: false,
197197
warnings: [],
198198
infos: [],
199199
path: '/test/path/site3.json',
@@ -208,7 +208,7 @@ describe('ExperienceSiteMigration', () => {
208208
// Assert
209209
expect(fileUtilStub.calledOnce).to.be.true;
210210
expect(processFileStub.calledTwice).to.be.true; // Only called for JSON files
211-
expect(result).to.have.length(1); // Only files with hasOmnistudioContent: true
211+
expect(result).to.have.length(1); // Only files with hasOmnistudioContentWithChanges: true
212212
expect(result[0].experienceSiteAssessmentPageInfos[0].name).to.equal('site1.json');
213213
});
214214

@@ -229,7 +229,7 @@ describe('ExperienceSiteMigration', () => {
229229
expect(result[0].experienceSiteAssessmentPageInfos[0].name).to.equal('error.json');
230230
expect(result[0].experienceSiteAssessmentPageInfos[0].status).to.equal('Failed');
231231
expect(result[0].experienceSiteAssessmentPageInfos[0].warnings).to.include('Unknown error occurred');
232-
expect(result[0].experienceSiteAssessmentPageInfos[0].hasOmnistudioContent).to.be.false;
232+
expect(result[0].experienceSiteAssessmentPageInfos[0].hasOmnistudioContentWithChanges).to.be.false;
233233
expect((Logger.error as sinon.SinonStub).called).to.be.true;
234234
});
235235
});
@@ -256,7 +256,11 @@ describe('ExperienceSiteMigration', () => {
256256
sinon.stub(require('fs'), 'writeFileSync').value(fsWriteStub);
257257

258258
storageUtilStub = sinon.stub(StorageUtil, 'getOmnistudioMigrationStorage');
259-
sinon.stub(FileDiffUtil.prototype, 'getFileDiff').returns([]);
259+
// Mock FileDiffUtil to return a non-empty diff (indicating changes were made)
260+
sinon.stub(FileDiffUtil.prototype, 'getFileDiff').returns([
261+
{ old: 'line1', new: 'line1' },
262+
{ old: 'oldline', new: 'newline' },
263+
]);
260264
});
261265

262266
it('should replace vlocityLWCOmniWrapper component with runtime_omnistudio_omniscript', () => {
@@ -286,7 +290,7 @@ describe('ExperienceSiteMigration', () => {
286290
const result = experienceSiteMigration.processExperienceSite(mockFile, Migrate);
287291

288292
// Assert
289-
expect(result.hasOmnistudioContent).to.be.true;
293+
expect(result.hasOmnistudioContentWithChanges).to.be.true;
290294
expect(fsWriteStub.calledOnce).to.be.true;
291295

292296
// Verify the file content was updated
@@ -303,19 +307,19 @@ describe('ExperienceSiteMigration', () => {
303307
expect(component.componentAttributes.theme).to.equal('lightning'); // Preserved from original layout
304308
});
305309

306-
it('should return hasOmnistudioContent false when no vlocityLWCOmniWrapper found', () => {
310+
it('should return hasOmnistudioContentWithChanges false when no vlocityLWCOmniWrapper found', () => {
307311
// Arrange
308312
fsReadStub.returns(JSON.stringify(sampleExperienceSiteJsonWithoutWrapper));
309313

310314
// Act
311315
const result = experienceSiteMigration.processExperienceSite(mockFile, Migrate);
312316

313317
// Assert
314-
expect(result.hasOmnistudioContent).to.be.false;
318+
expect(result.hasOmnistudioContentWithChanges).to.be.false;
315319
expect(fsWriteStub.called).to.be.false; // No changes made
316320
});
317321

318-
it('should return hasOmnistudioContent false when regions are undefined', () => {
322+
it('should return hasOmnistudioContentWithChanges false when regions are undefined', () => {
319323
// Arrange
320324
const siteWithoutRegions = { ...sampleExperienceSiteJson, regions: undefined };
321325
fsReadStub.returns(JSON.stringify(siteWithoutRegions));
@@ -324,7 +328,7 @@ describe('ExperienceSiteMigration', () => {
324328
const result = experienceSiteMigration.processExperienceSite(mockFile, Migrate);
325329

326330
// Assert
327-
expect(result.hasOmnistudioContent).to.be.false;
331+
expect(result.hasOmnistudioContentWithChanges).to.be.false;
328332
expect(fsWriteStub.called).to.be.false;
329333
});
330334

@@ -342,7 +346,7 @@ describe('ExperienceSiteMigration', () => {
342346
const result = experienceSiteMigration.processExperienceSite(mockFile, Migrate);
343347

344348
// Assert
345-
expect(result.hasOmnistudioContent).to.be.true;
349+
expect(result.hasOmnistudioContentWithChanges).to.be.true;
346350
expect(result.warnings).to.have.length(1);
347351
expect(result.warnings[0]).to.include('TestSubtype:English Needs manual intervention');
348352
});
@@ -374,7 +378,7 @@ describe('ExperienceSiteMigration', () => {
374378
const result = experienceSiteMigration.processExperienceSite(mockFile, Migrate);
375379

376380
// Assert
377-
expect(result.hasOmnistudioContent).to.be.true;
381+
expect(result.hasOmnistudioContentWithChanges).to.be.true;
378382
expect(result.warnings).to.have.length(1);
379383
});
380384

@@ -405,7 +409,7 @@ describe('ExperienceSiteMigration', () => {
405409
const result = experienceSiteMigration.processExperienceSite(mockFile, Migrate);
406410

407411
// Assert
408-
expect(result.hasOmnistudioContent).to.be.true;
412+
expect(result.hasOmnistudioContentWithChanges).to.be.true;
409413
expect(result.warnings).to.have.length(1);
410414
expect(result.warnings[0]).to.include('Needs manual intervention as duplicated key found');
411415
});
@@ -427,7 +431,7 @@ describe('ExperienceSiteMigration', () => {
427431
const result = experienceSiteMigration.processExperienceSite(mockFile, Migrate);
428432

429433
// Assert
430-
expect(result.hasOmnistudioContent).to.be.true;
434+
expect(result.hasOmnistudioContentWithChanges).to.be.true;
431435
expect(result.warnings).to.have.length(1);
432436
expect(result.warnings[0]).to.include('The Target Name is empty. Check your Experience Cloud site configuration');
433437
});
@@ -450,7 +454,7 @@ describe('ExperienceSiteMigration', () => {
450454
const result = experienceSiteMigration.processExperienceSite(mockFile, Migrate);
451455

452456
// Assert
453-
expect(result.hasOmnistudioContent).to.be.true;
457+
expect(result.hasOmnistudioContentWithChanges).to.be.true;
454458
// Should not throw an error and continue processing
455459
});
456460

@@ -514,7 +518,11 @@ describe('ExperienceSiteMigration', () => {
514518
sinon.stub(require('fs'), 'writeFileSync').value(fsWriteStub);
515519

516520
storageUtilStub = sinon.stub(StorageUtil, 'getOmnistudioAssessmentStorage');
517-
sinon.stub(FileDiffUtil.prototype, 'getFileDiff').returns([]);
521+
// Mock FileDiffUtil to return a non-empty diff (indicating changes were made)
522+
sinon.stub(FileDiffUtil.prototype, 'getFileDiff').returns([
523+
{ old: 'line1', new: 'line1' },
524+
{ old: 'oldline', new: 'newline' },
525+
]);
518526
});
519527

520528
it('should use assessment storage instead of migration storage in assess mode', () => {
@@ -545,7 +553,7 @@ describe('ExperienceSiteMigration', () => {
545553

546554
// Assert
547555
expect(storageUtilStub.calledOnce).to.be.true;
548-
expect(result.hasOmnistudioContent).to.be.true;
556+
expect(result.hasOmnistudioContentWithChanges).to.be.true;
549557
expect(result.warnings).to.have.length(0);
550558
});
551559

@@ -564,7 +572,7 @@ describe('ExperienceSiteMigration', () => {
564572
const result = experienceSiteMigration.processExperienceSite(mockFile, Assess);
565573

566574
// Assert
567-
expect(result.hasOmnistudioContent).to.be.true;
575+
expect(result.hasOmnistudioContentWithChanges).to.be.true;
568576
expect(result.warnings).to.have.length(1);
569577
expect(result.warnings[0]).to.include('TestSubtype:English Needs manual intervention');
570578
});
@@ -596,7 +604,7 @@ describe('ExperienceSiteMigration', () => {
596604
const result = experienceSiteMigration.processExperienceSite(mockFile, Assess);
597605

598606
// Assert
599-
expect(result.hasOmnistudioContent).to.be.true;
607+
expect(result.hasOmnistudioContentWithChanges).to.be.true;
600608
expect(result.warnings).to.have.length(1);
601609
expect(result.warnings[0]).to.include('Needs manual intervention as migration failed');
602610
});
@@ -628,12 +636,12 @@ describe('ExperienceSiteMigration', () => {
628636
const result = experienceSiteMigration.processExperienceSite(mockFile, Assess);
629637

630638
// Assert
631-
expect(result.hasOmnistudioContent).to.be.true;
639+
expect(result.hasOmnistudioContentWithChanges).to.be.true;
632640
expect(result.warnings).to.have.length(1);
633641
expect(result.warnings[0]).to.include('Needs manual intervention as duplicated key found');
634642
});
635643

636-
it('should return false for hasOmnistudioContent when no wrapper component found in assess mode', () => {
644+
it('should return false for hasOmnistudioContentWithChanges when no wrapper component found in assess mode', () => {
637645
// Arrange
638646
const mockStorage: MigrationStorage = {
639647
osStorage: new Map<string, OmniScriptStorage>(),
@@ -647,7 +655,7 @@ describe('ExperienceSiteMigration', () => {
647655
const result = experienceSiteMigration.processExperienceSite(mockFile, Assess);
648656

649657
// Assert
650-
expect(result.hasOmnistudioContent).to.be.false;
658+
expect(result.hasOmnistudioContentWithChanges).to.be.false;
651659
expect(result.warnings).to.have.length(0);
652660
expect(fsWriteStub.called).to.be.false;
653661
});
@@ -712,7 +720,7 @@ describe('ExperienceSiteMigration', () => {
712720
const result = experienceSiteMigration.processExperienceSite(mockFile, Assess);
713721

714722
// Assert
715-
expect(result.hasOmnistudioContent).to.be.true;
723+
expect(result.hasOmnistudioContentWithChanges).to.be.true;
716724
expect(result.warnings).to.have.length(1); // Only the duplicate should generate a warning
717725
expect(result.warnings[0]).to.include('DuplicateSubtype:English');
718726
expect(result.warnings[0]).to.include('duplicated key found');
@@ -732,7 +740,7 @@ describe('ExperienceSiteMigration', () => {
732740
const result = experienceSiteMigration.processExperienceSite(mockFile, Assess);
733741

734742
// Assert
735-
expect(result.hasOmnistudioContent).to.be.true;
743+
expect(result.hasOmnistudioContentWithChanges).to.be.true;
736744
expect(result.warnings).to.have.length(1);
737745
expect(result.warnings[0]).to.include('Needs manual intervention');
738746
expect(result.status).to.equal('Needs manual intervention');
@@ -782,7 +790,11 @@ describe('ExperienceSiteMigration', () => {
782790
sinon.stub(require('fs'), 'writeFileSync').value(fsWriteStub);
783791

784792
storageUtilStub = sinon.stub(StorageUtil, 'getOmnistudioMigrationStorage');
785-
sinon.stub(FileDiffUtil.prototype, 'getFileDiff').returns([]);
793+
// Mock FileDiffUtil to return a non-empty diff (indicating changes were made)
794+
sinon.stub(FileDiffUtil.prototype, 'getFileDiff').returns([
795+
{ old: 'line1', new: 'line1' },
796+
{ old: 'oldline', new: 'newline' },
797+
]);
786798
});
787799

788800
it('should process standard data model OmniScript component successfully', () => {
@@ -838,7 +850,7 @@ describe('ExperienceSiteMigration', () => {
838850
const result = standardDataModelExperienceSiteMigration.processExperienceSite(mockFile, Migrate);
839851

840852
// Assert
841-
expect(result.hasOmnistudioContent).to.be.true;
853+
expect(result.hasOmnistudioContentWithChanges).to.be.true;
842854
expect(fsWriteStub.calledOnce).to.be.true;
843855

844856
// Verify the file content was updated
@@ -889,7 +901,7 @@ describe('ExperienceSiteMigration', () => {
889901
const result = standardDataModelExperienceSiteMigration.processExperienceSite(mockFile, Migrate);
890902

891903
// Assert
892-
expect(result.hasOmnistudioContent).to.be.true;
904+
expect(result.hasOmnistudioContentWithChanges).to.be.true;
893905
expect(result.warnings).to.have.length(1);
894906
expect(result.warnings[0]).to.include('standard-test.json needs manual intervention for configuration');
895907
expect(result.status).to.equal('Skipped');
@@ -939,7 +951,7 @@ describe('ExperienceSiteMigration', () => {
939951
const result = standardDataModelExperienceSiteMigration.processExperienceSite(mockFile, Migrate);
940952

941953
// Assert
942-
expect(result.hasOmnistudioContent).to.be.true;
954+
expect(result.hasOmnistudioContentWithChanges).to.be.true;
943955
expect(fsWriteStub.calledOnce).to.be.true;
944956

945957
// Verify the file content was updated

test/migration/related/FlexipageMigration.test.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -104,8 +104,8 @@ describe('FlexipageMigration', () => {
104104

105105
// Mock FileDiffUtil
106106
mockFileDiffUtil = {
107-
getFileDiff: sandbox.stub().returns('mock-diff'),
108-
getXMLDiff: sandbox.stub().returns('mock-diff'),
107+
getFileDiff: sandbox.stub().returns([{ old: 'old-line', new: 'new-line' }]),
108+
getXMLDiff: sandbox.stub().returns([{ old: 'old-line', new: 'new-line' }]),
109109
};
110110

111111
// Mock transformFlexipageBundle
@@ -324,7 +324,7 @@ describe('FlexipageMigration', () => {
324324
expect(result).to.deep.include({
325325
path: filePath,
326326
name: fileName,
327-
diff: JSON.stringify('mock-diff'),
327+
diff: JSON.stringify([{ old: 'old-line', new: 'new-line' }]),
328328
errors: [],
329329
status: 'Ready for migration',
330330
});
@@ -352,7 +352,7 @@ describe('FlexipageMigration', () => {
352352
expect(result).to.deep.include({
353353
path: filePath,
354354
name: fileName,
355-
diff: JSON.stringify('mock-diff'),
355+
diff: JSON.stringify([{ old: 'old-line', new: 'new-line' }]),
356356
errors: [],
357357
status: 'Successfully migrated',
358358
});

0 commit comments

Comments
 (0)