Skip to content

Commit

Permalink
Address PR comments
Browse files Browse the repository at this point in the history
Signed-off-by: Lin Wang <[email protected]>
  • Loading branch information
wanglam committed Dec 12, 2023
1 parent 24f877d commit eea4e46
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 14 deletions.
19 changes: 6 additions & 13 deletions public/components/__tests__/chat_window_header_title.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,9 @@ import { IMessage } from '../../../common/types/chat_saved_object_attributes';
import { ChatWindowHeaderTitle } from '../chat_window_header_title';

const setup = ({
title = 'foo',
messages = [],
sessionId = '1',
}: { title?: string; messages?: IMessage[]; sessionId?: string } = {}) => {
...rest
}: { messages?: IMessage[]; sessionId?: string | undefined } = {}) => {
const useCoreMock = {
services: {
...coreMock.createStart(),
Expand All @@ -46,8 +45,8 @@ const setup = ({
chatState: { messages },
};
const useChatContextMock = {
sessionId,
title,
sessionId: 'sessionId' in rest ? rest.sessionId : '1',
title: 'foo',
setSessionId: jest.fn(),
setTitle: jest.fn(),
};
Expand Down Expand Up @@ -201,17 +200,11 @@ describe('<ChatWindowHeaderTitle />', () => {
expect(renderResult.getByRole('button', { name: 'Save to notebook' })).toBeDisabled();
});

it('should show "OpenSearch Assistant" when sessionId is not defined', async () => {
it('should show "OpenSearch Assistant" when sessionId is undefined', async () => {
const { renderResult } = setup({
sessionId: undefined,
});

act(() => {
fireEvent.click(renderResult.getByText('foo'));
});

await waitFor(() => {
expect(renderResult.queryByText('OpenSearch Assistant')).not.toBeInTheDocument();
});
expect(renderResult.getByText('OpenSearch Assistant')).toBeInTheDocument();
});
});
2 changes: 1 addition & 1 deletion public/components/chat_experimental_badge.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* SPDX-License-Identifier: Apache-2.0
*/

import React, { useEffect, useState } from 'react';
import React, { useState } from 'react';
import {
EuiPopover,
EuiButtonIcon,
Expand Down

0 comments on commit eea4e46

Please sign in to comment.