Skip to content

Commit feb8e1d

Browse files
chore: minor fixes in expsites
1 parent 91768d6 commit feb8e1d

File tree

10 files changed

+60
-48
lines changed

10 files changed

+60
-48
lines changed

messages/assess.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -183,5 +183,6 @@
183183
"missingInfo": "Info is missing",
184184
"errorCheckingGlobalAutoNumber": "We couldn’t check whether the Global Auto Number setting is enabled: %s. Try again later.",
185185
"errorMigrationMessage": "Error migrating object: %s",
186-
"nameMappingUndefined": "Name Mapping is undefined"
186+
"nameMappingUndefined": "Name Mapping is undefined",
187+
"experienceSiteException": "Exception occurred while processing experience sites"
187188
}

messages/migrate.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -195,8 +195,8 @@
195195
"flexcardStorageProcessingStarted": "Started preparing storage for flexcards",
196196
"errorWhileProcessingFlexcardStorage": "Error occurred while processing key for flexcard storage",
197197
"missingInfo": "Info is missing",
198-
"incompleteMigrationDetected": "We couldn’t complete the migration process",
199198
"errorCheckingGlobalAutoNumber": "We couldn’t check whether the Global Auto Number setting is enabled: %s. Try again later.",
200199
"errorMigrationMessage": "Error migrating object: %s",
201-
"nameMappingUndefined": "Name Mapping is undefined"
200+
"nameMappingUndefined": "Name Mapping is undefined",
201+
"experienceSiteException": "Exception occurred while processing experience sites"
202202
}

src/commands/omnistudio/migration/assess.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ export default class Assess extends OmniStudioBaseCommand {
9898

9999
const namespace = orgs.packageDetails.namespace;
100100
let projectPath = '';
101-
const preMigrate: PreMigrate = new PreMigrate(this.org, namespace, conn, this.logger, messages, this.ux);
101+
const preMigrate: PreMigrate = new PreMigrate(namespace, conn, this.logger, messages, this.ux);
102102
if (relatedObjects) {
103103
objectsToProcess = relatedObjects.split(',').map((obj) => obj.trim());
104104
projectPath = await ProjectPathUtil.getProjectPath(messages, true);

src/commands/omnistudio/migration/migrate.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ export default class Migrate extends OmniStudioBaseCommand {
132132
let projectPath: string;
133133
let objectsToProcess: string[] = [];
134134
let targetApexNamespace: string;
135-
const preMigrate: PreMigrate = new PreMigrate(this.org, namespace, conn, this.logger, messages, this.ux);
135+
const preMigrate: PreMigrate = new PreMigrate(namespace, conn, this.logger, messages, this.ux);
136136
const isExperienceBundleMetadataAPIProgramaticallyEnabled: { value: boolean } = { value: false };
137137
if (relatedObjects) {
138138
// To-Do: Add LWC to valid options when GA is released
@@ -452,11 +452,14 @@ export default class Migrate extends OmniStudioBaseCommand {
452452
let errors: any[] = obj.errors || [];
453453
errors = errors.concat(recordResults.errors || []);
454454

455+
obj.status = 'Complete';
456+
/*
455457
obj.status = recordResults?.skipped
456458
? messages.getMessage('labelStatusSkipped')
457459
: !recordResults || recordResults.hasErrors
458-
? messages.getMessage('labelStatusFailed')
459-
: messages.getMessage('labelStatusComplete');
460+
? messages.getMessage('labelStatusFailed')
461+
: messages.getMessage('labelStatusComplete');
462+
*/
460463
obj.errors = errors;
461464
obj.migratedId = recordResults.id;
462465
obj.warnings = recordResults.warnings;

src/migration/flexcard.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -636,7 +636,7 @@ export class CardMigrationTool extends BaseMigrationTool implements MigrationToo
636636
flexCardAssessmentInfo.nameMapping === undefined ||
637637
flexCardAssessmentInfo.nameMapping === null
638638
) {
639-
Logger.logVerbose(this.messages.getMessage('missingInfo'));
639+
Logger.error(this.messages.getMessage('missingInfo'));
640640
return;
641641
}
642642

@@ -689,13 +689,13 @@ export class CardMigrationTool extends BaseMigrationTool implements MigrationToo
689689

690690
if (newrecord === undefined) {
691691
value.error = ['Migration Failed'];
692-
}
693-
694-
if (newrecord.hasErrors) {
695-
value.error = newrecord.errors;
696-
value.migrationSuccess = false;
697692
} else {
698-
value.migrationSuccess = true;
693+
if (newrecord.hasErrors) {
694+
value.error = newrecord.errors;
695+
value.migrationSuccess = false;
696+
} else {
697+
value.migrationSuccess = true;
698+
}
699699
}
700700

701701
let finalKey = `${oldrecord['Name']}`;

src/migration/omniscript.ts

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -537,6 +537,7 @@ export class OmniScriptMigrationTool extends BaseMigrationTool implements Migrat
537537

538538
private updateStorageForOmniscriptAssessment(osAssessmentInfo: OSAssessmentInfo[]): void {
539539
if (osAssessmentInfo === undefined || osAssessmentInfo === null) {
540+
Logger.error(this.messages.getMessage('missingInfo'));
540541
return;
541542
}
542543

@@ -579,7 +580,7 @@ export class OmniScriptMigrationTool extends BaseMigrationTool implements Migrat
579580
storage.osStorage.set(finalKey, value);
580581
}
581582
} catch (error) {
582-
Logger.logVerbose(error);
583+
Logger.error(error);
583584
}
584585
}
585586

@@ -905,11 +906,16 @@ export class OmniScriptMigrationTool extends BaseMigrationTool implements Migrat
905906
isDuplicate: false,
906907
};
907908

908-
if (newrecord.hasErrors) {
909-
value.error = newrecord.errors;
909+
// New record can be undefined
910+
if (newrecord === undefined) {
910911
value.migrationSuccess = false;
911912
} else {
912-
value.migrationSuccess = true;
913+
if (newrecord.hasErrors) {
914+
value.error = newrecord.errors;
915+
value.migrationSuccess = false;
916+
} else {
917+
value.migrationSuccess = true;
918+
}
913919
}
914920

915921
let finalKey = `${oldrecord[this.namespacePrefix + 'Type__c']}${

src/migration/premigrate.ts

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/* eslint-disable */
22

3-
import { Connection, Messages, Org } from '@salesforce/core';
3+
import { Connection, Messages } from '@salesforce/core';
44
import { UX } from '@salesforce/command';
55
import { Logger } from '../utils/logger';
66
import { Constants } from '../utils/constants/stringContants';
@@ -9,21 +9,9 @@ import { BaseMigrationTool } from './base';
99
import { askStringWithTimeout } from '../utils/promptUtil';
1010

1111
export class PreMigrate extends BaseMigrationTool {
12-
private readonly org: Org;
13-
1412
// Source Custom Object Names
15-
constructor(org: Org, namespace: string, connection: Connection, logger: Logger, messages: Messages, ux: UX) {
13+
constructor(namespace: string, connection: Connection, logger: Logger, messages: Messages, ux: UX) {
1614
super(namespace, connection, logger, messages, ux);
17-
this.org = org;
18-
}
19-
20-
// Just to disable org is unused error coming
21-
public printOrgDetails(): void {
22-
try {
23-
Logger.log(JSON.stringify(this.org));
24-
} catch (e) {
25-
Logger.log(e);
26-
}
2715
}
2816

2917
public async handleExperienceSitePrerequisites(

src/migration/related/ExperienceSiteMigration.ts

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,7 @@ export class ExperienceSiteMigration extends BaseRelatedObjectMigration {
9797
Logger.logVerbose(this.messages.getMessage('fileNotHavingWrapper'));
9898
}
9999
} catch (err) {
100+
this.populateExceptionInfo(file, experienceSitesAssessmentInfo);
100101
Logger.error(this.messages.getMessage('errorProcessingExperienceSite', [file.name]));
101102
Logger.error(JSON.stringify(err));
102103
}
@@ -168,6 +169,25 @@ export class ExperienceSiteMigration extends BaseRelatedObjectMigration {
168169
return experienceSiteAssessmentInfo;
169170
}
170171

172+
private populateExceptionInfo(file: File, experienceSiteAssessmentInfos: ExperienceSiteAssessmentInfo[]): void {
173+
try {
174+
const experienceSiteAssessmentInfo: ExperienceSiteAssessmentInfo = {
175+
name: file.name,
176+
warnings: [],
177+
errors: ['Unknown error occurred'],
178+
infos: [],
179+
path: file.location,
180+
diff: JSON.stringify([]),
181+
hasOmnistudioContent: false,
182+
status: 'Errors',
183+
};
184+
185+
experienceSiteAssessmentInfos.push(experienceSiteAssessmentInfo);
186+
} catch {
187+
Logger.error(this.messages.getMessage('experienceSiteException'));
188+
}
189+
}
190+
171191
private processRegion(
172192
region: ExpSiteRegion,
173193
experienceSiteAssessmentInfo: ExperienceSiteAssessmentInfo,
@@ -290,7 +310,6 @@ export class ExperienceSiteMigration extends BaseRelatedObjectMigration {
290310
Logger.logVerbose(this.messages.getMessage('processingOmniscriptComponent', [JSON.stringify(component)]));
291311
// Use storage to find the updated properties
292312
const targetDataFromStorage: OmniScriptStorage = storage.osStorage.get(targetName.toLowerCase());
293-
StorageUtil.printAssessmentStorage();
294313
Logger.logVerbose(this.messages.getMessage('targetData', [JSON.stringify(targetDataFromStorage)]));
295314

296315
if (this.shouldAddWarning(targetDataFromStorage)) {
@@ -308,7 +327,7 @@ export class ExperienceSiteMigration extends BaseRelatedObjectMigration {
308327
keysToDelete.forEach((key) => delete currentAttribute[key]);
309328

310329
currentAttribute['direction'] = 'ltr';
311-
currentAttribute['display'] = 'Display button to open Omniscript';
330+
currentAttribute['display'] = 'Display OmniScript on page';
312331
currentAttribute['inlineVariant'] = 'brand';
313332
currentAttribute['language'] =
314333
targetDataFromStorage.language === undefined ? 'English' : targetDataFromStorage.language;

src/utils/resultsbuilder/index.ts

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -251,7 +251,7 @@ export class ResultsBuilder {
251251
},
252252
assessmentDate: new Date().toString(),
253253
total: result.length,
254-
filterGroups: [createFilterGroupParam('Filter by Status', 'status', ['Complete', 'Error'])],
254+
filterGroups: [createFilterGroupParam('Filter by Status', 'status', ['Can be Automated', 'Error'])],
255255
headerGroups: [
256256
{
257257
header: [
@@ -288,16 +288,7 @@ export class ResultsBuilder {
288288
data: [
289289
createRowDataParam('name', item.name, true, 1, 1, false),
290290
createRowDataParam('path', item.path, false, 1, 1, false),
291-
createRowDataParam(
292-
'status',
293-
item.warnings ? 'Error' : 'Complete', // This is the value which the status key takes
294-
false,
295-
1,
296-
1,
297-
false,
298-
undefined,
299-
item.warnings ? 'Error' : 'Complete' // This is what gets displayed
300-
),
291+
createRowDataParam('status', item.status, false, 1, 1, false, undefined, item.status),
301292
createRowDataParam(
302293
'diff',
303294
item.name + 'diff',
@@ -306,7 +297,7 @@ export class ResultsBuilder {
306297
1,
307298
false,
308299
undefined,
309-
FileDiffUtil.getDiffHTML(item.diff, item.name)
300+
FileDiffUtil.getDiffHTML(item.diff, this.rowId.toString())
310301
),
311302
createRowDataParam(
312303
'errors',

test/migration/related/ExperienceSiteMigration.test.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -203,7 +203,11 @@ describe('ExperienceSiteMigration', () => {
203203
const result = experienceSiteMigration.processExperienceSites('/test/project', Migrate);
204204

205205
// Assert
206-
expect(result).to.be.an('array').that.is.empty;
206+
expect(result).to.be.an('array').that.has.length(1);
207+
expect(result[0].name).to.equal('error.json');
208+
expect(result[0].status).to.equal('Errors');
209+
expect(result[0].errors).to.include('Unknown error occurred');
210+
expect(result[0].hasOmnistudioContent).to.be.false;
207211
expect((Logger.error as sinon.SinonStub).called).to.be.true;
208212
});
209213
});
@@ -269,7 +273,7 @@ describe('ExperienceSiteMigration', () => {
269273
expect(component.componentAttributes.subType).to.equal('TestSubtype');
270274
expect(component.componentAttributes.language).to.equal('English');
271275
expect(component.componentAttributes.direction).to.equal('ltr');
272-
expect(component.componentAttributes.display).to.equal('Display button to open Omniscript');
276+
expect(component.componentAttributes.display).to.equal('Display OmniScript on page');
273277
expect(component.componentAttributes.theme).to.equal('lightning'); // Preserved from original layout
274278
});
275279

0 commit comments

Comments
 (0)