-
Notifications
You must be signed in to change notification settings - Fork 178
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(app): Handle Unsafe Move to Plunger during Drop-Tip (#14910)
Closes EXEC-186 If the gantry is not homed and a powercycle occurs, drop-tip wizard cannot proceed with flows. An error is raised during the flow, and ultimately a home command is dispatched that has the side effect of potentially aspirating liquid into the pipette, damaging it. We special case home errors to prevent this. The primary functional difference is now that any time an error occurs, exiting the wizard via the header should not home the gantry. Homing as a result of an error should only occur when the "Confirm removal and home" button is presented and clicked.
- Loading branch information
1 parent
48001ac
commit 6a222c1
Showing
9 changed files
with
601 additions
and
248 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
131 changes: 131 additions & 0 deletions
131
app/src/organisms/DropTipWizard/__tests__/utils.test.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,131 @@ | ||
import { describe, it, expect, vi, beforeEach } from 'vitest' | ||
import { screen, render, fireEvent } from '@testing-library/react' | ||
|
||
import { useDropTipErrorComponents, useWizardExitHeader } from '../utils' | ||
import { DROP_TIP_SPECIAL_ERROR_TYPES } from '../constants' | ||
|
||
import type { Mock } from 'vitest' | ||
import type { | ||
UseDropTipErrorComponentsProps, | ||
UseWizardExitHeaderProps, | ||
} from '../utils' | ||
|
||
const MOCK_MAINTENANCE_RUN_ID = 'MOCK_MAINTENANCE_RUN_ID' | ||
const MOCK_ERROR_TYPE = 'MOCK_ERROR_TYPE' | ||
const MOCK_ERROR_MESSAGE = 'MOCK_ERROR_MESSAGE' | ||
const MOCK_ERROR_HEADER = 'MOCK_ERROR_HEADER' | ||
|
||
describe('useDropTipErrorComponents', () => { | ||
let props: UseDropTipErrorComponentsProps | ||
let mockOnClose: Mock | ||
let mockTranslation: Mock | ||
let mockChainRunCommands: Mock | ||
|
||
beforeEach(() => { | ||
mockOnClose = vi.fn() | ||
mockTranslation = vi.fn() | ||
mockChainRunCommands = vi.fn() | ||
|
||
props = { | ||
maintenanceRunId: MOCK_MAINTENANCE_RUN_ID, | ||
onClose: mockOnClose, | ||
errorDetails: { | ||
type: MOCK_ERROR_TYPE, | ||
message: MOCK_ERROR_MESSAGE, | ||
header: MOCK_ERROR_HEADER, | ||
}, | ||
isOnDevice: true, | ||
t: mockTranslation, | ||
chainRunCommands: mockChainRunCommands, | ||
} | ||
}) | ||
|
||
it('should return the generic text and error message if there is are no special-cased error details', () => { | ||
const result = useDropTipErrorComponents(props) | ||
expect(result.button).toBeNull() | ||
render(result.subHeader) | ||
expect(mockTranslation).toHaveBeenCalledWith('drop_tip_failed') | ||
screen.getByText(MOCK_ERROR_MESSAGE) | ||
}) | ||
|
||
it('should return a generic message only if there are no error details', () => { | ||
props.errorDetails = null | ||
const result = useDropTipErrorComponents(props) | ||
expect(result.button).toBeNull() | ||
render(result.subHeader) | ||
expect(mockTranslation).toHaveBeenCalledWith('drop_tip_failed') | ||
expect(screen.queryByText(MOCK_ERROR_MESSAGE)).not.toBeInTheDocument() | ||
}) | ||
|
||
it(`should return correct special components if error type is ${DROP_TIP_SPECIAL_ERROR_TYPES.MUST_HOME_ERROR}`, () => { | ||
// @ts-expect-error errorDetails is in fact not null in the test. | ||
props.errorDetails.type = DROP_TIP_SPECIAL_ERROR_TYPES.MUST_HOME_ERROR | ||
const result = useDropTipErrorComponents(props) | ||
expect(mockTranslation).toHaveBeenCalledWith('confirm_removal_and_home') | ||
|
||
render(result.button) | ||
const btn = screen.getByRole('button') | ||
fireEvent.click(btn) | ||
expect(mockOnClose).toHaveBeenCalled() | ||
expect(mockChainRunCommands).toHaveBeenCalledWith( | ||
MOCK_MAINTENANCE_RUN_ID, | ||
[ | ||
{ | ||
commandType: 'home' as const, | ||
params: {}, | ||
}, | ||
], | ||
true | ||
) | ||
|
||
render(result.subHeader) | ||
screen.getByText(MOCK_ERROR_MESSAGE) | ||
}) | ||
}) | ||
|
||
describe('useWizardExitHeader', () => { | ||
let props: UseWizardExitHeaderProps | ||
let mockHandleCleanUpAndClose: Mock | ||
let mockConfirmExit: Mock | ||
|
||
beforeEach(() => { | ||
mockHandleCleanUpAndClose = vi.fn() | ||
mockConfirmExit = vi.fn() | ||
|
||
props = { | ||
isFinalStep: true, | ||
hasInitiatedExit: false, | ||
errorDetails: null, | ||
handleCleanUpAndClose: mockHandleCleanUpAndClose, | ||
confirmExit: mockConfirmExit, | ||
} | ||
}) | ||
|
||
it('should appropriately return handleCleanUpAndClose', () => { | ||
const handleExit = useWizardExitHeader(props) | ||
expect(handleExit).toEqual(props.handleCleanUpAndClose) | ||
}) | ||
|
||
it('should appropriately return confirmExit', () => { | ||
props = { ...props, isFinalStep: false } | ||
const handleExit = useWizardExitHeader(props) | ||
expect(handleExit).toEqual(props.confirmExit) | ||
}) | ||
|
||
it('should appropriately return handleCleanUpAndClose with homeOnError = false', () => { | ||
const errorDetails = { message: 'Some error occurred' } | ||
const modifiedProps = { ...props, errorDetails } | ||
const handleExit = useWizardExitHeader(modifiedProps) | ||
expect(mockHandleCleanUpAndClose.mock.calls.length).toBe(0) | ||
handleExit() | ||
expect(mockHandleCleanUpAndClose).toHaveBeenCalledWith(false) | ||
}) | ||
|
||
it('should appropriately return a function that does nothing ', () => { | ||
const modifiedProps = { ...props, hasInitiatedExit: true } | ||
const handleExit = useWizardExitHeader(modifiedProps) | ||
handleExit() | ||
expect(mockHandleCleanUpAndClose.mock.calls.length).toBe(0) | ||
expect(mockConfirmExit.mock.calls.length).toBe(0) | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.