From 4da8206593bca58e80f4beab45b1aff7eac136ee Mon Sep 17 00:00:00 2001 From: Jamey H Date: Fri, 15 Dec 2023 14:48:21 -0500 Subject: [PATCH] fix(app): ODD - Remove dismisscurrentrun on protocol cancel button (#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. --- .../__tests__/ProtocolRunHeader.test.tsx | 9 --------- .../RunningProtocol/ConfirmCancelRunModal.tsx | 12 ++---------- .../__tests__/ConfirmCancelRunModal.test.tsx | 13 ++----------- 3 files changed, 4 insertions(+), 30 deletions(-) diff --git a/app/src/organisms/Devices/ProtocolRun/__tests__/ProtocolRunHeader.test.tsx b/app/src/organisms/Devices/ProtocolRun/__tests__/ProtocolRunHeader.test.tsx index aa65ae218e0..cad5de28172 100644 --- a/app/src/organisms/Devices/ProtocolRun/__tests__/ProtocolRunHeader.test.tsx +++ b/app/src/organisms/Devices/ProtocolRun/__tests__/ProtocolRunHeader.test.tsx @@ -22,7 +22,6 @@ import { useRunQuery, useModulesQuery, usePipettesQuery, - useDismissCurrentRunMutation, useEstopQuery, useDoorQuery, useInstrumentsQuery, @@ -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 > @@ -396,11 +392,6 @@ describe('ProtocolRunHeader', () => { .mockReturnValue({ data: { data: mockIdleUnstartedRun }, } as UseQueryResult) - when(mockUseDismissCurrentRunMutation) - .calledWith() - .mockReturnValue({ - dismissCurrentRun: jest.fn(), - } as any) when(mockUseProtocolDetailsForRun) .calledWith(RUN_ID) .mockReturnValue(PROTOCOL_DETAILS) diff --git a/app/src/organisms/OnDeviceDisplay/RunningProtocol/ConfirmCancelRunModal.tsx b/app/src/organisms/OnDeviceDisplay/RunningProtocol/ConfirmCancelRunModal.tsx index 1b6996ba885..771417f33c3 100644 --- a/app/src/organisms/OnDeviceDisplay/RunningProtocol/ConfirmCancelRunModal.tsx +++ b/app/src/organisms/OnDeviceDisplay/RunningProtocol/ConfirmCancelRunModal.tsx @@ -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' @@ -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() @@ -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}`) @@ -79,7 +71,7 @@ export function ConfirmCancelRunModal({ } }, [runStatus]) - return isCanceling || isDismissing ? ( + return isCanceling ? ( ) : ( { 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') @@ -147,7 +138,7 @@ describe('ConfirmCancelRunModal', () => { .mockReturnValue(RUN_STATUS_STOPPED) render(props) - expect(mockDismissCurrentRun).toHaveBeenCalled() + expect(mockDismissCurrentRun).not.toHaveBeenCalled() expect(mockTrackProtocolRunEvent).toHaveBeenCalled() }) @@ -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') })