-
Notifications
You must be signed in to change notification settings - Fork 8.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add a link to documentation in the alerts and actions management UI
- Loading branch information
Showing
3 changed files
with
116 additions
and
16 deletions.
There are no files selected for viewing
45 changes: 45 additions & 0 deletions
45
x-pack/plugins/triggers_actions_ui/public/application/home.test.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License; | ||
* you may not use this file except in compliance with the Elastic License. | ||
*/ | ||
|
||
import * as React from 'react'; | ||
import { RouteComponentProps, Router } from 'react-router-dom'; | ||
import { createMemoryHistory, createLocation } from 'history'; | ||
import { mountWithIntl } from 'test_utils/enzyme_helpers'; | ||
|
||
import TriggersActionsUIHome, { MatchParams } from './home'; | ||
import { AppContextProvider } from './app_context'; | ||
import { getMockedAppDependencies } from './test_utils'; | ||
|
||
describe('home', () => { | ||
it('renders the documentation link', async () => { | ||
const deps = await getMockedAppDependencies(); | ||
|
||
const props: RouteComponentProps<MatchParams> = { | ||
history: createMemoryHistory(), | ||
location: createLocation('/'), | ||
match: { | ||
isExact: true, | ||
path: `/alerts`, | ||
url: '', | ||
params: { | ||
section: 'alerts', | ||
}, | ||
}, | ||
}; | ||
const wrapper = mountWithIntl( | ||
<Router history={deps.history}> | ||
<AppContextProvider appDeps={deps}> | ||
<TriggersActionsUIHome {...props} /> | ||
</AppContextProvider> | ||
</Router> | ||
); | ||
const documentationLink = wrapper.find('[data-test-subj="documentationLink"]'); | ||
expect(documentationLink.exists()).toBeTruthy(); | ||
expect(documentationLink.first().prop('href')).toEqual( | ||
'https://www.elastic.co/guide/en/kibana/mocked-test-branch/managing-alerts-and-actions.html' | ||
); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
41 changes: 41 additions & 0 deletions
41
x-pack/plugins/triggers_actions_ui/public/application/test_utils/index.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License; | ||
* you may not use this file except in compliance with the Elastic License. | ||
*/ | ||
|
||
import { chartPluginMock } from '../../../../../../src/plugins/charts/public/mocks'; | ||
import { dataPluginMock } from '../../../../../../src/plugins/data/public/mocks'; | ||
import { alertingPluginMock } from '../../../../alerts/public/mocks'; | ||
import { actionTypeRegistryMock } from '../action_type_registry.mock'; | ||
import { alertTypeRegistryMock } from '../alert_type_registry.mock'; | ||
import { coreMock, scopedHistoryMock } from '../../../../../../src/core/public/mocks'; | ||
|
||
export async function getMockedAppDependencies() { | ||
const coreSetupMock = coreMock.createSetup(); | ||
const actionTypeRegistry = actionTypeRegistryMock.create(); | ||
const alertTypeRegistry = alertTypeRegistryMock.create(); | ||
const [ | ||
{ | ||
chrome, | ||
docLinks, | ||
application: { capabilities, navigateToApp }, | ||
}, | ||
] = await coreSetupMock.getStartServices(); | ||
return { | ||
chrome, | ||
docLinks, | ||
dataPlugin: dataPluginMock.createStartContract(), | ||
charts: chartPluginMock.createStartContract(), | ||
alerting: alertingPluginMock.createStartContract(), | ||
toastNotifications: coreSetupMock.notifications.toasts, | ||
http: coreSetupMock.http, | ||
uiSettings: coreSetupMock.uiSettings, | ||
navigateToApp, | ||
capabilities, | ||
history: scopedHistoryMock.create(), | ||
setBreadcrumbs: jest.fn(), | ||
actionTypeRegistry: actionTypeRegistry as any, | ||
alertTypeRegistry: alertTypeRegistry as any, | ||
}; | ||
} |