mirror of
https://github.com/grafana/grafana.git
synced 2025-02-11 16:15:42 -06:00
* Chore: moves alert to test-id * Chore: moves Dashboard navigation to test-id * Chore: moves Bar gauge value to data-testid * Chore move Folder picker select container to data-testid * Chore: moves Time zone picker select container to data-testid * Chore: moves Choose starting day of the week to data-testid * Chore: change tabIndex on search input * Chore: moves various search related aria-lables to data-testid * Chore: connects label to select input on alerting page * Chore: connects TimeZonePicker and WeekStartPicker with labels * Chore: moves CallToActionButton to data-testid * Chore: move user home preferences select to data-testid * Chore: lower all thresholds
60 lines
1.8 KiB
TypeScript
60 lines
1.8 KiB
TypeScript
import React from 'react';
|
|
import { Provider } from 'react-redux';
|
|
import { render, screen } from '@testing-library/react';
|
|
import { DataQueryError, LoadingState } from '@grafana/data';
|
|
import { selectors } from '@grafana/e2e-selectors';
|
|
|
|
import { configureStore } from '../../store/configureStore';
|
|
import { ResponseErrorContainer } from './ResponseErrorContainer';
|
|
import { ExploreId } from '../../types';
|
|
|
|
describe('ResponseErrorContainer', () => {
|
|
it('shows error message if it does not contain refId', async () => {
|
|
const errorMessage = 'test error';
|
|
setup({
|
|
message: errorMessage,
|
|
});
|
|
const errorEl = screen.getByTestId(selectors.components.Alert.alertV2('error'));
|
|
expect(errorEl).toBeInTheDocument();
|
|
expect(errorEl).toHaveTextContent(errorMessage);
|
|
});
|
|
|
|
it('shows error if there is refID', async () => {
|
|
const errorMessage = 'test error';
|
|
setup({
|
|
refId: 'someId',
|
|
message: errorMessage,
|
|
});
|
|
const errorEl = screen.getByTestId(selectors.components.Alert.alertV2('error'));
|
|
expect(errorEl).toBeInTheDocument();
|
|
expect(errorEl).toHaveTextContent(errorMessage);
|
|
});
|
|
|
|
it('shows error.data.message if error.message does not exist', async () => {
|
|
const errorMessage = 'test error';
|
|
setup({
|
|
data: {
|
|
message: 'test error',
|
|
},
|
|
});
|
|
const errorEl = screen.getByTestId(selectors.components.Alert.alertV2('error'));
|
|
expect(errorEl).toBeInTheDocument();
|
|
expect(errorEl).toHaveTextContent(errorMessage);
|
|
});
|
|
});
|
|
|
|
function setup(error: DataQueryError) {
|
|
const store = configureStore();
|
|
store.getState().explore[ExploreId.left].queryResponse = {
|
|
timeRange: {} as any,
|
|
series: [],
|
|
state: LoadingState.Error,
|
|
error,
|
|
};
|
|
render(
|
|
<Provider store={store}>
|
|
<ResponseErrorContainer exploreId={ExploreId.left} />
|
|
</Provider>
|
|
);
|
|
}
|