-
Notifications
You must be signed in to change notification settings - Fork 8.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
58 additions
and
2 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
55 changes: 55 additions & 0 deletions
55
...ty/public/components/shared/exploratory_view/series_editor/report_metric_options.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,55 @@ | ||
/* | ||
* 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 React from 'react'; | ||
import { screen } from '@testing-library/react'; | ||
import { mockAppIndexPattern, mockIndexPattern, mockUxSeries, render } from '../rtl_helpers'; | ||
import { getDefaultConfigs } from '../configurations/default_configs'; | ||
import { PERCENTILE } from '../configurations/constants'; | ||
import { ReportMetricOptions } from './report_metric_options'; | ||
|
||
describe('ReportMetricOptions', function () { | ||
const dataViewSeries = getDefaultConfigs({ | ||
reportType: 'kpi-over-time', | ||
indexPattern: mockIndexPattern, | ||
dataType: 'ux', | ||
}); | ||
|
||
it('should render properly', async function () { | ||
render( | ||
<ReportMetricOptions seriesId={0} seriesConfig={dataViewSeries} series={mockUxSeries} /> | ||
); | ||
|
||
expect(await screen.findByText('No data available')).toBeInTheDocument(); | ||
}); | ||
|
||
it('should display loading if index pattern is not available and is loading', async function () { | ||
mockAppIndexPattern({ loading: true, indexPatterns: undefined }); | ||
const { container } = render( | ||
<ReportMetricOptions | ||
seriesId={0} | ||
seriesConfig={{ ...dataViewSeries, hasOperationType: true }} | ||
series={{ ...mockUxSeries, breakdown: PERCENTILE }} | ||
/> | ||
); | ||
|
||
expect(container.getElementsByClassName('euiLoadingSpinner').length).toBe(1); | ||
}); | ||
|
||
it('should not display loading if index pattern is already loaded', async function () { | ||
mockAppIndexPattern({ loading: true }); | ||
render( | ||
<ReportMetricOptions | ||
seriesId={0} | ||
seriesConfig={{ ...dataViewSeries, hasOperationType: true }} | ||
series={{ ...mockUxSeries, breakdown: PERCENTILE }} | ||
/> | ||
); | ||
|
||
expect(await screen.findByText('Page load time')).toBeInTheDocument(); | ||
}); | ||
}); |