-
Notifications
You must be signed in to change notification settings - Fork 179
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(protocol-designer): allow custom labware on modules (#5175)
* feat(protocol-designer): allow custom labware on modules on deck closes #4910 * add tests * clean up files and tests * add more tests
- Loading branch information
jen-fong
authored
Mar 12, 2020
1 parent
65425da
commit 1c4e1b5
Showing
6 changed files
with
441 additions
and
20 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
102 changes: 102 additions & 0 deletions
102
protocol-designer/src/components/DeckSetup/LabwareOverlays/__tests__/SlotControls.test.js
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,102 @@ | ||
// @flow | ||
|
||
import React from 'react' | ||
import { shallow } from 'enzyme' | ||
import fixture_96_plate from '@opentrons/shared-data/labware/fixtures/2/fixture_96_plate.json' | ||
import { MAGNETIC_MODULE_TYPE } from '@opentrons/shared-data' | ||
import * as labwareModuleCompatibility from '../../../../utils/labwareModuleCompatibility' | ||
import { START_TERMINAL_ITEM_ID } from '../../../../steplist' | ||
import { SlotControlsComponent } from '../SlotControls' | ||
import { BlockedSlot } from '../BlockedSlot' | ||
|
||
describe('SlotControlsComponent', () => { | ||
let props, getLabwareIsCompatibleSpy | ||
beforeEach(() => { | ||
const slot = { | ||
id: 'deckSlot1', | ||
position: [1, 2, 3], | ||
boundingBox: { | ||
xDimension: 10, | ||
yDimension: 20, | ||
zDimension: 40, | ||
}, | ||
displayName: 'slot 1', | ||
compatibleModules: ['magdeck'], | ||
} | ||
|
||
const labwareOnDeck = { | ||
labwareDefURI: 'fixture/fixture_96_plate', | ||
id: 'plate123', | ||
slot: '3', | ||
def: fixture_96_plate, | ||
} | ||
|
||
props = { | ||
slot, | ||
addLabware: jest.fn(), | ||
moveDeckItem: jest.fn(), | ||
selectedTerminalItemId: START_TERMINAL_ITEM_ID, | ||
isOver: true, | ||
connectDropTarget: el => <svg>{el}</svg>, | ||
moduleType: MAGNETIC_MODULE_TYPE, | ||
draggedItem: { | ||
labwareOnDeck, | ||
}, | ||
customLabwareDefs: {}, | ||
} | ||
|
||
getLabwareIsCompatibleSpy = jest.spyOn( | ||
labwareModuleCompatibility, | ||
'getLabwareIsCompatible' | ||
) | ||
}) | ||
|
||
afterEach(() => { | ||
getLabwareIsCompatibleSpy.mockClear() | ||
}) | ||
|
||
it('renders nothing when not start terminal item', () => { | ||
props.selectedTerminalItemId = '__end__' | ||
|
||
const wrapper = shallow(<SlotControlsComponent {...props} />) | ||
|
||
expect(wrapper.get(0)).toBeNull() | ||
}) | ||
|
||
it('gives a slot blocked warning when dragged noncustom and incompatible labware is over a module slot with labware', () => { | ||
getLabwareIsCompatibleSpy.mockReturnValue(false) | ||
|
||
const wrapper = shallow(<SlotControlsComponent {...props} />) | ||
const blockedSlot = wrapper.find(BlockedSlot) | ||
|
||
expect(blockedSlot.prop('message')).toBe( | ||
'MODULE_INCOMPATIBLE_SINGLE_LABWARE' | ||
) | ||
}) | ||
|
||
it('displays place here when dragged compatible labware is hovered over slot with labware', () => { | ||
getLabwareIsCompatibleSpy.mockReturnValue(true) | ||
|
||
const wrapper = shallow(<SlotControlsComponent {...props} />) | ||
|
||
expect(wrapper.render().text()).toContain('Place Here') | ||
}) | ||
|
||
it('displays place here when dragged labware is custom and hovered over another labware on module slot', () => { | ||
props.customLabwareDefs = { | ||
'fixture/fixture_96_plate': fixture_96_plate, | ||
} | ||
|
||
const wrapper = shallow(<SlotControlsComponent {...props} />) | ||
|
||
expect(wrapper.render().text()).toContain('Place Here') | ||
}) | ||
|
||
it('displays add labware when slot is empty', () => { | ||
props.isOver = false | ||
|
||
const wrapper = shallow(<SlotControlsComponent {...props} />) | ||
|
||
expect(wrapper.render().text()).toContain('Add Labware') | ||
}) | ||
}) |
Oops, something went wrong.