@@ -4,6 +4,7 @@ import { assertEither } from '../../test-helpers/assert-either';
44import { isSkip } from '../../shared/utils' ;
55import { unparsedFieldBundleFromRawString } from '../../test-helpers/test-data-builders' ;
66import { CustomObjectXmlBuilder } from '../../test-helpers/test-data-builders/custom-object-xml-builder' ;
7+ import { CustomFieldXmlBuilder } from '../../test-helpers/test-data-builders/custom-field-xml-builder' ;
78
89const config = {
910 fileName : 'changelog' ,
@@ -347,7 +348,9 @@ describe('when generating a changelog', () => {
347348 const result = await generateChangeLog ( oldBundle , newBundle , config ) ( ) ;
348349
349350 assertEither ( result , ( data ) =>
350- expect ( ( data as ChangeLogPageData ) . content ) . toContain ( '## New or Removed Fields in Existing Objects' ) ,
351+ expect ( ( data as ChangeLogPageData ) . content ) . toContain (
352+ '## New or Removed Fields to Custom Objects or Standard Objects' ,
353+ ) ,
351354 ) ;
352355 } ) ;
353356
@@ -393,4 +396,74 @@ describe('when generating a changelog', () => {
393396 ) ;
394397 } ) ;
395398 } ) ;
399+
400+ describe ( 'that includes extension fields' , ( ) => {
401+ it ( 'does not include the fields when they are in both versions' , async ( ) => {
402+ const fieldSource = new CustomFieldXmlBuilder ( ) . build ( ) ;
403+
404+ const oldBundle : UnparsedSourceBundle [ ] = [
405+ {
406+ type : 'customfield' ,
407+ name : 'PhotoUrl__c' ,
408+ content : fieldSource ,
409+ filePath : 'PhotoUrl__c.field-meta.xml' ,
410+ parentName : 'MyTestObject' ,
411+ } ,
412+ ] ;
413+ const newBundle : UnparsedSourceBundle [ ] = [
414+ {
415+ type : 'customfield' ,
416+ name : 'PhotoUrl__c' ,
417+ content : fieldSource ,
418+ filePath : 'PhotoUrl__c.field-meta.xml' ,
419+ parentName : 'MyTestObject' ,
420+ } ,
421+ ] ;
422+
423+ const result = await generateChangeLog ( oldBundle , newBundle , config ) ( ) ;
424+
425+ assertEither ( result , ( data ) => expect ( ( data as ChangeLogPageData ) . content ) . not . toContain ( 'MyTestObject' ) ) ;
426+ assertEither ( result , ( data ) => expect ( ( data as ChangeLogPageData ) . content ) . not . toContain ( 'PhotoUrl__c' ) ) ;
427+ } ) ;
428+
429+ it ( 'includes added fields when they are not in the old version' , async ( ) => {
430+ const fieldSource = new CustomFieldXmlBuilder ( ) . build ( ) ;
431+
432+ const oldBundle : UnparsedSourceBundle [ ] = [ ] ;
433+ const newBundle : UnparsedSourceBundle [ ] = [
434+ {
435+ type : 'customfield' ,
436+ name : 'PhotoUrl__c' ,
437+ content : fieldSource ,
438+ filePath : 'PhotoUrl__c.field-meta.xml' ,
439+ parentName : 'MyTestObject' ,
440+ } ,
441+ ] ;
442+
443+ const result = await generateChangeLog ( oldBundle , newBundle , config ) ( ) ;
444+
445+ assertEither ( result , ( data ) => expect ( ( data as ChangeLogPageData ) . content ) . toContain ( 'MyTestObject' ) ) ;
446+ assertEither ( result , ( data ) => expect ( ( data as ChangeLogPageData ) . content ) . toContain ( 'PhotoUrl__c' ) ) ;
447+ } ) ;
448+
449+ it ( 'includes removed fields when they are not in the new version' , async ( ) => {
450+ const fieldSource = new CustomFieldXmlBuilder ( ) . build ( ) ;
451+
452+ const oldBundle : UnparsedSourceBundle [ ] = [
453+ {
454+ type : 'customfield' ,
455+ name : 'PhotoUrl__c' ,
456+ content : fieldSource ,
457+ filePath : 'PhotoUrl__c.field-meta.xml' ,
458+ parentName : 'MyTestObject' ,
459+ } ,
460+ ] ;
461+ const newBundle : UnparsedSourceBundle [ ] = [ ] ;
462+
463+ const result = await generateChangeLog ( oldBundle , newBundle , config ) ( ) ;
464+
465+ assertEither ( result , ( data ) => expect ( ( data as ChangeLogPageData ) . content ) . toContain ( 'MyTestObject' ) ) ;
466+ assertEither ( result , ( data ) => expect ( ( data as ChangeLogPageData ) . content ) . toContain ( 'PhotoUrl__c' ) ) ;
467+ } ) ;
468+ } ) ;
396469} ) ;
0 commit comments