@@ -21,6 +21,7 @@ import React from 'react';
21
21
import userEvent from '@testing-library/user-event' ;
22
22
import { render , screen } from 'spec/helpers/testing-library' ;
23
23
import { supersetTheme } from '@superset-ui/core' ;
24
+ import { isCurrentUserBot } from 'src/utils/isBot' ;
24
25
import ErrorAlert from './ErrorAlert' ;
25
26
import { ErrorLevel , ErrorSource } from './types' ;
26
27
@@ -31,6 +32,10 @@ jest.mock(
31
32
< span role = "img" aria-label = { fileName . replace ( '_' , '-' ) } /> ,
32
33
) ;
33
34
35
+ jest . mock ( 'src/utils/isBot' , ( ) => ( {
36
+ isCurrentUserBot : jest . fn ( ) ,
37
+ } ) ) ;
38
+
34
39
const mockedProps = {
35
40
body : 'Error body' ,
36
41
level : 'warning' as ErrorLevel ,
@@ -41,6 +46,14 @@ const mockedProps = {
41
46
description : 'we are unable to connect db.' ,
42
47
} ;
43
48
49
+ beforeEach ( ( ) => {
50
+ ( isCurrentUserBot as jest . Mock ) . mockReturnValue ( false ) ;
51
+ } ) ;
52
+
53
+ afterEach ( ( ) => {
54
+ jest . clearAllMocks ( ) ;
55
+ } ) ;
56
+
44
57
test ( 'should render' , ( ) => {
45
58
const { container } = render ( < ErrorAlert { ...mockedProps } /> ) ;
46
59
expect ( container ) . toBeInTheDocument ( ) ;
@@ -100,6 +113,17 @@ test('should render the See more button', () => {
100
113
expect ( screen . getByText ( 'See more' ) ) . toBeInTheDocument ( ) ;
101
114
} ) ;
102
115
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
+
103
127
test ( 'should render the modal' , ( ) => {
104
128
render ( < ErrorAlert { ...mockedProps } /> , { useRedux : true } ) ;
105
129
const button = screen . getByText ( 'See more' ) ;
0 commit comments