mirror of https://github.com/apache/superset.git
chore: Expand error detail on screencapture (#25519)
This commit is contained in:
parent
b92957e510
commit
ba541e8022
|
@ -21,6 +21,7 @@ import React from 'react';
|
||||||
import userEvent from '@testing-library/user-event';
|
import userEvent from '@testing-library/user-event';
|
||||||
import { render, screen } from 'spec/helpers/testing-library';
|
import { render, screen } from 'spec/helpers/testing-library';
|
||||||
import { supersetTheme } from '@superset-ui/core';
|
import { supersetTheme } from '@superset-ui/core';
|
||||||
|
import { isCurrentUserBot } from 'src/utils/isBot';
|
||||||
import ErrorAlert from './ErrorAlert';
|
import ErrorAlert from './ErrorAlert';
|
||||||
import { ErrorLevel, ErrorSource } from './types';
|
import { ErrorLevel, ErrorSource } from './types';
|
||||||
|
|
||||||
|
@ -31,6 +32,10 @@ jest.mock(
|
||||||
<span role="img" aria-label={fileName.replace('_', '-')} />,
|
<span role="img" aria-label={fileName.replace('_', '-')} />,
|
||||||
);
|
);
|
||||||
|
|
||||||
|
jest.mock('src/utils/isBot', () => ({
|
||||||
|
isCurrentUserBot: jest.fn(),
|
||||||
|
}));
|
||||||
|
|
||||||
const mockedProps = {
|
const mockedProps = {
|
||||||
body: 'Error body',
|
body: 'Error body',
|
||||||
level: 'warning' as ErrorLevel,
|
level: 'warning' as ErrorLevel,
|
||||||
|
@ -41,6 +46,14 @@ const mockedProps = {
|
||||||
description: 'we are unable to connect db.',
|
description: 'we are unable to connect db.',
|
||||||
};
|
};
|
||||||
|
|
||||||
|
beforeEach(() => {
|
||||||
|
(isCurrentUserBot as jest.Mock).mockReturnValue(false);
|
||||||
|
});
|
||||||
|
|
||||||
|
afterEach(() => {
|
||||||
|
jest.clearAllMocks();
|
||||||
|
});
|
||||||
|
|
||||||
test('should render', () => {
|
test('should render', () => {
|
||||||
const { container } = render(<ErrorAlert {...mockedProps} />);
|
const { container } = render(<ErrorAlert {...mockedProps} />);
|
||||||
expect(container).toBeInTheDocument();
|
expect(container).toBeInTheDocument();
|
||||||
|
@ -100,6 +113,17 @@ test('should render the See more button', () => {
|
||||||
expect(screen.getByText('See more')).toBeInTheDocument();
|
expect(screen.getByText('See more')).toBeInTheDocument();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test('should render the error subtitle and body defaultly for the screen capture request', () => {
|
||||||
|
const seemoreProps = {
|
||||||
|
...mockedProps,
|
||||||
|
source: 'explore' as ErrorSource,
|
||||||
|
};
|
||||||
|
(isCurrentUserBot as jest.Mock).mockReturnValue(true);
|
||||||
|
render(<ErrorAlert {...seemoreProps} />);
|
||||||
|
expect(screen.getByText('Error subtitle')).toBeInTheDocument();
|
||||||
|
expect(screen.getByText('Error body')).toBeInTheDocument();
|
||||||
|
});
|
||||||
|
|
||||||
test('should render the modal', () => {
|
test('should render the modal', () => {
|
||||||
render(<ErrorAlert {...mockedProps} />, { useRedux: true });
|
render(<ErrorAlert {...mockedProps} />, { useRedux: true });
|
||||||
const button = screen.getByText('See more');
|
const button = screen.getByText('See more');
|
||||||
|
|
|
@ -21,6 +21,7 @@ import { styled, useTheme, t } from '@superset-ui/core';
|
||||||
import { noOp } from 'src/utils/common';
|
import { noOp } from 'src/utils/common';
|
||||||
import Modal from 'src/components/Modal';
|
import Modal from 'src/components/Modal';
|
||||||
import Button from 'src/components/Button';
|
import Button from 'src/components/Button';
|
||||||
|
import { isCurrentUserBot } from 'src/utils/isBot';
|
||||||
|
|
||||||
import Icons from 'src/components/Icons';
|
import Icons from 'src/components/Icons';
|
||||||
import { ErrorLevel, ErrorSource } from './types';
|
import { ErrorLevel, ErrorSource } from './types';
|
||||||
|
@ -102,9 +103,10 @@ export default function ErrorAlert({
|
||||||
const theme = useTheme();
|
const theme = useTheme();
|
||||||
|
|
||||||
const [isModalOpen, setIsModalOpen] = useState(false);
|
const [isModalOpen, setIsModalOpen] = useState(false);
|
||||||
const [isBodyExpanded, setIsBodyExpanded] = useState(false);
|
const [isBodyExpanded, setIsBodyExpanded] = useState(isCurrentUserBot());
|
||||||
|
|
||||||
const isExpandable = ['explore', 'sqllab'].includes(source);
|
const isExpandable =
|
||||||
|
isCurrentUserBot() || ['explore', 'sqllab'].includes(source);
|
||||||
const iconColor = theme.colors[level].base;
|
const iconColor = theme.colors[level].base;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|
Loading…
Reference in New Issue