Skip to content

Commit 1880719

Browse files
committed
Fixing issue when parsing standard object without the label property
1 parent b93331f commit 1880719

File tree

5 files changed

+4
-86
lines changed

5 files changed

+4
-86
lines changed

src/core/markdown/adapters/type-to-renderable.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -280,7 +280,7 @@ function fieldMetadataToRenderable(
280280
heading: field.label ?? field.name,
281281
description: field.description ? [field.description] : [],
282282
apiName: getApiName(field.name, config),
283-
fieldType: field.type ?? '',
283+
fieldType: field.type,
284284
};
285285
}
286286

src/core/markdown/templates/custom-object-template.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,11 @@ export const customObjectTemplate = `
1919
2020
\`{{{apiName}}}\`
2121
22+
{{#if fieldType}}
2223
**Type**
2324
2425
*{{fieldType}}*
26+
{{/if}}
2527
2628
{{#unless @last}}---{{/unless}}
2729
{{/each}}

src/core/reflection/sobject/__test__/reflect-custom-field-sources.spec.ts

Lines changed: 0 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -137,66 +137,4 @@ describe('when parsing custom field metadata', () => {
137137

138138
expect(E.isLeft(result)).toBe(true);
139139
});
140-
141-
test('An error is returned when the CustomField key is not an object', async () => {
142-
const unparsed: UnparsedCustomFieldBundle = {
143-
type: 'customfield',
144-
name: 'PhotoUrl__c',
145-
parentName: 'MyFirstObject__c',
146-
filePath: 'src/field/PhotoUrl__c.field-meta.xml',
147-
content: `
148-
<?xml version="1.0" encoding="UTF-8"?>
149-
<CustomField xmlns="http://soap.sforce.com/2006/04/metadata">invalid</CustomField>`,
150-
};
151-
152-
const result = await reflectCustomFieldSources([unparsed])();
153-
154-
expect(E.isLeft(result)).toBe(true);
155-
});
156-
157-
test('An error is returned when the CustomKey object does not contain the label key', async () => {
158-
const unparsed: UnparsedCustomFieldBundle = {
159-
type: 'customfield',
160-
name: 'PhotoUrl__c',
161-
parentName: 'MyFirstObject__c',
162-
filePath: 'src/field/PhotoUrl__c.field-meta.xml',
163-
content: `
164-
<?xml version="1.0" encoding="UTF-8"?>
165-
<CustomField xmlns="http://soap.sforce.com/2006/04/metadata">
166-
<fullName>PhotoUrl__c</fullName>
167-
<externalId>false</externalId>
168-
<required>false</required>
169-
<trackFeedHistory>false</trackFeedHistory>
170-
<type>Url</type>
171-
<description>A Photo URL field</description>
172-
</CustomField>`,
173-
};
174-
175-
const result = await reflectCustomFieldSources([unparsed])();
176-
177-
expect(E.isLeft(result)).toBe(true);
178-
});
179-
180-
test('An error is returned when the CustomKey object does not contain the type key', async () => {
181-
const unparsed: UnparsedCustomFieldBundle = {
182-
type: 'customfield',
183-
name: 'PhotoUrl__c',
184-
parentName: 'MyFirstObject__c',
185-
filePath: 'src/field/PhotoUrl__c.field-meta.xml',
186-
content: `
187-
<?xml version="1.0" encoding="UTF-8"?>
188-
<CustomField xmlns="http://soap.sforce.com/2006/04/metadata">
189-
<fullName>PhotoUrl__c</fullName>
190-
<externalId>false</externalId>
191-
<label>PhotoUrl</label>
192-
<required>false</required>
193-
<trackFeedHistory>false</trackFeedHistory>
194-
<description>A Photo URL field</description>
195-
</CustomField>`,
196-
};
197-
198-
const result = await reflectCustomFieldSources([unparsed])();
199-
200-
expect(E.isLeft(result)).toBe(true);
201-
});
202140
});

src/core/reflection/sobject/__test__/reflect-custom-object-sources.spec.ts

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -156,26 +156,4 @@ describe('when parsing SObject metadata', () => {
156156

157157
expect(E.isLeft(result)).toBe(true);
158158
});
159-
160-
test('an error is thrown when the label is missing', async () => {
161-
const sObjectContent = `
162-
<?xml version="1.0" encoding="UTF-8"?>
163-
<CustomObject xmlns="http://soap.sforce.com/2006/04/metadata">
164-
<deploymentStatus>Deployed</deploymentStatus>
165-
<description>test object for testing</description>
166-
<pluralLabel>MyFirstObjects</pluralLabel>
167-
<visibility>Public</visibility>
168-
</CustomObject>`;
169-
170-
const unparsed: UnparsedCustomObjectBundle = {
171-
type: 'customobject',
172-
name: 'MyFirstObject__c',
173-
filePath: 'src/object/MyFirstObject__c.object-meta.xml',
174-
content: sObjectContent,
175-
};
176-
177-
const result = await reflectCustomObjectSources([unparsed])();
178-
179-
expect(E.isLeft(result)).toBe(true);
180-
});
181159
});

src/core/renderables/types.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,7 @@ export type RenderableCustomField = {
190190
apiName: string;
191191
description: RenderableContent[];
192192
type: 'field';
193-
fieldType: string;
193+
fieldType?: string | null;
194194
};
195195

196196
export type Renderable = (RenderableClass | RenderableInterface | RenderableEnum | RenderableCustomObject) & {

0 commit comments

Comments
 (0)