Skip to content

Commit

Permalink
fix(app): temporary fix for chained command race conditions in cal fl…
Browse files Browse the repository at this point in the history
…ows to unblock user testing (#6530)

Temporary patch to unblock user testing calibration flows. Introduces a third of a second delay between the first and second of two chained commands through out calibration flows on the run app. This should immediately be addressed by a more robust epic-based solution.
  • Loading branch information
b-cooper authored Sep 11, 2020
1 parent a269b0f commit 3c17d9e
Show file tree
Hide file tree
Showing 11 changed files with 49 additions and 6 deletions.
5 changes: 4 additions & 1 deletion app/src/components/CalibrateDeck/CompleteConfirmation.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,10 @@ export function CompleteConfirmation(
): React.Node {
const exitSession = () => {
props.sendSessionCommand(Sessions.deckCalCommands.EXIT)
props.deleteSession()
// TODO: IMMEDIATELY use actualy epic for managing chained dependent commands
setTimeout(() => {
props.deleteSession()
}, 300)
}
return (
<Flex
Expand Down
5 changes: 4 additions & 1 deletion app/src/components/CalibrateDeck/SaveXYPoint.js
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,10 @@ export function SaveXYPoint(props: CalibrateDeckChildProps): React.Node {

const savePoint = () => {
sendSessionCommand(Sessions.deckCalCommands.SAVE_OFFSET)
sendSessionCommand(proceedCommand)
// TODO: IMMEDIATELY use actualy epic for managing chained dependent commands
setTimeout(() => {
sendSessionCommand(proceedCommand)
}, 300)
}

const buttonText = buttonTextByCurrentStep[currentStep] || ''
Expand Down
5 changes: 4 additions & 1 deletion app/src/components/CalibrateDeck/SaveZPoint.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,10 @@ export function SaveZPoint(props: CalibrateDeckChildProps): React.Node {

const savePoint = () => {
sendSessionCommand(Sessions.deckCalCommands.SAVE_OFFSET)
sendSessionCommand(Sessions.deckCalCommands.MOVE_TO_POINT_ONE)
// TODO: IMMEDIATELY use actualy epic for managing chained dependent commands
setTimeout(() => {
sendSessionCommand(Sessions.deckCalCommands.MOVE_TO_POINT_ONE)
}, 300)
}

return (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ describe('SaveXYPoint', () => {
const getVideo = wrapper => wrapper.find(`source`)

beforeEach(() => {
jest.useFakeTimers()
render = (props = {}) => {
const {
pipMount = 'left',
Expand All @@ -48,6 +49,8 @@ describe('SaveXYPoint', () => {
})
afterEach(() => {
jest.resetAllMocks()
jest.clearAllTimers()
jest.useRealTimers()
})

it('displays proper asset', () => {
Expand Down Expand Up @@ -150,6 +153,7 @@ describe('SaveXYPoint', () => {
.invoke('onClick')()
)
wrapper.update()
jest.runAllTimers()

expect(mockSendCommand).toHaveBeenCalledWith(
Sessions.deckCalCommands.SAVE_OFFSET
Expand All @@ -168,6 +172,7 @@ describe('SaveXYPoint', () => {
.invoke('onClick')()
)
wrapper.update()
jest.runAllTimers()

expect(mockSendCommand).toHaveBeenCalledWith(
Sessions.deckCalCommands.SAVE_OFFSET
Expand All @@ -188,6 +193,7 @@ describe('SaveXYPoint', () => {
.invoke('onClick')()
)
wrapper.update()
jest.runAllTimers()

expect(mockSendCommand).toHaveBeenCalledWith(
Sessions.deckCalCommands.SAVE_OFFSET
Expand Down
4 changes: 4 additions & 0 deletions app/src/components/CalibrateDeck/__tests__/SaveZPoint.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ describe('SaveZPoint', () => {
const getVideo = wrapper => wrapper.find(`source`)

beforeEach(() => {
jest.useFakeTimers()
render = (props = {}) => {
const {
pipMount = 'left',
Expand All @@ -47,6 +48,8 @@ describe('SaveZPoint', () => {
})
afterEach(() => {
jest.resetAllMocks()
jest.clearAllTimers()
jest.useRealTimers()
})

it('displays proper asset', () => {
Expand Down Expand Up @@ -106,6 +109,7 @@ describe('SaveZPoint', () => {

act(() => getSaveButton(wrapper).invoke('onClick')())
wrapper.update()
jest.runAllTimers()

expect(mockSendCommand).toHaveBeenCalledWith(
Sessions.deckCalCommands.SAVE_OFFSET
Expand Down
5 changes: 4 additions & 1 deletion app/src/components/CalibrationPanels/CompleteConfirmation.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,10 @@ export function CompleteConfirmation(props: CalibrationPanelProps): React.Node {
// session command upon a successful exit response
const exitSession = () => {
props.sendSessionCommand(Sessions.sharedCalCommands.EXIT)
props.deleteSession()
// TODO: IMMEDIATELY use actualy epic for managing chained dependent commands
setTimeout(() => {
props.deleteSession()
}, 300)
}
return (
<Flex
Expand Down
5 changes: 4 additions & 1 deletion app/src/components/CalibrationPanels/SaveXYPoint.js
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,10 @@ export function SaveXYPoint(props: CalibrationPanelProps): React.Node {

const savePoint = () => {
sendSessionCommand(Sessions.sharedCalCommands.SAVE_OFFSET)
moveCommandString && sendSessionCommand(moveCommandString)
// TODO: IMMEDIATELY use actualy epic for managing chained dependent commands
setTimeout(() => {
moveCommandString && sendSessionCommand(moveCommandString)
}, 300)
}

return (
Expand Down
5 changes: 4 additions & 1 deletion app/src/components/CalibrationPanels/SaveZPoint.js
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,10 @@ export function SaveZPoint(props: CalibrationPanelProps): React.Node {

const savePoint = () => {
sendSessionCommand(Sessions.sharedCalCommands.SAVE_OFFSET)
sendSessionCommand(Sessions.sharedCalCommands.MOVE_TO_POINT_ONE)
// TODO: IMMEDIATELY use actualy epic for managing chained dependent commands
setTimeout(() => {
sendSessionCommand(Sessions.sharedCalCommands.MOVE_TO_POINT_ONE)
}, 300)
}

return (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ describe('CompleteConfirmation', () => {
wrapper.find('button[title="Return tip to tip rack and exit"]')

beforeEach(() => {
jest.useFakeTimers()
render = (
props: $Shape<React.ElementProps<typeof CompleteConfirmation>> = {}
) => {
Expand Down Expand Up @@ -44,6 +45,8 @@ describe('CompleteConfirmation', () => {

afterEach(() => {
jest.resetAllMocks()
jest.clearAllTimers()
jest.useRealTimers()
})

it('clicking continue sends exit command and deletes session', () => {
Expand All @@ -52,6 +55,7 @@ describe('CompleteConfirmation', () => {
expect(wrapper.find('ConfirmClearDeckModal').exists()).toBe(false)
getContinueButton(wrapper).invoke('onClick')()
wrapper.update()
jest.runAllTimers()
expect(mockDeleteSession).toHaveBeenCalled()
expect(mockSendCommand).toHaveBeenCalledWith(
Sessions.sharedCalCommands.EXIT
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ describe('SaveXYPoint', () => {
const getVideo = wrapper => wrapper.find(`source`)

beforeEach(() => {
jest.useFakeTimers()
render = (props = {}) => {
const {
pipMount = 'left',
Expand All @@ -52,6 +53,8 @@ describe('SaveXYPoint', () => {
})
afterEach(() => {
jest.resetAllMocks()
jest.clearAllTimers()
jest.useRealTimers()
})

it('displays proper asset', () => {
Expand Down Expand Up @@ -155,6 +158,7 @@ describe('SaveXYPoint', () => {
getSaveButton(wrapper).invoke('onClick')()

wrapper.update()
jest.runAllTimers()

expect(mockSendCommand).toHaveBeenCalledWith(
Sessions.sharedCalCommands.SAVE_OFFSET
Expand All @@ -173,6 +177,7 @@ describe('SaveXYPoint', () => {
expect(wrapper.text()).toContain('slot 3')
getSaveButton(wrapper).invoke('onClick')()
wrapper.update()
jest.runAllTimers()

expect(mockSendCommand).toHaveBeenCalledWith(
Sessions.sharedCalCommands.SAVE_OFFSET
Expand All @@ -191,6 +196,7 @@ describe('SaveXYPoint', () => {
expect(wrapper.text()).toContain('slot 7')
getSaveButton(wrapper).invoke('onClick')()
wrapper.update()
jest.runAllTimers()

expect(mockSendCommand).toHaveBeenCalledWith(
Sessions.sharedCalCommands.SAVE_OFFSET
Expand All @@ -211,6 +217,7 @@ describe('SaveXYPoint', () => {

getSaveButton(wrapper).invoke('onClick')()
wrapper.update()
jest.runAllTimers()
expect(mockSendCommand).toHaveBeenCalledWith(
Sessions.sharedCalCommands.SAVE_OFFSET
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ describe('SaveZPoint', () => {
const getVideo = wrapper => wrapper.find(`source`)

beforeEach(() => {
jest.useFakeTimers()
render = (props = {}) => {
const {
pipMount = 'left',
Expand All @@ -45,6 +46,8 @@ describe('SaveZPoint', () => {
})
afterEach(() => {
jest.resetAllMocks()
jest.clearAllTimers()
jest.useRealTimers()
})

it('displays proper asset', () => {
Expand Down Expand Up @@ -104,6 +107,7 @@ describe('SaveZPoint', () => {

getSaveButton(wrapper).invoke('onClick')()
wrapper.update()
jest.runAllTimers()

expect(mockSendCommand).toHaveBeenCalledWith(
Sessions.deckCalCommands.SAVE_OFFSET
Expand Down

0 comments on commit 3c17d9e

Please sign in to comment.