Skip to content

Commit

Permalink
refactor: remove hardcoded test
Browse files Browse the repository at this point in the history
  • Loading branch information
fbelginetw committed Oct 21, 2024
1 parent 7066170 commit c13515c
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -34,5 +34,7 @@
"well_allocations": "Well allocations: Describe where liquids should go in labware.",
"what_if_you": "<span>What if you don’t provide all of those pieces of information? <bold>OpentronsAI asks you to provide it!</bold></span>",
"what_typeof_protocol": "What type of protocol do you need?",
"you": "You"
"you": "You",
"prompt_preview_submit_button": "Submit prompt",
"prompt_preview_placeholder_message": "As you complete the sections on the left, your prompt will be built here. When all requirements are met you will be able to generate the protocol."
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,13 @@ import { screen } from '@testing-library/react'
import { describe, it, vi, beforeEach, expect } from 'vitest'
import { renderWithProviders } from '../../../__testing-utils__'
import { i18n } from '../../../i18n'
import { PROMPT_PREVIEW_PLACEHOLDER_MESSAGE, PromptPreview } from '..'
import { PromptPreview } from '..'

const PROMPT_PREVIEW_PLACEHOLDER_MESSAGE =
'As you complete the sections on the left, your prompt will be built here. When all requirements are met you will be able to generate the protocol.'

const mockHandleClick = vi.fn()

const render = (props: React.ComponentProps<typeof PromptPreview>) => {
return renderWithProviders(<PromptPreview {...props} />, {
i18nInstance: i18n,
Expand Down
10 changes: 5 additions & 5 deletions opentrons-ai-client/src/molecules/PromptPreview/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,7 @@ import {
} from '@opentrons/components'
import { PromptPreviewSection } from '../PromptPreviewSection'
import type { PromptPreviewSectionProps } from '../PromptPreviewSection'

export const PROMPT_PREVIEW_PLACEHOLDER_MESSAGE =
'As you complete the sections on the left, your prompt will be built here. When all requirements are met you will be able to generate the protocol.'
import { useTranslation } from 'react-i18next'

interface PromptPreviewProps {
isSubmitButtonEnabled?: boolean
Expand Down Expand Up @@ -49,6 +47,8 @@ export function PromptPreview({
handleSubmit,
promptPreviewData = [],
}: PromptPreviewProps): JSX.Element {
const { t } = useTranslation('protocol_generator')

const areAllSectionsEmpty = (): boolean => {
return promptPreviewData.every(section => section.items.length === 0)
}
Expand All @@ -58,15 +58,15 @@ export function PromptPreview({
<PromptPreviewHeading>
<StyledText desktopStyle="headingLargeBold">Prompt</StyledText>
<LargeButton
buttonText="Submit prompt"
buttonText={t('prompt_preview_submit_button')}
disabled={!isSubmitButtonEnabled}
onClick={handleSubmit}
/>
</PromptPreviewHeading>

{areAllSectionsEmpty() && (
<PromptPreviewPlaceholderMessage desktopStyle="headingSmallRegular">
{PROMPT_PREVIEW_PLACEHOLDER_MESSAGE}
{t('prompt_preview_placeholder_message')}
</PromptPreviewPlaceholderMessage>
)}

Expand Down

0 comments on commit c13515c

Please sign in to comment.