mirror of
https://github.com/grafana/grafana.git
synced 2025-02-11 08:05:43 -06:00
Explore: prevent eplore from hiding errors containing refId (#39504)
* Explore: prevent eplore from hiding errors containing refId * Update public/app/features/explore/ResponseErrorContainer.tsx Co-authored-by: Gábor Farkas <gabor.farkas@gmail.com> Co-authored-by: Gábor Farkas <gabor.farkas@gmail.com>
This commit is contained in:
parent
de9bcd6163
commit
5f48d0641b
@ -8,35 +8,36 @@ import { DataQueryError, LoadingState } from '@grafana/data';
|
||||
|
||||
describe('ResponseErrorContainer', () => {
|
||||
it('shows error message if it does not contain refId', async () => {
|
||||
const errorMessage = 'test error';
|
||||
setup({
|
||||
message: 'test error',
|
||||
message: errorMessage,
|
||||
});
|
||||
expect(screen.getByText('test error')).toBeInTheDocument();
|
||||
const errorEl = screen.getByLabelText('Alert 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.getByLabelText('Alert 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',
|
||||
},
|
||||
});
|
||||
expect(screen.getByText('test error')).toBeInTheDocument();
|
||||
});
|
||||
|
||||
it('does not show error if there is refID', async () => {
|
||||
setup({
|
||||
refId: 'someId',
|
||||
message: 'test error',
|
||||
});
|
||||
expect(screen.queryByText('test error')).not.toBeInTheDocument();
|
||||
});
|
||||
|
||||
it('does not show error if there is refID', async () => {
|
||||
setup({
|
||||
refId: 'someId',
|
||||
message: 'test error',
|
||||
});
|
||||
expect(screen.queryByText('test error')).not.toBeInTheDocument();
|
||||
const errorEl = screen.getByLabelText('Alert error');
|
||||
expect(errorEl).toBeInTheDocument();
|
||||
expect(errorEl).toHaveTextContent(errorMessage);
|
||||
});
|
||||
});
|
||||
|
||||
|
@ -10,12 +10,7 @@ interface Props {
|
||||
export function ResponseErrorContainer(props: Props) {
|
||||
const queryResponse = useSelector((state: StoreState) => state.explore[props.exploreId]?.queryResponse);
|
||||
|
||||
// Only show error if it does not have refId. Otherwise let query row to handle it so this condition has to be matched
|
||||
// with QueryRow.tsx so we don't loose errors.
|
||||
const queryError =
|
||||
queryResponse?.state === LoadingState.Error && queryResponse?.error && !queryResponse.error.refId
|
||||
? queryResponse.error
|
||||
: undefined;
|
||||
const queryError = queryResponse?.state === LoadingState.Error ? queryResponse?.error : undefined;
|
||||
|
||||
return <ErrorContainer queryError={queryError} />;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user