Skip to content

Commit

Permalink
fix(protocol-designer): missing labware modal logic (#15248)
Browse files Browse the repository at this point in the history
closes RQA-2769
  • Loading branch information
jerader authored May 22, 2024
1 parent ba28337 commit 51139bc
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 9 deletions.
8 changes: 8 additions & 0 deletions protocol-designer/src/ui/modules/selectors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,14 @@ export const getMagnetModuleHasLabware: Selector<boolean> = createSelector(
}
)

/** Returns boolean if heater-shaker module has labware */
export const getHeaterShakerModuleHasLabware: Selector<boolean> = createSelector(
getInitialDeckSetup,
initialDeckSetup => {
return getModuleHasLabware(initialDeckSetup, HEATERSHAKER_MODULE_TYPE)
}
)

/** Returns all moduleIds and if they have labware for MoaM */
export const getTemperatureModulesHaveLabware: Selector<
ModuleAndLabware[]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@ beforeEach(() => {
false
)
vi.mocked(uiModuleSelectors.getTemperatureModuleIds).mockReturnValue(null)
vi.mocked(uiModuleSelectors.getHeaterShakerModuleHasLabware).mockReturnValue(
false
)
vi.mocked(uiModuleSelectors.getSingleThermocyclerModuleId).mockReturnValue(
null
)
Expand Down Expand Up @@ -92,6 +95,7 @@ describe('addAndSelectStepWithHints', () => {
getSingleTemperatureModuleId: null,
getSingleThermocyclerModuleId: null,
getTemperatureModuleIds: [],
getHeaterShakerModuleHasLabware: false,
},
},
{
Expand All @@ -105,19 +109,34 @@ describe('addAndSelectStepWithHints', () => {
getThermocyclerModuleHasLabware: false,
getSingleTemperatureModuleId: 'something',
getSingleThermocyclerModuleId: null,
getTemperatureModuleIds: ['mockId'],
getTemperatureModuleIds: [],
getHeaterShakerModuleHasLabware: false,
},
},
{
testName: 'temperature step, when thermocycler has no labware',
stepType: 'temperature' as StepType,
testName: 'thermocycler step, when thermocycler has no labware',
stepType: 'thermocycler' as StepType,
selectorValues: {
getMagnetModuleHasLabware: false,
getTemperatureModulesHaveLabware: [],
getThermocyclerModuleHasLabware: false,
getSingleTemperatureModuleId: null,
getSingleThermocyclerModuleId: 'something',
getTemperatureModuleIds: [],
getHeaterShakerModuleHasLabware: false,
},
},
{
testName: 'heaterShaker step, when heaterShaker has no labware',
stepType: 'heaterShaker' as StepType,
selectorValues: {
getMagnetModuleHasLabware: false,
getTemperatureModulesHaveLabware: [],
getThermocyclerModuleHasLabware: false,
getSingleTemperatureModuleId: null,
getSingleThermocyclerModuleId: 'something',
getTemperatureModuleIds: [],
getHeaterShakerModuleHasLabware: false,
},
},
].forEach(({ testName, stepType, selectorValues }) => {
Expand All @@ -128,6 +147,9 @@ describe('addAndSelectStepWithHints', () => {
vi.mocked(
uiModuleSelectors.getTemperatureModulesHaveLabware
).mockReturnValue(selectorValues.getTemperatureModulesHaveLabware)
vi.mocked(
uiModuleSelectors.getHeaterShakerModuleHasLabware
).mockReturnValue(selectorValues.getHeaterShakerModuleHasLabware)
vi.mocked(
uiModuleSelectors.getThermocyclerModuleHasLabware
).mockReturnValue(selectorValues.getThermocyclerModuleHasLabware)
Expand Down
19 changes: 13 additions & 6 deletions protocol-designer/src/ui/steps/actions/thunks/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,29 +49,36 @@ export const addAndSelectStepWithHints: (arg: {
const temperatureModuleOnDeck = uiModuleSelectors.getTemperatureModuleIds(
state
)
const thermocyclerModuleOnDeck = uiModuleSelectors.getSingleThermocyclerModuleId(
const heaterShakerModuleHasLabware = uiModuleSelectors.getHeaterShakerModuleHasLabware(
state
)

const tempHasNoLabware = temperatureModulesHaveLabware.some(
module => !module.hasLabware
)
// TODO: Ian 2019-01-17 move out to centralized step info file - see #2926
const stepNeedsLiquid = ['mix', 'moveLiquid'].includes(payload.stepType)
const stepMagnetNeedsLabware = ['magnet'].includes(payload.stepType)
const stepTemperatureNeedsLabware = ['temperature'].includes(payload.stepType)
const stepThermocyclerNeedsLabware = ['thermocycler'].includes(
payload.stepType
)
const stepHeaterShakerNeedsLabware = ['heaterShaker'].includes(
payload.stepType
)

const stepModuleMissingLabware =
(stepMagnetNeedsLabware && !magnetModuleHasLabware) ||
(stepTemperatureNeedsLabware &&
thermocyclerModuleOnDeck &&
!thermocyclerModuleHasLabware) ||
(temperatureModuleOnDeck?.length === 1 && tempHasNoLabware)
(stepThermocyclerNeedsLabware && !thermocyclerModuleHasLabware) ||
(temperatureModuleOnDeck?.length === 0 && stepTemperatureNeedsLabware) ||
(stepHeaterShakerNeedsLabware && !heaterShakerModuleHasLabware)

if (stepNeedsLiquid && !deckHasLiquid) {
dispatch(tutorialActions.addHint('add_liquids_and_labware'))
}
if (stepModuleMissingLabware) {
dispatch(tutorialActions.addHint('module_without_labware'))
} else if (temperatureModuleOnDeck && tempHasNoLabware) {
} else if (temperatureModuleOnDeck != null && tempHasNoLabware) {
dispatch(tutorialActions.addHint('multiple_modules_without_labware'))
}
}
Expand Down

0 comments on commit 51139bc

Please sign in to comment.