Skip to content

Commit

Permalink
fix(app): Center app and robot update modals (#14541)
Browse files Browse the repository at this point in the history
Closes RQA-2349
  • Loading branch information
mjhuff authored Feb 26, 2024
1 parent 8478760 commit 76a4b03
Show file tree
Hide file tree
Showing 7 changed files with 35 additions and 14 deletions.
2 changes: 1 addition & 1 deletion app/src/assets/localization/en/device_settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -301,7 +301,7 @@
"update_robot_software_description": "Bypass the Opentrons App auto-update process and update the robot software manually.",
"update_robot_software_link": "Launch Opentrons software update page",
"updating": "Updating",
"updating_robot_system": "Updating the robot software requires restarting the robot",
"update_requires_restarting": "Updating the robot software requires restarting the robot",
"usage_settings": "Usage Settings",
"usb": "USB",
"usb_to_ethernet_description": "Looking for USB-to-Ethernet Adapter info?",
Expand Down
31 changes: 21 additions & 10 deletions app/src/molecules/LegacyModal/__tests__/LegacyModal.test.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import * as React from 'react'
import { screen } from '@testing-library/react'

import { COLORS, renderWithProviders } from '@opentrons/components'

Expand All @@ -20,33 +21,43 @@ describe('LegacyModal', () => {
})

it('should render modal without header icon when type is info', () => {
const [{ getByText, queryByTestId, getByTestId }] = render(props)
expect(queryByTestId('Modal_header_icon')).not.toBeInTheDocument()
getByText('mock info modal')
expect(getByTestId('Modal_header')).toHaveStyle(
render(props)
expect(screen.queryByTestId('Modal_header_icon')).not.toBeInTheDocument()
screen.getByText('mock info modal')
expect(screen.getByTestId('Modal_header')).toHaveStyle(
`background-color: ${COLORS.white}`
)
})

it('should render modal with orange header icon when type is warning', () => {
props.type = 'warning'
const [{ getByTestId }] = render(props)
const headerIcon = getByTestId('Modal_header_icon')
render(props)
const headerIcon = screen.getByTestId('Modal_header_icon')
expect(headerIcon).toBeInTheDocument()
expect(headerIcon).toHaveStyle(`color: ${COLORS.yellow50}`)
expect(getByTestId('Modal_header')).toHaveStyle(
expect(screen.getByTestId('Modal_header')).toHaveStyle(
`background-color: ${COLORS.white}`
)
})

it('should render modal with red header icon when type is error', () => {
props.type = 'error'
const [{ getByTestId }] = render(props)
const headerIcon = getByTestId('Modal_header_icon')
render(props)
const headerIcon = screen.getByTestId('Modal_header_icon')
expect(headerIcon).toBeInTheDocument()
expect(headerIcon).toHaveStyle(`color: ${COLORS.red50}`)
expect(getByTestId('Modal_header')).toHaveStyle(
expect(screen.getByTestId('Modal_header')).toHaveStyle(
`background-color: ${COLORS.white}`
)
})

it('should supply a default margin to account for the sidebar, aligning the modal in the center of the app', () => {
render(props)
expect(screen.getByLabelText('ModalShell_ModalArea')).toHaveStyle(
'width: 31.25rem'
)
expect(screen.getByLabelText('ModalShell_ModalArea')).toHaveStyle(
'margin-left: 5.656rem'
)
})
})
2 changes: 1 addition & 1 deletion app/src/molecules/LegacyModal/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ export const LegacyModal = (props: LegacyModalProps): JSX.Element => {
header={modalHeader}
onOutsideClick={closeOnOutsideClick ?? false ? onClose : undefined}
// center within viewport aside from nav
marginLeft={styleProps.marginLeft ?? '7.125rem'}
marginLeft={styleProps.marginLeft ?? '5.656rem'}
{...styleProps}
footer={footer}
>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ export function UpdateRobotModal({
>
<Flex flexDirection={DIRECTION_COLUMN}>
<UpdateAppBanner type="informing" marginBottom={SPACING.spacing8}>
{t('updating_robot_system')}
{t('update_requires_restarting')}
</UpdateAppBanner>
<ReleaseNotes source={releaseNotes} />
</Flex>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ export function RobotSystemVersionModal({
>
<InlineNotification
type="neutral"
heading={t('updating_robot_system')}
heading={t('update_requires_restarting')}
hug
/>
<ReleaseNotes source={releaseNotes} />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -133,4 +133,13 @@ describe('UpdateAppModal', () => {
screen.getByRole('heading', { name: 'Update Error' })
).toBeInTheDocument()
})
it('uses a custom width and left margin to properly center the modal', () => {
render(props)
expect(screen.getByLabelText('ModalShell_ModalArea')).toHaveStyle(
'width: 40rem'
)
expect(screen.getByLabelText('ModalShell_ModalArea')).toHaveStyle(
'margin-left: 5.336rem'
)
})
})
1 change: 1 addition & 0 deletions app/src/organisms/UpdateAppModal/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ const UPDATE_PROGRESS_BAR_STYLE = css`
`
const LEGACY_MODAL_STYLE = css`
width: 40rem;
margin-left: 5.336rem;
`

const RESTART_APP_AFTER_TIME = 5000
Expand Down

0 comments on commit 76a4b03

Please sign in to comment.