Merge pull request #15163 from RoadieHQ/show-array-types

show array of types on installed actions page
This commit is contained in:
Johan Haals
2022-12-12 13:35:40 +01:00
committed by GitHub
3 changed files with 53 additions and 1 deletions
+5
View File
@@ -0,0 +1,5 @@
---
'@backstage/plugin-scaffolder': patch
---
Show input type array correctly on installed actions page.
@@ -115,6 +115,48 @@ describe('TemplatePage', () => {
expect(rendered.getByText('Test output')).toBeInTheDocument();
});
it('renders action with multipel input types', async () => {
scaffolderApiMock.listActions.mockResolvedValue([
{
id: 'test',
description: 'example description',
schema: {
input: {
type: 'object',
required: ['foobar'],
properties: {
foobar: {
title: 'Test title',
type: ['array', 'number'],
},
},
},
output: {
type: 'object',
properties: {
buzz: {
title: 'Test output',
type: 'string',
},
},
},
},
},
]);
const rendered = await renderInTestApp(
<ApiProvider apis={apis}>
<ActionsPage />
</ApiProvider>,
{
mountedRoutes: {
'/create/actions': rootRouteRef,
},
},
);
expect(rendered.getByText('array')).toBeInTheDocument();
expect(rendered.getByText('number')).toBeInTheDocument();
});
it('renders action with oneOf input', async () => {
scaffolderApiMock.listActions.mockResolvedValue([
{
@@ -22,6 +22,7 @@ import {
Table,
TableBody,
Box,
Chip,
TableCell,
TableContainer,
TableHead,
@@ -107,7 +108,11 @@ export const ActionsPage = () => {
<TableCell>{props.title}</TableCell>
<TableCell>{props.description}</TableCell>
<TableCell>
<span className={classes.code}>{props.type}</span>
<>
{[props.type].flat().map(type => (
<Chip label={type} />
))}
</>
</TableCell>
</TableRow>
);