Skip to content

Commit 30f017b

Browse files
committed
fix: different case issue
1 parent 9869596 commit 30f017b

File tree

2 files changed

+102
-2
lines changed

2 files changed

+102
-2
lines changed

src/utils/flexipage/flexiPageTransformer.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -109,9 +109,9 @@ function createNewProps(
109109
componentInstanceProperties: FlexiComponentInstanceProperty[]
110110
): { componentName: string; identifier: string; props: Record<string, string> } {
111111
if (nameKey.startsWith(flexCardPrefix)) {
112-
return createNewPropsForFlexCard(nameKey.substring(flexCardPrefix.length), namespace, mode);
112+
return createNewPropsForFlexCard(nameKey.substring(flexCardPrefix.length).toLowerCase(), namespace, mode);
113113
}
114-
return createNewPropsForOmniScript(nameKey, namespace, mode, componentInstanceProperties);
114+
return createNewPropsForOmniScript(nameKey.toLowerCase(), namespace, mode, componentInstanceProperties);
115115
}
116116

117117
function createNewPropsForOmniScript(

test/utils/flexipage/flexiPageTransformer.test.ts

Lines changed: 100 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -287,4 +287,104 @@ describe('transformFlexipageBundle', () => {
287287
'runtime_omnistudio_flexcard1'
288288
);
289289
});
290+
291+
it('handles mixed case OmniScript names correctly', () => {
292+
// Mock StorageUtil
293+
const mockStorage = {
294+
osStorage: new Map([
295+
['mixedcase', { type: 'OSForCustomLWC', subtype: 'OSForCustomLWC', language: 'English', isDuplicate: false }],
296+
['lowercase', { type: 'OSForCustomLWC', subtype: 'OSForCustomLWC', language: 'English', isDuplicate: false }],
297+
]),
298+
fcStorage: new Map(),
299+
};
300+
sandbox.stub(StorageUtil, 'getOmnistudioMigrationStorage').returns(mockStorage);
301+
302+
const bundle: Flexipage = {
303+
flexiPageRegions: [
304+
makeRegion([
305+
makeItemInstance([{ name: 'target', value: 'type:MixedCase' }]),
306+
makeItemInstance([{ name: 'target', value: 'type:LowerCase' }]),
307+
]),
308+
],
309+
};
310+
const result = transformFlexipageBundle(bundle, namespace, 'migrate');
311+
expect(result).to.not.equal(false);
312+
const changed = result as Flexipage;
313+
314+
// All should be transformed to lowercase and find the correct storage entries
315+
expect(changed.flexiPageRegions[0].itemInstances[0].componentInstance.componentName).to.equal(targetComponentName);
316+
expect(changed.flexiPageRegions[0].itemInstances[1].componentInstance.componentName).to.equal(targetComponentName);
317+
});
318+
319+
it('handles mixed case FlexCard names correctly', () => {
320+
// Mock StorageUtil
321+
const mockStorage = {
322+
osStorage: new Map(),
323+
fcStorage: new Map([
324+
['mixedcase', { name: 'MixedCaseCard', isDuplicate: false }],
325+
['lowercase', { name: 'lowercasecard', isDuplicate: false }],
326+
]),
327+
};
328+
sandbox.stub(StorageUtil, 'getOmnistudioMigrationStorage').returns(mockStorage);
329+
330+
const bundle: Flexipage = {
331+
flexiPageRegions: [
332+
makeRegion([
333+
makeItemInstance([{ name: 'target', value: 'type:cfMixedCase' }]),
334+
makeItemInstance([{ name: 'target', value: 'type:cfLowerCase' }]),
335+
]),
336+
],
337+
};
338+
const result = transformFlexipageBundle(bundle, namespace, 'migrate');
339+
expect(result).to.not.equal(false);
340+
const changed = result as Flexipage;
341+
342+
// All should be transformed to lowercase and find the correct storage entries
343+
expect(changed.flexiPageRegions[0].itemInstances[0].componentInstance.componentName).to.equal(
344+
'runtime_omnistudio:flexcard'
345+
);
346+
expect(changed.flexiPageRegions[0].itemInstances[1].componentInstance.componentName).to.equal(
347+
'runtime_omnistudio:flexcard'
348+
);
349+
});
350+
351+
it('works with assess mode for mixed case OmniScript names', () => {
352+
// Mock StorageUtil for assess mode
353+
const mockStorage = {
354+
osStorage: new Map([
355+
['mixedcase', { type: 'OSForCustomLWC', subtype: 'OSForCustomLWC', language: 'English', isDuplicate: false }],
356+
]),
357+
fcStorage: new Map(),
358+
};
359+
sandbox.stub(StorageUtil, 'getOmnistudioAssessmentStorage').returns(mockStorage);
360+
361+
const bundle: Flexipage = {
362+
flexiPageRegions: [makeRegion([makeItemInstance([{ name: 'target', value: 'type:MixedCase' }])])],
363+
};
364+
const result = transformFlexipageBundle(bundle, namespace, 'assess');
365+
expect(result).to.not.equal(false);
366+
const changed = result as Flexipage;
367+
368+
expect(changed.flexiPageRegions[0].itemInstances[0].componentInstance.componentName).to.equal(targetComponentName);
369+
});
370+
371+
it('works with assess mode for mixed case FlexCard names', () => {
372+
// Mock StorageUtil for assess mode
373+
const mockStorage = {
374+
osStorage: new Map(),
375+
fcStorage: new Map([['mixedcase', { name: 'MixedCaseCard', isDuplicate: false }]]),
376+
};
377+
sandbox.stub(StorageUtil, 'getOmnistudioAssessmentStorage').returns(mockStorage);
378+
379+
const bundle: Flexipage = {
380+
flexiPageRegions: [makeRegion([makeItemInstance([{ name: 'target', value: 'type:cfMixedCase' }])])],
381+
};
382+
const result = transformFlexipageBundle(bundle, namespace, 'assess');
383+
expect(result).to.not.equal(false);
384+
const changed = result as Flexipage;
385+
386+
expect(changed.flexiPageRegions[0].itemInstances[0].componentInstance.componentName).to.equal(
387+
'runtime_omnistudio:flexcard'
388+
);
389+
});
290390
});

0 commit comments

Comments
 (0)