Skip to content

Commit

Permalink
lint fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
mjhuff committed Mar 4, 2024
1 parent eda4f56 commit e11059c
Show file tree
Hide file tree
Showing 32 changed files with 107 additions and 111 deletions.
6 changes: 4 additions & 2 deletions app-shell/src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ function createRendererLogger(): Logger {
return logger
}

function installDevtools(): Promise<void | Logger> {
function installDevtools(): Promise<Logger> {
const extensions = [
electronDevtoolsInstaller.REACT_DEVELOPER_TOOLS,
electronDevtoolsInstaller.REDUX_DEVTOOLS,
Expand All @@ -158,6 +158,8 @@ function installDevtools(): Promise<void | Logger> {
})
} else {
log.warn('could not resolve electron dev tools installer')
return Promise.reject('could not resolve electron dev tools installer')
return Promise.reject(
new Error('could not resolve electron dev tools installer')
)
}
}
1 change: 0 additions & 1 deletion app/src/__testing-utils__/matchers.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { when } from 'vitest-when'
import type { Matcher } from '@testing-library/react'

// Match things like <p>Some <strong>nested</strong> text</p>
Expand Down
4 changes: 2 additions & 2 deletions app/src/atoms/text/__tests__/StyledText.test.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import * as React from 'react'
import { describe, it, expect, vi, beforeEach } from 'vitest'
import { describe, it, expect } from 'vitest'
import '@testing-library/jest-dom/vitest'
import { fireEvent, screen } from '@testing-library/react'
import { screen } from '@testing-library/react'
import { TYPOGRAPHY } from '@opentrons/components'
import { StyledText } from '../'
import { renderWithProviders } from '../../../__testing-utils__'
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
import { describe, it, expect } from 'vitest'
import '@testing-library/jest-dom/vitest'
import { transfer_settings } from '@opentrons/shared-data'
import { ModuleModel, CompletedProtocolAnalysis } from '@opentrons/shared-data'
import {
transfer_settings,
ModuleModel,
CompletedProtocolAnalysis,
} from '@opentrons/shared-data'
import { createSnippet } from '../createSnippet'

const protocolWithMagTempTC = ({
Expand Down
64 changes: 33 additions & 31 deletions app/src/organisms/AdvancedSettings/ClearUnavailableRobots.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import { TertiaryButton } from '../../atoms/buttons'
import { ERROR_TOAST, SUCCESS_TOAST } from '../../atoms/Toast'
import { useToaster } from '../../organisms/ToasterOven'
import { LegacyModal } from '../../molecules/LegacyModal'
import { Portal, getTopPortalEl } from '../../App/portal'
import { getTopPortalEl } from '../../App/portal'
import {
clearDiscoveryCache,
getReachableRobots,
Expand Down Expand Up @@ -63,41 +63,43 @@ export function ClearUnavailableRobots(): JSX.Element {
} = useConditionalConfirm(handleDeleteUnavailRobots, true)
return (
<>
{showConfirmDeleteUnavailRobots ? createPortal(
<LegacyModal
type="warning"
title={t('clear_unavailable_robots')}
onClose={cancelExit}
>
<StyledText as="p">{t('clearing_cannot_be_undone')}</StyledText>
<Flex
flexDirection={DIRECTION_ROW}
paddingTop={SPACING.spacing32}
justifyContent={JUSTIFY_FLEX_END}
{showConfirmDeleteUnavailRobots
? createPortal(
<LegacyModal
type="warning"
title={t('clear_unavailable_robots')}
onClose={cancelExit}
>
<StyledText as="p">{t('clearing_cannot_be_undone')}</StyledText>
<Flex
paddingRight={SPACING.spacing4}
data-testid="AdvancedSettings_ConfirmClear_Cancel"
flexDirection={DIRECTION_ROW}
paddingTop={SPACING.spacing32}
justifyContent={JUSTIFY_FLEX_END}
>
<Btn
onClick={cancelExit}
textTransform={TYPOGRAPHY.textTransformCapitalize}
color={COLORS.blue50}
fontWeight={TYPOGRAPHY.fontWeightSemiBold}
marginRight={SPACING.spacing32}
<Flex
paddingRight={SPACING.spacing4}
data-testid="AdvancedSettings_ConfirmClear_Cancel"
>
{t('shared:cancel')}
</Btn>
</Flex>
<Flex data-testid="AdvancedSettings_ConfirmClear_Proceed">
<AlertPrimaryButton onClick={confirmDeleteUnavailRobots}>
{t('clear_confirm')}
</AlertPrimaryButton>
<Btn
onClick={cancelExit}
textTransform={TYPOGRAPHY.textTransformCapitalize}
color={COLORS.blue50}
fontWeight={TYPOGRAPHY.fontWeightSemiBold}
marginRight={SPACING.spacing32}
>
{t('shared:cancel')}
</Btn>
</Flex>
<Flex data-testid="AdvancedSettings_ConfirmClear_Proceed">
<AlertPrimaryButton onClick={confirmDeleteUnavailRobots}>
{t('clear_confirm')}
</AlertPrimaryButton>
</Flex>
</Flex>
</Flex>
</LegacyModal>,
getTopPortalEl()
) : null}
</LegacyModal>,
getTopPortalEl()
)
: null}
<Flex
alignItems={ALIGN_CENTER}
justifyContent={JUSTIFY_SPACE_BETWEEN}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import * as React from 'react'
import { screen, fireEvent, waitFor } from '@testing-library/react'
import { screen, fireEvent } from '@testing-library/react'
import { describe, it, expect, vi, beforeEach } from 'vitest'
import { useConditionalConfirm } from '@opentrons/components'
import { i18n } from '../../../i18n'
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { describe, it, expect, beforeEach } from 'vitest'
import { describe, it, expect } from 'vitest'
import {
getLabwareDefURI,
opentrons96PcrAdapterV1,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import * as React from 'react'
import { fireEvent, screen } from '@testing-library/react'
import { describe, it, beforeEach, vi, expect } from 'vitest'
import { describe, it, beforeEach, vi, expect, Mock } from 'vitest'

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

Expand All @@ -16,8 +16,6 @@ import {
import { getIsOnDevice } from '../../../../../redux/config'
import { LiquidDetailCard } from '../LiquidDetailCard'

import { Mock } from 'vitest'

vi.mock('../../../../../redux/analytics')
vi.mock('../../../../../redux/config')

Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
import * as React from 'react'
import { describe, it, beforeEach, vi } from 'vitest'
import { screen } from '@testing-library/react'
import { screen, fireEvent } from '@testing-library/react'

import { renderWithProviders } from '../../../../../__testing-utils__'
import { i18n } from '../../../../../i18n'
import { SetupLiquids } from '../index'
import { SetupLiquidsList } from '../SetupLiquidsList'
import { SetupLiquidsMap } from '../SetupLiquidsMap'
import { BackToTopButton } from '../../BackToTopButton'
import { fireEvent } from '@testing-library/react'

vi.mock('../SetupLiquidsList')
vi.mock('../SetupLiquidsMap')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,27 +77,27 @@ describe('SetupRobotCalibration', () => {
})

it('renders deck, pipette, and tip length calibration components', () => {
render()[0]
render()
screen.getByText('Mock SetupDeckCalibration')
screen.getByText('Mock SetupInstrumentCalibration')
screen.getByText('Mock SetupTipLengthCalibration')
})

it('renders only pipette calibration component for Flex', () => {
when(vi.mocked(useIsFlex)).calledWith(ROBOT_NAME).thenReturn(true)
render()[0]
render()
expect(screen.queryByText('Mock SetupDeckCalibration')).toBeNull()
screen.getByText('Mock SetupInstrumentCalibration')
expect(screen.queryByText('Mock SetupTipLengthCalibration')).toBeNull()
})

it('changes Proceed CTA copy based on next step', () => {
render({ nextStep: 'labware_setup_step' })[0]
render({ nextStep: 'labware_setup_step' })
screen.getByRole('button', { name: 'Proceed to labware' })
})

it('calls the expandStep function and tracks the analytics event on click', () => {
render()[0]
render()
fireEvent.click(screen.getByRole('button', { name: 'Proceed to modules' }))
expect(mockExpandStep).toHaveBeenCalled()
expect(mockTrackEvent).toHaveBeenCalledWith({
Expand All @@ -107,7 +107,7 @@ describe('SetupRobotCalibration', () => {
})

it('does not call the expandStep function on click if calibration is not complete', () => {
render({ calibrationStatus: { complete: false } })[0]
render({ calibrationStatus: { complete: false } })
const button = screen.getByRole('button', { name: 'Proceed to modules' })
expect(button).toBeDisabled()
fireEvent.click(button)
Expand All @@ -116,7 +116,7 @@ describe('SetupRobotCalibration', () => {

it('does not call the expandStep function on click if run has started', () => {
when(vi.mocked(useRunHasStarted)).calledWith(RUN_ID).thenReturn(true)
render()[0]
render()
const button = screen.getByRole('button', { name: 'Proceed to modules' })
expect(button).toBeDisabled()
fireEvent.click(button)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import { describe, it, expect } from 'vitest'
import { transfer_settings } from '@opentrons/shared-data'
import {
transfer_settings,
CompletedProtocolAnalysis,
} from '@opentrons/shared-data'
import { getModuleInitialLoadInfo } from '../getModuleInitialLoadInfo'
import { CompletedProtocolAnalysis } from '@opentrons/shared-data'
import type { LoadModuleRunTimeCommand } from '@opentrons/shared-data'

const protocolWithMagTempTC = (transfer_settings as unknown) as CompletedProtocolAnalysis
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,12 @@ import {
transfer_settings,
multiple_temp_modules,
ot2DeckDefV4,
} from '@opentrons/shared-data'
import { getProtocolModulesInfo } from '../getProtocolModulesInfo'
import {
getModuleDef2,
ProtocolAnalysisOutput,
LoadedLabware,
LoadedModule,
} from '@opentrons/shared-data'
import { getProtocolModulesInfo } from '../getProtocolModulesInfo'

const protocolWithMagTempTC = ({
...transfer_settings,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* eslint-disable testing-library/no-node-access */
import * as React from 'react'
import { MemoryRouter } from 'react-router-dom'
import { screen } from '@testing-library/react'
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* eslint-disable testing-library/no-node-access */
import * as React from 'react'
import { MemoryRouter } from 'react-router-dom'
import { screen } from '@testing-library/react'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ vi.mock('../../RunTimeControl/hooks')
vi.mock('../HistoricalProtocolRunOverflowMenu')
vi.mock('react-router-dom', async importOriginal => {
const reactRouterDom = importOriginal<typeof Dom>()
return {
return await {
...reactRouterDom,
useHistory: () => ({ push: mockPush } as any),
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import * as React from 'react'
import { MemoryRouter } from 'react-router-dom'
import { fireEvent } from '@testing-library/react'
import { screen } from '@testing-library/react'
import { fireEvent, screen } from '@testing-library/react'
import { describe, it, vi, beforeEach, expect } from 'vitest'
import '@testing-library/jest-dom/vitest'
import { renderWithProviders } from '../../../__testing-utils__'
Expand Down Expand Up @@ -68,7 +67,7 @@ describe('RobotOverflowMenu', () => {
render(props)
const btn = screen.getByLabelText('RobotOverflowMenu_button')
fireEvent.click(btn)
const why = screen.getByText('Why is this robot unavailable?')
screen.getByText('Why is this robot unavailable?')
screen.getByText('Forget unavailable robot')
})

Expand Down
2 changes: 1 addition & 1 deletion app/src/organisms/Devices/__tests__/RobotOverview.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ import type * as ReactApiClient from '@opentrons/react-api-client'

vi.mock('@opentrons/react-api-client', async importOriginal => {
const actual = importOriginal<typeof ReactApiClient>()
return {
return await {
...actual,
useAuthorization: vi.fn(),
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,10 @@ import { Provider } from 'react-redux'
import { I18nextProvider } from 'react-i18next'
import { createStore } from 'redux'
import { vi, it, expect, describe, beforeEach, afterEach } from 'vitest'
import { getLoadedLabwareDefinitionsByUri } from '@opentrons/shared-data'
import { simple_v6 as _uncastedSimpleV6Protocol } from '@opentrons/shared-data'
import {
getLoadedLabwareDefinitionsByUri,
simple_v6 as _uncastedSimpleV6Protocol,
} from '@opentrons/shared-data'
import { i18n } from '../../../../i18n'
import { RUN_ID_1 } from '../../../RunTimeControl/__fixtures__'
import { useLPCDisabledReason } from '../useLPCDisabledReason'
Expand All @@ -17,7 +19,6 @@ import {
} from '..'
import { useMostRecentCompletedAnalysis } from '../../../LabwarePositionCheck/useMostRecentCompletedAnalysis'
import type { Store } from 'redux'
import type { ProtocolAnalysisOutput } from '@opentrons/shared-data'
import type * as SharedData from '@opentrons/shared-data'
import type { State } from '../../../../redux/types'

Expand All @@ -31,7 +32,7 @@ vi.mock('@opentrons/shared-data', async importOriginal => {
}
})

const simpleV6Protocol = (_uncastedSimpleV6Protocol as unknown) as ProtocolAnalysisOutput
const simpleV6Protocol = (_uncastedSimpleV6Protocol as unknown) as SharedData.ProtocolAnalysisOutput

describe('useLPCDisabledReason', () => {
const store: Store<State> = createStore(vi.fn(), {})
Expand All @@ -48,7 +49,7 @@ describe('useLPCDisabledReason', () => {
simpleV6Protocol as any
)
vi.mocked(useStoredProtocolAnalysis).mockReturnValue(
(simpleV6Protocol as unknown) as ProtocolAnalysisOutput
(simpleV6Protocol as unknown) as SharedData.ProtocolAnalysisOutput
)
vi.mocked(useRunHasStarted).mockReturnValue(false)
vi.mocked(useRunCalibrationStatus).mockReturnValue({ complete: true })
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,10 @@ import { vi, it, expect, describe, beforeEach } from 'vitest'
import { when } from 'vitest-when'
import { UseQueryResult } from 'react-query'

import { STAGING_AREA_RIGHT_SLOT_FIXTURE } from '@opentrons/shared-data'
import { heater_shaker_commands_with_result as _heaterShakerCommandsWithResultsKey } from '@opentrons/shared-data'
import {
STAGING_AREA_RIGHT_SLOT_FIXTURE,
heater_shaker_commands_with_results_key,
} from '@opentrons/shared-data'
import { useMostRecentCompletedAnalysis } from '../../../LabwarePositionCheck/useMostRecentCompletedAnalysis'
import { useDeckConfigurationQuery } from '@opentrons/react-api-client'

Expand Down Expand Up @@ -35,7 +37,7 @@ vi.mock('../useAttachedModules')
vi.mock('../useStoredProtocolAnalysis')
vi.mock('../../../LabwarePositionCheck/useMostRecentCompletedAnalysis')

const heaterShakerCommandsWithResultsKey = (_heaterShakerCommandsWithResultsKey as unknown) as ProtocolAnalysisOutput
const heaterShakerCommandsWithResultsKey = (heater_shaker_commands_with_results_key as unknown) as ProtocolAnalysisOutput

const PROTOCOL_DETAILS = {
displayName: 'fake protocol',
Expand Down
Loading

0 comments on commit e11059c

Please sign in to comment.