Skip to content

Commit

Permalink
fix(app): send custom labware files to flex with protocol (#13089)
Browse files Browse the repository at this point in the history
Just as the create run from protocol function spreads in all known custom labware files when
creating a protocol record on a robot, the send to robot feature should also include custom labware.
  • Loading branch information
b-cooper authored Jul 12, 2023
1 parent 5aab331 commit 92ce671
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,14 @@ import { storedProtocolData as storedProtocolDataFixture } from '../../../redux/
import { SendProtocolToOT3Slideout } from '..'

import type { State } from '../../../redux/types'
import { getValidCustomLabwareFiles } from '../../../redux/custom-labware'

jest.mock('@opentrons/react-api-client')
jest.mock('../../../organisms/ToasterOven')
jest.mock('../../../redux/buildroot')
jest.mock('../../../redux/discovery')
jest.mock('../../../redux/networking')
jest.mock('../../../redux/custom-labware')
jest.mock('../../../redux/protocol-storage/selectors')

const mockGetBuildrootUpdateDisplayInfo = getBuildrootUpdateDisplayInfo as jest.MockedFunction<
Expand Down Expand Up @@ -73,6 +75,9 @@ const mockGetIsProtocolAnalysisInProgress = getIsProtocolAnalysisInProgress as j
const mockGetNetworkInterfaces = getNetworkInterfaces as jest.MockedFunction<
typeof getNetworkInterfaces
>
const mockGetValidCustomLabwareFiles = getValidCustomLabwareFiles as jest.MockedFunction<
typeof getValidCustomLabwareFiles
>

const render = (
props: React.ComponentProps<typeof SendProtocolToOT3Slideout>
Expand Down Expand Up @@ -110,6 +115,7 @@ const mockMakeSnackbar = jest.fn()
const mockMakeToast = jest.fn()
const mockEatToast = jest.fn()
const mockMutateAsync = jest.fn()
const mockCustomLabwareFile: File = { path: 'fake_custom_labware_path' } as any

describe('SendProtocolToOT3Slideout', () => {
beforeEach(() => {
Expand Down Expand Up @@ -144,6 +150,9 @@ describe('SendProtocolToOT3Slideout', () => {
when(mockGetNetworkInterfaces)
.calledWith({} as State, expect.any(String))
.mockReturnValue({ wifi: null, ethernet: null })
when(mockGetValidCustomLabwareFiles)
.calledWith({} as State)
.mockReturnValue([mockCustomLabwareFile])
})
afterEach(() => {
jest.resetAllMocks()
Expand Down Expand Up @@ -246,6 +255,9 @@ describe('SendProtocolToOT3Slideout', () => {
mockRobot.click()
expect(sendButton).not.toBeDisabled()
sendButton.click()
expect(mockMutateAsync).toBeCalled()
expect(mockMutateAsync).toBeCalledWith({
files: [expect.any(Object), mockCustomLabwareFile],
protocolKey: 'protocolKeyStub',
})
})
})
7 changes: 6 additions & 1 deletion app/src/organisms/SendProtocolToOT3Slideout/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import type { IconProps, StyleProps } from '@opentrons/components'
import type { Robot } from '../../redux/discovery/types'
import type { StoredProtocolData } from '../../redux/protocol-storage'
import type { State } from '../../redux/types'
import { getValidCustomLabwareFiles } from '../../redux/custom-labware'

interface SendProtocolToOT3SlideoutProps extends StyleProps {
storedProtocolData: StoredProtocolData
Expand Down Expand Up @@ -51,6 +52,7 @@ export function SendProtocolToOT3Slideout(
const isAnalyzing = useSelector((state: State) =>
getIsProtocolAnalysisInProgress(state, protocolKey)
)
const customLabwareFiles = useSelector(getValidCustomLabwareFiles)

const analysisStatus = getAnalysisStatus(isAnalyzing, mostRecentAnalysis)

Expand Down Expand Up @@ -82,7 +84,10 @@ export function SendProtocolToOT3Slideout(
disableTimeout: true,
})

createProtocolAsync({ files: srcFileObjects, protocolKey })
createProtocolAsync({
files: [...srcFileObjects, ...customLabwareFiles],
protocolKey,
})
.then(() => {
eatToast(toastId)
makeToast(selectedRobot?.name ?? '', SUCCESS_TOAST, {
Expand Down

0 comments on commit 92ce671

Please sign in to comment.