Skip to content

Commit 7d9b736

Browse files
authored
feat(@W-17728287): introducing lwc content type in site metadata (#1513)
1 parent 9282375 commit 7d9b736

File tree

2 files changed

+40
-1
lines changed

2 files changed

+40
-1
lines changed

src/resolve/adapters/digitalExperienceSourceAdapter.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ export class DigitalExperienceSourceAdapter extends BundleSourceAdapter {
124124

125125
protected parseMetadataXml(path: SourcePath): MetadataXml | undefined {
126126
const xml = super.parseMetadataXml(path);
127-
if (xml) {
127+
if (xml && this.isBundleType()) {
128128
return {
129129
fullName: this.getBundleName(path),
130130
suffix: xml.suffix,

test/resolve/adapters/digitalExperienceSourceAdapter.test.ts

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,12 @@ describe('DigitalExperienceSourceAdapter', () => {
3030
const HOME_VIEW_MOBILE_VARIANT_FILE = join(HOME_VIEW_MOBILE_PATH, 'mobile.json');
3131
const HOME_VIEW_TABLET_VARIANT_FILE = join(HOME_VIEW_TABLET_PATH, 'tablet.json');
3232

33+
const LWC_NAME = 'sfdc_cms__lwc/localComp';
34+
const LWC_PATH = join(BUNDLE_PATH, 'sfdc_cms__lwc', 'localComp');
35+
const LWC_META_FILE = join(LWC_PATH, DE_METAFILE);
36+
const LWC_CONTENT_FILE = join(LWC_PATH, 'content.json');
37+
const LWC_JS_META_XML_FILE = join(LWC_PATH, 'localComp.js-meta.xml');
38+
3339
const registryAccess = new RegistryAccess();
3440
const forceIgnore = new ForceIgnore();
3541
const tree = VirtualTreeContainer.fromFilePaths([
@@ -39,6 +45,9 @@ describe('DigitalExperienceSourceAdapter', () => {
3945
HOME_VIEW_FRENCH_VARIANT_FILE,
4046
HOME_VIEW_MOBILE_VARIANT_FILE,
4147
HOME_VIEW_TABLET_VARIANT_FILE,
48+
LWC_META_FILE,
49+
LWC_CONTENT_FILE,
50+
LWC_JS_META_XML_FILE,
4251
]);
4352

4453
const bundleAdapter = new DigitalExperienceSourceAdapter(
@@ -121,4 +130,34 @@ describe('DigitalExperienceSourceAdapter', () => {
121130
expect(digitalExperienceAdapter.getComponent(HOME_VIEW_TABLET_VARIANT_FILE)).to.deep.equal(component);
122131
});
123132
});
133+
134+
describe('DigitalExperienceSourceAdapter for DE LWC Content', () => {
135+
assert(registry.types.digitalexperiencebundle.children?.types.digitalexperience);
136+
const component = new SourceComponent(
137+
{
138+
name: LWC_NAME,
139+
type: registry.types.digitalexperiencebundle.children.types.digitalexperience,
140+
content: LWC_PATH,
141+
xml: LWC_META_FILE,
142+
parent: new SourceComponent(
143+
{
144+
name: BUNDLE_NAME,
145+
type: registry.types.digitalexperiencebundle,
146+
xml: BUNDLE_META_FILE,
147+
},
148+
tree,
149+
forceIgnore
150+
),
151+
parentType: registry.types.digitalexperiencebundle,
152+
},
153+
tree,
154+
forceIgnore
155+
);
156+
157+
it('should return a SourceComponent for content json and .js-meta.xml', () => {
158+
expect(digitalExperienceAdapter.getComponent(LWC_CONTENT_FILE)).to.deep.equal(component);
159+
expect(digitalExperienceAdapter.getComponent(LWC_META_FILE)).to.deep.equal(component);
160+
expect(digitalExperienceAdapter.getComponent(LWC_JS_META_XML_FILE)).to.deep.equal(component);
161+
});
162+
});
124163
});

0 commit comments

Comments
 (0)