Skip to content

Commit

Permalink
Fixup: remaining tests and address comments on PR
Browse files Browse the repository at this point in the history
  • Loading branch information
Laura-Danielle committed Oct 21, 2020
1 parent 6222e07 commit 91f20e5
Show file tree
Hide file tree
Showing 27 changed files with 298 additions and 1,068 deletions.
4 changes: 2 additions & 2 deletions app/src/components/CalibrationPanels/DeckSetup.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@ import { CalibrationLabwareRender } from './CalibrationLabwareRender'
import styles from './styles.css'

const DECK_SETUP_WITH_BLOCK_PROMPT =
'Place full tip rack(s) and Calibration Block on the deck within their designated slots as illustrated below.'
'Place full tip rack and Calibration Block on the deck within their designated slots as illustrated below.'
const DECK_SETUP_NO_BLOCK_PROMPT =
'Place full tip rack(s) on the deck within the designated slot as illustrated below.'
'Place full tip rack on the deck within the designated slot as illustrated below.'
const DECK_SETUP_BUTTON_TEXT = 'Confirm placement and continue'
const contentsBySessionType: {
[SessionType]: {
Expand Down
1 change: 0 additions & 1 deletion app/src/components/CalibrationPanels/SaveXYPoint.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ import * as Sessions from '../../sessions'
import type { JogAxis, JogDirection, JogStep } from '../../http-api-client'
import type { CalibrationPanelProps } from './types'
import type {
SessionCommandParams,
SessionType,
CalibrationSessionStep,
SessionCommandString,
Expand Down
31 changes: 16 additions & 15 deletions app/src/components/CalibrationPanels/SaveZPoint.js
Original file line number Diff line number Diff line change
Expand Up @@ -93,20 +93,21 @@ export function SaveZPoint(props: CalibrationPanelProps): React.Node {
})
}

let continueCommands
if (sessionType === Sessions.SESSION_TYPE_CALIBRATION_HEALTH_CHECK) {
continueCommands = () => {
sendCommands(
{ command: Sessions.checkCommands.COMPARE_POINT },
{ command: Sessions.sharedCalCommands.MOVE_TO_POINT_ONE }
)
}
} else {
continueCommands = () => {
sendCommands(
{ command: Sessions.sharedCalCommands.SAVE_OFFSET },
{ command: Sessions.sharedCalCommands.MOVE_TO_POINT_ONE }
)
const continueCommands = () => {
if (sessionType === Sessions.SESSION_TYPE_CALIBRATION_HEALTH_CHECK) {
return () => {
sendCommands(
{ command: Sessions.checkCommands.COMPARE_POINT },
{ command: Sessions.sharedCalCommands.MOVE_TO_POINT_ONE }
)
}
} else {
return () => {
sendCommands(
{ command: Sessions.sharedCalCommands.SAVE_OFFSET },
{ command: Sessions.sharedCalCommands.MOVE_TO_POINT_ONE }
)
}
}
}

Expand Down Expand Up @@ -157,7 +158,7 @@ export function SaveZPoint(props: CalibrationPanelProps): React.Node {
>
<PrimaryBtn
title="save"
onClick={continueCommands}
onClick={continueCommands()}
flex="1"
marginX={SPACING_5}
>
Expand Down
4 changes: 4 additions & 0 deletions app/src/components/CalibrationPanels/types.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@ import type {
CalibrationHealthCheckComparisonByPipette,
} from '../../sessions/types'

// TODO (lc 10-20-2020) Given there are lots of optional
// keys here now we should split these panel props out
// into different session types and combine them into
// a union object
export type CalibrationPanelProps = {|
sendCommands: (...Array<SessionCommandParams>) => void,
cleanUpAndExit: () => void,
Expand Down
69 changes: 12 additions & 57 deletions app/src/components/CheckCalibration/ResultsSummary.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,21 +5,14 @@ import find from 'lodash/find'
import * as Sessions from '../../sessions'
import styles from './styles.css'
import { PipetteComparisons } from './PipetteComparisons'
import { BadOutcomeBody } from './BadOutcomeBody'
import { saveAs } from 'file-saver'
import { getBadOutcomeHeader } from './utils'

import type { CalibrationPanelProps } from '../CalibrationPanels/types'
import type {
CalibrationHealthCheckComparison,
CalibrationHealthCheckInstrument,
} from '../../sessions/types'
import type { CalibrationHealthCheckInstrument } from '../../sessions/types'

const ROBOT_CALIBRATION_CHECK_SUMMARY_HEADER = 'Calibration check summary:'
const DROP_TIP_AND_EXIT = 'Drop tip in trash and exit'
const HOME_AND_EXIT = 'Home robot and exit'
const DOWNLOAD_SUMMARY = 'Download JSON summary'
const STILL_HAVING_PROBLEMS =
'If you are still experiencing issues, please download the JSON summary and share it with our support team who will then follow up with you.'

export function ResultsSummary(props: CalibrationPanelProps): React.Node {
const { comparisonsByPipette, instruments, cleanUpAndExit } = props
Expand Down Expand Up @@ -47,31 +40,16 @@ export function ResultsSummary(props: CalibrationPanelProps): React.Node {
(p: CalibrationHealthCheckInstrument) =>
p.rank === Sessions.CHECK_PIPETTE_RANK_SECOND
)
const firstComparisonsByStep = comparisonsByPipette?.first
const secondComparisonsByStep = comparisonsByPipette?.second
const firstComparisonsByStep = firstPipette
? comparisonsByPipette?.first
: null
const secondComparisonsByStep = secondPipette
? comparisonsByPipette?.second
: null

const lastFailedComparison = [
...Sessions.FIRST_PIPETTE_COMPARISON_STEPS,
].reduce((acc, step): CalibrationHealthCheckComparison | null => {
const first_pipette_comparison = comparisonsByPipette?.first[step]
const second_pipette_comparison = comparisonsByPipette?.second[step]
if (
second_pipette_comparison &&
second_pipette_comparison.exceedsThreshold
) {
// We must first check if a comparison for the second
// pipette exists and return that, otherwise check
// the first pipette's steps.
return second_pipette_comparison
} else if (
first_pipette_comparison &&
first_pipette_comparison.exceedsThreshold
) {
return first_pipette_comparison
} else {
return acc
}
}, null)
// TODO (lc 10-20-2020): Rather than having the app decide
// what the last failed comparison was, the robot should
// just send a final report over to the app to decipher.

return (
<>
Expand Down Expand Up @@ -105,36 +83,13 @@ export function ResultsSummary(props: CalibrationPanelProps): React.Node {
>
{DOWNLOAD_SUMMARY}
</OutlineButton>
{lastFailedComparison && (
<TroubleshootingInstructions comparison={lastFailedComparison} />
)}

<PrimaryButton
className={styles.summary_exit_button}
onClick={cleanUpAndExit}
>
{DROP_TIP_AND_EXIT}
{HOME_AND_EXIT}
</PrimaryButton>
</>
)
}

type TroubleshootingInstructionsProps = {
comparison: CalibrationHealthCheckComparison,
}
function TroubleshootingInstructions(
props: TroubleshootingInstructionsProps
): React.Node {
const { comparison } = props
return (
<div>
<p className={styles.summary_bad_outcome_header}>
{getBadOutcomeHeader(comparison.transformType)}
</p>
<p className={styles.summary_bad_outcome_body}>
<BadOutcomeBody transform={comparison.transformType} />
</p>
<p className={styles.summary_bad_outcome_body}>{STILL_HAVING_PROBLEMS}</p>
</div>
)
}
25 changes: 11 additions & 14 deletions app/src/components/CheckCalibration/ReturnTip.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,18 +24,15 @@ export function ReturnTip(props: CalibrationPanelProps): React.Node {
const onFinalPipette =
!checkBothPipettes ||
activePipette?.rank === Sessions.CHECK_PIPETTE_RANK_SECOND
let commandsList
if (!onFinalPipette) {
commandsList = [
{ command: Sessions.checkCommands.RETURN_TIP },
{ command: Sessions.checkCommands.CHECK_SWITCH_PIPETTE },
]
} else {
commandsList = [
{ command: Sessions.checkCommands.RETURN_TIP },
{ command: Sessions.checkCommands.TRANSITION },
]
}
const commandsList = onFinalPipette
? [
{ command: Sessions.checkCommands.RETURN_TIP },
{ command: Sessions.checkCommands.TRANSITION },
]
: [
{ command: Sessions.checkCommands.RETURN_TIP },
{ command: Sessions.checkCommands.CHECK_SWITCH_PIPETTE },
]

const confirmReturnTip = () => {
sendCommands(...commandsList)
Expand All @@ -49,15 +46,15 @@ export function ReturnTip(props: CalibrationPanelProps): React.Node {
>
<Text marginBottom={SPACING_3}>
{`${CONFIRM_RETURN_BODY}
${!onFinalPipette ? CONTINUE_TO_NEXT : EXIT_PROGRAM}`}
${onFinalPipette ? EXIT_PROGRAM : CONTINUE_TO_NEXT}`}
</Text>
<PrimaryBtn
title="confirmReturnTip"
marginTop={SPACING_3}
width="80%"
onClick={confirmReturnTip}
>
{!onFinalPipette ? CONTINUE : EXIT}
{onFinalPipette ? EXIT : CONTINUE}
</PrimaryBtn>
</Flex>
)
Expand Down
Loading

0 comments on commit 91f20e5

Please sign in to comment.