Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(app): clear lw calibration state if top level home is called #4703

Merged
merged 2 commits into from
Jan 8, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 },
})
})
})