Skip to content

Commit 5b44448

Browse files
fix: exclude folder when folder content is excluded from org connection (#1535)
1 parent 3dd6227 commit 5b44448

File tree

2 files changed

+60
-0
lines changed

2 files changed

+60
-0
lines changed

src/collections/componentSetBuilder.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -392,6 +392,9 @@ const buildMapFromMetadata = (mdOption: MetadataOption, registry: RegistryAccess
392392
if (cmp.metadataName === '*') {
393393
excludedTypes.push(cmp.type.name);
394394
}
395+
if (cmp.type.folderType) {
396+
excludedTypes.push(registry.getTypeByName(cmp.type.folderType).name);
397+
}
395398
});
396399
if (mdMap.size === 0) {
397400
// we are excluding specific metadata types from all supported types

test/collections/componentSetBuilder.test.ts

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -623,6 +623,63 @@ describe('ComponentSetBuilder', () => {
623623
expect(compSet.has(apexClassWildcardMatch)).to.equal(true);
624624
});
625625

626+
it('should exclude folder type when excluding a type that is stored in folders', async () => {
627+
const packageDir1 = path.resolve('force-app');
628+
const registry = new RegistryAccess();
629+
const dashboardType = registry.getTypeByName('Dashboard');
630+
const dashboardFolderType = registry.getTypeByName('DashboardFolder');
631+
632+
fromConnectionStub.resolves(new ComponentSet());
633+
await ComponentSetBuilder.build({
634+
sourcepath: undefined,
635+
manifest: undefined,
636+
metadata: {
637+
metadataEntries: [],
638+
excludedEntries: ['Dashboard'],
639+
directoryPaths: [packageDir1],
640+
},
641+
org: {
642+
username: testOrg.username,
643+
exclude: [],
644+
},
645+
});
646+
647+
expect(fromConnectionStub.callCount).to.equal(1);
648+
const fromConnectionArgs = fromConnectionStub.firstCall.args[0];
649+
const expectedMdTypes = Object.values(registry.getRegistry().types)
650+
.filter((t) => t.name !== dashboardType.name && t.name !== dashboardFolderType.name)
651+
.map((t) => t.name);
652+
expect(fromConnectionArgs).to.have.deep.property('metadataTypes', expectedMdTypes);
653+
});
654+
655+
it('should not exclude folder type when excluding a type that is not stored in folders', async () => {
656+
const packageDir1 = path.resolve('force-app');
657+
const registry = new RegistryAccess();
658+
const apexClassType = registry.getTypeByName('ApexClass');
659+
660+
fromConnectionStub.resolves(new ComponentSet());
661+
await ComponentSetBuilder.build({
662+
sourcepath: undefined,
663+
manifest: undefined,
664+
metadata: {
665+
metadataEntries: [],
666+
excludedEntries: ['ApexClass'],
667+
directoryPaths: [packageDir1],
668+
},
669+
org: {
670+
username: testOrg.username,
671+
exclude: [],
672+
},
673+
});
674+
675+
expect(fromConnectionStub.callCount).to.equal(1);
676+
const fromConnectionArgs = fromConnectionStub.firstCall.args[0];
677+
const expectedMdTypes = Object.values(registry.getRegistry().types)
678+
.filter((t) => t.name !== apexClassType.name)
679+
.map((t) => t.name);
680+
expect(fromConnectionArgs).to.have.deep.property('metadataTypes', expectedMdTypes);
681+
});
682+
626683
describe('Agent pseudo type', () => {
627684
const genAiPlannerId = '16jSB000000H3JFYA0';
628685
const genAiPlannerId15 = '16jSB000000H3JF';

0 commit comments

Comments
 (0)