-
Notifications
You must be signed in to change notification settings - Fork 39
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(#2553): remove config with no properties + support metadata check…
… for config without properties (#2641) ## Proposed change - Remove config with no properties - Support metadata check for config without properties ## Related issues <!-- Please make sure to follow the [contribution guidelines](https://github.com/amadeus-digital/Otter/blob/main/CONTRIBUTING.md) --> <!-- * 🐛 Fix #issue --> * 🐛 Fix resolves #2553 <!-- * 🚀 Feature #issue --> <!-- * 🚀 Feature resolves #issue --> <!-- * Pull Request #issue -->
- Loading branch information
Showing
5 changed files
with
154 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
94 changes: 94 additions & 0 deletions
94
...@o3r/components/builders/metadata-check/helpers/config-metadata-comparison.helper.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,94 @@ | ||
import { | ||
configMetadataComparator, | ||
} from './config-metadata-comparison.helper'; | ||
import { | ||
ComponentConfigOutput, | ||
} from '@o3r/components'; | ||
|
||
describe('configMetadataComparator', () => { | ||
describe('getArray', () => { | ||
it('should return one element per configuration property', () => { | ||
const result = configMetadataComparator.getArray([ | ||
{ properties: [ | ||
{ description: 'description', label: 'prop1', name: 'prop1', type: 'string' }, | ||
{ description: 'description', label: 'prop2', name: 'prop2', type: 'string' } | ||
], library: 'lib', name: 'ConfigWithProp', path: '', type: 'COMPONENT' } | ||
]); | ||
expect(result.length).toBe(2); | ||
result.forEach((item) => { | ||
expect(item.properties.length).toBe(1); | ||
}); | ||
}); | ||
|
||
it('should return only configurations with properties', () => { | ||
const result = configMetadataComparator.getArray([ | ||
{ properties: [], library: 'lib', name: 'ConfigWithoutProp', path: '', type: 'COMPONENT' }, | ||
{ properties: [ | ||
{ description: 'description', label: 'prop', name: 'prop', type: 'string' } | ||
], library: 'lib', name: 'ConfigWithProp', path: '', type: 'COMPONENT' } | ||
]); | ||
expect(result.length).toBe(1); | ||
expect(result[0].name).toBe('ConfigWithProp'); | ||
}); | ||
}); | ||
|
||
describe('getIdentifier', () => { | ||
it('should return an identifier with the property name', () => { | ||
const result = configMetadataComparator.getIdentifier({ | ||
properties: [ | ||
{ description: 'description', label: 'prop', name: 'prop', type: 'string' } | ||
], library: 'lib', name: 'ConfigWithProp', path: '', type: 'COMPONENT' | ||
}); | ||
expect(result).toBe('lib#ConfigWithProp prop'); | ||
}); | ||
|
||
it('should return an identifier without property name if none available', () => { | ||
const result = configMetadataComparator.getIdentifier({ | ||
properties: [], library: 'lib', name: 'ConfigWithoutProp', path: '', type: 'COMPONENT' | ||
}); | ||
expect(result).toBe('lib#ConfigWithoutProp'); | ||
}); | ||
}); | ||
|
||
describe('isMigrationDataMatch', () => { | ||
it('should return true', () => { | ||
const metadata = { | ||
properties: [ | ||
{ description: 'description', label: 'prop', name: 'prop', type: 'string' } | ||
], library: 'lib', name: 'ConfigWithProp', path: '', type: 'COMPONENT' | ||
} satisfies ComponentConfigOutput; | ||
expect(configMetadataComparator.isMigrationDataMatch( | ||
metadata, | ||
{ libraryName: 'lib', configName: 'ConfigWithProp', propertyName: 'prop' } | ||
)).toBeTruthy(); | ||
expect(configMetadataComparator.isMigrationDataMatch( | ||
metadata, | ||
{ libraryName: 'lib', configName: 'ConfigWithProp' } | ||
)).toBeTruthy(); | ||
expect(configMetadataComparator.isMigrationDataMatch( | ||
metadata, | ||
{ libraryName: 'lib' } | ||
)).toBeTruthy(); | ||
}); | ||
|
||
it('should return false', () => { | ||
const metadata = { | ||
properties: [ | ||
{ description: 'description', label: 'prop', name: 'prop', type: 'string' } | ||
], library: 'lib', name: 'ConfigWithProp', path: '', type: 'COMPONENT' | ||
} satisfies ComponentConfigOutput; | ||
expect(configMetadataComparator.isMigrationDataMatch( | ||
metadata, | ||
{ libraryName: 'anotherLib', configName: 'ConfigWithProp', propertyName: 'prop' } | ||
)).toBeFalsy(); | ||
expect(configMetadataComparator.isMigrationDataMatch( | ||
metadata, | ||
{ libraryName: 'lib', configName: 'AnotherConfig', propertyName: 'prop' } | ||
)).toBeFalsy(); | ||
expect(configMetadataComparator.isMigrationDataMatch( | ||
metadata, | ||
{ libraryName: 'lib', configName: 'ConfigWithProp', propertyName: 'anotherProp' } | ||
)).toBeFalsy(); | ||
}); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -216,7 +216,8 @@ | |
} | ||
} | ||
] | ||
} | ||
}, | ||
"minItems": 1 | ||
} | ||
} | ||
} | ||
|