diff --git a/app/src/calibration/__tests__/reducer.test.js b/app/src/calibration/__tests__/reducer.test.js index 039285affafa..ecfbc20af548 100644 --- a/app/src/calibration/__tests__/reducer.test.js +++ b/app/src/calibration/__tests__/reducer.test.js @@ -21,13 +21,13 @@ describe('calibration reducer', () => { it('should handle a FETCH_LABWARE_CALIBRATION_SUCCESS', () => { const action = LabwareActions.fetchLabwareCalibrationSuccess( 'robot-name', - [LabwareFixtures.mockLabwareCalibration], + LabwareFixtures.mockAllLabwareCalibraton, {} ) expect(calibrationReducer({}, action)).toEqual({ 'robot-name': { - labwareCalibration: [LabwareFixtures.mockLabwareCalibration], + labwareCalibration: LabwareFixtures.mockAllLabwareCalibraton, }, }) }) diff --git a/app/src/calibration/labware/__fixtures__/labware-calibration.js b/app/src/calibration/labware/__fixtures__/labware-calibration.js index b49b888f3d62..d3225d926fed 100644 --- a/app/src/calibration/labware/__fixtures__/labware-calibration.js +++ b/app/src/calibration/labware/__fixtures__/labware-calibration.js @@ -45,13 +45,13 @@ export const { success: mockFetchLabwareCalibrationSuccess, failure: mockFetchLabwareCalibrationFailure, }: ResponseFixtures< - Array, + AllLabwareCalibrations, {| message: string |} > = makeResponseFixtures({ method: GET, path: LABWARE_CALIBRATION_PATH, successStatus: 200, - successBody: [mockLabwareCalibration], + successBody: mockAllLabwareCalibraton, failureStatus: 500, failureBody: mockFailureBody, }) diff --git a/app/src/calibration/labware/__tests__/actions.test.js b/app/src/calibration/labware/__tests__/actions.test.js index a3668f6d6a53..bc8294181ab0 100644 --- a/app/src/calibration/labware/__tests__/actions.test.js +++ b/app/src/calibration/labware/__tests__/actions.test.js @@ -34,7 +34,7 @@ const SPECS: Array = [ type: 'calibration:FETCH_LABWARE_CALIBRATION_SUCCESS', payload: { robotName: 'robot-name', - labwareCalibration: [Fixtures.mockLabwareCalibration], + labwareCalibration: Fixtures.mockAllLabwareCalibraton, }, meta: { requestId: '123' }, }, diff --git a/app/src/calibration/labware/__tests__/selectors.test.js b/app/src/calibration/labware/__tests__/selectors.test.js index c0c1210afb18..c88c93cd1c3f 100644 --- a/app/src/calibration/labware/__tests__/selectors.test.js +++ b/app/src/calibration/labware/__tests__/selectors.test.js @@ -1,6 +1,7 @@ // @flow import * as Fixtures from '../__fixtures__' +import * as StatusFixtures from '../../__fixtures__' import * as Selectors from '../selectors' import type { State } from '../../../types' @@ -10,7 +11,7 @@ describe('calibration selectors', () => { it('should return null if no robot in state', () => { const state: $Shape = { calibration: {} } expect(Selectors.getListOfLabwareCalibrations(state, 'robotName')).toBe( - [] + null ) }) @@ -18,34 +19,14 @@ describe('calibration selectors', () => { const state: $Shape = { calibration: { robotName: { - calibrationStatus: null, - labwareCalibration: [Fixtures.mockLabwareCalibration], + calibrationStatus: StatusFixtures.mockCalibrationStatus, + labwareCalibration: Fixtures.mockAllLabwareCalibraton, }, }, } expect( Selectors.getListOfLabwareCalibrations(state, 'robotName') - ).toEqual([Fixtures.mockLabwareCalibration]) + ).toEqual(Fixtures.mockAllLabwareCalibraton.data) }) }) }) - -// describe('get single labware', () => { -// it('should return null if no robot in state', () => { -// const state: $Shape = { calibration: {} } -// expect(Selectors.getDeckCalibrationStatus(state, 'robotName')).toBe(null) -// }) - -// it('should return the single labware', () => { -// const state: $Shape = { -// calibration: { -// robotName: { calibrationStatus: Fixtures.mockCalibrationStatus }, -// }, -// labwareCalibration: {}, -// } -// expect(Selectors.getDeckCalibrationStatus(state, 'robotName')).toEqual( -// Fixtures.mockCalibrationStatus.deckCalibration.status -// ) -// }) -// }) -// }) diff --git a/app/src/calibration/labware/actions.js b/app/src/calibration/labware/actions.js index 68bf3b5f1790..a87696253b5e 100644 --- a/app/src/calibration/labware/actions.js +++ b/app/src/calibration/labware/actions.js @@ -17,25 +17,6 @@ export const fetchAllLabwareCalibrations = ( meta: {}, }) -export const fetchSingleLabwareCalibration = ( - robotName: string, - calibrationId: string -): Types.FetchSingleLabwareCalibrationAction => ({ - type: Constants.FETCH_SINGLE_LABWARE_CALIBRATION, - payload: { robotName, calibrationId }, - meta: {}, -}) - -export const fetchSingleLabwareCalibrationSuccess = ( - robotName: string, - labwareCalibration: APITypes.LabwareCalibrationObjects, - meta: RobotApiRequestMeta -): Types.FetchSingleLabwareCalibrationSuccessAction => ({ - type: Constants.FETCH_LABWARE_CALIBRATION_SUCCESS, - payload: { robotName, labwareCalibration }, - meta, -}) - export const fetchLabwareCalibrationSuccess = ( robotName: string, labwareCalibration: APITypes.AllLabwareCalibrations, diff --git a/app/src/calibration/labware/constants.js b/app/src/calibration/labware/constants.js index ee484081bb2d..7034a15350da 100644 --- a/app/src/calibration/labware/constants.js +++ b/app/src/calibration/labware/constants.js @@ -5,8 +5,6 @@ export const LABWARE_CALIBRATION_PATH: '/labware/calibrations' = export const FETCH_ALL_LABWARE_CALIBRATIONS: 'calibration:FETCH_ALL_LABWARE_CALIBRATIONS' = 'calibration:FETCH_ALL_LABWARE_CALIBRATIONS' -export const FETCH_SINGLE_LABWARE_CALIBRATION: 'calibration:FETCH_SINGLE_LABWARE_CALIBRATION' = - 'calibration:FETCH_SINGLE_LABWARE_CALIBRATION' export const FETCH_LABWARE_CALIBRATION_SUCCESS: 'calibration:FETCH_LABWARE_CALIBRATION_SUCCESS' = 'calibration:FETCH_LABWARE_CALIBRATION_SUCCESS' diff --git a/app/src/calibration/labware/epic/__tests__/fetchLabwareCalibrationsEpic.test.js b/app/src/calibration/labware/epic/__tests__/fetchLabwareCalibrationsEpic.test.js index 6d54052c77ee..25899f4c5757 100644 --- a/app/src/calibration/labware/epic/__tests__/fetchLabwareCalibrationsEpic.test.js +++ b/app/src/calibration/labware/epic/__tests__/fetchLabwareCalibrationsEpic.test.js @@ -9,8 +9,6 @@ import { labwareCalibrationEpic } from '..' const makeTriggerActionAllCalibrations = robotName => Actions.fetchAllLabwareCalibrations(robotName) -const makeTriggerActionSingleCalibrations = robotName => - Actions.fetchSingleLabwareCalibration(robotName) describe('fetch labware calibration epics', () => { afterEach(() => { diff --git a/app/src/calibration/labware/epic/fetchAllLabwareCalibrationEpic.js b/app/src/calibration/labware/epic/fetchAllLabwareCalibrationEpic.js index 0933ecad6c20..e1eb7fa0bba2 100644 --- a/app/src/calibration/labware/epic/fetchAllLabwareCalibrationEpic.js +++ b/app/src/calibration/labware/epic/fetchAllLabwareCalibrationEpic.js @@ -17,7 +17,12 @@ import type { FetchLabwareCalibrationAction } from '../types' const mapActionToRequest: ActionToRequestMapper = action => { // $FlowFixMe(lc, 2020-07-08): lodash flow types do not support keys with values of different types - const queryDict = omitBy(action.payload, isEmpty) + const payloadWithoutRobot = omitBy(action.payload, function(value, key) { + return key === 'robotName' + }) + // $FlowFixMe(lc, 2020-07-08): lodash flow types do not support keys with values of different types + const queryDict = omitBy(payloadWithoutRobot, isEmpty) + return { method: GET, path: Constants.LABWARE_CALIBRATION_PATH, diff --git a/app/src/calibration/labware/epic/fetchSingleLabwareCalibrationEpic.js b/app/src/calibration/labware/epic/fetchSingleLabwareCalibrationEpic.js deleted file mode 100644 index 124ac287da87..000000000000 --- a/app/src/calibration/labware/epic/fetchSingleLabwareCalibrationEpic.js +++ /dev/null @@ -1,43 +0,0 @@ -// @flow -import { ofType } from 'redux-observable' - -import { GET } from '../../../robot-api/constants' -import { mapToRobotApiRequest } from '../../../robot-api/operators' -import * as Actions from '../actions' -import * as Constants from '../constants' - -import type { - ActionToRequestMapper, - ResponseToActionMapper, -} from '../../../robot-api/operators' -import type { Epic } from '../../../types' -import type { FetchSingleLabwareCalibrationAction } from '../types' - -const mapActionToRequest: ActionToRequestMapper = action => ({ - method: GET, - path: `${Constants.LABWARE_CALIBRATION_PATH}/${action.payload.calibrationId}`, -}) - -const mapResponseToAction: ResponseToActionMapper = ( - response, - originalAction -) => { - const { host, body, ...responseMeta } = response - const meta = { ...originalAction.meta, response: responseMeta } - - return response.ok - ? Actions.fetchSingleLabwareCalibrationSuccess(host.name, body, meta) - : Actions.fetchLabwareCalibrationFailure(host.name, body, meta) -} - -export const fetchSingleLabwareCalibrationEpic: Epic = (action$, state$) => { - return action$.pipe( - ofType(Constants.FETCH_SINGLE_LABWARE_CALIBRATION), - mapToRobotApiRequest( - state$, - a => a.payload.robotName, - mapActionToRequest, - mapResponseToAction - ) - ) -} diff --git a/app/src/calibration/labware/epic/index.js b/app/src/calibration/labware/epic/index.js index 8da9e1f7193f..9951e6ef2ac1 100644 --- a/app/src/calibration/labware/epic/index.js +++ b/app/src/calibration/labware/epic/index.js @@ -2,11 +2,9 @@ import { combineEpics } from 'redux-observable' import { fetchAllLabwareCalibrationEpic } from './fetchAllLabwareCalibrationEpic' -import { fetchSingleLabwareCalibrationEpic } from './fetchSingleLabwareCalibrationEpic' import type { Epic } from '../../../types' export const labwareCalibrationEpic: Epic = combineEpics( - fetchAllLabwareCalibrationEpic, - fetchSingleLabwareCalibrationEpic + fetchAllLabwareCalibrationEpic ) diff --git a/app/src/calibration/labware/types.js b/app/src/calibration/labware/types.js index 0a569946c763..f98cfa338ac3 100644 --- a/app/src/calibration/labware/types.js +++ b/app/src/calibration/labware/types.js @@ -7,15 +7,11 @@ import type { import typeof { FETCH_ALL_LABWARE_CALIBRATIONS, - FETCH_SINGLE_LABWARE_CALIBRATION, FETCH_LABWARE_CALIBRATION_SUCCESS, FETCH_LABWARE_CALIBRATION_FAILURE, } from './constants' -import type { - AllLabwareCalibrations, - LabwareCalibrationObjects, -} from './../api-types' +import type { AllLabwareCalibrations } from './../api-types' export type FetchLabwareCalibrationAction = {| type: FETCH_ALL_LABWARE_CALIBRATIONS, @@ -28,15 +24,6 @@ export type FetchLabwareCalibrationAction = {| meta: RobotApiRequestMeta, |} -export type FetchSingleLabwareCalibrationAction = {| - type: FETCH_SINGLE_LABWARE_CALIBRATION, - payload: {| - robotName: string, - calibrationId: string, - |}, - meta: RobotApiRequestMeta, -|} - export type FetchAllLabwareCalibrationSuccessAction = {| type: FETCH_LABWARE_CALIBRATION_SUCCESS, payload: {| @@ -46,15 +33,6 @@ export type FetchAllLabwareCalibrationSuccessAction = {| meta: RobotApiRequestMeta, |} -export type FetchSingleLabwareCalibrationSuccessAction = {| - type: FETCH_LABWARE_CALIBRATION_SUCCESS, - payload: {| - robotName: string, - labwareCalibration: LabwareCalibrationObjects, - |}, - meta: RobotApiRequestMeta, -|} - export type FetchLabwareCalibrationFailureAction = {| type: FETCH_LABWARE_CALIBRATION_FAILURE, payload: {| robotName: string, error: RobotApiErrorResponse |}, @@ -63,7 +41,5 @@ export type FetchLabwareCalibrationFailureAction = {| export type LawareCalibrationAction = | FetchLabwareCalibrationAction - | FetchSingleLabwareCalibrationAction | FetchAllLabwareCalibrationSuccessAction - | FetchSingleLabwareCalibrationSuccessAction | FetchLabwareCalibrationFailureAction diff --git a/app/src/components/FileInfo/ProtocolLabwareList.js b/app/src/components/FileInfo/ProtocolLabwareList.js index 09a034625ba6..6039b5c3c27d 100644 --- a/app/src/components/FileInfo/ProtocolLabwareList.js +++ b/app/src/components/FileInfo/ProtocolLabwareList.js @@ -33,12 +33,15 @@ export function ProtocolLabwareList({ const [targetProps, tooltipProps] = useHoverTooltip({ placement: TOOLTIP_AUTO, }) - const iconComponent = + const iconComponent = ( + + ) const toolTipComponent = ( {'calibrated offset from labware origin point'} ) + return ( - - {calibration} +
+ {calibration}
diff --git a/app/src/components/FileInfo/__tests__/continue.test.js b/app/src/components/FileInfo/__tests__/continue.test.js index 40b48749a6cc..e5d46fa0db00 100644 --- a/app/src/components/FileInfo/__tests__/continue.test.js +++ b/app/src/components/FileInfo/__tests__/continue.test.js @@ -1,26 +1,77 @@ // @flow import * as React from 'react' +import { Provider } from 'react-redux' import { mount } from 'enzyme' +import { getCalibrateLocation, getRunLocation } from '../../../nav' import { PrimaryButton } from '@opentrons/components' import { Continue } from '../Continue' +import type { State } from '../../../types' + +jest.mock('../../nav') + +const mockGetCalNavigation: JestMockFn< + [State], + $Call +> = getCalibrateLocation + +const mockGetRunNavigation: JestMockFn< + [State], + $Call +> = getRunLocation + +const mockRunPath = '/path/to/run' +const mockCalPath = '/path/to/cal' + describe('Continue to run or calibration button component', () => { - const render = (status: boolean = false) => { - return mount() + let mockStore + let render + + const CALIBRATE_SELECTOR = { + id: 'calibrate', + path: mockCalPath, + title: 'CALIBRATE', + iconName: 'ot-calibrate', + disabledReason: null, } + const RUN_SELECTOR = { + id: 'run', + path: mockRunPath, + title: 'RUN', + iconName: 'ot-run', + disabledReason: null, + } + + beforeEach(() => { + mockGetCalNavigation.mockReturnValue(CALIBRATE_SELECTOR) + mockGetRunNavigation.mockReturnValue(RUN_SELECTOR) + + mockStore = { + subscribe: () => {}, + getState: () => ({ state: true }), + dispatch: jest.fn(), + } + render = (labwareCalibrated: boolean = false) => + mount( + + + + ) + }) + it('Default button renders to continue to labware when not all labware is calibrated', () => { const wrapper = render() const button = wrapper.find(PrimaryButton) - console.log(button) - expect(button.children).toEqual('Proceed to Calibrate') + expect(wrapper.children).toEqual('Proceed to Calibrate') + expect(button.props.path).toEqual(mockCalPath) }) it('renders nothing when calibration is OK', () => { const wrapper = render(true) const button = wrapper.find(PrimaryButton) - console.log(button.children) - expect(button.children).toEqual('Proceed to Calibrate') + expect(wrapper.children).toEqual('Proceed to Run') + expect(button.props.path).toEqual(mockRunPath) }) }) diff --git a/app/src/components/FileInfo/__tests__/protocollabwarelist.test.js b/app/src/components/FileInfo/__tests__/protocollabwarelist.test.js deleted file mode 100644 index 58ae8fd179f0..000000000000 --- a/app/src/components/FileInfo/__tests__/protocollabwarelist.test.js +++ /dev/null @@ -1,54 +0,0 @@ -// @flow -import * as React from 'react' -import { mount } from 'enzyme' - -import { Flex, Icon } from '@opentrons/components' -import { ProtocolLabwareList } from '../ProtocolLabwareList' - -import { SectionContentFlex } from '../../layout' - -describe('Protocol Labware List Component', () => { - const render = ( - labware: Array, - quantity: Array, - calibration: Array - ) => { - return mount( - - ) - } - - it('renders nothing when no labware exists in the protocol', () => { - const wrapper = render([], [], []) - expect(wrapper).toEqual({}) - }) - - it('renders three columns when a labware exists', () => { - const rowToRender = ( - - Not yet calibrated - - ) - const wrapper = render(['opentrons_labware'], ['x1'], [rowToRender]) - const flex = wrapper.find(Flex) - const sections = flex.find(SectionContentFlex) - console.log(sections) - expect(wrapper).toEqual({}) - }) - - it('renders a table with values when given calibration data', () => { - const rowToRender = Not yet calibrated - // const wrapper = render(['opentrons_labware'], ['x1'], [rowToRender]) - // const parent = wrapper.find(Flex).first() - // const icon = wrapper.find(Icon) - - // expect(parent.prop('color')).toBe(COLOR_WARNING) - // expect(icon.prop('name')).toEqual('alert-circle') - // expect(wrapper.html()).toMatch(/not yet been calibrated/i) - // expect(wrapper.html()).toMatch(/please perform a deck calibration/i) - }) -}) diff --git a/app/src/components/FileInfo/index.js b/app/src/components/FileInfo/index.js index f98c76d94dcc..a5add26e2916 100644 --- a/app/src/components/FileInfo/index.js +++ b/app/src/components/FileInfo/index.js @@ -65,7 +65,7 @@ export function FileInfo(props: FileInfoProps): React.Node { const calibrationLoadNamesMap = keyBy(calibrations, function(labwareObject) { return labwareObject?.attributes.loadName }) - console.log(calibrationLoadNamesMap) + const allLabwareCalibrated = every(Object.keys(labwareCount), function(a) { return Object.keys(calibrationLoadNamesMap).includes(a) }) diff --git a/app/src/components/FileInfo/styles.css b/app/src/components/FileInfo/styles.css index 235a0c0e2bf7..85ef0f0ad35e 100644 --- a/app/src/components/FileInfo/styles.css +++ b/app/src/components/FileInfo/styles.css @@ -115,6 +115,12 @@ margin: 0.5rem 0.5rem 0.5rem 0; } +.calibration_data_info_icon { + height: 1rem; + width: 1rem; + fill: var(--c-med-gray); + } + .warning_info_wrapper { display: flex; align-items: center; diff --git a/app/src/components/layout/SectionContentFlex.js b/app/src/components/layout/SectionContentFlex.js index 6360254aed93..1774ba139761 100644 --- a/app/src/components/layout/SectionContentFlex.js +++ b/app/src/components/layout/SectionContentFlex.js @@ -1,7 +1,13 @@ // @flow import * as React from 'react' -import { SPACING_1, Flex, Box, ALIGN_CENTER } from '@opentrons/components' +import { + SPACING_1, + Flex, + Box, + ALIGN_CENTER, + FLEX_AUTO, +} from '@opentrons/components' import type { UseHoverTooltipTargetProps, StyleProps, @@ -25,19 +31,17 @@ export function SectionContentFlex({ ...styleProps }: SectionContentFlexProps): React.Node { return ( - - - - -

{title}

-
- - {icon} - {toolTipComponent} - -
- {children} -
-
+ + + +

{title}

+
+ + {icon} + {toolTipComponent} + +
+ {children} +
) }