From a477505291aa88bc5f1b35004ffca33d7320ade3 Mon Sep 17 00:00:00 2001 From: Phillip Kelley-Dotson Date: Thu, 24 Jun 2021 09:37:13 -0700 Subject: [PATCH] refactor: icon to icons for basicerror componenet (#15336) * initial commit * initial commit * fix test * lint fix * Update superset-frontend/src/components/ErrorMessage/BasicErrorAlert.tsx Co-authored-by: David Aaron Suddjian <1858430+suddjian@users.noreply.github.com> * lint Co-authored-by: David Aaron Suddjian <1858430+suddjian@users.noreply.github.com> --- .../ErrorMessage/BasicErrorAlert.test.tsx | 14 ++++---------- .../components/ErrorMessage/BasicErrorAlert.tsx | 11 ++++++----- 2 files changed, 10 insertions(+), 15 deletions(-) diff --git a/superset-frontend/src/components/ErrorMessage/BasicErrorAlert.test.tsx b/superset-frontend/src/components/ErrorMessage/BasicErrorAlert.test.tsx index 99db37d927..22335213dc 100644 --- a/superset-frontend/src/components/ErrorMessage/BasicErrorAlert.test.tsx +++ b/superset-frontend/src/components/ErrorMessage/BasicErrorAlert.test.tsx @@ -43,11 +43,9 @@ test('should render', () => { test('should render warning icon', () => { render(); - expect(screen.getByTestId('icon')).toBeInTheDocument(); - expect(screen.getByTestId('icon')).toHaveAttribute( - 'data-name', - 'warning-solid', - ); + expect( + screen.getByRole('img', { name: 'warning-solid' }), + ).toBeInTheDocument(); }); test('should render error icon', () => { @@ -56,11 +54,7 @@ test('should render error icon', () => { level: 'error' as ErrorLevel, }; render(); - expect(screen.getByTestId('icon')).toBeInTheDocument(); - expect(screen.getByTestId('icon')).toHaveAttribute( - 'data-name', - 'error-solid', - ); + expect(screen.getByRole('img', { name: 'error-solid' })).toBeInTheDocument(); }); test('should render the error title', () => { diff --git a/superset-frontend/src/components/ErrorMessage/BasicErrorAlert.tsx b/superset-frontend/src/components/ErrorMessage/BasicErrorAlert.tsx index 6c460096ad..0d5d99305d 100644 --- a/superset-frontend/src/components/ErrorMessage/BasicErrorAlert.tsx +++ b/superset-frontend/src/components/ErrorMessage/BasicErrorAlert.tsx @@ -18,7 +18,7 @@ */ import React from 'react'; import { styled, supersetTheme } from '@superset-ui/core'; -import Icon from '../Icon'; +import Icons from 'src/components/Icons'; import { ErrorLevel } from './types'; const StyledContainer = styled.div<{ level: ErrorLevel }>` @@ -56,10 +56,11 @@ export default function BasicErrorAlert({ }: BasicErrorAlertProps) { return ( - + {level === 'error' ? ( + + ) : ( + + )} {title}

{body}