|
1 | | -import { UnparsedApexBundle, UnparsedCustomObjectBundle } from '../../shared/types'; |
| 1 | +import { |
| 2 | + UnparsedApexBundle, |
| 3 | + UnparsedCustomFieldBundle, |
| 4 | + UnparsedCustomObjectBundle, |
| 5 | + UnparsedSourceBundle, |
| 6 | +} from '../../shared/types'; |
2 | 7 | import { ChangeLogPageData, generateChangeLog } from '../generate-change-log'; |
3 | 8 | import { assertEither } from '../../test-helpers/assert-either'; |
4 | 9 | import { isSkip } from '../../shared/utils'; |
@@ -27,31 +32,31 @@ function customObjectGenerator( |
27 | 32 | </CustomObject>`; |
28 | 33 | } |
29 | 34 |
|
30 | | -// export const customField = ` |
31 | | -// <?xml version="1.0" encoding="UTF-8"?> |
32 | | -// <CustomField xmlns="http://soap.sforce.com/2006/04/metadata"> |
33 | | -// <fullName>PhotoUrl__c</fullName> |
34 | | -// <externalId>false</externalId> |
35 | | -// <label>PhotoUrl</label> |
36 | | -// <required>false</required> |
37 | | -// <trackFeedHistory>false</trackFeedHistory> |
38 | | -// <type>Url</type> |
39 | | -// <description>A URL that points to a photo</description> |
40 | | -// </CustomField>`; |
41 | | -// |
42 | | -// function unparsedFieldBundleFromRawString(meta: { |
43 | | -// rawContent: string; |
44 | | -// filePath: string; |
45 | | -// parentName: string; |
46 | | -// }): UnparsedCustomFieldBundle { |
47 | | -// return { |
48 | | -// type: 'customfield', |
49 | | -// name: 'TestField__c', |
50 | | -// filePath: meta.filePath, |
51 | | -// content: meta.rawContent, |
52 | | -// parentName: meta.parentName, |
53 | | -// }; |
54 | | -// } |
| 35 | +export const customField = ` |
| 36 | +<?xml version="1.0" encoding="UTF-8"?> |
| 37 | +<CustomField xmlns="http://soap.sforce.com/2006/04/metadata"> |
| 38 | + <fullName>PhotoUrl__c</fullName> |
| 39 | + <externalId>false</externalId> |
| 40 | + <label>PhotoUrl</label> |
| 41 | + <required>false</required> |
| 42 | + <trackFeedHistory>false</trackFeedHistory> |
| 43 | + <type>Url</type> |
| 44 | + <description>A URL that points to a photo</description> |
| 45 | +</CustomField>`; |
| 46 | + |
| 47 | +function unparsedFieldBundleFromRawString(meta: { |
| 48 | + rawContent: string; |
| 49 | + filePath: string; |
| 50 | + parentName: string; |
| 51 | +}): UnparsedCustomFieldBundle { |
| 52 | + return { |
| 53 | + type: 'customfield', |
| 54 | + name: 'TestField__c', |
| 55 | + filePath: meta.filePath, |
| 56 | + content: meta.rawContent, |
| 57 | + parentName: meta.parentName, |
| 58 | + }; |
| 59 | +} |
55 | 60 |
|
56 | 61 | describe('when generating a changelog', () => { |
57 | 62 | it('should not skip when skipIfNoChanges, even if there are no changes', async () => { |
@@ -366,32 +371,72 @@ describe('when generating a changelog', () => { |
366 | 371 | }); |
367 | 372 | }); |
368 | 373 |
|
369 | | - // describe('that includes modifications to custom fields', () => { |
370 | | - // it('should include a section for new or modified custom fields', async () => { |
371 | | - // const oldObjectSource = customObjectGenerator(); |
372 | | - // const newObjectSource = customObjectGenerator(); |
373 | | - // |
374 | | - // const oldBundle: UnparsedSourceBundle[] = [ |
375 | | - // { type: 'customobject', name: 'MyTestObject', content: oldObjectSource, filePath: 'MyTestObject.object' }, |
376 | | - // ]; |
377 | | - // const newBundle: UnparsedSourceBundle[] = [ |
378 | | - // { type: 'customobject', name: 'MyTestObject', content: newObjectSource, filePath: 'MyTestObject.object' }, |
379 | | - // unparsedFieldBundleFromRawString({ |
380 | | - // rawContent: customField, |
381 | | - // filePath: 'MyTestObject__c.field-meta.xml', |
382 | | - // parentName: 'MyTestObject', |
383 | | - // }), |
384 | | - // ]; |
385 | | - // |
386 | | - // const result = await generateChangeLog(oldBundle, newBundle, config)(); |
387 | | - // |
388 | | - // assertEither(result, (data) => |
389 | | - // expect((data as ChangeLogPageData).content).toContain('## New or Modified Fields in Existing Objects'), |
390 | | - // ); |
391 | | - // }); |
392 | | - // |
393 | | - // // TODO: should list new custom fields |
394 | | - // // TODO: Should list removed custom fields |
395 | | - // // TODO: Should mention custom field label modification |
396 | | - // }); |
| 374 | + describe('that includes modifications to custom fields', () => { |
| 375 | + it('should include a section for new or removed custom fields', async () => { |
| 376 | + const oldObjectSource = customObjectGenerator(); |
| 377 | + const newObjectSource = customObjectGenerator(); |
| 378 | + |
| 379 | + const oldBundle: UnparsedSourceBundle[] = [ |
| 380 | + { type: 'customobject', name: 'MyTestObject', content: oldObjectSource, filePath: 'MyTestObject.object' }, |
| 381 | + ]; |
| 382 | + const newBundle: UnparsedSourceBundle[] = [ |
| 383 | + { type: 'customobject', name: 'MyTestObject', content: newObjectSource, filePath: 'MyTestObject.object' }, |
| 384 | + unparsedFieldBundleFromRawString({ |
| 385 | + rawContent: customField, |
| 386 | + filePath: 'MyTestObject__c.field-meta.xml', |
| 387 | + parentName: 'MyTestObject', |
| 388 | + }), |
| 389 | + ]; |
| 390 | + |
| 391 | + const result = await generateChangeLog(oldBundle, newBundle, config)(); |
| 392 | + |
| 393 | + assertEither(result, (data) => |
| 394 | + expect((data as ChangeLogPageData).content).toContain('## New or Removed Fields in Existing Objects'), |
| 395 | + ); |
| 396 | + }); |
| 397 | + |
| 398 | + it('should include new custom field names', async () => { |
| 399 | + const oldObjectSource = customObjectGenerator(); |
| 400 | + const newObjectSource = customObjectGenerator(); |
| 401 | + |
| 402 | + const oldBundle: UnparsedSourceBundle[] = [ |
| 403 | + { type: 'customobject', name: 'MyTestObject', content: oldObjectSource, filePath: 'MyTestObject.object' }, |
| 404 | + ]; |
| 405 | + const newBundle: UnparsedSourceBundle[] = [ |
| 406 | + { type: 'customobject', name: 'MyTestObject', content: newObjectSource, filePath: 'MyTestObject.object' }, |
| 407 | + unparsedFieldBundleFromRawString({ |
| 408 | + rawContent: customField, |
| 409 | + filePath: 'MyTestObject__c.field-meta.xml', |
| 410 | + parentName: 'MyTestObject', |
| 411 | + }), |
| 412 | + ]; |
| 413 | + |
| 414 | + const result = await generateChangeLog(oldBundle, newBundle, config)(); |
| 415 | + |
| 416 | + assertEither(result, (data) => expect((data as ChangeLogPageData).content).toContain('New Field: TestField__c')); |
| 417 | + }); |
| 418 | + |
| 419 | + it('should include removed custom field names', async () => { |
| 420 | + const oldObjectSource = customObjectGenerator(); |
| 421 | + const newObjectSource = customObjectGenerator(); |
| 422 | + |
| 423 | + const oldBundle: UnparsedSourceBundle[] = [ |
| 424 | + { type: 'customobject', name: 'MyTestObject', content: oldObjectSource, filePath: 'MyTestObject.object' }, |
| 425 | + unparsedFieldBundleFromRawString({ |
| 426 | + rawContent: customField, |
| 427 | + filePath: 'MyTestObject__c.field-meta.xml', |
| 428 | + parentName: 'MyTestObject', |
| 429 | + }), |
| 430 | + ]; |
| 431 | + const newBundle: UnparsedSourceBundle[] = [ |
| 432 | + { type: 'customobject', name: 'MyTestObject', content: newObjectSource, filePath: 'MyTestObject.object' }, |
| 433 | + ]; |
| 434 | + |
| 435 | + const result = await generateChangeLog(oldBundle, newBundle, config)(); |
| 436 | + |
| 437 | + assertEither(result, (data) => |
| 438 | + expect((data as ChangeLogPageData).content).toContain('Removed Field: TestField__c'), |
| 439 | + ); |
| 440 | + }); |
| 441 | + }); |
397 | 442 | }); |
0 commit comments