diff --git a/test/mock/type-constants/decomposedCustomLabelsConstant.ts b/test/mock/type-constants/decomposedCustomLabelsConstant.ts index 488f00f1bd..92422ca808 100644 --- a/test/mock/type-constants/decomposedCustomLabelsConstant.ts +++ b/test/mock/type-constants/decomposedCustomLabelsConstant.ts @@ -10,7 +10,9 @@ import { SourceComponent, VirtualTreeContainer, presetMap, RegistryAccess } from import { getEffectiveRegistry } from '../../../src/registry/variants'; // Constants for a matching content file type -const regAcc = new RegistryAccess(getEffectiveRegistry({ presets: [presetMap.get('decomposeCustomLabelsBeta2')!] })); +export const regAcc = new RegistryAccess( + getEffectiveRegistry({ presets: [presetMap.get('decomposeCustomLabelsBeta2')!] }) +); const customLabelsType = regAcc.getTypeByName('CustomLabels'); const customLabelType = regAcc.getTypeByName('CustomLabel'); diff --git a/test/mock/type-constants/decomposedPermissionSetConstant.ts b/test/mock/type-constants/decomposedPermissionSetConstant.ts index 6d732d4142..4583fa427e 100644 --- a/test/mock/type-constants/decomposedPermissionSetConstant.ts +++ b/test/mock/type-constants/decomposedPermissionSetConstant.ts @@ -9,7 +9,9 @@ import { SourceComponent, VirtualTreeContainer, presetMap, RegistryAccess } from import { getEffectiveRegistry } from '../../../src/registry/variants'; // Constants for a matching content file type -const regAcc = new RegistryAccess(getEffectiveRegistry({ presets: [presetMap.get('decomposePermissionSetBeta2')!] })); +export const regAcc = new RegistryAccess( + getEffectiveRegistry({ presets: [presetMap.get('decomposePermissionSetBeta2')!] }) +); const permissionSet = regAcc.getTypeByName('PermissionSet'); @@ -418,137 +420,3 @@ export const ONLY_PS_PARENT = new SourceComponent( }, ]) ); - -// export const THREE_CUSTOM_LABELS_CMP = new SourceComponent( -// { -// name: 'CustomLabels', -// type: permissionSet, -// xml: join('labels', MDAPI_XML_NAME), -// }, -// new VirtualTreeContainer([ -// { -// dirPath: 'permissionSet', -// children: [ -// { -// name: MDAPI_XML_NAME, -// data: Buffer.from(` -// -// -// DeleteMe -// en_US -// true -// DeleteMe -// Test -// -// -// KeepMe1 -// en_US -// true -// KeepMe1 -// Test -// -// -// KeepMe2 -// en_US -// true -// KeepMe2 -// Test -// -// `), -// }, -// ], -// }, -// ]) -// ); -// -// const ONLY_LABEL_CONTENTS = ` -// -// OnlyLabel -// en_US -// true -// OnlyLabel -// OnlyLabel -// `; -// -// export const ONLY_LABEL_CMP_IN_DEFAULT_DIR_CMP = new SourceComponent( -// { -// name: 'OnlyLabel', -// type: customLabelType, -// xml: join('main', 'default', 'labels', 'OnlyLabel.label-meta.xml'), -// }, -// new VirtualTreeContainer([ -// { -// dirPath: join('main', 'default', 'labels'), -// children: [ -// { -// name: 'OnlyLabel.label-meta.xml', -// data: Buffer.from(ONLY_LABEL_CONTENTS), -// }, -// ], -// }, -// ]) -// ); -// -// export const ONLY_LABEL_CMP_IN_ANOTHER_DIR_CMP = new SourceComponent( -// { -// name: 'OnlyLabel', -// type: customLabelType, -// xml: join('other', 'dir', 'labels', 'OnlyLabel.label-meta.xml'), -// }, -// new VirtualTreeContainer([ -// { -// dirPath: join('other', 'dir', 'labels'), -// children: [ -// { -// name: 'OnlyLabel.label-meta.xml', -// data: Buffer.from(ONLY_LABEL_CONTENTS), -// }, -// ], -// }, -// ]) -// ); -// -// export const ONLY_LABEL_NO_DIR_CMP = new SourceComponent( -// { -// name: 'OnlyLabel', -// type: customLabelType, -// xml: 'OnlyLabel.label-meta.xml', -// }, -// new VirtualTreeContainer([ -// { -// dirPath: '', -// children: [ -// { -// name: 'OnlyLabel.label-meta.xml', -// data: Buffer.from(ONLY_LABEL_CONTENTS), -// }, -// ], -// }, -// ]) -// ); -// -// export const OTHER_LABEL_CMP = new SourceComponent( -// { -// name: 'OtherLabel', -// type: customLabelType, -// xml: join('labels', 'OtherLabel.label-meta.xml'), -// }, -// new VirtualTreeContainer([ -// { -// dirPath: 'permissionSet', -// children: [ -// { -// name: 'OtherLabel.label-meta.xml', -// data: Buffer.from(` -// -// OtherLabel -// en_US -// true -// OtherLabel -// OtherLabel -// `), -// }, -// ], -// }, -// ]) -// ); diff --git a/test/resolve/metadataResolver.test.ts b/test/resolve/metadataResolver.test.ts index a6825df9e3..9d0f3f13ff 100644 --- a/test/resolve/metadataResolver.test.ts +++ b/test/resolve/metadataResolver.test.ts @@ -44,6 +44,11 @@ import { MIXED_CONTENT_DIRECTORY_VIRTUAL_FS, MIXED_CONTENT_DIRECTORY_XML_PATHS, } from '../mock/type-constants/staticresourceConstant'; +import { + SOURCE_FORMAT_PS, + regAcc as regAccPermissionSet, +} from '../mock/type-constants/decomposedPermissionSetConstant'; +// import { THREE_CUSTOM_LABELS_CMP, regAcc as regAccCustomLabels } from '../mock/type-constants/decomposedCustomLabelsConstant'; import { META_XML_SUFFIX } from '../../src/common'; import { DE_METAFILE } from '../mock/type-constants/digitalExperienceBundleConstants'; import { RegistryTestUtil } from './registryTestUtil'; @@ -94,6 +99,7 @@ describe('MetadataResolver', () => { expect(resolver.getComponentsFromPath(CONTENT_PATHS[0])).to.deep.equal([COMPONENTS[0]]); }); }); + describe('getComponentsFromPath', () => { afterEach(() => testUtil.restore()); @@ -147,6 +153,25 @@ describe('MetadataResolver', () => { expect(access.getComponentsFromPath(path)).to.deep.equal([matchingContentFile.COMPONENT]); }); + it('Should resolve decomposed permission set file to PermissionSet type', () => { + const resolver = new MetadataResolver(regAccPermissionSet, SOURCE_FORMAT_PS.tree); + const objectSettingsPath = join( + 'main', + 'default', + 'permissionsets', + 'myPS', + 'objectSettings', + 'Account.objectSettings-meta.xml' + ); + const classAccessPath = join('main', 'default', 'permissionsets', 'myPS', 'myPS.classAccess-meta.xml'); + const components = resolver.getComponentsFromPath(objectSettingsPath); + const components2 = resolver.getComponentsFromPath(classAccessPath); + expect(components).to.have.lengthOf(1); + expect(components[0].type.name).to.equal('PermissionSet'); + expect(components2).to.have.lengthOf(1); + expect(components2[0].type.name).to.equal('PermissionSet'); + }); + it('Should determine type for metadata file with known suffix and strictDirectoryName', () => { // CustomSite is an example. The conditions are: // 1. Type has "strictDirectoryName": true