Merge pull request #30296 from backstage/blam/changeset-cleanup
`{backend-plugin-api,backend-defaults,backend-test-utils}`: changeset cleanup
This commit is contained in:
@@ -2,4 +2,29 @@
|
||||
'@backstage/backend-test-utils': minor
|
||||
---
|
||||
|
||||
Added mock implementations for `ActionsService` and `ActionsRegistryService`
|
||||
Added an `actionsRegistryServiceMock` and `actionsServiceMock` to `/alpha` export for the experimental services.
|
||||
|
||||
This allows you to write tests for your actions by doing something similar to the following:
|
||||
|
||||
```ts
|
||||
import { actionsRegistryServiceMock } from '@backstage/backend-test-utils/alpha';
|
||||
|
||||
const mockActionsRegistry = actionsRegistryServiceMock();
|
||||
const mockCatalog = catalogServiceMock({
|
||||
entities: [
|
||||
...
|
||||
],
|
||||
});
|
||||
|
||||
createGetCatalogEntityAction({
|
||||
catalog: mockCatalog,
|
||||
actionsRegistry: mockActionsRegistry,
|
||||
});
|
||||
|
||||
await expect(
|
||||
mockActionsRegistry.invoke({
|
||||
id: 'test:get-catalog-entity',
|
||||
input: { name: 'test' },
|
||||
}),
|
||||
).resolves.toEqual(...)
|
||||
```
|
||||
|
||||
@@ -2,4 +2,30 @@
|
||||
'@backstage/backend-plugin-api': minor
|
||||
---
|
||||
|
||||
Added `coreServices.actionsRegistry` and `coreServices.actions` to allow registration of distributed actions from plugins, and the ability to invoke these actions
|
||||
Added `actionsRegistry` and `actions` experimental services to `/alpha` to allow registration of distributed actions from plugins, and the ability to invoke these actions. You can use these services by including them like the following:
|
||||
|
||||
```ts
|
||||
import {
|
||||
actionsRegistryServiceRef,
|
||||
actionsServiceRef,
|
||||
} from '@backstage/backend-plugin-api/alpha';
|
||||
|
||||
createBackendPlugin({
|
||||
pluginId: 'test-plugin',
|
||||
register({ registerInit }) {
|
||||
registerInit({
|
||||
deps: {
|
||||
actions: actionsServiceRef,
|
||||
actionsRegistry: actionsRegistryServiceRef,
|
||||
},
|
||||
async init({ actions, actionsRegistry }) {
|
||||
actionsRegistry.register({
|
||||
...,
|
||||
});
|
||||
|
||||
await actions.invoke(...);
|
||||
},
|
||||
});
|
||||
},
|
||||
});
|
||||
```
|
||||
|
||||
@@ -2,4 +2,4 @@
|
||||
'@backstage/backend-defaults': patch
|
||||
---
|
||||
|
||||
Added some default implementations for the `ActionsService` and `ActionsRegistryService` that allow registration of actions for a particular plugin.
|
||||
Added some default implementations for the experimental `ActionsService` and `ActionsRegistryService` under `/alpha` that allow registration of actions for a particular plugin.
|
||||
|
||||
Reference in New Issue
Block a user