From: Stas Vilchik Date: Tue, 6 Mar 2018 09:18:04 +0000 (+0100) Subject: fix application leak tooltip (#3117) X-Git-Tag: 7.5~1582 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=refs%2Fpull%2F3116%2Fhead;p=sonarqube.git fix application leak tooltip (#3117) --- diff --git a/server/sonar-web/src/main/js/apps/overview/components/ApplicationLeakPeriodLegend.tsx b/server/sonar-web/src/main/js/apps/overview/components/ApplicationLeakPeriodLegend.tsx index 55d8c5082ce..6045dd6871d 100644 --- a/server/sonar-web/src/main/js/apps/overview/components/ApplicationLeakPeriodLegend.tsx +++ b/server/sonar-web/src/main/js/apps/overview/components/ApplicationLeakPeriodLegend.tsx @@ -50,7 +50,7 @@ export default class ApplicationLeakPeriodLegend extends React.Component { - if (visible && this.state.leaks) { + if (visible && !this.state.leaks) { getApplicationLeak(this.props.component).then( leaks => { if (this.mounted) { diff --git a/server/sonar-web/src/main/js/apps/overview/components/__tests__/ApplicationLeakPeriodLegend-test.tsx b/server/sonar-web/src/main/js/apps/overview/components/__tests__/ApplicationLeakPeriodLegend-test.tsx index ee95828e890..42b2caeb249 100644 --- a/server/sonar-web/src/main/js/apps/overview/components/__tests__/ApplicationLeakPeriodLegend-test.tsx +++ b/server/sonar-web/src/main/js/apps/overview/components/__tests__/ApplicationLeakPeriodLegend-test.tsx @@ -20,15 +20,22 @@ import * as React from 'react'; import { shallow } from 'enzyme'; import ApplicationLeakPeriodLegend from '../ApplicationLeakPeriodLegend'; +import { waitAndUpdate } from '../../../../helpers/testUtils'; -it('renders', () => { - const wrapper = shallow(); - expect(wrapper).toMatchSnapshot(); - wrapper.setState({ - leaks: [ +jest.mock('../../../../api/application', () => ({ + getApplicationLeak: jest.fn(() => + Promise.resolve([ { date: '2017-01-01T11:39:03+0100', project: 'foo', projectName: 'Foo' }, { date: '2017-02-01T11:39:03+0100', project: 'bar', projectName: 'Bar' } - ] - }); + ]) + ) +})); + +it('renders', async () => { + const wrapper = shallow(); + expect(wrapper).toMatchSnapshot(); + + wrapper.find('Tooltip').prop('onVisibleChange')(true); + await waitAndUpdate(wrapper); expect(wrapper).toMatchSnapshot(); });