diff --git a/public/app/features/explore/ResponseErrorContainer.test.tsx b/public/app/features/explore/ResponseErrorContainer.test.tsx index a4372358659..0d7e25569ac 100644 --- a/public/app/features/explore/ResponseErrorContainer.test.tsx +++ b/public/app/features/explore/ResponseErrorContainer.test.tsx @@ -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); }); }); diff --git a/public/app/features/explore/ResponseErrorContainer.tsx b/public/app/features/explore/ResponseErrorContainer.tsx index f144180b689..a23ad7fa2f4 100644 --- a/public/app/features/explore/ResponseErrorContainer.tsx +++ b/public/app/features/explore/ResponseErrorContainer.tsx @@ -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 ; }