mirror of
https://github.com/apache/superset.git
synced 2026-05-07 08:54:23 +00:00
chore(native-filters): Ensure consistent error handling (#24206)
Co-authored-by: Michael S. Molina <michael.s.molina@gmail.com>
This commit is contained in:
@@ -37,6 +37,7 @@ const StyledContent = styled.div`
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
margin-left: ${({ theme }) => theme.gridUnit * 2}px;
|
||||
overflow: hidden;
|
||||
`;
|
||||
|
||||
const StyledTitle = styled.span`
|
||||
|
||||
@@ -21,7 +21,8 @@ import React from 'react';
|
||||
import { render, screen } from 'spec/helpers/testing-library';
|
||||
import userEvent from '@testing-library/user-event';
|
||||
import ErrorMessageWithStackTrace from './ErrorMessageWithStackTrace';
|
||||
import { ErrorLevel, ErrorSource } from './types';
|
||||
import BasicErrorAlert from './BasicErrorAlert';
|
||||
import { ErrorLevel, ErrorSource, ErrorTypeEnum } from './types';
|
||||
|
||||
jest.mock(
|
||||
'src/components/Icons/Icon',
|
||||
@@ -57,3 +58,21 @@ test('should render the link', () => {
|
||||
expect(link).toHaveTextContent('(Request Access)');
|
||||
expect(link).toHaveAttribute('href', mockedProps.link);
|
||||
});
|
||||
|
||||
test('should render the fallback', () => {
|
||||
const body = 'Blahblah';
|
||||
render(
|
||||
<ErrorMessageWithStackTrace
|
||||
error={{
|
||||
error_type: ErrorTypeEnum.FRONTEND_NETWORK_ERROR,
|
||||
message: body,
|
||||
extra: {},
|
||||
level: 'error',
|
||||
}}
|
||||
fallback={<BasicErrorAlert title="Blah" body={body} level="error" />}
|
||||
{...mockedProps}
|
||||
/>,
|
||||
{ useRedux: true },
|
||||
);
|
||||
expect(screen.getByText(body)).toBeInTheDocument();
|
||||
});
|
||||
|
||||
@@ -34,6 +34,7 @@ type Props = {
|
||||
source?: ErrorSource;
|
||||
description?: string;
|
||||
errorMitigationFunction?: () => void;
|
||||
fallback?: React.ReactNode;
|
||||
};
|
||||
|
||||
export default function ErrorMessageWithStackTrace({
|
||||
@@ -45,6 +46,7 @@ export default function ErrorMessageWithStackTrace({
|
||||
stackTrace,
|
||||
source,
|
||||
description,
|
||||
fallback,
|
||||
}: Props) {
|
||||
// Check if a custom error message component was registered for this message
|
||||
if (error) {
|
||||
@@ -62,6 +64,10 @@ export default function ErrorMessageWithStackTrace({
|
||||
}
|
||||
}
|
||||
|
||||
if (fallback) {
|
||||
return <>{fallback}</>;
|
||||
}
|
||||
|
||||
return (
|
||||
<ErrorAlert
|
||||
level="warning"
|
||||
|
||||
Reference in New Issue
Block a user