From 0592367a19c43544028700f58895d5e0dd33a1ac Mon Sep 17 00:00:00 2001 From: Jethary Date: Wed, 17 Jul 2024 17:24:56 -0400 Subject: [PATCH] feat(components, app, labware-library): migrate to react-router-dom v6.24.1 closes AUTH-564 --- app/src/App/__tests__/Navbar.test.tsx | 10 ++--- .../buttons/__tests__/BackButton.test.tsx | 14 +++---- .../CardButton/__tests__/CardButton.test.tsx | 6 +-- .../__tests__/Breadcrumbs.test.tsx | 12 +++--- .../__tests__/CalibrationTaskList.test.tsx | 42 +++++++++---------- .../__tests__/ChangePipette.test.tsx | 8 ++-- .../__tests__/ChooseProtocolSlideout.test.tsx | 6 +-- .../__tests__/ChooseRobotSlideout.test.tsx | 6 +-- .../__tests__/FileCard.test.tsx | 6 +-- .../ChooseRobotToRunProtocolSlideout.test.tsx | 6 +-- ...kConfigurationDiscardChangesModal.test.tsx | 10 ++--- .../__tests__/LabwareListItem.test.tsx | 6 +-- .../__tests__/OffDeckLabwareList.test.tsx | 6 +-- .../__tests__/SetupLabware.test.tsx | 6 +-- .../__tests__/SetupLabwareList.test.tsx | 6 +-- .../__tests__/SetupLabwareMap.test.tsx | 6 +-- .../SetupLabwarePositionCheck.test.tsx | 6 +-- .../__tests__/SetupModulesMap.test.tsx | 6 +-- .../__tests__/BackToTopButton.test.tsx | 6 +-- .../__tests__/ProtocolRunHeader.test.tsx | 6 +-- .../__tests__/InstrumentInfo.test.tsx | 4 +- .../__tests__/NavigationMenu.test.tsx | 10 ++--- .../AlternativeSecurityTypeModal.test.tsx | 10 ++--- .../__tests__/DisplayWifiList.test.tsx | 10 ++--- .../SelectAuthenticationType.test.tsx | 8 ++-- .../__tests__/WifiConnectionDetails.test.tsx | 10 ++--- .../__tests__/ConfirmRobotName.test.tsx | 10 ++--- .../__tests__/RecentRunProtocolCard.test.tsx | 10 ++--- .../__tests__/ConfirmCancelRunModal.test.tsx | 10 ++--- .../__tests__/RunFailedModal.test.tsx | 10 ++--- .../ProtocolAnalysisFailure.test.tsx | 6 +-- .../__tests__/ProtocolDetails.test.tsx | 6 +-- .../__tests__/LabwareMapViewModal.test.tsx | 6 +-- .../__tests__/AnalysisFailedModal.test.tsx | 8 ++-- .../ProtocolSetupParameters.test.tsx | 8 ++-- .../__tests__/SummaryAndSettings.test.tsx | 4 +- .../__tests__/WifiConnectionDetails.test.tsx | 4 +- .../RobotSystemVersionModal.test.tsx | 6 +-- .../SendProtocolToFlexSlideout.test.tsx | 6 +-- .../__tests__/UpdateAppModal.test.tsx | 4 +- app/src/pages/AppSettings/index.tsx | 2 +- .../DisplayConnectionStatus.test.tsx | 6 +-- .../__tests__/TitleHeader.test.tsx | 6 +-- .../_tests__/ConnectedViaUSB.test.tsx | 8 ++-- .../__tests__/DeckConfiguration.test.tsx | 2 +- app/src/pages/Devices/DeviceDetails/index.tsx | 2 +- .../Devices/ProtocolRunDetails/index.tsx | 2 +- app/src/pages/Devices/RobotSettings/index.tsx | 3 +- .../__tests__/EmergencyStop.test.tsx | 6 +-- .../__tests__/InstrumentDetail.test.tsx | 2 +- .../NameRobot/__tests__/NameRobot.test.tsx | 6 +-- .../__tests__/NetworkSetupMenu.test.tsx | 10 ++--- .../__tests__/PinnedProtocol.test.tsx | 6 +-- .../__tests__/ProtocolCard.test.tsx | 6 +-- .../__tests__/ProtocolSetup.test.tsx | 10 ++--- .../pages/Protocols/ProtocolDetails/index.tsx | 2 +- .../DeleteTransferConfirmationModal.test.tsx | 4 +- .../__tests__/PinnedTransfer.test.tsx | 6 +-- .../__tests__/QuickTransferCard.test.tsx | 6 +-- .../__tests__/RobotDashboard.test.tsx | 4 +- 60 files changed, 211 insertions(+), 218 deletions(-) diff --git a/app/src/App/__tests__/Navbar.test.tsx b/app/src/App/__tests__/Navbar.test.tsx index c5ec4661226d..db7eedc744b0 100644 --- a/app/src/App/__tests__/Navbar.test.tsx +++ b/app/src/App/__tests__/Navbar.test.tsx @@ -1,7 +1,7 @@ import * as React from 'react' import { describe, it } from 'vitest' import { screen, render } from '@testing-library/react' -import { StaticRouter } from 'react-router-dom' +import { MemoryRouter } from 'react-router-dom' import { Navbar } from '../Navbar' @@ -16,9 +16,9 @@ const ROUTE_PROPS: RouteProps[] = [ describe('Navbar', () => { it('should render a NavbarLink for every nav location', () => { render( - + - + ) screen.getByRole('link', { name: 'foo' }) screen.getByRole('link', { name: 'bar' }) @@ -26,9 +26,9 @@ describe('Navbar', () => { }) it('should render logo, settings, and help', () => { render( - + - + ) screen.getByRole('img', { name: 'opentrons logo' }) screen.getByTestId('Navbar_settingsLink') diff --git a/app/src/atoms/buttons/__tests__/BackButton.test.tsx b/app/src/atoms/buttons/__tests__/BackButton.test.tsx index e1c2ae3e68f5..f1146315e2da 100644 --- a/app/src/atoms/buttons/__tests__/BackButton.test.tsx +++ b/app/src/atoms/buttons/__tests__/BackButton.test.tsx @@ -2,7 +2,7 @@ import * as React from 'react' import { fireEvent, screen } from '@testing-library/react' import { describe, it, expect, vi } from 'vitest' import '@testing-library/jest-dom/vitest' -import { MemoryRouter, Route, Switch } from 'react-router-dom' +import { MemoryRouter, Route, Routes } from 'react-router-dom' import { renderWithProviders } from '../../../__testing-utils__' @@ -16,14 +16,10 @@ const render = (props?: React.HTMLProps) => { initialIndex={1} > - - - this is the current page - - - this is the previous page - - + + this is the current page + this is the previous page + , { i18nInstance: i18n } )[0] diff --git a/app/src/molecules/CardButton/__tests__/CardButton.test.tsx b/app/src/molecules/CardButton/__tests__/CardButton.test.tsx index 80d17c32d080..ff0adec6d2b3 100644 --- a/app/src/molecules/CardButton/__tests__/CardButton.test.tsx +++ b/app/src/molecules/CardButton/__tests__/CardButton.test.tsx @@ -9,13 +9,13 @@ import { i18n } from '../../../i18n' import { CardButton } from '..' import type * as ReactRouterDom from 'react-router-dom' -const mockPush = vi.fn() +const mockNavigate = vi.fn() vi.mock('react-router-dom', async importOriginal => { const reactRouterDom = await importOriginal() return { ...reactRouterDom, - useHistory: () => ({ push: mockPush } as any), + useNavigate: () => mockNavigate, } }) @@ -65,6 +65,6 @@ describe('CardButton', () => { render(props) const button = screen.getByRole('button') fireEvent.click(button) - expect(mockPush).toHaveBeenCalledWith('/mockPath') + expect(mockNavigate).toHaveBeenCalledWith('/mockPath') }) }) diff --git a/app/src/organisms/Breadcrumbs/__tests__/Breadcrumbs.test.tsx b/app/src/organisms/Breadcrumbs/__tests__/Breadcrumbs.test.tsx index 688a3d8a9f1c..88b6575b2cd1 100644 --- a/app/src/organisms/Breadcrumbs/__tests__/Breadcrumbs.test.tsx +++ b/app/src/organisms/Breadcrumbs/__tests__/Breadcrumbs.test.tsx @@ -1,5 +1,5 @@ import * as React from 'react' -import { MemoryRouter, Route, Switch } from 'react-router-dom' +import { MemoryRouter, Route, Routes } from 'react-router-dom' import { when } from 'vitest-when' import { describe, it, expect, beforeEach, vi } from 'vitest' @@ -34,20 +34,20 @@ const PROTOCOL_NAME = 'a protocol for otie' const render = (path = '/') => { return renderWithProviders( - - + +
device details path matched
- +
protocol run details path matched
- +
protocol details path matched
-
+
, { i18nInstance: i18n, diff --git a/app/src/organisms/CalibrationTaskList/__tests__/CalibrationTaskList.test.tsx b/app/src/organisms/CalibrationTaskList/__tests__/CalibrationTaskList.test.tsx index 8ad8fe61ce66..2c3e27b43df6 100644 --- a/app/src/organisms/CalibrationTaskList/__tests__/CalibrationTaskList.test.tsx +++ b/app/src/organisms/CalibrationTaskList/__tests__/CalibrationTaskList.test.tsx @@ -1,5 +1,5 @@ import * as React from 'react' -import { StaticRouter } from 'react-router-dom' +import { MemoryRouter } from 'react-router-dom' import { vi, it, describe, expect, beforeEach, afterEach } from 'vitest' import { fireEvent, screen } from '@testing-library/react' @@ -30,7 +30,7 @@ vi.mock('../../ProtocolUpload/hooks') const render = (robotName: string = 'otie') => { return renderWithProviders( - + { deckCalLauncher={mockDeckCalLauncher} exitBeforeDeckConfigCompletion={false} /> - , + , { i18nInstance: i18n, } @@ -82,7 +82,7 @@ describe('CalibrationTaskList', () => { // Complete screen will only render if a wizard has been launched fireEvent.click(screen.getByText('Calibrate')) rerender( - + { deckCalLauncher={mockDeckCalLauncher} exitBeforeDeckConfigCompletion={false} /> - + ) expect(screen.getByText('Calibrations complete!')).toBeTruthy() }) @@ -108,7 +108,7 @@ describe('CalibrationTaskList', () => { screen.getByText('Right Mount') fireEvent.click(screen.getByText('Calibrate')) rerender( - + { deckCalLauncher={mockDeckCalLauncher} exitBeforeDeckConfigCompletion={false} /> - + ) expect(screen.getByText('Calibrations complete!')).toBeTruthy() }) @@ -133,7 +133,7 @@ describe('CalibrationTaskList', () => { screen.getByText('Right Mount') fireEvent.click(screen.getByText('Calibrate')) rerender( - + { deckCalLauncher={mockDeckCalLauncher} exitBeforeDeckConfigCompletion={false} /> - + ) expect(screen.getByText('Calibrations complete!')).toBeTruthy() }) @@ -158,7 +158,7 @@ describe('CalibrationTaskList', () => { screen.getByText('Right Mount') fireEvent.click(screen.getByText('Calibrate')) rerender( - + { deckCalLauncher={mockDeckCalLauncher} exitBeforeDeckConfigCompletion={false} /> - + ) expect(screen.getByText('Calibrations complete!')).toBeTruthy() }) @@ -182,7 +182,7 @@ describe('CalibrationTaskList', () => { expect(recalibrateLinks).toHaveLength(3) fireEvent.click(recalibrateLinks[2]) rerender( - + { deckCalLauncher={mockDeckCalLauncher} exitBeforeDeckConfigCompletion={false} /> - + ) expect(screen.getByText('Calibrations complete!')).toBeTruthy() }) @@ -206,7 +206,7 @@ describe('CalibrationTaskList', () => { expect(recalibrateLinks).toHaveLength(3) fireEvent.click(recalibrateLinks[0]) rerender( - + { deckCalLauncher={mockDeckCalLauncher} exitBeforeDeckConfigCompletion={false} /> - + ) expect(screen.getByText('Calibrations complete!')).toBeTruthy() }) @@ -228,7 +228,7 @@ describe('CalibrationTaskList', () => { const recalibrateLink = screen.getByText('Recalibrate') fireEvent.click(recalibrateLink) rerender( - + { deckCalLauncher={mockDeckCalLauncher} exitBeforeDeckConfigCompletion={true} /> - + ) expect(screen.getByText('Using current calibrations.')).toBeTruthy() }) @@ -253,7 +253,7 @@ describe('CalibrationTaskList', () => { fireEvent.click(calibrateButtons[0]) expect(mockDeckCalLauncher).not.toHaveBeenCalled() rerender( - + { deckCalLauncher={mockDeckCalLauncher} exitBeforeDeckConfigCompletion={false} /> - + ) const recalibrateLinks = screen.getAllByText('Recalibrate') expect(recalibrateLinks).toHaveLength(1) // only deck's recalibration link should be shown @@ -281,7 +281,7 @@ describe('CalibrationTaskList', () => { fireEvent.click(calibrateButtons[0]) expect(mockTipLengthCalLauncher).not.toHaveBeenCalled() rerender( - + { deckCalLauncher={mockDeckCalLauncher} exitBeforeDeckConfigCompletion={false} /> - + ) fireEvent.click(screen.getByText('Left Mount')) const recalibrateLinks = screen.getAllByText('Recalibrate') diff --git a/app/src/organisms/ChangePipette/__tests__/ChangePipette.test.tsx b/app/src/organisms/ChangePipette/__tests__/ChangePipette.test.tsx index 47277d64b76b..0b22ed519217 100644 --- a/app/src/organisms/ChangePipette/__tests__/ChangePipette.test.tsx +++ b/app/src/organisms/ChangePipette/__tests__/ChangePipette.test.tsx @@ -21,18 +21,18 @@ import { ExitModal } from '../ExitModal' import { ConfirmPipette } from '../ConfirmPipette' import { ChangePipette } from '..' -import type { useHistory } from 'react-router-dom' +import type { useNavigate } from 'react-router-dom' import type { PipetteNameSpecs } from '@opentrons/shared-data' import type { AttachedPipette } from '../../../redux/pipettes/types' import type { DispatchApiRequestType } from '../../../redux/robot-api' -const mockPush = vi.fn() +const mockNavigate = vi.fn() vi.mock('react-router-dom', async importOriginal => { - const actual = await importOriginal() + const actual = await importOriginal() return { ...actual, - useHistory: () => ({ push: mockPush }), + useNavigate: () => mockNavigate, } }) diff --git a/app/src/organisms/ChooseProtocolSlideout/__tests__/ChooseProtocolSlideout.test.tsx b/app/src/organisms/ChooseProtocolSlideout/__tests__/ChooseProtocolSlideout.test.tsx index 0b812ae060cb..af2ce2166633 100644 --- a/app/src/organisms/ChooseProtocolSlideout/__tests__/ChooseProtocolSlideout.test.tsx +++ b/app/src/organisms/ChooseProtocolSlideout/__tests__/ChooseProtocolSlideout.test.tsx @@ -1,6 +1,6 @@ import * as React from 'react' import { vi, it, describe, expect, beforeEach } from 'vitest' -import { StaticRouter } from 'react-router-dom' +import { MemoryRouter } from 'react-router-dom' import { fireEvent, screen, waitFor } from '@testing-library/react' import { simpleAnalysisFileFixture } from '@opentrons/api-client' @@ -27,9 +27,9 @@ vi.mock('../../../resources/useNotifyDataReady') const render = (props: React.ComponentProps) => { return renderWithProviders( - + - , + , { i18nInstance: i18n, } diff --git a/app/src/organisms/ChooseRobotSlideout/__tests__/ChooseRobotSlideout.test.tsx b/app/src/organisms/ChooseRobotSlideout/__tests__/ChooseRobotSlideout.test.tsx index 4d5a66671904..41dff450fb05 100644 --- a/app/src/organisms/ChooseRobotSlideout/__tests__/ChooseRobotSlideout.test.tsx +++ b/app/src/organisms/ChooseRobotSlideout/__tests__/ChooseRobotSlideout.test.tsx @@ -1,7 +1,7 @@ import * as React from 'react' import { vi, it, describe, expect, beforeEach } from 'vitest' -import { StaticRouter } from 'react-router-dom' +import { MemoryRouter } from 'react-router-dom' import { fireEvent, screen } from '@testing-library/react' import { OT2_ROBOT_TYPE } from '@opentrons/shared-data' @@ -30,9 +30,9 @@ vi.mock('../../../redux/networking') vi.mock('../../../resources/useNotifyDataReady') const render = (props: React.ComponentProps) => { return renderWithProviders( - + - , + , { i18nInstance: i18n, } diff --git a/app/src/organisms/ChooseRobotSlideout/__tests__/FileCard.test.tsx b/app/src/organisms/ChooseRobotSlideout/__tests__/FileCard.test.tsx index b96493860906..0370fc68e093 100644 --- a/app/src/organisms/ChooseRobotSlideout/__tests__/FileCard.test.tsx +++ b/app/src/organisms/ChooseRobotSlideout/__tests__/FileCard.test.tsx @@ -1,7 +1,7 @@ import * as React from 'react' import { vi, it, describe, expect } from 'vitest' -import { StaticRouter } from 'react-router-dom' +import { MemoryRouter } from 'react-router-dom' import { fireEvent, screen } from '@testing-library/react' import { renderWithProviders } from '../../../__testing-utils__' @@ -16,9 +16,9 @@ vi.mock('../../../resources/useNotifyDataReady') vi.mock('../../../redux/config') const render = (props: React.ComponentProps) => { return renderWithProviders( - + - , + , { i18nInstance: i18n, } diff --git a/app/src/organisms/ChooseRobotToRunProtocolSlideout/__tests__/ChooseRobotToRunProtocolSlideout.test.tsx b/app/src/organisms/ChooseRobotToRunProtocolSlideout/__tests__/ChooseRobotToRunProtocolSlideout.test.tsx index 6085ff5636d8..6216e7d1ae9b 100644 --- a/app/src/organisms/ChooseRobotToRunProtocolSlideout/__tests__/ChooseRobotToRunProtocolSlideout.test.tsx +++ b/app/src/organisms/ChooseRobotToRunProtocolSlideout/__tests__/ChooseRobotToRunProtocolSlideout.test.tsx @@ -1,6 +1,6 @@ import * as React from 'react' import { vi, it, describe, expect, beforeEach, afterEach } from 'vitest' -import { StaticRouter } from 'react-router-dom' +import { MemoryRouter } from 'react-router-dom' import { fireEvent, screen, waitFor } from '@testing-library/react' import { when } from 'vitest-when' @@ -51,9 +51,9 @@ const render = ( props: React.ComponentProps ) => { return renderWithProviders( - + - , + , { i18nInstance: i18n, } diff --git a/app/src/organisms/DeviceDetailsDeckConfiguration/__tests__/DeckConfigurationDiscardChangesModal.test.tsx b/app/src/organisms/DeviceDetailsDeckConfiguration/__tests__/DeckConfigurationDiscardChangesModal.test.tsx index 0461f81496b7..522ad0d1bec6 100644 --- a/app/src/organisms/DeviceDetailsDeckConfiguration/__tests__/DeckConfigurationDiscardChangesModal.test.tsx +++ b/app/src/organisms/DeviceDetailsDeckConfiguration/__tests__/DeckConfigurationDiscardChangesModal.test.tsx @@ -5,16 +5,16 @@ import { describe, it, beforeEach, vi, expect } from 'vitest' import { renderWithProviders } from '../../../__testing-utils__' import { i18n } from '../../../i18n' import { DeckConfigurationDiscardChangesModal } from '../DeckConfigurationDiscardChangesModal' -import type { useHistory } from 'react-router-dom' +import type { useNavigate } from 'react-router-dom' const mockFunc = vi.fn() -const mockGoBack = vi.fn() +const mockNavigate = vi.fn() vi.mock('react-router-dom', async importOriginal => { - const actual = await importOriginal() + const actual = await importOriginal() return { ...actual, - useHistory: () => ({ goBack: mockGoBack }), + useNavigate: () => ({ mockNavigate}), } }) @@ -51,7 +51,7 @@ describe('DeckConfigurationDiscardChangesModal', () => { render(props) fireEvent.click(screen.getByText('Discard changes')) expect(mockFunc).toHaveBeenCalledWith(false) - expect(mockGoBack).toHaveBeenCalled() + expect(mockNavigate).toHaveBeenCalled() }) it('should call a mock function when tapping continue editing button', () => { diff --git a/app/src/organisms/Devices/ProtocolRun/SetupLabware/__tests__/LabwareListItem.test.tsx b/app/src/organisms/Devices/ProtocolRun/SetupLabware/__tests__/LabwareListItem.test.tsx index 267e27cc20ef..2d4bea7e5a69 100644 --- a/app/src/organisms/Devices/ProtocolRun/SetupLabware/__tests__/LabwareListItem.test.tsx +++ b/app/src/organisms/Devices/ProtocolRun/SetupLabware/__tests__/LabwareListItem.test.tsx @@ -1,7 +1,7 @@ import * as React from 'react' import { fireEvent, screen } from '@testing-library/react' import { describe, it, beforeEach, vi, expect } from 'vitest' -import { StaticRouter } from 'react-router-dom' +import { MemoryRouter } from 'react-router-dom' import { opentrons96PcrAdapterV1 } from '@opentrons/shared-data' import { useCreateLiveCommandMutation } from '@opentrons/react-api-client' @@ -68,9 +68,9 @@ const mockNickName = 'nickName' const render = (props: React.ComponentProps) => { return renderWithProviders( - + - , + , { i18nInstance: i18n, } diff --git a/app/src/organisms/Devices/ProtocolRun/SetupLabware/__tests__/OffDeckLabwareList.test.tsx b/app/src/organisms/Devices/ProtocolRun/SetupLabware/__tests__/OffDeckLabwareList.test.tsx index 0fbe91a3265e..594872467329 100644 --- a/app/src/organisms/Devices/ProtocolRun/SetupLabware/__tests__/OffDeckLabwareList.test.tsx +++ b/app/src/organisms/Devices/ProtocolRun/SetupLabware/__tests__/OffDeckLabwareList.test.tsx @@ -1,5 +1,5 @@ import * as React from 'react' -import { StaticRouter } from 'react-router-dom' +import { MemoryRouter } from 'react-router-dom' import { screen } from '@testing-library/react' import { describe, it, beforeEach, vi, expect } from 'vitest' @@ -13,9 +13,9 @@ vi.mock('../LabwareListItem') const render = (props: React.ComponentProps) => { return renderWithProviders( - + - , + , { i18nInstance: i18n, } diff --git a/app/src/organisms/Devices/ProtocolRun/SetupLabware/__tests__/SetupLabware.test.tsx b/app/src/organisms/Devices/ProtocolRun/SetupLabware/__tests__/SetupLabware.test.tsx index 0e19191306d3..d6a6ab4b05e1 100644 --- a/app/src/organisms/Devices/ProtocolRun/SetupLabware/__tests__/SetupLabware.test.tsx +++ b/app/src/organisms/Devices/ProtocolRun/SetupLabware/__tests__/SetupLabware.test.tsx @@ -1,5 +1,5 @@ import * as React from 'react' -import { StaticRouter } from 'react-router-dom' +import { MemoryRouter } from 'react-router-dom' import { fireEvent, screen } from '@testing-library/react' import { describe, it, beforeEach, vi, afterEach, expect } from 'vitest' import { when } from 'vitest-when' @@ -36,7 +36,7 @@ const RUN_ID = '1' const render = () => { return renderWithProviders( - + { expandStep={vi.fn()} nextStep={'liquid_setup_step'} /> - , + , { i18nInstance: i18n, } diff --git a/app/src/organisms/Devices/ProtocolRun/SetupLabware/__tests__/SetupLabwareList.test.tsx b/app/src/organisms/Devices/ProtocolRun/SetupLabware/__tests__/SetupLabwareList.test.tsx index 34b8412f5369..f55a8fc1bfed 100644 --- a/app/src/organisms/Devices/ProtocolRun/SetupLabware/__tests__/SetupLabwareList.test.tsx +++ b/app/src/organisms/Devices/ProtocolRun/SetupLabware/__tests__/SetupLabwareList.test.tsx @@ -1,5 +1,5 @@ import * as React from 'react' -import { StaticRouter } from 'react-router-dom' +import { MemoryRouter } from 'react-router-dom' import { describe, it, beforeEach, vi, expect } from 'vitest' import { screen } from '@testing-library/react' @@ -21,9 +21,9 @@ const protocolWithTC = (multiple_tipacks_with_tc as unknown) as CompletedProtoco const render = (props: React.ComponentProps) => { return renderWithProviders( - + - , + , { i18nInstance: i18n, } diff --git a/app/src/organisms/Devices/ProtocolRun/SetupLabware/__tests__/SetupLabwareMap.test.tsx b/app/src/organisms/Devices/ProtocolRun/SetupLabware/__tests__/SetupLabwareMap.test.tsx index a9fe5d6d1fc1..2f305f90dabc 100644 --- a/app/src/organisms/Devices/ProtocolRun/SetupLabware/__tests__/SetupLabwareMap.test.tsx +++ b/app/src/organisms/Devices/ProtocolRun/SetupLabware/__tests__/SetupLabwareMap.test.tsx @@ -1,6 +1,6 @@ import * as React from 'react' import { when } from 'vitest-when' -import { StaticRouter } from 'react-router-dom' +import { MemoryRouter } from 'react-router-dom' import { describe, it, beforeEach, vi, afterEach, expect } from 'vitest' import { screen } from '@testing-library/react' @@ -86,9 +86,9 @@ const mockTCModule = { const render = (props: React.ComponentProps) => { return renderWithProviders( - + - , + , { i18nInstance: i18n, } diff --git a/app/src/organisms/Devices/ProtocolRun/SetupLabwarePositionCheck/__tests__/SetupLabwarePositionCheck.test.tsx b/app/src/organisms/Devices/ProtocolRun/SetupLabwarePositionCheck/__tests__/SetupLabwarePositionCheck.test.tsx index 98bfe60da4a1..0bf4aaebbfca 100644 --- a/app/src/organisms/Devices/ProtocolRun/SetupLabwarePositionCheck/__tests__/SetupLabwarePositionCheck.test.tsx +++ b/app/src/organisms/Devices/ProtocolRun/SetupLabwarePositionCheck/__tests__/SetupLabwarePositionCheck.test.tsx @@ -1,6 +1,6 @@ import * as React from 'react' import { when } from 'vitest-when' -import { StaticRouter } from 'react-router-dom' +import { MemoryRouter } from 'react-router-dom' import { screen, fireEvent } from '@testing-library/react' import { describe, it, beforeEach, vi, expect, afterEach } from 'vitest' @@ -43,13 +43,13 @@ const RUN_ID = '1' const render = () => { return renderWithProviders( - + - , + , { i18nInstance: i18n, } diff --git a/app/src/organisms/Devices/ProtocolRun/SetupModuleAndDeck/__tests__/SetupModulesMap.test.tsx b/app/src/organisms/Devices/ProtocolRun/SetupModuleAndDeck/__tests__/SetupModulesMap.test.tsx index 17522ebdfb5e..e08ff19f415c 100644 --- a/app/src/organisms/Devices/ProtocolRun/SetupModuleAndDeck/__tests__/SetupModulesMap.test.tsx +++ b/app/src/organisms/Devices/ProtocolRun/SetupModuleAndDeck/__tests__/SetupModulesMap.test.tsx @@ -2,7 +2,7 @@ import * as React from 'react' import { when } from 'vitest-when' -import { StaticRouter } from 'react-router-dom' +import { MemoryRouter } from 'react-router-dom' import { describe, it, beforeEach, vi, afterEach, expect } from 'vitest' import { screen } from '@testing-library/react' @@ -50,9 +50,9 @@ vi.mock('../../../hooks') const render = (props: React.ComponentProps) => { return renderWithProviders( - + - , + , { i18nInstance: i18n, } diff --git a/app/src/organisms/Devices/ProtocolRun/__tests__/BackToTopButton.test.tsx b/app/src/organisms/Devices/ProtocolRun/__tests__/BackToTopButton.test.tsx index 4113d2c131c1..65c5f106f1aa 100644 --- a/app/src/organisms/Devices/ProtocolRun/__tests__/BackToTopButton.test.tsx +++ b/app/src/organisms/Devices/ProtocolRun/__tests__/BackToTopButton.test.tsx @@ -1,7 +1,7 @@ import * as React from 'react' import { fireEvent, screen } from '@testing-library/react' import { when } from 'vitest-when' -import { StaticRouter } from 'react-router-dom' +import { MemoryRouter } from 'react-router-dom' import { describe, it, beforeEach, vi, afterEach, expect } from 'vitest' import { renderWithProviders } from '../../../../__testing-utils__' @@ -25,14 +25,14 @@ const ROBOT_SERIAL_NUMBER = 'OT123' const render = () => { return renderWithProviders( - + - , + , { i18nInstance: i18n, } diff --git a/app/src/organisms/Devices/ProtocolRun/__tests__/ProtocolRunHeader.test.tsx b/app/src/organisms/Devices/ProtocolRun/__tests__/ProtocolRunHeader.test.tsx index 0ae4fd544bba..fa11a58147bc 100644 --- a/app/src/organisms/Devices/ProtocolRun/__tests__/ProtocolRunHeader.test.tsx +++ b/app/src/organisms/Devices/ProtocolRun/__tests__/ProtocolRunHeader.test.tsx @@ -104,13 +104,13 @@ import type * as OpentronsSharedData from '@opentrons/shared-data' import type * as OpentronsComponents from '@opentrons/components' import type * as OpentronsApiClient from '@opentrons/api-client' -const mockPush = vi.fn() +const mockNavigate = vi.fn() vi.mock('react-router-dom', async importOriginal => { const reactRouterDom = await importOriginal() return { ...reactRouterDom, - useHistory: () => ({ push: mockPush } as any), + useNavigate: () => mockNavigate, } }) @@ -945,7 +945,7 @@ describe('ProtocolRunHeader', () => { vi.mocked(useIsRobotViewable).mockReturnValue(false) render() await waitFor(() => { - expect(mockPush).toHaveBeenCalledWith('/devices') + expect(mockNavigate).toHaveBeenCalledWith('/devices') }) }) diff --git a/app/src/organisms/InstrumentInfo/__tests__/InstrumentInfo.test.tsx b/app/src/organisms/InstrumentInfo/__tests__/InstrumentInfo.test.tsx index 35bd692a589e..adccba35529f 100644 --- a/app/src/organisms/InstrumentInfo/__tests__/InstrumentInfo.test.tsx +++ b/app/src/organisms/InstrumentInfo/__tests__/InstrumentInfo.test.tsx @@ -11,7 +11,7 @@ import { InstrumentInfo } from '..' import type { GripperData } from '@opentrons/api-client' import type * as Dom from 'react-router-dom' -const mockPush = vi.fn() +const mockNavigate = vi.fn() vi.mock('../../PipetteWizardFlows') vi.mock('../../GripperWizardFlows') @@ -19,7 +19,7 @@ vi.mock('react-router-dom', async importOriginal => { const reactRouterDom = await importOriginal() return { ...reactRouterDom, - useHistory: () => ({ push: mockPush } as any), + useNavigate: () => mockNavigate, } }) diff --git a/app/src/organisms/Navigation/__tests__/NavigationMenu.test.tsx b/app/src/organisms/Navigation/__tests__/NavigationMenu.test.tsx index 1c85aa478613..d0a5444456a9 100644 --- a/app/src/organisms/Navigation/__tests__/NavigationMenu.test.tsx +++ b/app/src/organisms/Navigation/__tests__/NavigationMenu.test.tsx @@ -9,19 +9,19 @@ import { useLights } from '../../Devices/hooks' import { RestartRobotConfirmationModal } from '../RestartRobotConfirmationModal' import { NavigationMenu } from '../NavigationMenu' -import type { useHistory } from 'react-router-dom' +import type { useNavigate } from 'react-router-dom' vi.mock('../../../redux/robot-admin') vi.mock('../../../redux/robot-controls') vi.mock('../../Devices/hooks') vi.mock('../RestartRobotConfirmationModal') -const mockPush = vi.fn() +const mockNavigate = vi.fn() vi.mock('react-router-dom', async importOriginal => { - const actual = await importOriginal() + const actual = await importOriginal() return { ...actual, - useHistory: () => ({ push: mockPush } as any), + useHNavigate: () => mockNavigate, } }) @@ -97,6 +97,6 @@ describe('NavigationMenu', () => { it('should call a mock function when tapping deck configuration', () => { render(props) fireEvent.click(screen.getByText('Deck configuration')) - expect(mockPush).toHaveBeenCalledWith('/deck-configuration') + expect(mockNavigate).toHaveBeenCalledWith('/deck-configuration') }) }) diff --git a/app/src/organisms/NetworkSettings/__tests__/AlternativeSecurityTypeModal.test.tsx b/app/src/organisms/NetworkSettings/__tests__/AlternativeSecurityTypeModal.test.tsx index d838c3979422..5ab7976bc88e 100644 --- a/app/src/organisms/NetworkSettings/__tests__/AlternativeSecurityTypeModal.test.tsx +++ b/app/src/organisms/NetworkSettings/__tests__/AlternativeSecurityTypeModal.test.tsx @@ -6,15 +6,15 @@ import { renderWithProviders } from '../../../__testing-utils__' import { i18n } from '../../../i18n' import { AlternativeSecurityTypeModal } from '../AlternativeSecurityTypeModal' -import type { useHistory } from 'react-router-dom' +import type { useNavigate } from 'react-router-dom' const mockFunc = vi.fn() -const mockPush = vi.fn() +const mockNavigate = vi.fn() vi.mock('react-router-dom', async importOriginal => { - const actual = await importOriginal() + const actual = await importOriginal() return { ...actual, - useHistory: () => ({ push: mockPush } as any), + useNavigate: () => mockNavigate, } }) @@ -55,6 +55,6 @@ describe('AlternativeSecurityTypeModal', () => { const button = screen.getByText('Connect via USB') fireEvent.click(button) expect(mockFunc).toHaveBeenCalled() - expect(mockPush).toHaveBeenCalledWith('/network-setup/usb') + expect(mockNavigate).toHaveBeenCalledWith('/network-setup/usb') }) }) diff --git a/app/src/organisms/NetworkSettings/__tests__/DisplayWifiList.test.tsx b/app/src/organisms/NetworkSettings/__tests__/DisplayWifiList.test.tsx index 04920134deec..d7ff93ca02d5 100644 --- a/app/src/organisms/NetworkSettings/__tests__/DisplayWifiList.test.tsx +++ b/app/src/organisms/NetworkSettings/__tests__/DisplayWifiList.test.tsx @@ -8,9 +8,9 @@ import * as Fixtures from '../../../redux/networking/__fixtures__' import { DisplaySearchNetwork } from '../DisplaySearchNetwork' import { DisplayWifiList } from '../DisplayWifiList' -import type { useHistory } from 'react-router-dom' +import type { useNavigate } from 'react-router-dom' -const mockPush = vi.fn() +const mockNavigate = vi.fn() const mockWifiList = [ { ...Fixtures.mockWifiNetwork, ssid: 'foo', active: true }, { ...Fixtures.mockWifiNetwork, ssid: 'bar' }, @@ -24,10 +24,10 @@ vi.mock('../../../redux/networking/selectors') vi.mock('../../../redux/discovery/selectors') vi.mock('../DisplaySearchNetwork') vi.mock('react-router-dom', async importOriginal => { - const actual = await importOriginal() + const actual = await importOriginal() return { ...actual, - useHistory: () => ({ push: mockPush } as any), + useNavigate: () => mockNavigate, } }) @@ -76,7 +76,7 @@ describe('DisplayWifiList', () => { render(props) const button = screen.getByLabelText('back-button') fireEvent.click(button) - expect(mockPush).toHaveBeenCalledWith('/network-setup') + expect(mockNavigate).toHaveBeenCalledWith('/network-setup') }) it('should call mock function when tapping tapping a ssid', () => { diff --git a/app/src/organisms/NetworkSettings/__tests__/SelectAuthenticationType.test.tsx b/app/src/organisms/NetworkSettings/__tests__/SelectAuthenticationType.test.tsx index 2028e1009917..5531c4ca294d 100644 --- a/app/src/organisms/NetworkSettings/__tests__/SelectAuthenticationType.test.tsx +++ b/app/src/organisms/NetworkSettings/__tests__/SelectAuthenticationType.test.tsx @@ -11,9 +11,9 @@ import { AlternativeSecurityTypeModal } from '../AlternativeSecurityTypeModal' import { SelectAuthenticationType } from '../SelectAuthenticationType' import { SetWifiCred } from '../SetWifiCred' -import type { useHistory } from 'react-router-dom' +import type { useNavigate } from 'react-router-dom' -const mockPush = vi.fn() +const mockNavigate = vi.fn() const mockSetSelectedAuthType = vi.fn() vi.mock('../SetWifiCred') @@ -22,10 +22,10 @@ vi.mock('../../../redux/discovery/selectors') vi.mock('../AlternativeSecurityTypeModal') vi.mock('../../RobotSettingsDashboard/NetworkSettings/hooks') vi.mock('react-router-dom', async importOriginal => { - const actual = await importOriginal() + const actual = await importOriginal() return { ...actual, - useHistory: () => ({ push: mockPush } as any), + useNavigate: () => mockNavigate, } }) diff --git a/app/src/organisms/NetworkSettings/__tests__/WifiConnectionDetails.test.tsx b/app/src/organisms/NetworkSettings/__tests__/WifiConnectionDetails.test.tsx index 479f8c65ab02..a7acd1e28706 100644 --- a/app/src/organisms/NetworkSettings/__tests__/WifiConnectionDetails.test.tsx +++ b/app/src/organisms/NetworkSettings/__tests__/WifiConnectionDetails.test.tsx @@ -11,19 +11,19 @@ import * as Fixtures from '../../../redux/networking/__fixtures__' import { NetworkDetailsModal } from '../../RobotSettingsDashboard/NetworkSettings/NetworkDetailsModal' import { WifiConnectionDetails } from '../WifiConnectionDetails' -import type { useHistory } from 'react-router-dom' +import type { useNavigate } from 'react-router-dom' vi.mock('../../../resources/networking/hooks') vi.mock('../../../redux/networking') vi.mock('../../../redux/discovery/selectors') vi.mock('../../RobotSettingsDashboard/NetworkSettings/NetworkDetailsModal') -const mockPush = vi.fn() +const mockNavigate = vi.fn() vi.mock('react-router-dom', async importOriginal => { - const actual = await importOriginal() + const actual = await importOriginal() return { ...actual, - useHistory: () => ({ push: mockPush } as any), + useNavigate: () => mockNavigate, } }) @@ -88,7 +88,7 @@ describe('WifiConnectionDetails', () => { it('when clicking Check for updates button, should call mock function', () => { render(props) fireEvent.click(screen.getByText('Continue')) - expect(mockPush).toHaveBeenCalledWith( + expect(mockNavigate).toHaveBeenCalledWith( '/robot-settings/update-robot-during-onboarding' ) }) diff --git a/app/src/organisms/OnDeviceDisplay/NameRobot/__tests__/ConfirmRobotName.test.tsx b/app/src/organisms/OnDeviceDisplay/NameRobot/__tests__/ConfirmRobotName.test.tsx index 5b6966ff0a66..8be97f779198 100644 --- a/app/src/organisms/OnDeviceDisplay/NameRobot/__tests__/ConfirmRobotName.test.tsx +++ b/app/src/organisms/OnDeviceDisplay/NameRobot/__tests__/ConfirmRobotName.test.tsx @@ -7,15 +7,15 @@ import { renderWithProviders } from '../../../../__testing-utils__' import { i18n } from '../../../../i18n' import { ConfirmRobotName } from '../ConfirmRobotName' -import type { useHistory } from 'react-router-dom' +import type { useNavigate } from 'react-router-dom' -const mockPush = vi.fn() +const mockNavigate = vi.fn() vi.mock('react-router-dom', async importOriginal => { - const actual = await importOriginal() + const actual = await importOriginal() return { ...actual, - useHistory: () => ({ push: mockPush } as any), + useNavigate: () => mockNavigate, } }) @@ -49,6 +49,6 @@ describe('ConfirmRobotName', () => { render(props) const button = screen.getByText('Finish setup') fireEvent.click(button) - expect(mockPush).toBeCalledWith('/dashboard') + expect(mockNavigate).toBeCalledWith('/dashboard') }) }) diff --git a/app/src/organisms/OnDeviceDisplay/RobotDashboard/__tests__/RecentRunProtocolCard.test.tsx b/app/src/organisms/OnDeviceDisplay/RobotDashboard/__tests__/RecentRunProtocolCard.test.tsx index 25e040583a7f..2a42077d54be 100644 --- a/app/src/organisms/OnDeviceDisplay/RobotDashboard/__tests__/RecentRunProtocolCard.test.tsx +++ b/app/src/organisms/OnDeviceDisplay/RobotDashboard/__tests__/RecentRunProtocolCard.test.tsx @@ -33,16 +33,16 @@ import { INIT_STATUS, } from '../../../../resources/health/hooks' -import type { useHistory } from 'react-router-dom' +import type { useNavigate } from 'react-router-dom' import type { ProtocolHardware } from '../../../../pages/Protocols/hooks' -const mockPush = vi.fn() +const mockNavigate = vi.fn() vi.mock('react-router-dom', async importOriginal => { - const actual = await importOriginal() + const actual = await importOriginal() return { ...actual, - useHistory: () => ({ push: mockPush } as any), + useNavigate: () => mockNavigate, } }) @@ -292,6 +292,6 @@ describe('RecentRunProtocolCard', () => { render(props) const button = screen.getByLabelText('RecentRunProtocolCard') fireEvent.click(button) - expect(mockPush).toBeCalledWith('/protocols/mockProtocolId') + expect(mockNavigate).toBeCalledWith('/protocols/mockProtocolId') }) }) diff --git a/app/src/organisms/OnDeviceDisplay/RunningProtocol/__tests__/ConfirmCancelRunModal.test.tsx b/app/src/organisms/OnDeviceDisplay/RunningProtocol/__tests__/ConfirmCancelRunModal.test.tsx index 36e23a35df6d..1772ae433d23 100644 --- a/app/src/organisms/OnDeviceDisplay/RunningProtocol/__tests__/ConfirmCancelRunModal.test.tsx +++ b/app/src/organisms/OnDeviceDisplay/RunningProtocol/__tests__/ConfirmCancelRunModal.test.tsx @@ -20,7 +20,7 @@ import { mockConnectedRobot } from '../../../../redux/discovery/__fixtures__' import { ConfirmCancelRunModal } from '../ConfirmCancelRunModal' import { CancelingRunModal } from '../CancelingRunModal' -import type { useHistory } from 'react-router-dom' +import type { useNavigate } from 'react-router-dom' vi.mock('@opentrons/react-api-client') vi.mock('../../../../organisms/Devices/hooks') @@ -29,7 +29,7 @@ vi.mock('../../../../redux/analytics') vi.mock('../../../ProtocolUpload/hooks') vi.mock('../CancelingRunModal') vi.mock('../../../../redux/discovery') -const mockPush = vi.fn() +const mockNavigate = vi.fn() const mockStopRun = vi.fn() const mockDismissCurrentRun = vi.fn() const mockTrackEvent = vi.fn() @@ -38,10 +38,10 @@ const mockTrackProtocolRunEvent = vi.fn( ) vi.mock('react-router-dom', async importOriginal => { - const actual = await importOriginal() + const actual = await importOriginal() return { ...actual, - useHistory: () => ({ push: mockPush } as any), + useNavigate: () => mockNavigate, } }) @@ -150,6 +150,6 @@ describe('ConfirmCancelRunModal', () => { expect(mockDismissCurrentRun).toHaveBeenCalled() expect(mockTrackProtocolRunEvent).toHaveBeenCalled() - expect(mockPush).toHaveBeenCalledWith('/protocols') + expect(mockNavigate).toHaveBeenCalledWith('/protocols') }) }) diff --git a/app/src/organisms/OnDeviceDisplay/RunningProtocol/__tests__/RunFailedModal.test.tsx b/app/src/organisms/OnDeviceDisplay/RunningProtocol/__tests__/RunFailedModal.test.tsx index 9634879ee441..3f02a2bc2569 100644 --- a/app/src/organisms/OnDeviceDisplay/RunningProtocol/__tests__/RunFailedModal.test.tsx +++ b/app/src/organisms/OnDeviceDisplay/RunningProtocol/__tests__/RunFailedModal.test.tsx @@ -9,13 +9,13 @@ import { renderWithProviders } from '../../../../__testing-utils__' import { i18n } from '../../../../i18n' import { RunFailedModal } from '../RunFailedModal' -import type { useHistory } from 'react-router-dom' +import type { useNavigate } from 'react-router-dom' vi.mock('@opentrons/react-api-client') const RUN_ID = 'mock_runID' const mockFn = vi.fn() -const mockPush = vi.fn() +const mockNavigate = vi.fn() const mockErrors = [ { id: 'd0245210-dfb9-4f1c-8ad0-3416b603a7ba', @@ -74,10 +74,10 @@ const mockErrors = [ const mockStopRun = vi.fn((_runId, opts) => opts.onSuccess()) vi.mock('react-router-dom', async importOriginal => { - const actual = await importOriginal() + const actual = await importOriginal() return { ...actual, - useHistory: () => ({ push: mockPush } as any), + useNavigate: () => mockNavigate, } }) @@ -123,6 +123,6 @@ describe('RunFailedModal', () => { const button = screen.getByText('Close') fireEvent.click(button) expect(mockStopRun).toHaveBeenCalled() - expect(mockPush).toHaveBeenCalledWith('/dashboard') + expect(mockNavigate).toHaveBeenCalledWith('/dashboard') }) }) diff --git a/app/src/organisms/ProtocolAnalysisFailure/__tests__/ProtocolAnalysisFailure.test.tsx b/app/src/organisms/ProtocolAnalysisFailure/__tests__/ProtocolAnalysisFailure.test.tsx index a2b0d712d54f..86f0feb73734 100644 --- a/app/src/organisms/ProtocolAnalysisFailure/__tests__/ProtocolAnalysisFailure.test.tsx +++ b/app/src/organisms/ProtocolAnalysisFailure/__tests__/ProtocolAnalysisFailure.test.tsx @@ -1,5 +1,5 @@ import * as React from 'react' -import { StaticRouter } from 'react-router-dom' +import { MemoryRouter } from 'react-router-dom' import { fireEvent, screen } from '@testing-library/react' import { describe, it, expect } from 'vitest' @@ -13,7 +13,7 @@ const render = ( props: Partial> = {} ) => { return renderWithProviders( - + - , + , { i18nInstance: i18n, } diff --git a/app/src/organisms/ProtocolDetails/__tests__/ProtocolDetails.test.tsx b/app/src/organisms/ProtocolDetails/__tests__/ProtocolDetails.test.tsx index 130c3ceedbdf..140cf3f63737 100644 --- a/app/src/organisms/ProtocolDetails/__tests__/ProtocolDetails.test.tsx +++ b/app/src/organisms/ProtocolDetails/__tests__/ProtocolDetails.test.tsx @@ -1,6 +1,6 @@ import * as React from 'react' import { act, screen, waitFor } from '@testing-library/react' -import { StaticRouter } from 'react-router-dom' +import { MemoryRouter } from 'react-router-dom' import { describe, it, beforeEach, vi, expect, afterEach } from 'vitest' import { renderWithProviders } from '../../../__testing-utils__' @@ -40,9 +40,9 @@ const render = ( props: Partial> = {} ) => { return renderWithProviders( - + - , + , { i18nInstance: i18n, } diff --git a/app/src/organisms/ProtocolSetupLabware/__tests__/LabwareMapViewModal.test.tsx b/app/src/organisms/ProtocolSetupLabware/__tests__/LabwareMapViewModal.test.tsx index 8a76e5703fe0..04b4df83d09c 100644 --- a/app/src/organisms/ProtocolSetupLabware/__tests__/LabwareMapViewModal.test.tsx +++ b/app/src/organisms/ProtocolSetupLabware/__tests__/LabwareMapViewModal.test.tsx @@ -1,5 +1,5 @@ import * as React from 'react' -import { StaticRouter } from 'react-router-dom' +import { MemoryRouter } from 'react-router-dom' import { when } from 'vitest-when' import { fireEvent, screen } from '@testing-library/react' import { describe, it, vi, beforeEach, afterEach, expect } from 'vitest' @@ -53,9 +53,9 @@ vi.mock('@opentrons/components', async importOriginal => { const render = (props: React.ComponentProps) => { return renderWithProviders( - + - , + , { i18nInstance: i18n, } diff --git a/app/src/organisms/ProtocolSetupParameters/__tests__/AnalysisFailedModal.test.tsx b/app/src/organisms/ProtocolSetupParameters/__tests__/AnalysisFailedModal.test.tsx index 143f6d92feb7..bf72fb108397 100644 --- a/app/src/organisms/ProtocolSetupParameters/__tests__/AnalysisFailedModal.test.tsx +++ b/app/src/organisms/ProtocolSetupParameters/__tests__/AnalysisFailedModal.test.tsx @@ -7,7 +7,7 @@ import { i18n } from '../../../i18n' import { AnalysisFailedModal } from '../AnalysisFailedModal' import type * as ReactRouterDom from 'react-router-dom' -const mockPush = vi.fn() +const mockNavigate = vi.fn() const PROTOCOL_ID = 'mockId' const mockSetShowAnalysisFailedModal = vi.fn() @@ -15,7 +15,7 @@ vi.mock('react-router-dom', async importOriginal => { const reactRouterDom = await importOriginal() return { ...reactRouterDom, - useHistory: () => ({ push: mockPush } as any), + useNavigate: () => mockNavigate, } }) @@ -58,12 +58,12 @@ describe('AnalysisFailedModal', () => { it('should call a mock function when tapping restart setup button', () => { render(props) fireEvent.click(screen.getByText('Restart setup')) - expect(mockPush).toHaveBeenCalledWith(`/protocols/${PROTOCOL_ID}`) + expect(mockNavigate).toHaveBeenCalledWith(`/protocols/${PROTOCOL_ID}`) }) it('should push to protocols dashboard when tapping restart setup button and protocol ID is null', () => { render({ ...props, protocolId: null }) fireEvent.click(screen.getByText('Restart setup')) - expect(mockPush).toHaveBeenCalledWith('/protocols') + expect(mockNavigate).toHaveBeenCalledWith('/protocols') }) }) diff --git a/app/src/organisms/ProtocolSetupParameters/__tests__/ProtocolSetupParameters.test.tsx b/app/src/organisms/ProtocolSetupParameters/__tests__/ProtocolSetupParameters.test.tsx index 6cc96f3bf1e0..66395fab2928 100644 --- a/app/src/organisms/ProtocolSetupParameters/__tests__/ProtocolSetupParameters.test.tsx +++ b/app/src/organisms/ProtocolSetupParameters/__tests__/ProtocolSetupParameters.test.tsx @@ -24,7 +24,7 @@ import type * as ReactRouterDom from 'react-router-dom' import type { HostConfig } from '@opentrons/api-client' import type { CompletedProtocolAnalysis } from '@opentrons/shared-data' -const mockGoBack = vi.fn() +const mockNavigate = vi.fn() vi.mock('../ChooseEnum') vi.mock('../ChooseNumber') @@ -37,7 +37,7 @@ vi.mock('react-router-dom', async importOriginal => { const reactRouterDom = await importOriginal() return { ...reactRouterDom, - useHistory: () => ({ goBack: mockGoBack } as any), + useNavigate: () => mockNavigate, } }) vi.mock('../../../redux/config') @@ -148,10 +148,10 @@ describe('ProtocolSetupParameters', () => { // screen.getByText('CSV File') // }) - it('renders the back icon and calls useHistory', () => { + it('renders the back icon and calls useNavigate', () => { render(props) fireEvent.click(screen.getAllByRole('button')[0]) - expect(mockGoBack).toHaveBeenCalled() + expect(mockNavigate).toHaveBeenCalled() }) it('renders the confirm values button and clicking on it creates a run', () => { diff --git a/app/src/organisms/QuickTransferFlow/__tests__/SummaryAndSettings.test.tsx b/app/src/organisms/QuickTransferFlow/__tests__/SummaryAndSettings.test.tsx index 9635b05eb037..a1b07177efde 100644 --- a/app/src/organisms/QuickTransferFlow/__tests__/SummaryAndSettings.test.tsx +++ b/app/src/organisms/QuickTransferFlow/__tests__/SummaryAndSettings.test.tsx @@ -14,13 +14,13 @@ import { NameQuickTransfer } from '../NameQuickTransfer' import { Overview } from '../Overview' import type * as ReactRouterDom from 'react-router-dom' -const mockPush = vi.fn() +const mockNavigate = vi.fn() vi.mock('react-router-dom', async importOriginal => { const reactRouterDom = await importOriginal() return { ...reactRouterDom, - useHistory: () => ({ push: mockPush } as any), + useNavigate: () => mockNavigate, } }) vi.mock('../Overview') diff --git a/app/src/organisms/RobotSettingsDashboard/NetworkSettings/__tests__/WifiConnectionDetails.test.tsx b/app/src/organisms/RobotSettingsDashboard/NetworkSettings/__tests__/WifiConnectionDetails.test.tsx index a8ec836d044f..02da87250d38 100644 --- a/app/src/organisms/RobotSettingsDashboard/NetworkSettings/__tests__/WifiConnectionDetails.test.tsx +++ b/app/src/organisms/RobotSettingsDashboard/NetworkSettings/__tests__/WifiConnectionDetails.test.tsx @@ -17,12 +17,12 @@ vi.mock('../../../../redux/discovery') vi.mock('../../../../redux/networking') vi.mock('../NetworkDetailsModal') -const mockPush = vi.fn() +const mockNavigate = vi.fn() vi.mock('react-router-dom', async importOriginal => { const reactRouterDom = await importOriginal() return { ...reactRouterDom, - useHistory: () => ({ push: mockPush } as any), + useNavigate: () => mockNavigate, } }) diff --git a/app/src/organisms/RobotSettingsDashboard/__tests__/RobotSystemVersionModal.test.tsx b/app/src/organisms/RobotSettingsDashboard/__tests__/RobotSystemVersionModal.test.tsx index 6e6f4780e0d3..887b36c332b6 100644 --- a/app/src/organisms/RobotSettingsDashboard/__tests__/RobotSystemVersionModal.test.tsx +++ b/app/src/organisms/RobotSettingsDashboard/__tests__/RobotSystemVersionModal.test.tsx @@ -9,13 +9,13 @@ import { RobotSystemVersionModal } from '../RobotSystemVersionModal' import type * as Dom from 'react-router-dom' const mockFn = vi.fn() -const mockPush = vi.fn() +const mockNavigate = vi.fn() vi.mock('react-router-dom', async importOriginal => { const reactRouterDom = await importOriginal() return { ...reactRouterDom, - useHistory: () => ({ push: mockPush } as any), + useNavigate: () => mockNavigate, } }) @@ -52,7 +52,7 @@ describe('RobotSystemVersionModal', () => { it('should close the modal when tapping remind me later', () => { render(props) fireEvent.click(screen.getByText('Update')) - expect(mockPush).toHaveBeenCalledWith('/robot-settings/update-robot') + expect(mockNavigate).toHaveBeenCalledWith('/robot-settings/update-robot') }) it('should call the mock function when tapping update', () => { diff --git a/app/src/organisms/SendProtocolToFlexSlideout/__tests__/SendProtocolToFlexSlideout.test.tsx b/app/src/organisms/SendProtocolToFlexSlideout/__tests__/SendProtocolToFlexSlideout.test.tsx index 9f5279aa18f3..cd3ab48d411d 100644 --- a/app/src/organisms/SendProtocolToFlexSlideout/__tests__/SendProtocolToFlexSlideout.test.tsx +++ b/app/src/organisms/SendProtocolToFlexSlideout/__tests__/SendProtocolToFlexSlideout.test.tsx @@ -2,7 +2,7 @@ import * as React from 'react' import { fireEvent, screen } from '@testing-library/react' import { describe, it, expect, vi, beforeEach } from 'vitest' import '@testing-library/jest-dom/vitest' -import { StaticRouter } from 'react-router-dom' +import { MemoryRouter } from 'react-router-dom' import { mockOT3HealthResponse, @@ -57,9 +57,9 @@ const render = ( props: React.ComponentProps ) => { return renderWithProviders( - + - , + , { i18nInstance: i18n, } diff --git a/app/src/organisms/UpdateAppModal/__tests__/UpdateAppModal.test.tsx b/app/src/organisms/UpdateAppModal/__tests__/UpdateAppModal.test.tsx index 95681e4a6614..7f9576dfacd4 100644 --- a/app/src/organisms/UpdateAppModal/__tests__/UpdateAppModal.test.tsx +++ b/app/src/organisms/UpdateAppModal/__tests__/UpdateAppModal.test.tsx @@ -27,8 +27,8 @@ vi.mock('react-router-dom', async importOriginal => { const actual = await importOriginal() return { ...actual, - useHistory: () => ({ - push: vi.fn(), + useNavigate: () => ({ + mockNav: vi.fn(), }), } }) diff --git a/app/src/pages/AppSettings/index.tsx b/app/src/pages/AppSettings/index.tsx index 1b2b0d6bb383..61b5f619c961 100644 --- a/app/src/pages/AppSettings/index.tsx +++ b/app/src/pages/AppSettings/index.tsx @@ -1,7 +1,7 @@ import * as React from 'react' import { useTranslation } from 'react-i18next' import { useSelector } from 'react-redux' -import { Navigate, Route, useParams } from 'react-router-dom' +import { Navigate, useParams } from 'react-router-dom' import { ALIGN_START, diff --git a/app/src/pages/ConnectViaEthernet/__tests__/DisplayConnectionStatus.test.tsx b/app/src/pages/ConnectViaEthernet/__tests__/DisplayConnectionStatus.test.tsx index 76c195f3ff6b..b6b3bc6ca856 100644 --- a/app/src/pages/ConnectViaEthernet/__tests__/DisplayConnectionStatus.test.tsx +++ b/app/src/pages/ConnectViaEthernet/__tests__/DisplayConnectionStatus.test.tsx @@ -9,12 +9,12 @@ import { DisplayConnectionStatus } from '../../../pages/ConnectViaEthernet/Displ import type * as ReactRouterDom from 'react-router-dom' const mockFunc = vi.fn() -const mockPush = vi.fn() +const mockNavigate = vi.fn() vi.mock('react-router-dom', async importOriginal => { const actual = await importOriginal() return { ...actual, - useHistory: () => ({ push: mockPush } as any), + useNavigate: () => mockNavigate, } }) @@ -70,7 +70,7 @@ describe('DisplayConnectionStatus', () => { it('should call a mock push when tapping continue button', () => { render(props) fireEvent.click(screen.getByText('Continue')) - expect(mockPush).toHaveBeenCalledWith( + expect(mockNavigate).toHaveBeenCalledWith( '/robot-settings/update-robot-during-onboarding' ) }) diff --git a/app/src/pages/ConnectViaEthernet/__tests__/TitleHeader.test.tsx b/app/src/pages/ConnectViaEthernet/__tests__/TitleHeader.test.tsx index 67921d8203c7..febd566749a9 100644 --- a/app/src/pages/ConnectViaEthernet/__tests__/TitleHeader.test.tsx +++ b/app/src/pages/ConnectViaEthernet/__tests__/TitleHeader.test.tsx @@ -7,12 +7,12 @@ import { TitleHeader } from '../../../pages/ConnectViaEthernet/TitleHeader' import type * as ReactRouterDom from 'react-router-dom' -const mockPush = vi.fn() +const mockNavigate = vi.fn() vi.mock('react-router-dom', async importOriginal => { const actual = await importOriginal() return { ...actual, - useHistory: () => ({ push: mockPush } as any), + useNavigate: () => mockNavigate, } }) @@ -38,6 +38,6 @@ describe('TitleHeader', () => { it('should call a mock function when tapping back button', () => { render(props) fireEvent.click(screen.getByTestId('Ethernet_header_back_button')) - expect(mockPush).toHaveBeenCalledWith('/network-setup') + expect(mockNavigate).toHaveBeenCalledWith('/network-setup') }) }) diff --git a/app/src/pages/ConnectViaUSB/_tests__/ConnectedViaUSB.test.tsx b/app/src/pages/ConnectViaUSB/_tests__/ConnectedViaUSB.test.tsx index 16bc9bb98bf2..139a9f0dcd27 100644 --- a/app/src/pages/ConnectViaUSB/_tests__/ConnectedViaUSB.test.tsx +++ b/app/src/pages/ConnectViaUSB/_tests__/ConnectedViaUSB.test.tsx @@ -13,13 +13,13 @@ import type { UseQueryResult } from 'react-query' import type { ActiveConnections } from '@opentrons/api-client' import type * as ReactRouterDom from 'react-router-dom' -const mockPush = vi.fn() +const mockNavigate = vi.fn() vi.mock('react-router-dom', async importOriginal => { const actual = await importOriginal() return { ...actual, - useHistory: () => ({ push: mockPush } as any), + useNavigate: () => mockNavigate, } }) vi.mock('@opentrons/react-api-client') @@ -58,7 +58,7 @@ describe('ConnectViaUSB', () => { it('should call a mock function when tapping back button', () => { const [{ getByRole }] = render() fireEvent.click(getByRole('button')) - expect(mockPush).toHaveBeenCalledWith('/network-setup') + expect(mockNavigate).toHaveBeenCalledWith('/network-setup') }) it('should render successful connection text and button', () => { @@ -81,6 +81,6 @@ describe('ConnectViaUSB', () => { const [{ getByText }] = render() const button = getByText('Continue') fireEvent.click(button) - expect(mockPush).toHaveBeenCalledWith('/emergency-stop') + expect(mockNavigate).toHaveBeenCalledWith('/emergency-stop') }) }) diff --git a/app/src/pages/DeckConfiguration/__tests__/DeckConfiguration.test.tsx b/app/src/pages/DeckConfiguration/__tests__/DeckConfiguration.test.tsx index d0fab1277b08..f125de92966e 100644 --- a/app/src/pages/DeckConfiguration/__tests__/DeckConfiguration.test.tsx +++ b/app/src/pages/DeckConfiguration/__tests__/DeckConfiguration.test.tsx @@ -28,7 +28,7 @@ vi.mock('react-router-dom', async importOriginal => { const actual = await importOriginal() return { ...actual, - useHistory: () => ({ goBack: mockGoBack } as any), + useNavigate: () => mockGoBack, } }) vi.mock('@opentrons/components', async importOriginal => { diff --git a/app/src/pages/Devices/DeviceDetails/index.tsx b/app/src/pages/Devices/DeviceDetails/index.tsx index 3e7cabd4bf7c..962dd229d87c 100644 --- a/app/src/pages/Devices/DeviceDetails/index.tsx +++ b/app/src/pages/Devices/DeviceDetails/index.tsx @@ -1,6 +1,6 @@ import * as React from 'react' import { useSelector } from 'react-redux' -import { Navigate, Route, useParams } from 'react-router-dom' +import { Navigate, useParams } from 'react-router-dom' import { ApiHostProvider } from '@opentrons/react-api-client' diff --git a/app/src/pages/Devices/ProtocolRunDetails/index.tsx b/app/src/pages/Devices/ProtocolRunDetails/index.tsx index aaeecb62ceb7..e77841ec980e 100644 --- a/app/src/pages/Devices/ProtocolRunDetails/index.tsx +++ b/app/src/pages/Devices/ProtocolRunDetails/index.tsx @@ -2,7 +2,7 @@ import * as React from 'react' import isEmpty from 'lodash/isEmpty' import { useTranslation } from 'react-i18next' import { useDispatch } from 'react-redux' -import { NavLink, Navigate, Route, useParams } from 'react-router-dom' +import { NavLink, Navigate, useParams } from 'react-router-dom' import styled, { css } from 'styled-components' import { diff --git a/app/src/pages/Devices/RobotSettings/index.tsx b/app/src/pages/Devices/RobotSettings/index.tsx index a16b9345d8e9..b3b7580377b3 100644 --- a/app/src/pages/Devices/RobotSettings/index.tsx +++ b/app/src/pages/Devices/RobotSettings/index.tsx @@ -1,6 +1,6 @@ import * as React from 'react' import { useTranslation } from 'react-i18next' -import { Route, useParams, Navigate } from 'react-router-dom' +import { useParams, Navigate } from 'react-router-dom' import { BORDERS, @@ -102,7 +102,6 @@ export function RobotSettings(): JSX.Element | null { const robotSettingsContent = robotSettingsContentByTab[robotSettingsTab] ?? ( // default to the calibration tab if no tab or nonexistent tab is passed as a param - ) diff --git a/app/src/pages/EmergencyStop/__tests__/EmergencyStop.test.tsx b/app/src/pages/EmergencyStop/__tests__/EmergencyStop.test.tsx index bbfee8eb3769..7d7a85986848 100644 --- a/app/src/pages/EmergencyStop/__tests__/EmergencyStop.test.tsx +++ b/app/src/pages/EmergencyStop/__tests__/EmergencyStop.test.tsx @@ -19,12 +19,12 @@ const mockDisconnectedEstop = { rightEstopPhysicalStatus: 'notPresent', }, } as any -const mockPush = vi.fn() +const mockNavigate = vi.fn() vi.mock('react-router-dom', async importOriginal => { const actual = await importOriginal() return { ...actual, - useHistory: () => ({ push: mockPush } as any), + useNavigate: () => mockNavigate, } }) @@ -85,6 +85,6 @@ describe('EmergencyStop', () => { } as any) render() fireEvent.click(screen.getByRole('button')) - expect(mockPush).toHaveBeenCalledWith('/robot-settings/rename-robot') + expect(mockNavigate).toHaveBeenCalledWith('/robot-settings/rename-robot') }) }) diff --git a/app/src/pages/InstrumentDetail/__tests__/InstrumentDetail.test.tsx b/app/src/pages/InstrumentDetail/__tests__/InstrumentDetail.test.tsx index af9489f2c6c5..6b92a5ab9bed 100644 --- a/app/src/pages/InstrumentDetail/__tests__/InstrumentDetail.test.tsx +++ b/app/src/pages/InstrumentDetail/__tests__/InstrumentDetail.test.tsx @@ -19,7 +19,7 @@ import type { Instruments } from '@opentrons/api-client' vi.mock('@opentrons/react-api-client') vi.mock('react-router-dom', () => ({ useParams: vi.fn(), - useHistory: vi.fn(), + useNavigate: vi.fn(), })) vi.mock('../../../resources/instruments/hooks') vi.mock('../../../resources/robot-settings/hooks') diff --git a/app/src/pages/NameRobot/__tests__/NameRobot.test.tsx b/app/src/pages/NameRobot/__tests__/NameRobot.test.tsx index c7b9b546645e..67287056b95d 100644 --- a/app/src/pages/NameRobot/__tests__/NameRobot.test.tsx +++ b/app/src/pages/NameRobot/__tests__/NameRobot.test.tsx @@ -26,13 +26,13 @@ vi.mock('../../../redux/config') vi.mock('../../../redux/analytics') vi.mock('../../../organisms/RobotSettingsDashboard/NetworkSettings/hooks') -const mockPush = vi.fn() +const mockNavigate = vi.fn() vi.mock('react-router-dom', async importOriginal => { const actual = await importOriginal() return { ...actual, - useHistory: () => ({ push: mockPush } as any), + useNavigate: () => mockNavigate, } }) @@ -142,6 +142,6 @@ describe('NameRobot', () => { vi.mocked(useIsUnboxingFlowOngoing).mockReturnValue(false) render() fireEvent.click(screen.getByTestId('name_back_button')) - expect(mockPush).toHaveBeenCalledWith('/robot-settings') + expect(mockNavigate).toHaveBeenCalledWith('/robot-settings') }) }) diff --git a/app/src/pages/NetworkSetupMenu/__tests__/NetworkSetupMenu.test.tsx b/app/src/pages/NetworkSetupMenu/__tests__/NetworkSetupMenu.test.tsx index f2febd1a32d2..d8b3174f3362 100644 --- a/app/src/pages/NetworkSetupMenu/__tests__/NetworkSetupMenu.test.tsx +++ b/app/src/pages/NetworkSetupMenu/__tests__/NetworkSetupMenu.test.tsx @@ -8,13 +8,13 @@ import { i18n } from '../../../i18n' import { NetworkSetupMenu } from '..' import type * as ReactRouterDom from 'react-router-dom' -const mockPush = vi.fn() +const mockNavigate = vi.fn() vi.mock('react-router-dom', async importOriginal => { const actual = await importOriginal() return { ...actual, - useHistory: () => ({ push: mockPush } as any), + useNavigate: () => mockNavigate, } }) @@ -53,10 +53,10 @@ describe('NetworkSetupMenu', () => { const ethernetButton = screen.getByText('Ethernet') const usbButton = screen.getByText('USB') fireEvent.click(wifiButton) - expect(mockPush).toHaveBeenCalledWith('/network-setup/wifi') + expect(mockNavigate).toHaveBeenCalledWith('/network-setup/wifi') fireEvent.click(ethernetButton) - expect(mockPush).toHaveBeenCalledWith('/network-setup/ethernet') + expect(mockNavigate).toHaveBeenCalledWith('/network-setup/ethernet') fireEvent.click(usbButton) - expect(mockPush).toHaveBeenCalledWith('/network-setup/usb') + expect(mockNavigate).toHaveBeenCalledWith('/network-setup/usb') }) }) diff --git a/app/src/pages/ProtocolDashboard/__tests__/PinnedProtocol.test.tsx b/app/src/pages/ProtocolDashboard/__tests__/PinnedProtocol.test.tsx index e1e2125c88a6..8b1c4e90bef6 100644 --- a/app/src/pages/ProtocolDashboard/__tests__/PinnedProtocol.test.tsx +++ b/app/src/pages/ProtocolDashboard/__tests__/PinnedProtocol.test.tsx @@ -14,13 +14,13 @@ import type { Chip } from '@opentrons/components' import type { ProtocolResource } from '@opentrons/shared-data' import type * as ReactRouterDom from 'react-router-dom' -const mockPush = vi.fn() +const mockNavigate = vi.fn() vi.mock('react-router-dom', async importOriginal => { const actual = await importOriginal() return { ...actual, - useHistory: () => ({ push: mockPush } as any), + useNavigate: () => mockNavigate, } }) vi.mock('@opentrons/components', async importOriginal => { @@ -119,7 +119,7 @@ describe('Pinned Protocol', () => { render(props) const name = screen.getByText('yay mock protocol') fireEvent.click(name) - expect(mockPush).toHaveBeenCalledWith('/protocols/mockProtocol1') + expect(mockNavigate).toHaveBeenCalledWith('/protocols/mockProtocol1') }) it('should display modal after long click', async () => { diff --git a/app/src/pages/ProtocolDashboard/__tests__/ProtocolCard.test.tsx b/app/src/pages/ProtocolDashboard/__tests__/ProtocolCard.test.tsx index 304087cf5bbf..9c775e72dd5a 100644 --- a/app/src/pages/ProtocolDashboard/__tests__/ProtocolCard.test.tsx +++ b/app/src/pages/ProtocolDashboard/__tests__/ProtocolCard.test.tsx @@ -21,13 +21,13 @@ import type { ProtocolResource, } from '@opentrons/shared-data' -const mockPush = vi.fn() +const mockNavigate = vi.fn() vi.mock('react-router-dom', async importOriginal => { const actual = await importOriginal() return { ...actual, - useHistory: () => ({ push: mockPush } as any), + useNavigate: () => mockNavigate, } }) vi.mock('@opentrons/react-api-client') @@ -107,7 +107,7 @@ describe('ProtocolCard', () => { const card = screen.getByTestId('protocol_card') expect(card).toHaveStyle(`background-color: ${COLORS.grey35}`) fireEvent.click(name) - expect(mockPush).toHaveBeenCalledWith('/protocols/mockProtocol1') + expect(mockNavigate).toHaveBeenCalledWith('/protocols/mockProtocol1') }) it('should display the analysis failed error modal when clicking on the protocol', () => { diff --git a/app/src/pages/ProtocolSetup/__tests__/ProtocolSetup.test.tsx b/app/src/pages/ProtocolSetup/__tests__/ProtocolSetup.test.tsx index 30cfe51c9472..cad31ca5ed74 100644 --- a/app/src/pages/ProtocolSetup/__tests__/ProtocolSetup.test.tsx +++ b/app/src/pages/ProtocolSetup/__tests__/ProtocolSetup.test.tsx @@ -74,7 +74,7 @@ Object.defineProperty(window, 'IntersectionObserver', { value: IntersectionObserver, }) -let mockHistoryPush = vi.fn() +let mockNavigate = vi.fn() vi.mock('@opentrons/shared-data', async importOriginal => { const sharedData = await importOriginal() @@ -88,9 +88,7 @@ vi.mock('react-router-dom', async importOriginal => { const reactRouterDom = await importOriginal() return { ...reactRouterDom, - useHistory: () => ({ - push: mockHistoryPush, - }), + useNavigate: () => mockNavigate, } }) @@ -193,7 +191,7 @@ describe('ProtocolSetup', () => { let mockLaunchLPC = vi.fn() beforeEach(() => { mockLaunchLPC = vi.fn() - mockHistoryPush = vi.fn() + mockNavigate = vi.fn() vi.mocked(useLPCDisabledReason).mockReturnValue(null) vi.mocked(useAttachedModules).mockReturnValue([]) vi.mocked(useModuleCalibrationStatus).mockReturnValue({ complete: true }) @@ -430,6 +428,6 @@ describe('ProtocolSetup', () => { it('should redirect to the protocols page when a run is stopped', () => { vi.mocked(useRunStatus).mockReturnValue(RUN_STATUS_STOPPED) render(`/runs/${RUN_ID}/setup/`) - expect(mockHistoryPush).toHaveBeenCalledWith('/protocols') + expect(mockNavigate).toHaveBeenCalledWith('/protocols') }) }) diff --git a/app/src/pages/Protocols/ProtocolDetails/index.tsx b/app/src/pages/Protocols/ProtocolDetails/index.tsx index daabb89f71a8..a75e3457540d 100644 --- a/app/src/pages/Protocols/ProtocolDetails/index.tsx +++ b/app/src/pages/Protocols/ProtocolDetails/index.tsx @@ -1,5 +1,5 @@ import * as React from 'react' -import { useParams, Route, Navigate } from 'react-router-dom' +import { useParams, Navigate } from 'react-router-dom' import { useDispatch, useSelector } from 'react-redux' import { diff --git a/app/src/pages/QuickTransferDashboard/__tests__/DeleteTransferConfirmationModal.test.tsx b/app/src/pages/QuickTransferDashboard/__tests__/DeleteTransferConfirmationModal.test.tsx index 7715f6efff8b..2268d00a0f9e 100644 --- a/app/src/pages/QuickTransferDashboard/__tests__/DeleteTransferConfirmationModal.test.tsx +++ b/app/src/pages/QuickTransferDashboard/__tests__/DeleteTransferConfirmationModal.test.tsx @@ -14,7 +14,7 @@ import { DeleteTransferConfirmationModal } from '../DeleteTransferConfirmationMo import type * as ReactRouterDom from 'react-router-dom' import type { HostConfig } from '@opentrons/api-client' -const mockPush = vi.fn() +const mockNavigate = vi.fn() vi.mock('@opentrons/api-client') vi.mock('@opentrons/react-api-client') @@ -23,7 +23,7 @@ vi.mock('react-router-dom', async importOriginal => { const reactRouterDom = await importOriginal() return { ...reactRouterDom, - useHistory: () => ({ push: mockPush } as any), + useNavigate: () => mockNavigate, } }) diff --git a/app/src/pages/QuickTransferDashboard/__tests__/PinnedTransfer.test.tsx b/app/src/pages/QuickTransferDashboard/__tests__/PinnedTransfer.test.tsx index 5ae26b3f1da7..7c6fa45a8728 100644 --- a/app/src/pages/QuickTransferDashboard/__tests__/PinnedTransfer.test.tsx +++ b/app/src/pages/QuickTransferDashboard/__tests__/PinnedTransfer.test.tsx @@ -10,13 +10,13 @@ import { PinnedTransfer } from '../PinnedTransfer' import type { ProtocolResource } from '@opentrons/shared-data' import type * as ReactRouterDom from 'react-router-dom' -const mockPush = vi.fn() +const mockNavigate = vi.fn() vi.mock('react-router-dom', async importOriginal => { const actual = await importOriginal() return { ...actual, - useHistory: () => ({ push: mockPush } as any), + useNavigate: () => mockNavigate, } }) @@ -63,7 +63,7 @@ describe('Pinned Transfer', () => { render() const name = screen.getByText('yay mock transfer') fireEvent.click(name) - expect(mockPush).toHaveBeenCalledWith('/quick-transfer/mockTransfer1') + expect(mockNavigate).toHaveBeenCalledWith('/quick-transfer/mockTransfer1') }) it('should display modal after long click', async () => { diff --git a/app/src/pages/QuickTransferDashboard/__tests__/QuickTransferCard.test.tsx b/app/src/pages/QuickTransferDashboard/__tests__/QuickTransferCard.test.tsx index de3a23700d9f..246cd1fbfdc4 100644 --- a/app/src/pages/QuickTransferDashboard/__tests__/QuickTransferCard.test.tsx +++ b/app/src/pages/QuickTransferDashboard/__tests__/QuickTransferCard.test.tsx @@ -18,13 +18,13 @@ import type { ProtocolResource, } from '@opentrons/shared-data' -const mockPush = vi.fn() +const mockNavigate = vi.fn() vi.mock('react-router-dom', async importOriginal => { const actual = await importOriginal() return { ...actual, - useHistory: () => ({ push: mockPush } as any), + useNavigate: () => mockNavigate, } }) vi.mock('@opentrons/react-api-client') @@ -81,7 +81,7 @@ describe('QuickTransferCard', () => { render() const name = screen.getByText('yay mock transfer') fireEvent.click(name) - expect(mockPush).toHaveBeenCalledWith('/quick-transfer/mockTransfer1') + expect(mockNavigate).toHaveBeenCalledWith('/quick-transfer/mockTransfer1') }) it('should display the analysis failed error modal when clicking on the transfer', () => { diff --git a/app/src/pages/RobotDashboard/__tests__/RobotDashboard.test.tsx b/app/src/pages/RobotDashboard/__tests__/RobotDashboard.test.tsx index f930ba4c6b70..1e379847b980 100644 --- a/app/src/pages/RobotDashboard/__tests__/RobotDashboard.test.tsx +++ b/app/src/pages/RobotDashboard/__tests__/RobotDashboard.test.tsx @@ -21,13 +21,13 @@ import { useNotifyAllRunsQuery } from '../../../resources/runs' import type { ProtocolResource } from '@opentrons/shared-data' import type * as ReactRouterDom from 'react-router-dom' -const mockPush = vi.fn() +const mockNavigate = vi.fn() vi.mock('react-router-dom', async importOriginal => { const actual = await importOriginal() return { ...actual, - useHistory: () => ({ push: mockPush } as any), + useNavigate: () => mockNavigate, } }) vi.mock('@opentrons/react-api-client')