Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Uptime] Fix/details page tabs #86296

Merged
merged 32 commits into from
Jan 11, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
ccf1107
Remove tabs from details page
shahzad31 Dec 15, 2020
1b9bce4
Merge branch 'master' into details-page-tabs
shahzad31 Dec 15, 2020
12b3303
update
shahzad31 Dec 15, 2020
b8977ca
fix monitord id
shahzad31 Dec 15, 2020
c6ea0a6
Merge branch 'master' into details-page-tabs
shahzad31 Dec 15, 2020
914f9b3
var name
shahzad31 Dec 15, 2020
0b9a3b2
add Uptime PageHeader tests to test for the presences of tabs or header
dominiqueclarke Dec 17, 2020
57439d6
add Uptime MonitorPageTitle test
dominiqueclarke Dec 17, 2020
b157dae
Uptime adjust auto generated monitor id regex
dominiqueclarke Dec 17, 2020
1792f21
Uptime add tests for MonitorPageTitle to test behavior for missing mo…
dominiqueclarke Dec 17, 2020
5df147c
Merge branch 'master' into fix/details-page-tabs
kibanamachine Dec 17, 2020
b1df186
remove history from MonitorPageTitle test
dominiqueclarke Dec 17, 2020
93a3441
Merge branch 'master' into fix/details-page-tabs
kibanamachine Dec 22, 2020
fd703a6
adjust uptime tabs tests
dominiqueclarke Dec 23, 2020
34cbb18
adjust MonitorPageTitle tests to mock useSelector
dominiqueclarke Dec 29, 2020
2cb107c
Merge branch 'master' into fix/details-page-tabs
kibanamachine Dec 29, 2020
c96b6e3
adjust uptime PageHeader tests
dominiqueclarke Dec 29, 2020
6d4b1cd
Merge branch 'fix/details-page-tabs' of https://github.com/dominiquec…
dominiqueclarke Dec 29, 2020
d7dcfc0
adjust import order in page_header.test
dominiqueclarke Dec 29, 2020
d0912ab
add props to Uptime PageHeader to determine render, rather than route…
dominiqueclarke Dec 30, 2020
0b21318
Merge branch 'master' into fix/details-page-tabs
kibanamachine Jan 4, 2021
6d63f3c
alphabetize props in Uptime PageHeader
dominiqueclarke Jan 4, 2021
ca811ab
Merge branch 'fix/details-page-tabs' of https://github.com/dominiquec…
dominiqueclarke Jan 4, 2021
9bac833
remove header from individual pages
dominiqueclarke Jan 5, 2021
104320f
add indepdent page header route that matches all paths
dominiqueclarke Jan 5, 2021
7e6de88
Merge branch 'master' into fix/details-page-tabs
kibanamachine Jan 5, 2021
d884b92
adjust monitor tests to use mockReduxHooks helper, and add mockReactR…
dominiqueclarke Jan 7, 2021
0791a25
Merge branch 'fix/details-page-tabs' of https://github.com/dominiquec…
dominiqueclarke Jan 7, 2021
cbca6e9
pull upstream master and resolve conflicts
dominiqueclarke Jan 7, 2021
8aae9e0
update tests
dominiqueclarke Jan 7, 2021
f294605
adjust header spacing
dominiqueclarke Jan 7, 2021
bae3e91
Merge branch 'master' into fix/details-page-tabs
kibanamachine Jan 10, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
adjust monitor tests to use mockReduxHooks helper, and add mockReactR…
…outerDomHooks
  • Loading branch information
dominiqueclarke committed Jan 7, 2021
commit d884b92c7f8dfe969b26de882c0077275136f4f0
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,10 @@

import React from 'react';
import moment from 'moment';
import * as reactRouterDom from 'react-router-dom';
import * as redux from 'react-redux';
import { Ping } from '../../../../common/runtime_types';
import { MonitorPageTitle } from '../monitor_title';
import { renderWithRouter } from '../../../lib';
import { mockReduxHooks, mockReactRouterDomHooks } from '../../../lib/helper/test_helpers';

jest.mock('react-router-dom', () => {
const originalModule = jest.requireActual('react-router-dom');
Expand All @@ -21,15 +20,6 @@ jest.mock('react-router-dom', () => {
};
});

jest.mock('react-redux', () => {
const originalModule = jest.requireActual('react-redux');

return {
...originalModule,
useSelector: jest.fn(),
};
});

describe('MonitorTitle component', () => {
const monitorName = 'sample monitor';
const defaultMonitorId = 'always-down';
Expand Down Expand Up @@ -61,29 +51,25 @@ describe('MonitorTitle component', () => {
};

beforeEach(() => {
jest.spyOn(reactRouterDom, 'useParams').mockReturnValue({ monitorId: defaultMonitorIdEncoded });
jest.spyOn(redux, 'useDispatch').mockReturnValue(jest.fn());
jest.spyOn(redux, 'useSelector').mockReturnValue(defaultMonitorStatus);
mockReactRouterDomHooks({ useParamsResponse: { monitorId: defaultMonitorIdEncoded } });
mockReduxHooks(defaultMonitorStatus);
});

it('renders the monitor heading and EnableMonitorAlert toggle', () => {
jest.spyOn(redux, 'useSelector').mockReturnValue(monitorStatusWithName);

mockReduxHooks(monitorStatusWithName);
const component = renderWithRouter(<MonitorPageTitle />);
expect(component.find('h1').text()).toBe(monitorName);
expect(component.find('[data-test-subj="uptimeDisplayDefineConnector"]').length).toBe(1);
});

it('renders the user provided monitorId when the name is not present', () => {
jest.spyOn(reactRouterDom, 'useParams').mockReturnValue({ monitorId: defaultMonitorIdEncoded }); // resolves to always-down
mockReactRouterDomHooks({ useParamsResponse: { monitorId: defaultMonitorIdEncoded } });
const component = renderWithRouter(<MonitorPageTitle />);
expect(component.find('h1').text()).toBe(defaultMonitorId);
});

it('renders the url when the monitorId is auto generated and the monitor name is not present', () => {
jest
.spyOn(reactRouterDom, 'useParams')
.mockReturnValue({ monitorId: autoGeneratedMonitorIdEncoded }); // resolves to auto-icmp-0X24948F467C6C4F01
mockReactRouterDomHooks({ useParamsResponse: { monitorId: autoGeneratedMonitorIdEncoded } });
const component = renderWithRouter(<MonitorPageTitle />);
expect(component.find('h1').text()).toBe(defaultMonitorStatus.url?.full);
});
Expand Down
5 changes: 5 additions & 0 deletions x-pack/plugins/uptime/public/lib/helper/test_helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import moment from 'moment';
import { Moment } from 'moment-timezone';
import * as redux from 'react-redux';
import * as reactRouterDom from 'react-router-dom';

export function mockMoment() {
// avoid timezone issues
Expand All @@ -27,3 +28,7 @@ export function mockReduxHooks(response?: any) {

jest.spyOn(redux, 'useSelector').mockReturnValue(response);
}

export function mockReactRouterDomHooks({ useParamsResponse }: { useParamsResponse: any }) {
jest.spyOn(reactRouterDom, 'useParams').mockReturnValue(useParamsResponse);
}