Skip to content

Commit

Permalink
fix(app): return calibration flow even if pipette is already calibrat…
Browse files Browse the repository at this point in the history
…ed (#14506)

fix RQA-2357
  • Loading branch information
smb2268 committed Feb 15, 2024
1 parent 9dc8f2d commit 9224b13
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 38 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,29 +24,13 @@ const mockSingleMountPipetteAttached = {
}

describe('getPipetteWizardStepsForProtocol', () => {
it('returns an empty array of info when the attached pipette matches required pipette', () => {
const mockFlowSteps = [] as PipetteWizardStep[]
expect(
getPipetteWizardStepsForProtocol(
mockSingleMountPipetteAttached,
[
{
id: '123',
pipetteName: 'p1000_single_flex',
mount: 'left',
},
],
LEFT
)
).toStrictEqual(mockFlowSteps)
})
it('returns an empty array when there is no pipette attached and no pipette is needed', () => {
const mockFlowSteps = [] as PipetteWizardStep[]
const mockFlowSteps = null as PipetteWizardStep[] | null
expect(
getPipetteWizardStepsForProtocol({ left: null, right: null }, [], LEFT)
).toStrictEqual(mockFlowSteps)
})
it('returns the calibration flow only when correct pipette is attached but there is no pip cal data', () => {
it('returns the calibration flow only when correct pipette is attached even if there is pip cal data', () => {
const mockFlowSteps = [
{
section: SECTIONS.BEFORE_BEGINNING,
Expand All @@ -71,7 +55,6 @@ describe('getPipetteWizardStepsForProtocol', () => {
left: null,
right: {
...mockAttachedPipetteInformation,
data: { calibratedOffset: undefined as any },
} as any,
},
[{ id: '123', pipetteName: 'p1000_single_flex', mount: 'right' }],
Expand Down
4 changes: 2 additions & 2 deletions app/src/organisms/PipetteWizardFlows/getPipetteWizardSteps.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ export const getPipetteWizardSteps = (
mount: PipetteMount,
selectedPipette: SelectablePipettes,
isGantryEmpty: boolean
): PipetteWizardStep[] => {
): PipetteWizardStep[] | null => {
switch (flowType) {
case FLOWS.CALIBRATE: {
return [
Expand Down Expand Up @@ -205,5 +205,5 @@ export const getPipetteWizardSteps = (
}
}
}
return []
return null
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,23 +8,17 @@ export const getPipetteWizardStepsForProtocol = (
attachedPipettes: AttachedPipettesFromInstrumentsQuery,
pipetteInfo: LoadedPipette[],
mount: Mount
): PipetteWizardStep[] => {
): PipetteWizardStep[] | null => {
const requiredPipette = pipetteInfo.find(pipette => pipette.mount === mount)
const nintySixChannelAttached =
attachedPipettes[LEFT]?.instrumentName === 'p1000_96'

// return empty array when correct pipette is attached && pipette cal not needed or
// no pipette is required in the protocol
if (
(requiredPipette?.pipetteName === attachedPipettes[mount]?.instrumentName &&
attachedPipettes[mount]?.data?.calibratedOffset?.last_modified != null) ||
requiredPipette == null
) {
return []
// return calibration flow only if correct pipette is attached and pipette cal null
// return empty array if no pipette is required in the protocol
if (requiredPipette == null) {
return null
// return calibration flow if correct pipette is attached
} else if (
requiredPipette?.pipetteName === attachedPipettes[mount]?.instrumentName &&
attachedPipettes[mount]?.data?.calibratedOffset?.last_modified == null
requiredPipette?.pipetteName === attachedPipettes[mount]?.instrumentName
) {
return [
{
Expand Down
10 changes: 5 additions & 5 deletions app/src/organisms/PipetteWizardFlows/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -86,8 +86,8 @@ export const PipetteWizardFlows = (
)
const host = useHost()
const [currentStepIndex, setCurrentStepIndex] = React.useState<number>(0)
const totalStepCount = pipetteWizardSteps.length - 1
const currentStep = pipetteWizardSteps?.[currentStepIndex]
const totalStepCount = pipetteWizardSteps ? pipetteWizardSteps.length - 1 : 0
const currentStep = pipetteWizardSteps?.[currentStepIndex] ?? null
const [isFetchingPipettes, setIsFetchingPipettes] = React.useState<boolean>(
false
)
Expand Down Expand Up @@ -253,10 +253,10 @@ export const PipetteWizardFlows = (
isOnDevice,
}
const is96ChannelUnskippableStep =
currentStep.section === SECTIONS.CARRIAGE ||
currentStep.section === SECTIONS.MOUNTING_PLATE ||
currentStep?.section === SECTIONS.CARRIAGE ||
currentStep?.section === SECTIONS.MOUNTING_PLATE ||
(selectedPipette === NINETY_SIX_CHANNEL &&
currentStep.section === SECTIONS.DETACH_PIPETTE)
currentStep?.section === SECTIONS.DETACH_PIPETTE)

const exitModal = is96ChannelUnskippableStep ? (
<UnskippableModal
Expand Down

0 comments on commit 9224b13

Please sign in to comment.