Skip to content

Commit

Permalink
fix: resolve strictDirectoryName types in mdapi format (#601)
Browse files Browse the repository at this point in the history
* fix: resolve strictDirectoryName types in mdapi format

* chore: adding types for SDR

* fix: add test for EmailServicesFunction

Co-authored-by: Willie Ruemmele <[email protected]>
  • Loading branch information
shetzel and WillieRuemmele authored Apr 1, 2022
1 parent b34e3d2 commit 823966e
Show file tree
Hide file tree
Showing 3 changed files with 59 additions and 5 deletions.
5 changes: 2 additions & 3 deletions METADATA_SUPPORT.md
Original file line number Diff line number Diff line change
Expand Up @@ -499,8 +499,6 @@ v55 introduces the following new types. Here's their current level of support
|ExpressionSetDefinition|||
|ExpressionSetDefinitionVersion|||
|ExternalDataSrcDescriptor||Not supported, but support could be added|
|ExternalDataTranField||Not supported, but support could be added|
|ExternalDataTranObject||Not supported, but support could be added|
|FlowTest|||
|ForecastingFilter||Not supported, but support could be added|
|ForecastingFilterCondition||Not supported, but support could be added|
Expand All @@ -511,10 +509,11 @@ v55 introduces the following new types. Here's their current level of support
|MessagingChannel|undefined|undefined|
|PaymentsManagementEnabledSettings|||
|RegisteredExternalService||Not supported, but support could be added|
|SchedulingObjective||Not supported, but support could be added|
|SchedulingObjective|undefined|undefined|
|StreamingAppDataConnector||Not supported, but support could be added|
|SubscriptionManagementSettings|||
|VoiceSettings|||
|WarrantyLifecycleMgmtSettings|||

## Additional Types

Expand Down
4 changes: 2 additions & 2 deletions src/resolve/metadataResolver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -174,8 +174,8 @@ export class MetadataResolver {
// any of the following 3 options is considered a good match
// mixedContent and bundles don't have a suffix to match
['mixedContent', 'bundle'].includes(type.strategies?.adapter) ||
// the suffix matches the type we think it is
(type.suffix && fsPath.endsWith(`${type.suffix}${META_XML_SUFFIX}`)) ||
// the file suffix (in source or mdapi format) matches the type suffix we think it is
(type.suffix && [type.suffix, `${type.suffix}${META_XML_SUFFIX}`].some((s) => fsPath.endsWith(s))) ||
// the type has children and the path also includes THAT directory
(type.children?.types &&
Object.values(type.children?.types)
Expand Down
55 changes: 55 additions & 0 deletions test/resolve/metadataResolver.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,61 @@ describe('MetadataResolver', () => {
expect(access.getComponentsFromPath(path)).to.deep.equal([matchingContentFile.COMPONENT]);
});

it('Should determine type for metadata file with known suffix and strictDirectoryName', () => {
// CustomSite is an example. The conditions are:
// 1. Type has "strictDirectoryName": true
// 2. Type strategy adapter is neither "mixedContent" nor "bundle"
// 3. Type doesn't have children
// 4. mdapi format file path (E_Bikes.site)
const path = join('unpackaged', 'sites', 'E_Bikes.site');
const treeContainer = VirtualTreeContainer.fromFilePaths([path]);
const mdResolver = new MetadataResolver(undefined, treeContainer);
const expectedComponent = new SourceComponent(
{
name: 'E_Bikes',
type: registry.types.customsite,
xml: path,
},
treeContainer
);
expect(mdResolver.getComponentsFromPath(path)).to.deep.equal([expectedComponent]);
});

it('Should determine type for source file with known suffix and strictDirectoryName', () => {
// CustomSite is an example. The conditions are:
// 1. Type has "strictDirectoryName": true
// 2. Type strategy adapter is neither "mixedContent" nor "bundle"
// 3. Type doesn't have children
// 4. source format file path (E_Bikes.site-meta.xml)
const path = join('unpackaged', 'sites', 'E_Bikes.site-meta.xml');
const treeContainer = VirtualTreeContainer.fromFilePaths([path]);
const mdResolver = new MetadataResolver(undefined, treeContainer);
const expectedComponent = new SourceComponent(
{
name: 'E_Bikes',
type: registry.types.customsite,
xml: path,
},
treeContainer
);
expect(mdResolver.getComponentsFromPath(path)).to.deep.equal([expectedComponent]);
});

it('Should determine type for EmailServicesFunction metadata file (mdapi format)', () => {
const path = join('unpackaged', 'emailservices', 'MyEmailServices.xml');
const treeContainer = VirtualTreeContainer.fromFilePaths([path]);
const mdResolver = new MetadataResolver(undefined, treeContainer);
const expectedComponent = new SourceComponent(
{
name: 'MyEmailServices',
type: registry.types.emailservicesfunction,
xml: path,
},
treeContainer
);
expect(mdResolver.getComponentsFromPath(path)).to.deep.equal([expectedComponent]);
});

it('Should determine type for path of mixed content type', () => {
const path = mixedContentDirectory.MIXED_CONTENT_DIRECTORY_SOURCE_PATHS[1];
const access = testUtil.createMetadataResolver([
Expand Down

0 comments on commit 823966e

Please sign in to comment.