-
Notifications
You must be signed in to change notification settings - Fork 175
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(opentrons-ai-client): add ChatContainer component (#14921)
* feat(opentrons-ai-client): add ChatContainer component
- Loading branch information
Showing
6 changed files
with
156 additions
and
52 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,29 @@ | ||
import React from 'react' | ||
import { screen } from '@testing-library/react' | ||
import { describe, it } from 'vitest' | ||
import { describe, it, vi, beforeEach } from 'vitest' | ||
|
||
import { renderWithProviders } from './__testing-utils__' | ||
import { SidePanel } from './molecules/SidePanel' | ||
import { ChatContainer } from './organisms/ChatContainer' | ||
|
||
import { App } from './App' | ||
|
||
vi.mock('./molecules/SidePanel') | ||
vi.mock('./organisms/ChatContainer') | ||
|
||
const render = (): ReturnType<typeof renderWithProviders> => { | ||
return renderWithProviders(<App />) | ||
} | ||
|
||
describe('App', () => { | ||
beforeEach(() => { | ||
vi.mocked(SidePanel).mockReturnValue(<div>mock SidePanel</div>) | ||
vi.mocked(ChatContainer).mockReturnValue(<div>mock ChatContainer</div>) | ||
}) | ||
|
||
it('should render text', () => { | ||
render() | ||
screen.getByText('Opentrons AI') | ||
screen.getByText('mock SidePanel') | ||
screen.getByText('mock ChatContainer') | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,14 @@ | ||
import React from 'react' | ||
import { Flex, StyledText } from '@opentrons/components' | ||
import { DIRECTION_ROW, Flex } from '@opentrons/components' | ||
|
||
import { SidePanel } from './molecules/SidePanel' | ||
import { ChatContainer } from './organisms/ChatContainer' | ||
|
||
export function App(): JSX.Element { | ||
return ( | ||
<Flex> | ||
<StyledText as="h1">Opentrons AI</StyledText> | ||
<Flex flexDirection={DIRECTION_ROW}> | ||
<SidePanel /> | ||
<ChatContainer /> | ||
</Flex> | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
21 changes: 21 additions & 0 deletions
21
opentrons-ai-client/src/organisms/ChatContainer/ChatContainer.stories.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import React from 'react' | ||
import { I18nextProvider } from 'react-i18next' | ||
import { i18n } from '../../i18n' | ||
import { ChatContainer as ChatContainerComponent } from './index' | ||
|
||
import type { Meta, StoryObj } from '@storybook/react' | ||
|
||
const meta: Meta<typeof ChatContainerComponent> = { | ||
title: 'AI/organisms/ChatContainer', | ||
component: ChatContainerComponent, | ||
decorators: [ | ||
Story => ( | ||
<I18nextProvider i18n={i18n}> | ||
<Story /> | ||
</I18nextProvider> | ||
), | ||
], | ||
} | ||
export default meta | ||
type Story = StoryObj<typeof ChatContainerComponent> | ||
export const ChatContainer: Story = {} |
28 changes: 28 additions & 0 deletions
28
opentrons-ai-client/src/organisms/ChatContainer/__tests__/ChatContainer.test.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import React from 'react' | ||
import { screen } from '@testing-library/react' | ||
import { describe, it, vi, beforeEach } from 'vitest' | ||
import { renderWithProviders } from '../../../__testing-utils__' | ||
import { i18n } from '../../../i18n' | ||
import { PromptGuide } from '../../../molecules/PromptGuide' | ||
import { ChatContainer } from '../index' | ||
|
||
vi.mock('../../../molecules/PromptGuide') | ||
|
||
const render = (): ReturnType<typeof renderWithProviders> => { | ||
return renderWithProviders(<ChatContainer />, { | ||
i18nInstance: i18n, | ||
}) | ||
} | ||
|
||
describe('ChatContainer', () => { | ||
beforeEach(() => { | ||
vi.mocked(PromptGuide).mockReturnValue(<div>mock PromptGuide</div>) | ||
}) | ||
it('should render prompt guide and text', () => { | ||
render() | ||
screen.getByText('OpentronsAI') | ||
screen.getByText('mock PromptGuide') | ||
}) | ||
|
||
// ToDo (kk:04/16/2024) Add more test cases | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
import React from 'react' | ||
import { useTranslation } from 'react-i18next' | ||
import { | ||
COLORS, | ||
DIRECTION_COLUMN, | ||
FLEX_MAX_CONTENT, | ||
Flex, | ||
SPACING, | ||
StyledText, | ||
} from '@opentrons/components' | ||
import { PromptGuide } from '../../molecules/PromptGuide' | ||
|
||
export function ChatContainer(): JSX.Element { | ||
const { t } = useTranslation('protocol_generator') | ||
const isDummyInitial = true | ||
return ( | ||
<Flex | ||
padding={SPACING.spacing40} | ||
backgroundColor={COLORS.grey10} | ||
width={FLEX_MAX_CONTENT} | ||
> | ||
{/* This will be updated when input textbox and function are implemented */} | ||
{isDummyInitial ? ( | ||
<Flex | ||
flexDirection={DIRECTION_COLUMN} | ||
gridGap={SPACING.spacing12} | ||
width="100%" | ||
> | ||
<StyledText>{t('opentronsai')}</StyledText> | ||
<PromptGuide /> | ||
</Flex> | ||
) : null} | ||
</Flex> | ||
) | ||
} |