Fix for next version of template scaffolder for the steps without properties

Signed-off-by: bnechyporenko <bnechyporenko@bol.com>
This commit is contained in:
bnechyporenko
2023-03-01 09:07:10 +01:00
parent a9b1daf979
commit d9893263ba
3 changed files with 40 additions and 1 deletions
+5
View File
@@ -0,0 +1,5 @@
---
'@backstage/plugin-scaffolder-react': major
---
Fix for next version of template scaffolder for the steps without properties
@@ -232,5 +232,39 @@ describe('useTemplateSchema', () => {
},
});
});
it('should deal with steps having no properties', () => {
const manifest: TemplateParameterSchema = {
title: 'Test Template',
description: 'Test Template Description',
steps: [
{
title: 'About step',
description:
'The first step giving the initial information about the template',
schema: {
type: 'object',
},
},
],
};
const { result } = renderHook(() => useTemplateSchema(manifest), {
wrapper: ({ children }) => (
<TestApiProvider
apis={[[featureFlagsApiRef, { isActive: () => false }]]}
>
{children}
</TestApiProvider>
),
});
const [first] = result.current.steps;
expect(first.schema).toEqual({
type: 'object',
properties: {},
});
});
});
});
@@ -62,7 +62,7 @@ export const useTemplateSchema = (
// Title is rendered at the top of the page, so let's ignore this from jsonschemaform
title: undefined,
properties: Object.fromEntries(
Object.entries(step.schema.properties as JsonObject).filter(
Object.entries((step.schema.properties || []) as JsonObject).filter(
([key]) => {
const stepFeatureFlag =
step.uiSchema[key]?.['ui:backstage']?.featureFlag;