feat: support title if present in schema definition

Signed-off-by: blam <ben@blam.sh>
This commit is contained in:
blam
2024-08-27 12:44:12 +02:00
parent e372b650d3
commit 2b1b0eba84
2 changed files with 33 additions and 1 deletions
@@ -435,6 +435,35 @@ describe('ReviewState', () => {
).not.toBeInTheDocument();
});
it('should allow using the title property', async () => {
const formState = {
foo: 'test',
};
const schemas: ParsedTemplateSchema[] = [
{
mergedSchema: {
type: 'object',
properties: {
foo: {
type: 'string',
title: 'Test Thing',
},
},
},
schema: {},
title: 'test',
uiSchema: {},
},
];
const { queryByRole } = render(
<ReviewState formState={formState} schemas={schemas} />,
);
expect(queryByRole('row', { name: 'Test Thing test' })).toBeInTheDocument();
});
it('should allow custom review name', async () => {
const formState = {
foo: 'test',
@@ -41,7 +41,10 @@ function processSchema(
data: formState,
});
const name = definitionInSchema?.['ui:backstage']?.review?.name ?? key;
const name =
definitionInSchema?.['ui:backstage']?.review?.name ??
definitionInSchema?.title ??
key;
if (definitionInSchema) {
const backstageReviewOptions = definitionInSchema['ui:backstage']?.review;