@@ -68,6 +68,8 @@ import {
|
||||
import { createDefaultFilters } from '../lib/templating/filters/createDefaultFilters';
|
||||
import { createRouter } from './router';
|
||||
import { DatabaseTaskStore } from '../scaffolder/tasks/DatabaseTaskStore';
|
||||
import { actionsRegistryServiceMock } from '@backstage/backend-test-utils/alpha';
|
||||
import { ActionsService } from '@backstage/backend-plugin-api/alpha';
|
||||
|
||||
function createDatabase(): DatabaseService {
|
||||
return DatabaseManager.fromConfig(
|
||||
@@ -178,6 +180,7 @@ const createTestRouter = async (
|
||||
| Record<string, TemplateGlobal>
|
||||
| CreatedTemplateGlobal[];
|
||||
autocompleteHandlers?: Record<string, AutocompleteHandler>;
|
||||
actionsRegistry?: ActionsService;
|
||||
} = {},
|
||||
) => {
|
||||
const logger = mockServices.logger.mock({
|
||||
@@ -246,6 +249,7 @@ const createTestRouter = async (
|
||||
}),
|
||||
createDebugLogAction(),
|
||||
],
|
||||
actionsRegistry: overrides.actionsRegistry ?? actionsRegistryServiceMock(),
|
||||
});
|
||||
|
||||
router.use(mockErrorHandler());
|
||||
@@ -275,6 +279,49 @@ describe('scaffolder router', () => {
|
||||
expect(response.body[0].id).toBeDefined();
|
||||
expect(response.body.length).toBe(2);
|
||||
});
|
||||
|
||||
it('should include actiosn from the remote actions registry', async () => {
|
||||
const mockActionsRegistry = actionsRegistryServiceMock();
|
||||
mockActionsRegistry.register({
|
||||
name: 'my-demo-action',
|
||||
title: 'Test',
|
||||
description: 'Test',
|
||||
schema: {
|
||||
input: z => z.object({ name: z.string() }),
|
||||
output: z => z.object({ name: z.string() }),
|
||||
},
|
||||
action: async () => ({ output: { name: 'test' } }),
|
||||
});
|
||||
const { router } = await createTestRouter({
|
||||
actionsRegistry: mockActionsRegistry,
|
||||
});
|
||||
const response = await request(router).get('/v2/actions').send();
|
||||
|
||||
expect(response.status).toEqual(200);
|
||||
expect(response.body.length).toBe(3);
|
||||
|
||||
expect(response.body).toContainEqual({
|
||||
description: 'Test',
|
||||
examples: [],
|
||||
id: 'test:my-demo-action',
|
||||
schema: {
|
||||
input: {
|
||||
$schema: 'http://json-schema.org/draft-07/schema#',
|
||||
additionalProperties: false,
|
||||
properties: { name: { type: 'string' } },
|
||||
required: ['name'],
|
||||
type: 'object',
|
||||
},
|
||||
output: {
|
||||
$schema: 'http://json-schema.org/draft-07/schema#',
|
||||
additionalProperties: false,
|
||||
properties: { name: { type: 'string' } },
|
||||
required: ['name'],
|
||||
type: 'object',
|
||||
},
|
||||
},
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('GET /v2/templating-extensions', () => {
|
||||
|
||||
Reference in New Issue
Block a user