chore: cleanup

Signed-off-by: benjdlambert <ben@blam.sh>

Signed-off-by: benjdlambert <ben@blam.sh>
This commit is contained in:
benjdlambert
2025-06-16 15:15:47 +02:00
parent aa627f4481
commit 1feb96c828
2 changed files with 18 additions and 15 deletions
@@ -28,7 +28,7 @@ describe('MockActionsRegistry', () => {
const registry = mockServices.actionsRegistry();
registry.register({
name: 'test',
name: 'my-demo-action',
title: 'Test',
description: 'Test',
schema: {
@@ -45,7 +45,7 @@ describe('MockActionsRegistry', () => {
});
const result = await registry.invoke({
id: 'testing:test',
id: 'test:my-demo-action',
input: { name: 'test' },
});
@@ -56,7 +56,7 @@ describe('MockActionsRegistry', () => {
const registry = mockServices.actionsRegistry();
registry.register({
name: 'test',
name: 'my-demo-action',
title: 'Test',
description: 'Test',
schema: {
@@ -67,8 +67,8 @@ describe('MockActionsRegistry', () => {
});
await expect(
registry.invoke({ id: 'testing:test', input: { name: 1 } }),
).rejects.toThrow('Invalid input to action "testing:test"');
registry.invoke({ id: 'test:my-demo-action', input: { name: 1 } }),
).rejects.toThrow('Invalid input to action "test:my-demo-action"');
});
it('should throw an error when the action is not found', async () => {
@@ -83,7 +83,7 @@ describe('MockActionsRegistry', () => {
const registry = mockServices.actionsRegistry();
registry.register({
name: 'test',
name: 'my-demo-action',
title: 'Test',
description: 'Test',
schema: {
@@ -94,7 +94,7 @@ describe('MockActionsRegistry', () => {
});
await expect(registry.invoke({ id: 'test' })).rejects.toThrow(
'Action "test" not found, available actions: "testing:test"',
'Action "test" not found, available actions: "test:my-demo-action"',
);
});
@@ -102,7 +102,7 @@ describe('MockActionsRegistry', () => {
const registry = mockServices.actionsRegistry();
registry.register({
name: 'test',
name: 'my-demo-action',
title: 'Test',
description: 'Test',
schema: {
@@ -114,15 +114,15 @@ describe('MockActionsRegistry', () => {
});
await expect(
registry.invoke({ id: 'testing:test', input: { name: 1 } }),
).rejects.toThrow('Invalid output from action "testing:test"');
registry.invoke({ id: 'test:my-demo-action', input: { name: 1 } }),
).rejects.toThrow('Invalid output from action "test:my-demo-action"');
});
it('should list the actions correctly', async () => {
const registry = mockServices.actionsRegistry();
registry.register({
name: 'test',
name: 'my-demo-action',
title: 'Test',
description: 'Test',
schema: {
@@ -137,8 +137,8 @@ describe('MockActionsRegistry', () => {
expect(result).toMatchObject({
actions: [
{
id: 'testing:test',
name: 'test',
id: 'test:my-demo-action',
name: 'my-demo-action',
title: 'Test',
description: 'Test',
attributes: {
@@ -151,8 +151,11 @@ export class MockActionsRegistry
TInputSchema extends AnyZodObject,
TOutputSchema extends AnyZodObject,
>(options: ActionsRegistryActionOptions<TInputSchema, TOutputSchema>): void {
// hardcode testing: prefix similar to how the default actions registry does it
const id = `testing:${options.name}`;
// hardcode test: prefix similar to how the default actions registry does it
// and other places around the testing ecosystem:
// https://github.com/backstage/backstage/blob/a9219496d5c073aaa0b8caf32ece10455cf65e61/packages/backend-test-utils/src/next/services/mockServices.ts#L321
// https://github.com/backstage/backstage/blob/861f162b4a39117b824669d67a951ed1db142e3d/packages/backend-test-utils/src/next/wiring/ServiceFactoryTester.ts#L99
const id = `test:${options.name}`;
if (this.actions.has(id)) {
throw new Error(`Action with id "${id}" is already registered`);