Skip to content

Commit

Permalink
fix(app): clear lw calibration state if top level home is called (#4703)
Browse files Browse the repository at this point in the history
  • Loading branch information
b-cooper authored Jan 8, 2020
1 parent 5d358f2 commit 8fe7120
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 0 deletions.
2 changes: 2 additions & 0 deletions app/src/robot/reducer/calibration.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -84,6 +85,7 @@ export default function calibrationReducer(
return INITIAL_STATE

// reset calibration state on robot home
case HOME:
case 'robot:CLEAR_CALIBRATION_REQUEST':
return {
...state,
Expand Down
24 changes: 24 additions & 0 deletions app/src/robot/test/calibration-reducer.test.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
// calibration reducer tests
import { HOME } from '../../robot-controls'
import { robotReducer as reducer, actionTypes } from '../'

const EXPECTED_INITIAL_STATE = {
Expand Down Expand Up @@ -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 },
})
})
})

0 comments on commit 8fe7120

Please sign in to comment.