Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
"id": "yaml",
"isAddressable": false,
"name": "OAS Yaml Schema",
"strictDirectoryName": true,
"suffix": "yaml",
"xmlElementName": "schema"
}
Expand Down
2 changes: 1 addition & 1 deletion src/resolve/metadataResolver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -357,7 +357,7 @@ const resolveType =
// It is likely that the metadata file is misspelled or has the wrong suffix.
// A common occurrence is that a misspelled metadata file will fall back to
// `EmailServicesFunction` because that is the default for the `.xml` suffix
if (resolvedType?.strictDirectoryName === true) {
if (resolvedType?.strictDirectoryName === true && !fsPath.split(sep).includes(resolvedType.directoryName)) {
resolvedType = undefined;
}
}
Expand Down
28 changes: 28 additions & 0 deletions test/resolve/metadataResolver.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,14 @@ import { createSandbox } from 'sinon';
import {
ComponentSet,
MetadataResolver,
presetMap,
registry,
RegistryAccess,
SourceComponent,
VirtualDirectory,
VirtualTreeContainer,
} from '../../src';
import { getEffectiveRegistry } from '../../src/registry/variants';
import {
bundle,
decomposedtoplevel,
Expand Down Expand Up @@ -1044,4 +1046,30 @@ describe('MetadataResolver', () => {
expect(components[0].name).to.equal('myComponent');
});
});

describe('decomposeExternalServiceRegistrationBeta preset', () => {
const esrRegistry = new RegistryAccess(
getEffectiveRegistry({ presets: [presetMap.get('decomposeExternalServiceRegistrationBeta')!] })
);

it('should not resolve a .yaml file outside externalServiceRegistrations as ExternalServiceRegistration', () => {
const yamlPath = join('force-app', 'main', 'default', 'customMetadata', 'stateTransition', 'transitions.yaml');
const tree = VirtualTreeContainer.fromFilePaths([yamlPath]);
const resolver = new MetadataResolver(esrRegistry, tree, false);

expect(() => resolver.getComponentsFromPath(yamlPath)).to.throw('Could not infer a metadata type');
});

it('should resolve a .yaml file inside externalServiceRegistrations as ExternalServiceRegistration', () => {
const esrDir = join('force-app', 'main', 'default', 'externalServiceRegistrations');
const yamlPath = join(esrDir, 'MyService.yaml');
const metaPath = join(esrDir, 'MyService.externalServiceRegistration-meta.xml');
const tree = VirtualTreeContainer.fromFilePaths([yamlPath, metaPath]);
const resolver = new MetadataResolver(esrRegistry, tree, false);

const components = resolver.getComponentsFromPath(yamlPath);
expect(components).to.have.lengthOf(1);
expect(components[0].type.name).to.equal('ExternalServiceRegistration');
});
});
});
Loading