Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor(app): update Flex drop-tip modal copy #14889

Merged
merged 2 commits into from
Apr 12, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions app/src/assets/localization/en/run_details.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,12 @@
"anticipated": "Anticipated steps",
"apply_stored_data": "Apply stored data",
"apply_stored_labware_offset_data": "Apply stored Labware Offset data?",
"cancel_run_alert_info": "Doing so will terminate this run, drop any attached tips in the trash container and home your robot.",
"cancel_run_alert_info_flex": "Doing so will terminate this run and home your robot.",
"cancel_run_alert_info_ot2": "Doing so will terminate this run, drop any attached tips in the trash container and home your robot.",
mjhuff marked this conversation as resolved.
Show resolved Hide resolved
"cancel_run_and_restart": "Cancel the run and restart setup to edit",
"cancel_run_modal_back": "No, go back",
"cancel_run_modal_confirm": "Yes, cancel run",
"cancel_run_modal_heading": "Are you sure you want to cancel this run?",
"cancel_run_modal_heading": "Are you sure you want to cancel?",
"cancel_run_module_info": "Additionally, any hardware modules used within the protocol will remain active and maintain their current states until deactivated.",
"cancel_run": "Cancel run",
"canceling_run_dot": "canceling run...",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ export function ConfirmCancelRunModal({
paddingBottom={SPACING.spacing32}
paddingTop={`${isActiveRun ? SPACING.spacing32 : '0'}`}
>
<StyledText as="p">{t('cancel_run_alert_info')}</StyledText>
<StyledText as="p">{t('cancel_run_alert_info_flex')}</StyledText>
<StyledText as="p">{t('cancel_run_module_info')}</StyledText>
</Flex>
<Flex
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,12 +97,10 @@ describe('ConfirmCancelRunModal', () => {
vi.restoreAllMocks()
})

it('should render text and buttons', () => {
it('should render correct text and buttons', () => {
render(props)
screen.getByText('Are you sure you want to cancel this run?')
screen.getByText(
'Doing so will terminate this run, drop any attached tips in the trash container and home your robot.'
)
screen.getByText('Are you sure you want to cancel?')
screen.getByText('Doing so will terminate this run and home your robot.')
screen.getByText(
'Additionally, any hardware modules used within the protocol will remain active and maintain their current states until deactivated.'
)
Expand All @@ -111,7 +109,7 @@ describe('ConfirmCancelRunModal', () => {
screen.getByText('Cancel run')
})

it('shoudler render the canceling run modal when run is dismissing', () => {
it('should render the canceling run modal when run is dismissing', () => {
vi.mocked(useDismissCurrentRunMutation).mockReturnValue({
dismissCurrentRun: mockDismissCurrentRun,
isLoading: true,
Expand Down
9 changes: 7 additions & 2 deletions app/src/organisms/RunDetails/ConfirmCancelModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import { useStopRunMutation } from '@opentrons/react-api-client'

import { getModalPortalEl } from '../../App/portal'
import { LegacyModal } from '../../molecules/LegacyModal'
import { useTrackProtocolRunEvent } from '../Devices/hooks'
import { useTrackProtocolRunEvent, useIsFlex } from '../Devices/hooks'
import { useRunStatus } from '../RunTimeControl/hooks'
import { ANALYTICS_PROTOCOL_RUN_CANCEL } from '../../redux/analytics'

Expand All @@ -39,9 +39,14 @@ export function ConfirmCancelModal(
const { stopRun } = useStopRunMutation()
const [isCanceling, setIsCanceling] = React.useState(false)
const runStatus = useRunStatus(runId)
const isFlex = useIsFlex(robotName)
const { trackProtocolRunEvent } = useTrackProtocolRunEvent(runId, robotName)
const { t } = useTranslation('run_details')

const cancelRunAlertInfo = isFlex
? t('cancel_run_alert_info_flex')
: t('cancel_run_alert_info_ot2')

const cancelRun: React.MouseEventHandler<HTMLButtonElement> = (e): void => {
e.preventDefault()
e.stopPropagation()
Expand Down Expand Up @@ -72,7 +77,7 @@ export function ConfirmCancelModal(
>
<Flex flexDirection={DIRECTION_COLUMN}>
<StyledText as="p" marginBottom={SPACING.spacing24}>
{t('cancel_run_alert_info')}
{cancelRunAlertInfo}
</StyledText>
<StyledText as="p" marginBottom={SPACING.spacing24}>
{t('cancel_run_module_info')}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,10 @@ import {
import { useStopRunMutation } from '@opentrons/react-api-client'

import { i18n } from '../../../i18n'
import { useTrackProtocolRunEvent } from '../../../organisms/Devices/hooks'
import {
useIsFlex,
useTrackProtocolRunEvent,
} from '../../../organisms/Devices/hooks'
import { useTrackEvent } from '../../../redux/analytics'
import { renderWithProviders } from '../../../__testing-utils__'
import { ConfirmCancelModal } from '../../../organisms/RunDetails/ConfirmCancelModal'
Expand Down Expand Up @@ -56,6 +59,7 @@ describe('ConfirmCancelModal', () => {
when(useTrackProtocolRunEvent).calledWith(RUN_ID, ROBOT_NAME).thenReturn({
trackProtocolRunEvent: mockTrackProtocolRunEvent,
})
vi.mocked(useIsFlex).mockReturnValue(true)

props = { onClose: vi.fn(), runId: RUN_ID, robotName: ROBOT_NAME }
})
Expand All @@ -66,15 +70,20 @@ describe('ConfirmCancelModal', () => {

it('should render the correct title', () => {
render(props)
screen.getByText('Are you sure you want to cancel this run?')
screen.getByText('Are you sure you want to cancel?')
})
it('should render the correct body', () => {
it('should render the correct body text for a Flex', () => {
render(props)
screen.getByText('Doing so will terminate this run and home your robot.')
screen.getByText(
'Doing so will terminate this run, drop any attached tips in the trash container and home your robot.'
'Additionally, any hardware modules used within the protocol will remain active and maintain their current states until deactivated.'
)
})
it('should render correct alternative body text for an OT-2', () => {
vi.mocked(useIsFlex).mockReturnValue(false)
render(props)
screen.getByText(
'Additionally, any hardware modules used within the protocol will remain active and maintain their current states until deactivated.'
'Doing so will terminate this run, drop any attached tips in the trash container and home your robot.'
)
})
it('should render both buttons', () => {
Expand Down
Loading