mirror of https://github.com/grafana/grafana.git
Testing: Tidy up alerting handlers in default mock worker setup (#111292)
This commit is contained in:
parent
85534ae143
commit
310c83531c
|
@ -27,7 +27,7 @@ export const potentiallySetupMockApi = async () => {
|
|||
const { default: worker } = await import('@grafana/test-utils/worker');
|
||||
|
||||
// TODO: Generalise and move Alerting handlers into @grafana/test-utils or @grafana/alerting package
|
||||
const { default: alertingHandlers } = await import('./features/alerting/unified/mocks/server/all-handlers');
|
||||
const { alertingHandlers } = await import('./features/alerting/unified/mocks/server/all-handlers');
|
||||
worker.use(...alertingHandlers);
|
||||
|
||||
worker.start({ onUnhandledRequest: 'bypass' });
|
||||
|
|
|
@ -21,24 +21,16 @@ import searchHandlers from 'app/features/alerting/unified/mocks/server/handlers/
|
|||
import silenceHandlers from 'app/features/alerting/unified/mocks/server/handlers/silences';
|
||||
|
||||
/**
|
||||
* Array of all mock handlers that are required across Alerting tests
|
||||
* @deprecated Move to `@grafana/test-utils` instead
|
||||
* All alerting-specific handlers that are required across tests
|
||||
* @deprecated Move to `@grafana/alerting/testing` instead
|
||||
*/
|
||||
const allHandlers = [
|
||||
...accessControlHandlers,
|
||||
export const alertingHandlers = [
|
||||
...alertNotifierHandlers,
|
||||
...grafanaRulerHandlers,
|
||||
...mimirRulerHandlers,
|
||||
...alertmanagerHandlers,
|
||||
...datasourcesHandlers,
|
||||
...evalHandlers,
|
||||
...folderHandlers,
|
||||
...pluginsHandlers,
|
||||
...provisioningHandlers,
|
||||
...silenceHandlers,
|
||||
...searchHandlers,
|
||||
|
||||
...allPluginHandlers,
|
||||
...provisioningHandlers,
|
||||
|
||||
// Kubernetes-style handlers
|
||||
...timeIntervalK8sHandlers,
|
||||
|
@ -47,4 +39,22 @@ const allHandlers = [
|
|||
...routingTreeK8sHandlers,
|
||||
];
|
||||
|
||||
/**
|
||||
* Array of all mock handlers that are required across Alerting tests,
|
||||
* including some re-defined behaviour for handlers that are defined in `@grafana/test-utils`
|
||||
*
|
||||
* @deprecated Move to or use inbuilt handlers from `@grafana/test-utils` instead
|
||||
*/
|
||||
const allHandlers = [
|
||||
...alertingHandlers,
|
||||
...folderHandlers,
|
||||
...searchHandlers,
|
||||
|
||||
...accessControlHandlers,
|
||||
...allPluginHandlers,
|
||||
...datasourcesHandlers,
|
||||
...evalHandlers,
|
||||
...pluginsHandlers,
|
||||
];
|
||||
|
||||
export default allHandlers;
|
||||
|
|
|
@ -52,6 +52,7 @@ const listFoldersHandler = (folders = DEFAULT_FOLDERS) =>
|
|||
return HttpResponse.json(strippedFolders);
|
||||
});
|
||||
|
||||
/** @deprecated Move to or use inbuilt handlers from `@grafana/test-utils` instead */
|
||||
const handlers = [listFoldersHandler(), getFolderHandler()];
|
||||
|
||||
export default handlers;
|
||||
|
|
|
@ -29,6 +29,7 @@ const defaultSearchResponse = [
|
|||
export const searchHandler = (response = defaultSearchResponse) =>
|
||||
http.get(`/api/search`, () => HttpResponse.json(response));
|
||||
|
||||
/** @deprecated Move to or use inbuilt handlers from `@grafana/test-utils` instead */
|
||||
const handlers = [searchHandler()];
|
||||
|
||||
export default handlers;
|
||||
|
|
|
@ -1,5 +0,0 @@
|
|||
import { setupWorker } from 'msw/browser';
|
||||
|
||||
import allAlertingHandlers from 'app/features/alerting/unified/mocks/server/all-handlers';
|
||||
|
||||
export default setupWorker(...allAlertingHandlers);
|
Loading…
Reference in New Issue