Skip to content

Commit 0b6746d

Browse files
authored
refactor(app): round pipetting command params to 2 sig figs (#18708)
Closes RQA-3937 Rounds all pipetting command params to two significant figures.
1 parent a00cb11 commit 0b6746d

File tree

3 files changed

+31
-22
lines changed

3 files changed

+31
-22
lines changed

components/src/organisms/CommandText/__tests__/CommandText.test.tsx

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ describe('CommandText', () => {
5959
{ i18nInstance: i18n }
6060
)
6161
screen.getByText(
62-
'Aspirating 100 µL from well A1 of NEST 1 Well Reservoir 195 mL in Slot 5 at 150 µL/sec'
62+
'Aspirating 100.00 µL from well A1 of NEST 1 Well Reservoir 195 mL in Slot 5 at 150.00 µL/sec'
6363
)
6464
}
6565
})
@@ -79,7 +79,7 @@ describe('CommandText', () => {
7979
{ i18nInstance: i18n }
8080
)
8181
screen.getByText(
82-
'Dispensing 100 µL into well A1 of NEST 96 Well Plate 100 µL PCR Full Skirt (1) in Magnetic Module GEN2 in Slot 1 at 300 µL/sec'
82+
'Dispensing 100.00 µL into well A1 of NEST 96 Well Plate 100 µL PCR Full Skirt (1) in Magnetic Module GEN2 in Slot 1 at 300.00 µL/sec'
8383
)
8484
}
8585
})
@@ -106,7 +106,7 @@ describe('CommandText', () => {
106106
{ i18nInstance: i18n }
107107
)
108108
screen.getByText(
109-
'Dispensing 100 µL into well A1 of NEST 96 Well Plate 100 µL PCR Full Skirt (1) in Magnetic Module GEN2 in Slot 1 at 300 µL/sec and pushing out 10 µL'
109+
'Dispensing 100.00 µL into well A1 of NEST 96 Well Plate 100 µL PCR Full Skirt (1) in Magnetic Module GEN2 in Slot 1 at 300.00 µL/sec and pushing out 10.00 µL'
110110
)
111111
}
112112
})
@@ -129,7 +129,7 @@ describe('CommandText', () => {
129129
/>,
130130
{ i18nInstance: i18n }
131131
)
132-
screen.getByText('Dispensing 50 µL in place at 300 µL/sec')
132+
screen.getByText('Dispensing 50.00 µL in place at 300.00 µL/sec')
133133
})
134134
it('renders correct text for blowout', () => {
135135
const dispenseCommand = mockCommandTextData.commands.find(
@@ -151,7 +151,7 @@ describe('CommandText', () => {
151151
{ i18nInstance: i18n }
152152
)
153153
screen.getByText(
154-
'Blowing out at well A1 of NEST 96 Well Plate 100 µL PCR Full Skirt (1) in Magnetic Module GEN2 in Slot 1 at 300 µL/sec'
154+
'Blowing out at well A1 of NEST 96 Well Plate 100 µL PCR Full Skirt (1) in Magnetic Module GEN2 in Slot 1 at 300.00 µL/sec'
155155
)
156156
}
157157
})
@@ -173,7 +173,7 @@ describe('CommandText', () => {
173173
/>,
174174
{ i18nInstance: i18n }
175175
)
176-
screen.getByText('Blowing out in place at 300 µL/sec')
176+
screen.getByText('Blowing out in place at 300.00 µL/sec')
177177
})
178178
it('renders correct text for aspirateInPlace', () => {
179179
renderWithProviders(
@@ -186,15 +186,15 @@ describe('CommandText', () => {
186186
commandType: 'aspirateInPlace',
187187
params: {
188188
pipetteId: 'f6d1c83c-9d1b-4d0d-9de3-e6d649739cfb',
189-
flowRate: 300,
190-
volume: 10,
189+
flowRate: 300.7653423,
190+
volume: 10.12526,
191191
},
192192
} as AspirateInPlaceRunTimeCommand
193193
}
194194
/>,
195195
{ i18nInstance: i18n }
196196
)
197-
screen.getByText('Aspirating 10 µL in place at 300 µL/sec')
197+
screen.getByText('Aspirating 10.13 µL in place at 300.77 µL/sec')
198198
})
199199
it('renders correct text for moveToWell', () => {
200200
const dispenseCommand = mockCommandTextData.commands.find(

components/src/organisms/CommandText/useCommandTextString/utils/commandText/__tests__/getPipettingCommandText.test.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ describe('getPipettingCommandText', () => {
9191

9292
render(command)
9393
screen.getByText(
94-
/Aspirating 100 µL from well A1 of Test Labware in Slot 1 at 150 µL\/sec/
94+
/Aspirating 100.00 µL from well A1 of Test Labware in Slot 1 at 150.00 µL\/sec/
9595
)
9696
})
9797

@@ -109,7 +109,7 @@ describe('getPipettingCommandText', () => {
109109

110110
render(command)
111111
screen.getByText(
112-
/Dispensing 100 µL into well A1 of Test Labware in Slot 1 at 150 µL\/sec/
112+
/Dispensing 100.00 µL into well A1 of Test Labware in Slot 1 at 150.00 µL\/sec/
113113
)
114114
})
115115

@@ -128,7 +128,7 @@ describe('getPipettingCommandText', () => {
128128

129129
render(command)
130130
screen.getByText(
131-
/Dispensing 100 µL into well A1 of Test Labware in Slot 1 at 150 µL\/sec and pushing out 10 µL/
131+
/Dispensing 100.00 µL into well A1 of Test Labware in Slot 1 at 150.00 µL\/sec and pushing out 10.00 µL/
132132
)
133133
})
134134

components/src/organisms/CommandText/useCommandTextString/utils/commandText/getPipettingCommandText.ts

Lines changed: 19 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -57,9 +57,12 @@ export const getPipettingCommandText = ({
5757
})
5858
: null
5959

60+
const volume = formatCmdParamDecimal(command, 'volume')
61+
const flowRate = formatCmdParamDecimal(command, 'flowRate')
62+
const pushOutVolume = formatCmdParamDecimal(command, 'pushOut')
63+
6064
switch (command?.commandType) {
6165
case 'aspirate': {
62-
const { volume, flowRate } = command.params
6366
return t('aspirate', {
6467
well_name: wellName,
6568
labware: labwareName,
@@ -69,15 +72,14 @@ export const getPipettingCommandText = ({
6972
})
7073
}
7174
case 'dispense': {
72-
const { volume, flowRate, pushOut } = command.params
73-
return pushOut != null
75+
return pushOutVolume != null
7476
? t('dispense_push_out', {
7577
well_name: wellName,
7678
labware: labwareName,
7779
labware_location: displayLocation,
7880
volume,
7981
flow_rate: flowRate,
80-
push_out_volume: pushOut,
82+
push_out_volume: pushOutVolume,
8183
})
8284
: t('dispense', {
8385
well_name: wellName,
@@ -88,7 +90,6 @@ export const getPipettingCommandText = ({
8890
})
8991
}
9092
case 'blowout': {
91-
const { flowRate } = command.params
9293
return t('blowout', {
9394
well_name: wellName,
9495
labware: labwareName,
@@ -154,19 +155,15 @@ export const getPipettingCommandText = ({
154155
}
155156
}
156157
case 'dispenseInPlace': {
157-
const { volume, flowRate } = command.params
158158
return t('dispense_in_place', { volume, flow_rate: flowRate })
159159
}
160160
case 'blowOutInPlace': {
161-
const { flowRate } = command.params
162161
return t('blowout_in_place', { flow_rate: flowRate })
163162
}
164163
case 'aspirateInPlace': {
165-
const { flowRate, volume } = command.params
166164
return t('aspirate_in_place', { volume, flow_rate: flowRate })
167165
}
168166
case 'airGapInPlace': {
169-
const { volume } = command.params
170167
return t('air_gap_in_place', { volume })
171168
}
172169
case 'sealPipetteToTip': {
@@ -182,7 +179,6 @@ export const getPipettingCommandText = ({
182179
})
183180
}
184181
case 'pressureDispense': {
185-
const { flowRate, volume } = command.params
186182
return t('pressurizing_to_dispense', { volume, flow_rate: flowRate })
187183
}
188184
default: {
@@ -194,3 +190,16 @@ export const getPipettingCommandText = ({
194190
}
195191
}
196192
}
193+
194+
// Format the given command param to two decimals if it exists and can be cast as a number.
195+
const formatCmdParamDecimal = (
196+
command: RunTimeCommand | null | undefined,
197+
paramName: string
198+
): string | null =>
199+
command?.params &&
200+
paramName in command.params &&
201+
command.params[paramName as keyof typeof command.params] != null
202+
? Number(command.params[paramName as keyof typeof command.params]).toFixed(
203+
2
204+
)
205+
: null

0 commit comments

Comments
 (0)