Skip to content

Commit

Permalink
fix(app): No longer dismiss run if canceled while running on ODD (#16142
Browse files Browse the repository at this point in the history
  • Loading branch information
smb2268 authored Aug 27, 2024
1 parent 8a0ca2f commit f74aa8a
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 37 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,17 @@ export function ConfirmCancelRunModal({
dismissCurrentRun,
isLoading: isDismissing,
} = useDismissCurrentRunMutation({
onSuccess: () => {
if (isQuickTransfer && !isActiveRun) {
onSettled: () => {
if (isQuickTransfer && protocolId != null) {
deleteRun(runId)
navigate(`/quick-transfer/${protocolId}`)
} else if (isQuickTransfer) {
deleteRun(runId)
navigate('/quick-transfer')
} else if (protocolId != null) {
navigate(`/protocols/${protocolId}`)
} else {
navigate('/protocols')
}
},
})
Expand Down Expand Up @@ -87,17 +95,8 @@ export function ConfirmCancelRunModal({
React.useEffect(() => {
if (runStatus === RUN_STATUS_STOPPED) {
trackProtocolRunEvent({ name: ANALYTICS_PROTOCOL_RUN_ACTION.CANCEL })
dismissCurrentRun(runId)
if (!isActiveRun) {
if (isQuickTransfer && protocolId != null) {
navigate(`/quick-transfer/${protocolId}`)
} else if (isQuickTransfer) {
navigate('/quick-transfer')
} else if (protocolId != null) {
navigate(`/protocols/${protocolId}`)
} else {
navigate('/protocols')
}
dismissCurrentRun(runId)
}
}
}, [runStatus])
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -138,15 +138,7 @@ describe('ConfirmCancelRunModal', () => {
expect(mockStopRun).toHaveBeenCalled()
})

it('when run is stopped, the run is dismissed and the modal closes', () => {
when(useRunStatus).calledWith(RUN_ID).thenReturn(RUN_STATUS_STOPPED)
render(props)

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

it('when run is stopped, the run is dismissed and the modal closes - in prepare to run', () => {
it('when run is stopped, the run is dismissed and the modal closes if the run is not yet active', () => {
props = {
...props,
isActiveRun: false,
Expand All @@ -156,18 +148,13 @@ describe('ConfirmCancelRunModal', () => {

expect(mockDismissCurrentRun).toHaveBeenCalled()
expect(mockTrackProtocolRunEvent).toHaveBeenCalled()
expect(mockNavigate).toHaveBeenCalledWith('/protocols')
})
it('when quick transfer run is stopped, the run is dismissed and you return to quick transfer', () => {
props = {
...props,
isActiveRun: false,
isQuickTransfer: true,
}

it('when run is stopped, the run is not dismissed if the run is active', () => {
when(useRunStatus).calledWith(RUN_ID).thenReturn(RUN_STATUS_STOPPED)
render(props)

expect(mockDismissCurrentRun).toHaveBeenCalled()
expect(mockNavigate).toHaveBeenCalledWith('/quick-transfer')
expect(mockDismissCurrentRun).not.toHaveBeenCalled()
expect(mockTrackProtocolRunEvent).toHaveBeenCalled()
})
})
9 changes: 2 additions & 7 deletions app/src/pages/RunSummary/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -251,15 +251,10 @@ export function RunSummary(): JSX.Element {
}, [isRunCurrent, enteredER])

const returnToQuickTransfer = (): void => {
if (!isRunCurrent) {
closeCurrentRunIfValid(() => {
deleteRun(runId)
navigate('/quick-transfer')
} else {
closeCurrentRunIfValid(() => {
deleteRun(runId)
navigate('/quick-transfer')
})
}
})
}

// TODO(jh, 05-30-24): EXEC-487. Refactor reset() so we can redirect to the setup page, showing the shimmer skeleton instead.
Expand Down

0 comments on commit f74aa8a

Please sign in to comment.