Skip to content

Commit f6c2a28

Browse files
committed
chore: add a test for decomposed permsets
1 parent 935645e commit f6c2a28

File tree

3 files changed

+31
-136
lines changed

3 files changed

+31
-136
lines changed

test/mock/type-constants/decomposedCustomLabelsConstant.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,9 @@ import { SourceComponent, VirtualTreeContainer, presetMap, RegistryAccess } from
1010
import { getEffectiveRegistry } from '../../../src/registry/variants';
1111

1212
// Constants for a matching content file type
13-
const regAcc = new RegistryAccess(getEffectiveRegistry({ presets: [presetMap.get('decomposeCustomLabelsBeta2')!] }));
13+
export const regAcc = new RegistryAccess(
14+
getEffectiveRegistry({ presets: [presetMap.get('decomposeCustomLabelsBeta2')!] })
15+
);
1416

1517
const customLabelsType = regAcc.getTypeByName('CustomLabels');
1618
const customLabelType = regAcc.getTypeByName('CustomLabel');

test/mock/type-constants/decomposedPermissionSetConstant.ts

Lines changed: 3 additions & 135 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,9 @@ import { SourceComponent, VirtualTreeContainer, presetMap, RegistryAccess } from
99
import { getEffectiveRegistry } from '../../../src/registry/variants';
1010

1111
// Constants for a matching content file type
12-
const regAcc = new RegistryAccess(getEffectiveRegistry({ presets: [presetMap.get('decomposePermissionSetBeta2')!] }));
12+
export const regAcc = new RegistryAccess(
13+
getEffectiveRegistry({ presets: [presetMap.get('decomposePermissionSetBeta2')!] })
14+
);
1315

1416
const permissionSet = regAcc.getTypeByName('PermissionSet');
1517

@@ -418,137 +420,3 @@ export const ONLY_PS_PARENT = new SourceComponent(
418420
},
419421
])
420422
);
421-
422-
// export const THREE_CUSTOM_LABELS_CMP = new SourceComponent(
423-
// {
424-
// name: 'CustomLabels',
425-
// type: permissionSet,
426-
// xml: join('labels', MDAPI_XML_NAME),
427-
// },
428-
// new VirtualTreeContainer([
429-
// {
430-
// dirPath: 'permissionSet',
431-
// children: [
432-
// {
433-
// name: MDAPI_XML_NAME,
434-
// data: Buffer.from(`<?xml version="1.0" encoding="UTF-8"?>
435-
// <CustomLabels xmlns="http://soap.sforce.com/2006/04/metadata">
436-
// <labels>
437-
// <fullName>DeleteMe</fullName>
438-
// <language>en_US</language>
439-
// <protected>true</protected>
440-
// <shortDescription>DeleteMe</shortDescription>
441-
// <value>Test</value>
442-
// </labels>
443-
// <labels>
444-
// <fullName>KeepMe1</fullName>
445-
// <language>en_US</language>
446-
// <protected>true</protected>
447-
// <shortDescription>KeepMe1</shortDescription>
448-
// <value>Test</value>
449-
// </labels>
450-
// <labels>
451-
// <fullName>KeepMe2</fullName>
452-
// <language>en_US</language>
453-
// <protected>true</protected>
454-
// <shortDescription>KeepMe2</shortDescription>
455-
// <value>Test</value>
456-
// </labels>
457-
// </CustomLabels>`),
458-
// },
459-
// ],
460-
// },
461-
// ])
462-
// );
463-
//
464-
// const ONLY_LABEL_CONTENTS = `<?xml version="1.0" encoding="UTF-8"?>
465-
// <CustomLabel xmlns="http://soap.sforce.com/2006/04/metadata">
466-
// <fullName>OnlyLabel</fullName>
467-
// <language>en_US</language>
468-
// <protected>true</protected>
469-
// <shortDescription>OnlyLabel</shortDescription>
470-
// <value>OnlyLabel</value>
471-
// </CustomLabel>`;
472-
//
473-
// export const ONLY_LABEL_CMP_IN_DEFAULT_DIR_CMP = new SourceComponent(
474-
// {
475-
// name: 'OnlyLabel',
476-
// type: customLabelType,
477-
// xml: join('main', 'default', 'labels', 'OnlyLabel.label-meta.xml'),
478-
// },
479-
// new VirtualTreeContainer([
480-
// {
481-
// dirPath: join('main', 'default', 'labels'),
482-
// children: [
483-
// {
484-
// name: 'OnlyLabel.label-meta.xml',
485-
// data: Buffer.from(ONLY_LABEL_CONTENTS),
486-
// },
487-
// ],
488-
// },
489-
// ])
490-
// );
491-
//
492-
// export const ONLY_LABEL_CMP_IN_ANOTHER_DIR_CMP = new SourceComponent(
493-
// {
494-
// name: 'OnlyLabel',
495-
// type: customLabelType,
496-
// xml: join('other', 'dir', 'labels', 'OnlyLabel.label-meta.xml'),
497-
// },
498-
// new VirtualTreeContainer([
499-
// {
500-
// dirPath: join('other', 'dir', 'labels'),
501-
// children: [
502-
// {
503-
// name: 'OnlyLabel.label-meta.xml',
504-
// data: Buffer.from(ONLY_LABEL_CONTENTS),
505-
// },
506-
// ],
507-
// },
508-
// ])
509-
// );
510-
//
511-
// export const ONLY_LABEL_NO_DIR_CMP = new SourceComponent(
512-
// {
513-
// name: 'OnlyLabel',
514-
// type: customLabelType,
515-
// xml: 'OnlyLabel.label-meta.xml',
516-
// },
517-
// new VirtualTreeContainer([
518-
// {
519-
// dirPath: '',
520-
// children: [
521-
// {
522-
// name: 'OnlyLabel.label-meta.xml',
523-
// data: Buffer.from(ONLY_LABEL_CONTENTS),
524-
// },
525-
// ],
526-
// },
527-
// ])
528-
// );
529-
//
530-
// export const OTHER_LABEL_CMP = new SourceComponent(
531-
// {
532-
// name: 'OtherLabel',
533-
// type: customLabelType,
534-
// xml: join('labels', 'OtherLabel.label-meta.xml'),
535-
// },
536-
// new VirtualTreeContainer([
537-
// {
538-
// dirPath: 'permissionSet',
539-
// children: [
540-
// {
541-
// name: 'OtherLabel.label-meta.xml',
542-
// data: Buffer.from(`<?xml version="1.0" encoding="UTF-8"?>
543-
// <CustomLabel xmlns="http://soap.sforce.com/2006/04/metadata">
544-
// <fullName>OtherLabel</fullName>
545-
// <language>en_US</language>
546-
// <protected>true</protected>
547-
// <shortDescription>OtherLabel</shortDescription>
548-
// <value>OtherLabel</value>
549-
// </CustomLabel>`),
550-
// },
551-
// ],
552-
// },
553-
// ])
554-
// );

test/resolve/metadataResolver.test.ts

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,11 @@ import {
4444
MIXED_CONTENT_DIRECTORY_VIRTUAL_FS,
4545
MIXED_CONTENT_DIRECTORY_XML_PATHS,
4646
} from '../mock/type-constants/staticresourceConstant';
47+
import {
48+
SOURCE_FORMAT_PS,
49+
regAcc as regAccPermissionSet,
50+
} from '../mock/type-constants/decomposedPermissionSetConstant';
51+
// import { THREE_CUSTOM_LABELS_CMP, regAcc as regAccCustomLabels } from '../mock/type-constants/decomposedCustomLabelsConstant';
4752
import { META_XML_SUFFIX } from '../../src/common';
4853
import { DE_METAFILE } from '../mock/type-constants/digitalExperienceBundleConstants';
4954
import { RegistryTestUtil } from './registryTestUtil';
@@ -94,6 +99,7 @@ describe('MetadataResolver', () => {
9499
expect(resolver.getComponentsFromPath(CONTENT_PATHS[0])).to.deep.equal([COMPONENTS[0]]);
95100
});
96101
});
102+
97103
describe('getComponentsFromPath', () => {
98104
afterEach(() => testUtil.restore());
99105

@@ -147,6 +153,25 @@ describe('MetadataResolver', () => {
147153
expect(access.getComponentsFromPath(path)).to.deep.equal([matchingContentFile.COMPONENT]);
148154
});
149155

156+
it('Should resolve decomposed permission set file to PermissionSet type', () => {
157+
const resolver = new MetadataResolver(regAccPermissionSet, SOURCE_FORMAT_PS.tree);
158+
const objectSettingsPath = join(
159+
'main',
160+
'default',
161+
'permissionsets',
162+
'myPS',
163+
'objectSettings',
164+
'Account.objectSettings-meta.xml'
165+
);
166+
const classAccessPath = join('main', 'default', 'permissionsets', 'myPS', 'myPS.classAccess-meta.xml');
167+
const components = resolver.getComponentsFromPath(objectSettingsPath);
168+
const components2 = resolver.getComponentsFromPath(classAccessPath);
169+
expect(components).to.have.lengthOf(1);
170+
expect(components[0].type.name).to.equal('PermissionSet');
171+
expect(components2).to.have.lengthOf(1);
172+
expect(components2[0].type.name).to.equal('PermissionSet');
173+
});
174+
150175
it('Should determine type for metadata file with known suffix and strictDirectoryName', () => {
151176
// CustomSite is an example. The conditions are:
152177
// 1. Type has "strictDirectoryName": true

0 commit comments

Comments
 (0)