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

feat(app): usb connection and moam modal functionality in module setup #8257

Merged
merged 39 commits into from
Sep 3, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
39 commits
Select commit Hold shift + click to select a range
c6b2b14
create module setup component and test
jerader Aug 6, 2021
eaf9892
create multiple modules modal and edit styles
jerader Aug 9, 2021
fd5e406
create module info and edited MoaM modal
jerader Aug 10, 2021
1e2f00d
address pr comments
jerader Aug 12, 2021
dc80ed7
fix test and deck view box
jerader Aug 12, 2021
090ce8d
fix styling and svg tag
jerader Aug 16, 2021
6441bdb
fix margin error
jerader Aug 16, 2021
296ba27
add poll the robot modules ever 5 seconds
jerader Aug 16, 2021
25c156a
add some usb info
jerader Aug 16, 2021
472558b
fix connected and not connected
jerader Aug 16, 2021
b9b783d
add button styling
jerader Aug 17, 2021
88e4e9b
begin to add usb detection
jerader Aug 18, 2021
aa0a4ff
add frontend port and module connection
jerader Aug 18, 2021
8875e36
modify css file
jerader Aug 19, 2021
522e112
fix module variable
jerader Aug 19, 2021
c5e984a
remove styles file and edit usb and hub
jerader Aug 19, 2021
866799b
add port and mode features
jerader Aug 23, 2021
1d9bfcb
style fix on labware setup file
jerader Aug 23, 2021
fb91ff7
fix hub and port connection
jerader Aug 23, 2021
5daa14c
add isAttached and fix usb and hub
jerader Aug 23, 2021
b8496f5
fix for both port and no port info compatibility
jerader Aug 24, 2021
9e35078
add labware setup step btn function
jerader Aug 24, 2021
2942f2f
add moam modal functionality
jerader Aug 24, 2021
377d8b3
reorg
jerader Aug 24, 2021
e04e11d
modify tests and fix labware setup button fxn
jerader Aug 25, 2021
eec117d
modify tests
jerader Aug 25, 2021
d0b08a8
feat(app): usb connection and moam modal functionality in module setup
jerader Aug 25, 2021
d21e5cc
clean up code
jerader Aug 26, 2021
111e4af
fix prettier formatting
jerader Aug 26, 2021
9263ca3
add test and fix robotname functionality
jerader Aug 26, 2021
a26d83c
remove unnecessary imports
jerader Aug 26, 2021
a02cd01
address comments and rework moduleInfo test
jerader Aug 27, 2021
133bde6
add expect corresponding matcher call to moduleInfo test
jerader Aug 27, 2021
2c3581f
fix import
jerader Aug 30, 2021
a52334c
address Emilys comment
jerader Aug 30, 2021
dc64a67
correct prettier formatting
jerader Aug 30, 2021
52696fe
address comments
jerader Sep 1, 2021
7109e2f
utilize i18n plural capabilities
jerader Sep 3, 2021
e8334fb
fix prettier formatting
jerader Sep 3, 2021
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
Prev Previous commit
Next Next commit
add test and fix robotname functionality
  • Loading branch information
jerader committed Aug 30, 2021
commit 9263ca34abe7dae36d6451cc3dbff6309c45bde5
Original file line number Diff line number Diff line change
@@ -0,0 +1,149 @@
import React from 'react'
import '@testing-library/jest-dom'
import { StaticRouter } from 'react-router-dom'
import { ModuleModel, ModuleRealType } from '@opentrons/shared-data'
import { renderWithProviders } from '@opentrons/components/__utils__'
import { i18n } from '../../../../../i18n'
import { ModuleInfo } from '../ModuleInfo'
import { when } from 'jest-when'

jest.mock('../ModuleInfo')
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this test should be testing ModuleInfo right? we don't actually want to mock it, we only want to mock the dependencies of ModuleInfo that we need to


const componentPropsMatcher = (matcher: unknown) =>
// @ts-expect-error(sa, 2021-08-03): when.allArgs not part of type definition yet for jest-when
when.allArgs((args, equals) => equals(args[0], matcher))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you should be able to import this from shared components now if you rebase on top of edge:

import {
  componentPropsMatcher,
  renderWithProviders,
} from '@opentrons/components/__utils__'


const render = (props: React.ComponentProps<typeof ModuleInfo>) => {
return renderWithProviders(
<StaticRouter>
<ModuleInfo {...props} />
</StaticRouter>,
{
i18nInstance: i18n,
}
)
}
const mockModuleInfo = ModuleInfo as jest.MockedFunction<typeof ModuleInfo>
const MOCK_IS_ATTACHED = false || true
const MOCK_TC_COORDS = [20, 30, 0]

const STUBBED_ORIENTATION_VALUE = 'left'
const mockTCModule = {
labwareOffset: { x: 3, y: 3, z: 3 },
moduleId: 'TCModuleId',
model: 'thermocyclerModuleV1' as ModuleModel,
type: 'thermocyclerModuleType' as ModuleRealType,
}

describe('ModuleInfo', () => {
let props: React.ComponentProps<typeof ModuleInfo>
beforeEach(() => {
props = {
x: 3,
y: 3,
orientation: 'left',
moduleModel: mockTCModule.model,
usbPort: '',
hubPort: '',
isAttached: MOCK_IS_ATTACHED,
}
})

it('should render no modules connected', () => {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this test isn't actually making any assertion, so it will always pass. what should module info be actually be doing?

the test name says it should not render any modules, but i dont think the ModuleInfo component has any concept of "modules", it just takes in info about a particular module and then renders some text and an icon depending on that info it loooks like

const usbPort = null
const hubPort = null
const isAttached = false
props = {
...props,
usbPort,
hubPort,
isAttached,
}

when(mockModuleInfo)
.calledWith(
componentPropsMatcher({
orientation: STUBBED_ORIENTATION_VALUE,
moduleModel: mockTCModule.model,
x: MOCK_TC_COORDS[0],
y: MOCK_TC_COORDS[1],
isAttached: true,
usbPort: null,
hubPort: null,
})
)
.mockReturnValue(<div>mock module info {mockTCModule.model} </div>)

props = {
...props,
usbPort,
hubPort,
isAttached,
}
})

it('should render modules connected on a robot server 4.3 or higher', () => {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same deal here, this test isn't making any assertions

const usbPort = '1'
const hubPort = '1'
const isAttached = true
props = {
...props,
usbPort,
hubPort,
isAttached,
}

when(mockModuleInfo)
.calledWith(
componentPropsMatcher({
orientation: STUBBED_ORIENTATION_VALUE,
moduleModel: mockTCModule.model,
x: MOCK_TC_COORDS[0],
y: MOCK_TC_COORDS[1],
isAttached: true,
usbPort: '1',
hubPort: '1',
})
)
.mockReturnValue(<div>mock module info {mockTCModule.model} </div>)

props = {
...props,
usbPort,
hubPort,
isAttached,
}
})
it('should render modules connected on a robot server lower than 4.3', () => {
const usbPort = null
const hubPort = null
const isAttached = true
props = {
...props,
usbPort,
hubPort,
isAttached,
}

when(mockModuleInfo)
.calledWith(
componentPropsMatcher({
orientation: STUBBED_ORIENTATION_VALUE,
moduleModel: mockTCModule.model,
x: MOCK_TC_COORDS[0],
y: MOCK_TC_COORDS[1],
isAttached: true,
usbPort: null,
hubPort: null,
})
)
.mockReturnValue(<div>mock module info {mockTCModule.model} </div>)

props = {
...props,
usbPort,
hubPort,
isAttached,
}
})
})
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ const render = (props: React.ComponentProps<typeof ModuleSetup>) => {
const STUBBED_ORIENTATION_VALUE = 'left'
const MOCK_MAGNETIC_MODULE_COORDS = [10, 20, 0]
const MOCK_TC_COORDS = [20, 30, 0]
const MOCK_ROBOT_NAME = 'ot-dev'

const mockMagneticModule = {
labwareOffset: { x: 5, y: 5, z: 5 },
Expand All @@ -87,7 +88,7 @@ describe('ModuleSetup', () => {
let props: React.ComponentProps<typeof ModuleSetup>
beforeEach(() => {
props = {
robotName: 'opentrons-dev',
robotName: MOCK_ROBOT_NAME,
moduleRenderCoords: {},
expandLabwareSetupStep: () => {},
}
Expand All @@ -114,7 +115,7 @@ describe('ModuleSetup', () => {
</div>
))
when(mockGetAttachedModules)
.calledWith(undefined as any, 'opentrons-dev')
.calledWith(undefined as any, MOCK_ROBOT_NAME)
.mockReturnValue([])
})

Expand Down Expand Up @@ -230,7 +231,7 @@ describe('ModuleSetup', () => {
},
}
when(mockGetAttachedModules)
.calledWith(undefined as any, 'opentrons-dev')
.calledWith(undefined as any, MOCK_ROBOT_NAME)
.mockReturnValue([
{
...mockMagneticModuleFixture,
Expand Down
2 changes: 1 addition & 1 deletion app/src/organisms/ProtocolSetup/RunSetupCard/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ export function RunSetupCard(): JSX.Element | null {
<ModuleSetup
moduleRenderCoords={moduleRenderCoords}
expandLabwareSetupStep={() => setExpandedStepKey(LABWARE_SETUP_KEY)}
robotName={'opentrons-dev'} // TODO: immediately import robot name
robotName={robot.name}
/>
),
[LABWARE_SETUP_KEY]: (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ describe('RunSetupCard', () => {
componentPropsMatcher({
moduleRenderCoords: mockModuleRenderCoords,
expandLabwareSetupStep: expect.anything(),
robotName: 'opentrons-dev', // replace this with a mocked robot name
robotName: mockConnectedRobot.name,
})
)
.mockImplementation(({ expandLabwareSetupStep }) => (
Expand Down