Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(api-client): update initial loaded labware to support addressable areas #14150

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 43 additions & 1 deletion api-client/src/protocols/__tests__/utils.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,7 @@ describe('parseInitialLoadedLabwareByAdapter', () => {
})
})
describe('parseInitialLoadedLabwareBySlot', () => {
it('returns only labware loaded in slots', () => {
it('returns labware loaded in slots', () => {
const expected = {
2: mockRunTimeCommands.find(
c =>
Expand All @@ -282,6 +282,48 @@ describe('parseInitialLoadedLabwareBySlot', () => {
expected
)
})
it('returns labware loaded in addressable areas', () => {
const mockAddressableAreaLoadedLabwareCommand = ([
{
id: 'commands.LOAD_LABWARE-3',
createdAt: '2022-04-01T15:46:01.745870+00:00',
commandType: 'loadLabware',
key: 'commands.LOAD_LABWARE-3',
status: 'succeeded',
params: {
location: {
addressableAreaName: 'D4',
},
loadName: 'nest_96_wellplate_100ul_pcr_full_skirt',
namespace: 'opentrons',
version: 1,
labwareId: null,
displayName: 'NEST 96 Well Plate 100 µL PCR Full Skirt',
},
result: {
labwareId: 'labware-3',
definition: {},
offsetId: null,
},
error: null,
startedAt: '2022-04-01T15:46:01.745870+00:00',
completedAt: '2022-04-01T15:46:01.745870+00:00',
},
] as any) as RunTimeCommand[]

const expected = {
D4: mockAddressableAreaLoadedLabwareCommand.find(
c =>
c.commandType === 'loadLabware' &&
typeof c.params.location === 'object' &&
'addressableAreaName' in c.params?.location &&
c.params?.location?.addressableAreaName === 'D4'
),
}
expect(
parseInitialLoadedLabwareBySlot(mockAddressableAreaLoadedLabwareCommand)
).toEqual(expected)
})
})
describe('parseInitialLoadedLabwareByModuleId', () => {
it('returns only labware loaded in modules', () => {
Expand Down
13 changes: 8 additions & 5 deletions api-client/src/protocols/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,11 @@
export function parseInitialPipetteNamesByMount(
commands: RunTimeCommand[]
): PipetteNamesByMount {
const rightPipetteName = commands.find(

Check warning on line 28 in api-client/src/protocols/utils.ts

View workflow job for this annotation

GitHub Actions / js checks

This assertion is unnecessary since it does not change the type of the expression

Check warning on line 28 in api-client/src/protocols/utils.ts

View workflow job for this annotation

GitHub Actions / js checks

This assertion is unnecessary since it does not change the type of the expression
(command): command is LoadPipetteRunTimeCommand =>
command.commandType === 'loadPipette' && command.params.mount === 'right'
)?.params.pipetteName as PipetteName | undefined
const leftPipetteName = commands.find(

Check warning on line 32 in api-client/src/protocols/utils.ts

View workflow job for this annotation

GitHub Actions / js checks

This assertion is unnecessary since it does not change the type of the expression

Check warning on line 32 in api-client/src/protocols/utils.ts

View workflow job for this annotation

GitHub Actions / js checks

This assertion is unnecessary since it does not change the type of the expression
(command): command is LoadPipetteRunTimeCommand =>
command.commandType === 'loadPipette' && command.params.mount === 'left'
)?.params.pipetteName as PipetteName | undefined
Expand Down Expand Up @@ -117,11 +117,14 @@
return reduce<LoadLabwareRunTimeCommand, LoadedLabwareBySlot>(
loadLabwareCommandsReversed,
(acc, command) => {
if (
typeof command.params.location === 'object' &&
'slotName' in command.params.location
) {
return { ...acc, [command.params.location.slotName]: command }
if (typeof command.params.location === 'object') {
let slot: string
if ('slotName' in command.params.location) {
slot = command.params.location.slotName
} else if ('addressableAreaName' in command.params.location) {
slot = command.params.location.addressableAreaName
} else return acc
return { ...acc, [slot]: command }
} else {
return acc
}
Expand Down
Loading