Skip to content

Commit

Permalink
test fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
mjhuff committed Aug 12, 2024
1 parent ef561f7 commit 5a11613
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 22 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ import { DropTipWizardFlows } from '../../DropTipWizardFlows'
import { DT_ROUTES } from '../../DropTipWizardFlows/constants'
import { SelectRecoveryOption } from './SelectRecoveryOption'

import type { PipettingRunTimeCommand } from '@opentrons/shared-data'
import type { PipetteWithTip } from '../../DropTipWizardFlows'
import type { RecoveryContentProps, RecoveryRoute, RouteStep } from '../types'
import type { FixitCommandTypeUtils } from '../../DropTipWizardFlows/types'
Expand Down Expand Up @@ -201,7 +200,6 @@ export function useDropTipFlowUtils({
subMapUtils,
routeUpdateActions,
recoveryMap,
failedPipetteInfo,
}: RecoveryContentProps): FixitCommandTypeUtils {
const { t } = useTranslation('error_recovery')
const {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* eslint-disable testing-library/prefer-presence-queries */
import * as React from 'react'
import { describe, it, vi, expect, beforeEach } from 'vitest'
import { screen, fireEvent } from '@testing-library/react'
Expand Down Expand Up @@ -48,63 +49,63 @@ describe('RecoveryError', () => {
RECOVERY_MAP.ERROR_WHILE_RECOVERING.STEPS.RECOVERY_ACTION_FAILED
render(props)

expect(screen.getByText('Retry step failed')).toBeInTheDocument()
expect(screen.queryAllByText('Retry step failed')[0]).toBeInTheDocument()
expect(
screen.getByText(
screen.queryAllByText(
'Next, you can try another recovery action or cancel the run.'
)
)[0]
).toBeInTheDocument()
expect(screen.getByText('Back to menu')).toBeInTheDocument()
expect(screen.queryAllByText('Back to menu')[0]).toBeInTheDocument()
})

it(`renders RecoveryDropTipFlowErrors when step is ${ERROR_WHILE_RECOVERING.STEPS.DROP_TIP_GENERAL_ERROR}`, () => {
props.recoveryMap.step =
RECOVERY_MAP.ERROR_WHILE_RECOVERING.STEPS.DROP_TIP_GENERAL_ERROR
render(props)

expect(screen.getByText('Retry step failed')).toBeInTheDocument()
expect(screen.queryAllByText('Retry step failed')[0]).toBeInTheDocument()
expect(
screen.getByText(
screen.queryAllByText(
'Next, you can try another recovery action or cancel the run.'
)
)[0]
).toBeInTheDocument()
expect(screen.getByText('Return to menu')).toBeInTheDocument()
expect(screen.queryAllByText('Return to menu')[0]).toBeInTheDocument()
})

it(`renders RecoveryDropTipFlowErrors when step is ${ERROR_WHILE_RECOVERING.STEPS.DROP_TIP_BLOWOUT_FAILED}`, () => {
props.recoveryMap.step =
RECOVERY_MAP.ERROR_WHILE_RECOVERING.STEPS.DROP_TIP_BLOWOUT_FAILED
render(props)

expect(screen.getByText('Blowout failed')).toBeInTheDocument()
expect(screen.queryAllByText('Blowout failed')[0]).toBeInTheDocument()
expect(
screen.getByText(
screen.queryAllByText(
'You can still drop the attached tips before proceeding to tip selection.'
)
)[0]
).toBeInTheDocument()
expect(screen.getByText('Continue to drop tip')).toBeInTheDocument()
expect(screen.queryAllByText('Continue to drop tip')[0]).toBeInTheDocument()
})

it(`renders RecoveryDropTipFlowErrors when step is ${ERROR_WHILE_RECOVERING.STEPS.DROP_TIP_TIP_DROP_FAILED}`, () => {
props.recoveryMap.step =
RECOVERY_MAP.ERROR_WHILE_RECOVERING.STEPS.DROP_TIP_TIP_DROP_FAILED
render(props)

expect(screen.getByText('Tip drop failed')).toBeInTheDocument()
expect(screen.queryAllByText('Tip drop failed')[0]).toBeInTheDocument()
expect(
screen.getByText(
screen.queryAllByText(
'Next, you can try another recovery action or cancel the run.'
)
)[0]
).toBeInTheDocument()
expect(screen.getByText('Return to menu')).toBeInTheDocument()
expect(screen.queryAllByText('Return to menu')[0]).toBeInTheDocument()
})

it(`calls proceedToRouteAndStep with ${RECOVERY_MAP.OPTION_SELECTION.ROUTE} when the "Back to menu" button is clicked in ErrorRecoveryFlowError`, () => {
props.recoveryMap.step =
RECOVERY_MAP.ERROR_WHILE_RECOVERING.STEPS.RECOVERY_ACTION_FAILED
render(props)

fireEvent.click(screen.getByText('Back to menu'))
fireEvent.click(screen.queryAllByText('Back to menu')[0])

expect(proceedToRouteAndStepMock).toHaveBeenCalledWith(
RECOVERY_MAP.OPTION_SELECTION.ROUTE
Expand All @@ -116,7 +117,7 @@ describe('RecoveryError', () => {
RECOVERY_MAP.ERROR_WHILE_RECOVERING.STEPS.DROP_TIP_GENERAL_ERROR
render(props)

fireEvent.click(screen.getByText('Return to menu'))
fireEvent.click(screen.queryAllByText('Return to menu')[0])

expect(proceedToRouteAndStepMock).toHaveBeenCalledWith(
RECOVERY_MAP.OPTION_SELECTION.ROUTE
Expand All @@ -128,7 +129,7 @@ describe('RecoveryError', () => {
RECOVERY_MAP.ERROR_WHILE_RECOVERING.STEPS.DROP_TIP_TIP_DROP_FAILED
render(props)

fireEvent.click(screen.getByText('Return to menu'))
fireEvent.click(screen.queryAllByText('Return to menu')[0])

expect(proceedToRouteAndStepMock).toHaveBeenCalledWith(
RECOVERY_MAP.OPTION_SELECTION.ROUTE
Expand All @@ -140,7 +141,7 @@ describe('RecoveryError', () => {
RECOVERY_MAP.ERROR_WHILE_RECOVERING.STEPS.DROP_TIP_BLOWOUT_FAILED
render(props)

fireEvent.click(screen.getByText('Continue to drop tip'))
fireEvent.click(screen.queryAllByText('Continue to drop tip')[0])

expect(proceedToRouteAndStepMock).toHaveBeenCalledWith(
RECOVERY_MAP.DROP_TIP_FLOWS.ROUTE,
Expand Down

0 comments on commit 5a11613

Please sign in to comment.