Skip to content

Commit 67e5d10

Browse files
authored
chore: Expand error detail on screencapture (apache#25519)
1 parent 89eefca commit 67e5d10

File tree

2 files changed

+28
-2
lines changed

2 files changed

+28
-2
lines changed

superset-frontend/src/components/ErrorMessage/ErrorAlert.test.tsx

+24
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ import React from 'react';
2121
import userEvent from '@testing-library/user-event';
2222
import { render, screen } from 'spec/helpers/testing-library';
2323
import { supersetTheme } from '@superset-ui/core';
24+
import { isCurrentUserBot } from 'src/utils/isBot';
2425
import ErrorAlert from './ErrorAlert';
2526
import { ErrorLevel, ErrorSource } from './types';
2627

@@ -31,6 +32,10 @@ jest.mock(
3132
<span role="img" aria-label={fileName.replace('_', '-')} />,
3233
);
3334

35+
jest.mock('src/utils/isBot', () => ({
36+
isCurrentUserBot: jest.fn(),
37+
}));
38+
3439
const mockedProps = {
3540
body: 'Error body',
3641
level: 'warning' as ErrorLevel,
@@ -41,6 +46,14 @@ const mockedProps = {
4146
description: 'we are unable to connect db.',
4247
};
4348

49+
beforeEach(() => {
50+
(isCurrentUserBot as jest.Mock).mockReturnValue(false);
51+
});
52+
53+
afterEach(() => {
54+
jest.clearAllMocks();
55+
});
56+
4457
test('should render', () => {
4558
const { container } = render(<ErrorAlert {...mockedProps} />);
4659
expect(container).toBeInTheDocument();
@@ -100,6 +113,17 @@ test('should render the See more button', () => {
100113
expect(screen.getByText('See more')).toBeInTheDocument();
101114
});
102115

116+
test('should render the error subtitle and body defaultly for the screen capture request', () => {
117+
const seemoreProps = {
118+
...mockedProps,
119+
source: 'explore' as ErrorSource,
120+
};
121+
(isCurrentUserBot as jest.Mock).mockReturnValue(true);
122+
render(<ErrorAlert {...seemoreProps} />);
123+
expect(screen.getByText('Error subtitle')).toBeInTheDocument();
124+
expect(screen.getByText('Error body')).toBeInTheDocument();
125+
});
126+
103127
test('should render the modal', () => {
104128
render(<ErrorAlert {...mockedProps} />, { useRedux: true });
105129
const button = screen.getByText('See more');

superset-frontend/src/components/ErrorMessage/ErrorAlert.tsx

+4-2
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ import { styled, useTheme, t } from '@superset-ui/core';
2121
import { noOp } from 'src/utils/common';
2222
import Modal from 'src/components/Modal';
2323
import Button from 'src/components/Button';
24+
import { isCurrentUserBot } from 'src/utils/isBot';
2425

2526
import Icons from 'src/components/Icons';
2627
import { ErrorLevel, ErrorSource } from './types';
@@ -102,9 +103,10 @@ export default function ErrorAlert({
102103
const theme = useTheme();
103104

104105
const [isModalOpen, setIsModalOpen] = useState(false);
105-
const [isBodyExpanded, setIsBodyExpanded] = useState(false);
106+
const [isBodyExpanded, setIsBodyExpanded] = useState(isCurrentUserBot());
106107

107-
const isExpandable = ['explore', 'sqllab'].includes(source);
108+
const isExpandable =
109+
isCurrentUserBot() || ['explore', 'sqllab'].includes(source);
108110
const iconColor = theme.colors[level].base;
109111

110112
return (

0 commit comments

Comments
 (0)