From 17fd1150f44bbb90de86ec887d6cad510e043944 Mon Sep 17 00:00:00 2001 From: Brian Cooper Date: Wed, 8 Jan 2020 11:17:01 -0500 Subject: [PATCH 1/2] fix(app): clear lw calibration state if top level home is called --- app/src/robot/reducer/calibration.js | 1 + 1 file changed, 1 insertion(+) diff --git a/app/src/robot/reducer/calibration.js b/app/src/robot/reducer/calibration.js index ac0e9431fca..777133c95cf 100755 --- a/app/src/robot/reducer/calibration.js +++ b/app/src/robot/reducer/calibration.js @@ -84,6 +84,7 @@ export default function calibrationReducer( return INITIAL_STATE // reset calibration state on robot home + case 'robotControls:HOME': case 'robot:CLEAR_CALIBRATION_REQUEST': return { ...state, From 8d25fc5710a7761ab5215040e46f7de18b4e0f08 Mon Sep 17 00:00:00 2001 From: Brian Cooper Date: Wed, 8 Jan 2020 13:28:40 -0500 Subject: [PATCH 2/2] use constant and add test --- app/src/robot/reducer/calibration.js | 3 ++- .../robot/test/calibration-reducer.test.js | 24 +++++++++++++++++++ 2 files changed, 26 insertions(+), 1 deletion(-) diff --git a/app/src/robot/reducer/calibration.js b/app/src/robot/reducer/calibration.js index 777133c95cf..1f07cde3994 100755 --- a/app/src/robot/reducer/calibration.js +++ b/app/src/robot/reducer/calibration.js @@ -4,6 +4,7 @@ import mapValues from 'lodash/mapValues' import type { Action, Error } from '../../types' +import { HOME } from '../../robot-controls' import type { Mount, Slot } from '../types' import { actionTypes } from '../actions' import type { @@ -84,7 +85,7 @@ export default function calibrationReducer( return INITIAL_STATE // reset calibration state on robot home - case 'robotControls:HOME': + case HOME: case 'robot:CLEAR_CALIBRATION_REQUEST': return { ...state, diff --git a/app/src/robot/test/calibration-reducer.test.js b/app/src/robot/test/calibration-reducer.test.js index f58ac642cc3..df01b634969 100644 --- a/app/src/robot/test/calibration-reducer.test.js +++ b/app/src/robot/test/calibration-reducer.test.js @@ -1,4 +1,5 @@ // calibration reducer tests +import { HOME } from '../../robot-controls' import { robotReducer as reducer, actionTypes } from '../' const EXPECTED_INITIAL_STATE = { @@ -681,4 +682,27 @@ describe('robot reducer - calibration', () => { confirmedBySlot: { 5: true }, }) }) + + test('handles CLEAR_CALIBRATION_REQUEST and robot home actions', () => { + const state = { + calibration: { + calibrationRequest: { + type: 'JOG', + inProgress: true, + error: null, + mount: 'right', + }, + }, + } + + const clearAction = { type: 'robot:CLEAR_CALIBRATION_REQUEST' } + expect(reducer(state, clearAction).calibration).toEqual({ + calibrationRequest: { type: '', inProgress: false, error: null }, + }) + + const homeAction = { type: HOME } + expect(reducer(state, homeAction).calibration).toEqual({ + calibrationRequest: { type: '', inProgress: false, error: null }, + }) + }) })