-
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.
refactor(app): Update
dropTipInPlace
command text (#16610)
Closes EXEC-182 This commit updates tip drop command text when trash is dropped into a waste container, increasing specificity. Unfortunately, the command metadata itself does not give any location when performing a drop tip, so the app must derive the location from looking at the most recent addressableArea command. Fortunately, this should never be a compute-heavy scan unless the protocol does something like "move to trash" followed by a ton of "dispense over trash" before dropping tips, which seems quite unlikely in practice. Regardless, this instance serves as an example of places in which we should reduce compute done on the app in the future.
- Loading branch information
Showing
36 changed files
with
317 additions
and
95 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
186 changes: 186 additions & 0 deletions
186
...s/hooks/useCommandTextString/utils/commandText/__tests__/getPipettingCommandText.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,186 @@ | ||
import { screen } from '@testing-library/react' | ||
import { vi, describe, it, beforeEach } from 'vitest' | ||
import { useTranslation } from 'react-i18next' | ||
|
||
import { renderWithProviders } from '/app/__testing-utils__' | ||
import { i18n } from '/app/i18n' | ||
import { | ||
getLabwareDefinitionsFromCommands, | ||
getLabwareName, | ||
getLoadedLabware, | ||
getLabwareDisplayLocation, | ||
} from '/app/local-resources/labware' | ||
import { getPipettingCommandText } from '../getPipettingCommandText' | ||
import { getLabwareDefURI } from '@opentrons/shared-data' | ||
import { getFinalLabwareLocation } from '../../getFinalLabwareLocation' | ||
import { getWellRange } from '../../getWellRange' | ||
import { getFinalMoveToAddressableAreaCmd } from '../../getFinalAddressableAreaCmd' | ||
import { getAddressableAreaDisplayName } from '../../getAddressableAreaDisplayName' | ||
|
||
vi.mock('@opentrons/shared-data') | ||
vi.mock('../../getFinalLabwareLocation') | ||
vi.mock('../../getWellRange') | ||
vi.mock('/app/local-resources/labware') | ||
vi.mock('../../getFinalAddressableAreaCmd') | ||
vi.mock('../../getAddressableAreaDisplayName') | ||
|
||
const baseCommandData = { | ||
allRunDefs: {}, | ||
robotType: 'OT-2', | ||
commandTextData: { | ||
commands: [], | ||
labware: [], | ||
modules: [], | ||
pipettes: [{ id: 'pipette-1', pipetteName: 'p300_single' }], | ||
}, | ||
} as any | ||
|
||
function TestWrapper({ command }: { command: any }): JSX.Element { | ||
const { t } = useTranslation('protocol_command_text') | ||
const text = getPipettingCommandText({ | ||
command, | ||
...baseCommandData, | ||
t, | ||
}) | ||
|
||
return <div>{text}</div> | ||
} | ||
|
||
const render = (command: any) => { | ||
return renderWithProviders(<TestWrapper command={command} />, { | ||
i18nInstance: i18n, | ||
}) | ||
} | ||
|
||
describe('getPipettingCommandText', () => { | ||
beforeEach(() => { | ||
vi.mocked(getLabwareDefURI).mockImplementation((def: any) => def.uri) | ||
vi.mocked(getFinalLabwareLocation).mockReturnValue('slot-1' as any) | ||
vi.mocked(getWellRange).mockReturnValue('A1') | ||
vi.mocked(getLabwareDefinitionsFromCommands).mockReturnValue([ | ||
{ uri: 'tiprack-uri', parameters: { isTiprack: true } }, | ||
{ uri: 'plate-uri', parameters: { isTiprack: false } }, | ||
] as any) | ||
vi.mocked(getLabwareName).mockReturnValue('Test Labware') | ||
vi.mocked(getLoadedLabware).mockImplementation( | ||
(labware, id) => | ||
({ | ||
definitionUri: id === 'tiprack-id' ? 'tiprack-uri' : 'plate-uri', | ||
} as any) | ||
) | ||
vi.mocked(getLabwareDisplayLocation).mockReturnValue('Slot 1') | ||
vi.mocked(getFinalMoveToAddressableAreaCmd).mockReturnValue({ | ||
id: 'cmd-1', | ||
commandType: 'moveToAddressableArea', | ||
} as any) | ||
vi.mocked(getAddressableAreaDisplayName).mockReturnValue('Fixed Trash') | ||
}) | ||
|
||
it('should render aspirate command text correctly', () => { | ||
const command = { | ||
id: 'cmd-1', | ||
commandType: 'aspirate', | ||
params: { | ||
labwareId: 'labware-1', | ||
wellName: 'A1', | ||
volume: 100, | ||
flowRate: 150, | ||
}, | ||
} | ||
|
||
render(command) | ||
screen.getByText( | ||
/Aspirating 100 µL from well A1 of Test Labware in Slot 1 at 150 µL\/sec/ | ||
) | ||
}) | ||
|
||
it('should render dispense command text correctly', () => { | ||
const command = { | ||
id: 'cmd-1', | ||
commandType: 'dispense', | ||
params: { | ||
labwareId: 'labware-1', | ||
wellName: 'A1', | ||
volume: 100, | ||
flowRate: 150, | ||
}, | ||
} | ||
|
||
render(command) | ||
screen.getByText( | ||
/Dispensing 100 µL into well A1 of Test Labware in Slot 1 at 150 µL\/sec/ | ||
) | ||
}) | ||
|
||
it('should render dispense with push out command text correctly', () => { | ||
const command = { | ||
id: 'cmd-1', | ||
commandType: 'dispense', | ||
params: { | ||
labwareId: 'labware-1', | ||
wellName: 'A1', | ||
volume: 100, | ||
flowRate: 150, | ||
pushOut: 10, | ||
}, | ||
} | ||
|
||
render(command) | ||
screen.getByText( | ||
/Dispensing 100 µL into well A1 of Test Labware in Slot 1 at 150 µL\/sec and pushing out 10 µL/ | ||
) | ||
}) | ||
|
||
it('should render pickup tip command text correctly', () => { | ||
const command = { | ||
id: 'cmd-1', | ||
commandType: 'pickUpTip', | ||
params: { | ||
labwareId: 'tiprack-id', | ||
wellName: 'A1', | ||
pipetteId: 'pipette-1', | ||
}, | ||
} | ||
|
||
render(command) | ||
screen.getByText(/Picking up tip\(s\) from A1 of Test Labware in Slot 1/) | ||
}) | ||
|
||
it('should render drop tip in tiprack command text correctly', () => { | ||
const command = { | ||
id: 'cmd-1', | ||
commandType: 'dropTip', | ||
params: { | ||
labwareId: 'tiprack-id', | ||
wellName: 'A1', | ||
}, | ||
} | ||
|
||
render(command) | ||
screen.getByText(/Returning tip to A1 of Test Labware in Slot 1/) | ||
}) | ||
|
||
it('should render drop tip in place command text correctly if there is an addressable area name', () => { | ||
const command = { | ||
id: 'cmd-1', | ||
commandType: 'dropTipInPlace', | ||
params: {}, | ||
} | ||
|
||
render(command) | ||
screen.getByText('Dropping tip in Fixed Trash') | ||
}) | ||
|
||
it('should render drop tip in place command text correctly if there is not an addressable area name', () => { | ||
const command = { | ||
id: 'cmd-1', | ||
commandType: 'dropTipInPlace', | ||
params: {}, | ||
} | ||
|
||
vi.mocked(getFinalMoveToAddressableAreaCmd).mockReturnValue(null) | ||
|
||
render(command) | ||
screen.getByText('Dropping tip in place') | ||
}) | ||
}) |
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
2 changes: 1 addition & 1 deletion
2
...TextString/utils/getCommentCommandText.ts → ...tils/commandText/getCommentCommandText.ts
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
2 changes: 1 addition & 1 deletion
2
...utils/getConfigureForVolumeCommandText.ts → ...dText/getConfigureForVolumeCommandText.ts
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
2 changes: 1 addition & 1 deletion
2
...ls/getConfigureNozzleLayoutCommandText.ts → ...xt/getConfigureNozzleLayoutCommandText.ts
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
2 changes: 1 addition & 1 deletion
2
...dTextString/utils/getCustomCommandText.ts → ...utils/commandText/getCustomCommandText.ts
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
2 changes: 1 addition & 1 deletion
2
...ndTextString/utils/getDelayCommandText.ts → .../utils/commandText/getDelayCommandText.ts
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
2 changes: 1 addition & 1 deletion
2
.../utils/getDirectTranslationCommandText.ts → ...ndText/getDirectTranslationCommandText.ts
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
2 changes: 1 addition & 1 deletion
2
...tring/utils/getHSShakeSpeedCommandText.ts → ...commandText/getHSShakeSpeedCommandText.ts
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
4 changes: 2 additions & 2 deletions
4
...String/utils/getMoveLabwareCommandText.ts → .../commandText/getMoveLabwareCommandText.ts
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
2 changes: 1 addition & 1 deletion
2
...tring/utils/getMoveRelativeCommandText.ts → ...commandText/getMoveRelativeCommandText.ts
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
Oops, something went wrong.