Skip to content

Commit

Permalink
fix(app): ODD - Remove dismisscurrentrun on protocol cancel button (#…
Browse files Browse the repository at this point in the history
…14218)

* fix(app): remove dismissCurrentRun when run is cancelled on ODD

Mirror the desktop app. Dismissing the run context on run cancel means drop tip will not work.
  • Loading branch information
mjhuff authored Dec 15, 2023
1 parent f5a99be commit 4da8206
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 30 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ import {
useRunQuery,
useModulesQuery,
usePipettesQuery,
useDismissCurrentRunMutation,
useEstopQuery,
useDoorQuery,
useInstrumentsQuery,
Expand Down Expand Up @@ -187,9 +186,6 @@ const mockUseModulesQuery = useModulesQuery as jest.MockedFunction<
const mockUsePipettesQuery = usePipettesQuery as jest.MockedFunction<
typeof usePipettesQuery
>
const mockUseDismissCurrentRunMutation = useDismissCurrentRunMutation as jest.MockedFunction<
typeof useDismissCurrentRunMutation
>
const mockConfirmCancelModal = ConfirmCancelModal as jest.MockedFunction<
typeof ConfirmCancelModal
>
Expand Down Expand Up @@ -396,11 +392,6 @@ describe('ProtocolRunHeader', () => {
.mockReturnValue({
data: { data: mockIdleUnstartedRun },
} as UseQueryResult<Run>)
when(mockUseDismissCurrentRunMutation)
.calledWith()
.mockReturnValue({
dismissCurrentRun: jest.fn(),
} as any)
when(mockUseProtocolDetailsForRun)
.calledWith(RUN_ID)
.mockReturnValue(PROTOCOL_DETAILS)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,7 @@ import {
Flex,
SPACING,
} from '@opentrons/components'
import {
useStopRunMutation,
useDismissCurrentRunMutation,
} from '@opentrons/react-api-client'
import { useStopRunMutation } from '@opentrons/react-api-client'

import { StyledText } from '../../../atoms/text'
import { SmallButton } from '../../../atoms/buttons'
Expand All @@ -40,10 +37,6 @@ export function ConfirmCancelRunModal({
}: ConfirmCancelRunModalProps): JSX.Element {
const { t } = useTranslation(['run_details', 'shared'])
const { stopRun } = useStopRunMutation()
const {
dismissCurrentRun,
isLoading: isDismissing,
} = useDismissCurrentRunMutation()
const runStatus = useRunStatus(runId)
const { trackProtocolRunEvent } = useTrackProtocolRunEvent(runId)
const history = useHistory()
Expand All @@ -68,7 +61,6 @@ export function ConfirmCancelRunModal({
React.useEffect(() => {
if (runStatus === RUN_STATUS_STOPPED) {
trackProtocolRunEvent({ name: ANALYTICS_PROTOCOL_RUN_CANCEL })
dismissCurrentRun(runId)
if (!isActiveRun) {
if (protocolId != null) {
history.push(`/protocols/${protocolId}`)
Expand All @@ -79,7 +71,7 @@ export function ConfirmCancelRunModal({
}
}, [runStatus])

return isCanceling || isDismissing ? (
return isCanceling ? (
<CancelingRunModal />
) : (
<Modal
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -118,15 +118,6 @@ describe('ConfirmCancelRunModal', () => {
getByText('Cancel run')
})

it('shoudler render the canceling run modal when run is dismissing', () => {
mockUseDismissCurrentRunMutation.mockReturnValue({
dismissCurrentRun: mockDismissCurrentRun,
isLoading: true,
} as any)
const [{ getByText }] = render(props)
getByText('mock CancelingRunModal')
})

it('when tapping go back, the mock function is called', () => {
const [{ getByText }] = render(props)
const button = getByText('Go back')
Expand All @@ -147,7 +138,7 @@ describe('ConfirmCancelRunModal', () => {
.mockReturnValue(RUN_STATUS_STOPPED)
render(props)

expect(mockDismissCurrentRun).toHaveBeenCalled()
expect(mockDismissCurrentRun).not.toHaveBeenCalled()
expect(mockTrackProtocolRunEvent).toHaveBeenCalled()
})

Expand All @@ -161,7 +152,7 @@ describe('ConfirmCancelRunModal', () => {
.mockReturnValue(RUN_STATUS_STOPPED)
render(props)

expect(mockDismissCurrentRun).toHaveBeenCalled()
expect(mockDismissCurrentRun).not.toHaveBeenCalled()
expect(mockTrackProtocolRunEvent).toHaveBeenCalled()
expect(mockPush).toHaveBeenCalledWith('/protocols')
})
Expand Down

0 comments on commit 4da8206

Please sign in to comment.