forked from elastic/kibana
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[ML] APM Latency Correlations: Fix empty state (elastic#109813)
- Correctly renders the empty chart state when no data is available. - Hides the "Click drag to select" and trace samples message when the chart shows an empty state to avoid redundant info. - Adds jest unit tests that would fail with the previously visible loading indicators. - Fix a bug with cancelling search strategies.
- Loading branch information
1 parent
62f1770
commit f4a83a0
Showing
15 changed files
with
621 additions
and
300 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
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
131 changes: 131 additions & 0 deletions
131
x-pack/plugins/apm/public/components/app/correlations/latency_correlations.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,131 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0; you may not use this file except in compliance with the Elastic License | ||
* 2.0. | ||
*/ | ||
|
||
import { render, screen, waitFor } from '@testing-library/react'; | ||
import { createMemoryHistory } from 'history'; | ||
import React, { ReactNode } from 'react'; | ||
import { of } from 'rxjs'; | ||
|
||
import { __IntlProvider as IntlProvider } from '@kbn/i18n/react'; | ||
|
||
import { CoreStart } from 'kibana/public'; | ||
import { merge } from 'lodash'; | ||
import { dataPluginMock } from 'src/plugins/data/public/mocks'; | ||
import type { IKibanaSearchResponse } from 'src/plugins/data/public'; | ||
import { EuiThemeProvider } from 'src/plugins/kibana_react/common'; | ||
import { createKibanaReactContext } from 'src/plugins/kibana_react/public'; | ||
import type { SearchServiceRawResponse } from '../../../../common/search_strategies/correlations/types'; | ||
import { MockUrlParamsContextProvider } from '../../../context/url_params_context/mock_url_params_context_provider'; | ||
import { ApmPluginContextValue } from '../../../context/apm_plugin/apm_plugin_context'; | ||
import { | ||
mockApmPluginContextValue, | ||
MockApmPluginContextWrapper, | ||
} from '../../../context/apm_plugin/mock_apm_plugin_context'; | ||
import { fromQuery } from '../../shared/Links/url_helpers'; | ||
|
||
import { LatencyCorrelations } from './latency_correlations'; | ||
|
||
function Wrapper({ | ||
children, | ||
dataSearchResponse, | ||
}: { | ||
children?: ReactNode; | ||
dataSearchResponse: IKibanaSearchResponse<SearchServiceRawResponse>; | ||
}) { | ||
const mockDataSearch = jest.fn(() => of(dataSearchResponse)); | ||
|
||
const dataPluginMockStart = dataPluginMock.createStartContract(); | ||
const KibanaReactContext = createKibanaReactContext({ | ||
data: { | ||
...dataPluginMockStart, | ||
search: { | ||
...dataPluginMockStart.search, | ||
search: mockDataSearch, | ||
}, | ||
}, | ||
usageCollection: { reportUiCounter: () => {} }, | ||
} as Partial<CoreStart>); | ||
|
||
const httpGet = jest.fn(); | ||
|
||
const history = createMemoryHistory(); | ||
jest.spyOn(history, 'push'); | ||
jest.spyOn(history, 'replace'); | ||
|
||
history.replace({ | ||
pathname: '/services/the-service-name/transactions/view', | ||
search: fromQuery({ transactionName: 'the-transaction-name' }), | ||
}); | ||
|
||
const mockPluginContext = (merge({}, mockApmPluginContextValue, { | ||
core: { http: { get: httpGet } }, | ||
}) as unknown) as ApmPluginContextValue; | ||
|
||
return ( | ||
<IntlProvider locale="en"> | ||
<EuiThemeProvider darkMode={false}> | ||
<KibanaReactContext.Provider> | ||
<MockApmPluginContextWrapper | ||
history={history} | ||
value={mockPluginContext} | ||
> | ||
<MockUrlParamsContextProvider | ||
params={{ | ||
rangeFrom: 'now-15m', | ||
rangeTo: 'now', | ||
start: 'mystart', | ||
end: 'myend', | ||
}} | ||
> | ||
{children} | ||
</MockUrlParamsContextProvider> | ||
</MockApmPluginContextWrapper> | ||
</KibanaReactContext.Provider> | ||
</EuiThemeProvider> | ||
</IntlProvider> | ||
); | ||
} | ||
|
||
describe('correlations', () => { | ||
describe('LatencyCorrelations', () => { | ||
it('shows loading indicator when the service is running and returned no results yet', async () => { | ||
render( | ||
<Wrapper | ||
dataSearchResponse={{ | ||
isRunning: true, | ||
rawResponse: { ccsWarning: false, took: 1234, values: [], log: [] }, | ||
}} | ||
> | ||
<LatencyCorrelations onFilter={jest.fn()} /> | ||
</Wrapper> | ||
); | ||
|
||
await waitFor(() => { | ||
expect(screen.getByTestId('apmCorrelationsChart')).toBeInTheDocument(); | ||
expect(screen.getByTestId('loading')).toBeInTheDocument(); | ||
}); | ||
}); | ||
|
||
it("doesn't show loading indicator when the service isn't running", async () => { | ||
render( | ||
<Wrapper | ||
dataSearchResponse={{ | ||
isRunning: false, | ||
rawResponse: { ccsWarning: false, took: 1234, values: [], log: [] }, | ||
}} | ||
> | ||
<LatencyCorrelations onFilter={jest.fn()} /> | ||
</Wrapper> | ||
); | ||
|
||
await waitFor(() => { | ||
expect(screen.getByTestId('apmCorrelationsChart')).toBeInTheDocument(); | ||
expect(screen.queryByTestId('loading')).toBeNull(); // it doesn't exist | ||
}); | ||
}); | ||
}); | ||
}); |
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
22 changes: 0 additions & 22 deletions
22
x-pack/plugins/apm/public/components/app/transaction_details/distribution/index.test.ts
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.