@@ -10,16 +10,13 @@ import { ChatWindowHeader } from '../chat_window_header';
10
10
import * as chatContextExports from '../../contexts/chat_context' ;
11
11
import { TabId } from '../../types' ;
12
12
import { SIDECAR_DOCKED_MODE } from '../../../../../src/core/public' ;
13
+ import { setupConfigSchemaMock } from '../../../test/config_schema_mock' ;
13
14
14
15
jest . mock ( '../../components/chat_window_header_title' , ( ) => {
15
16
return { ChatWindowHeaderTitle : ( ) => < div > OpenSearch Assistant</ div > } ;
16
17
} ) ;
17
18
18
- jest . mock ( '../../services' , ( ) => {
19
- return {
20
- getLogoIcon : jest . fn ( ) . mockReturnValue ( '' ) ,
21
- } ;
22
- } ) ;
19
+ jest . mock ( '../../services' ) ;
23
20
24
21
const setup = ( { selectedTabId } : { selectedTabId ?: TabId } = { } ) => {
25
22
const useChatContextMock = {
@@ -43,15 +40,28 @@ const setup = ({ selectedTabId }: { selectedTabId?: TabId } = {}) => {
43
40
} ;
44
41
45
42
describe ( '<ChatWindowHeader />' , ( ) => {
43
+ beforeEach ( ( ) => {
44
+ setupConfigSchemaMock ( ) ;
45
+ } ) ;
46
46
it ( 'should render title, history, setSidecarMode and close button' , ( ) => {
47
47
const { renderResult } = setup ( ) ;
48
-
49
48
expect ( renderResult . getByText ( 'OpenSearch Assistant' ) ) . toBeInTheDocument ( ) ;
50
49
expect ( renderResult . getByLabelText ( 'history' ) ) . toBeInTheDocument ( ) ;
51
50
expect ( renderResult . getByLabelText ( 'setSidecarMode' ) ) . toBeInTheDocument ( ) ;
52
51
expect ( renderResult . getByLabelText ( 'close' ) ) . toBeInTheDocument ( ) ;
53
52
} ) ;
54
53
54
+ it ( 'should not display conversation list when feature flag is false' , ( ) => {
55
+ setupConfigSchemaMock ( {
56
+ chat : {
57
+ showConversationHistory : false ,
58
+ } ,
59
+ } ) ;
60
+ const { renderResult } = setup ( ) ;
61
+ expect ( renderResult . queryByLabelText ( 'history' ) ) . not . toBeInTheDocument ( ) ;
62
+ } ) ;
63
+
64
+ it ( 'should not display conversation history icon when feature flag is false' , ( ) => { } ) ;
55
65
it ( 'should call setFlyoutVisible with false after close button clicked' , ( ) => {
56
66
const { renderResult, useChatContextMock } = setup ( ) ;
57
67
0 commit comments