-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
NETOBSERV-1266 Netflow traffic tab crash (#377)
* fix props infinite loop * ensure nav always loaded * fix testing * add tab examples to standalone
- Loading branch information
1 parent
19a7ab9
commit 1ca3b6a
Showing
6 changed files
with
223 additions
and
134 deletions.
There are no files selected for viewing
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
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 |
---|---|---|
@@ -1,24 +1,55 @@ | ||
import { useResolvedExtensions } from '@openshift-console/dynamic-plugin-sdk'; | ||
import { EmptyState } from '@patternfly/react-core'; | ||
import { shallow } from 'enzyme'; | ||
import { mount } from 'enzyme'; | ||
import { waitFor } from '@testing-library/react'; | ||
import { extensionsMock } from '../__tests-data__/extensions'; | ||
import * as React from 'react'; | ||
import NetflowTab from '../netflow-tab'; | ||
import NetflowTraffic from '../netflow-traffic'; | ||
import { PodTabParam, ServiceTabParam, UnknownTabParam } from '../__tests-data__/tabs'; | ||
import { ConfigResultSample } from '../__tests-data__/config'; | ||
import { GenericMetricsResult, TopologyMetricsResult } from '../../api/loki'; | ||
import { AlertsResult, SilencedAlert } from '../../api/alert'; | ||
|
||
const useResolvedExtensionsMock = useResolvedExtensions as jest.Mock; | ||
|
||
jest.mock('../../api/routes', () => ({ | ||
getConfig: jest.fn(() => Promise.resolve(ConfigResultSample)), | ||
getFlows: jest.fn(() => Promise.resolve([])), | ||
getTopologyMetrics: jest.fn(() => | ||
Promise.resolve({ metrics: [], stats: { numQueries: 0, limitReached: false } } as TopologyMetricsResult) | ||
), | ||
getGenericMetrics: jest.fn(() => | ||
Promise.resolve({ metrics: [], stats: { numQueries: 0, limitReached: false } } as GenericMetricsResult) | ||
), | ||
getAlerts: jest.fn(() => Promise.resolve({ data: { groups: [] }, status: 'success' } as AlertsResult)), | ||
getSilencedAlerts: jest.fn(() => Promise.resolve([] as SilencedAlert[])) | ||
})); | ||
|
||
describe('<NetflowTab />', () => { | ||
it('should shallow component for Pod', async () => { | ||
const wrapper = shallow(<NetflowTab obj={PodTabParam} />); | ||
expect(wrapper.find(NetflowTab)).toBeTruthy(); | ||
expect(wrapper.find(NetflowTraffic)).toHaveLength(1); | ||
beforeAll(() => { | ||
useResolvedExtensionsMock.mockReturnValue(extensionsMock); | ||
}); | ||
|
||
it('should mount component for Pod', async () => { | ||
const wrapper = mount(<NetflowTab obj={PodTabParam} />); | ||
await waitFor(() => { | ||
expect(wrapper.find(NetflowTab)).toBeTruthy(); | ||
expect(wrapper.find(NetflowTraffic)).toHaveLength(1); | ||
}); | ||
}); | ||
it('should shallow component for Service', async () => { | ||
const wrapper = shallow(<NetflowTab obj={ServiceTabParam} />); | ||
expect(wrapper.find(NetflowTab)).toBeTruthy(); | ||
expect(wrapper.find(NetflowTraffic)).toHaveLength(1); | ||
it('should mount component for Service', async () => { | ||
const wrapper = mount(<NetflowTab obj={ServiceTabParam} />); | ||
await waitFor(() => { | ||
expect(wrapper.find(NetflowTab)).toBeTruthy(); | ||
expect(wrapper.find(NetflowTraffic)).toHaveLength(1); | ||
}); | ||
}); | ||
it('should render empty state', async () => { | ||
const wrapper = shallow(<NetflowTab obj={UnknownTabParam} />); | ||
expect(wrapper.find(NetflowTraffic)).toHaveLength(0); | ||
expect(wrapper.find(EmptyState)).toHaveLength(1); | ||
it('should mount empty state', async () => { | ||
const wrapper = mount(<NetflowTab obj={UnknownTabParam} />); | ||
await waitFor(() => { | ||
expect(wrapper.find(NetflowTraffic)).toHaveLength(0); | ||
expect(wrapper.find(EmptyState)).toHaveLength(1); | ||
}); | ||
}); | ||
}); |
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
Oops, something went wrong.