From 98d982637e1df0d9b69ca1aeb7fb07fc79472985 Mon Sep 17 00:00:00 2001 From: Connie Liu Date: Tue, 7 Jan 2025 10:52:50 -0500 Subject: [PATCH] switch PG create back to react router dom (used in LinodeCreate as well) --- .../PlacementGroupsCreateDrawer.test.tsx | 27 +++++++++---------- .../PlacementGroupsCreateDrawer.tsx | 3 ++- .../PlacementGroupsUnassignModal.tsx | 2 +- .../src/features/PlacementGroups/types.ts | 2 +- 4 files changed, 16 insertions(+), 18 deletions(-) diff --git a/packages/manager/src/features/PlacementGroups/PlacementGroupsCreateDrawer.test.tsx b/packages/manager/src/features/PlacementGroups/PlacementGroupsCreateDrawer.test.tsx index a132d0a5195..f0102f7a4b9 100644 --- a/packages/manager/src/features/PlacementGroups/PlacementGroupsCreateDrawer.test.tsx +++ b/packages/manager/src/features/PlacementGroups/PlacementGroupsCreateDrawer.test.tsx @@ -2,7 +2,8 @@ import { fireEvent, waitFor } from '@testing-library/react'; import * as React from 'react'; import { placementGroupFactory } from 'src/factories'; -import { renderWithThemeAndRouter } from 'src/utilities/testHelpers'; +// eslint-disable-next-line no-restricted-imports +import { renderWithTheme } from 'src/utilities/testHelpers'; import { PlacementGroupsCreateDrawer } from './PlacementGroupsCreateDrawer'; @@ -31,12 +32,8 @@ vi.mock('src/queries/placementGroups', async () => { }); describe('PlacementGroupsCreateDrawer', () => { - it('should render and have its fields enabled', async () => { - const { - getAllByRole, - getByLabelText, - getByText, - } = await renderWithThemeAndRouter( + it('should render and have its fields enabled', () => { + const { getAllByRole, getByLabelText, getByText } = renderWithTheme( ); @@ -50,8 +47,8 @@ describe('PlacementGroupsCreateDrawer', () => { expect(radioInputs[0]).toBeChecked(); }); - it('Placement Group Type select should have the correct options', async () => { - const { getByPlaceholderText, getByText } = await renderWithThemeAndRouter( + it('Placement Group Type select should have the correct options', () => { + const { getByPlaceholderText, getByText } = renderWithTheme( ); @@ -66,13 +63,15 @@ describe('PlacementGroupsCreateDrawer', () => { }); it('should populate the region select with the selected region prop', async () => { - const { getByText } = await renderWithThemeAndRouter( + const { getByText } = renderWithTheme( , { - initialRoute: 'linodes/create', + MemoryRouter: { + initialEntries: ['/linodes/create'], + }, } ); @@ -87,9 +86,7 @@ describe('PlacementGroupsCreateDrawer', () => { getByPlaceholderText, getByRole, getByText, - } = await renderWithThemeAndRouter( - - ); + } = renderWithTheme(); fireEvent.change(getByLabelText('Label'), { target: { value: 'my-label' }, @@ -124,7 +121,7 @@ describe('PlacementGroupsCreateDrawer', () => { data: [placementGroupFactory.build({ region: 'us-west' })], }); const regionWithoutCapacity = 'US, Fremont, CA (us-west)'; - const { getByPlaceholderText, getByText } = await renderWithThemeAndRouter( + const { getByPlaceholderText, getByText } = renderWithTheme( ); diff --git a/packages/manager/src/features/PlacementGroups/PlacementGroupsCreateDrawer.tsx b/packages/manager/src/features/PlacementGroups/PlacementGroupsCreateDrawer.tsx index 5a440a3eebb..911bab3be4a 100644 --- a/packages/manager/src/features/PlacementGroups/PlacementGroupsCreateDrawer.tsx +++ b/packages/manager/src/features/PlacementGroups/PlacementGroupsCreateDrawer.tsx @@ -8,10 +8,11 @@ import { Typography, } from '@linode/ui'; import { createPlacementGroupSchema } from '@linode/validation'; -import { useLocation } from '@tanstack/react-router'; import { useFormik } from 'formik'; import { useSnackbar } from 'notistack'; import * as React from 'react'; +// eslint-disable-next-line no-restricted-imports +import { useLocation } from 'react-router-dom'; import { ActionsPanel } from 'src/components/ActionsPanel/ActionsPanel'; import { DescriptionList } from 'src/components/DescriptionList/DescriptionList'; diff --git a/packages/manager/src/features/PlacementGroups/PlacementGroupsUnassignModal.tsx b/packages/manager/src/features/PlacementGroups/PlacementGroupsUnassignModal.tsx index a0b59cce925..4b58a5c5211 100644 --- a/packages/manager/src/features/PlacementGroups/PlacementGroupsUnassignModal.tsx +++ b/packages/manager/src/features/PlacementGroups/PlacementGroupsUnassignModal.tsx @@ -1,7 +1,7 @@ import { CircleProgress, Notice, Typography } from '@linode/ui'; +import { useParams } from '@tanstack/react-router'; import { useSnackbar } from 'notistack'; import * as React from 'react'; -import { useParams } from '@tanstack/react-router'; import { ActionsPanel } from 'src/components/ActionsPanel/ActionsPanel'; import { ConfirmationDialog } from 'src/components/ConfirmationDialog/ConfirmationDialog'; diff --git a/packages/manager/src/features/PlacementGroups/types.ts b/packages/manager/src/features/PlacementGroups/types.ts index 15e78d12e3b..2363ad85216 100644 --- a/packages/manager/src/features/PlacementGroups/types.ts +++ b/packages/manager/src/features/PlacementGroups/types.ts @@ -1,4 +1,4 @@ -import { PlacementGroup, Region } from '@linode/api-v4'; +import type { PlacementGroup, Region } from '@linode/api-v4'; export interface PlacementGroupsDrawerPropsBase { onClose: () => void;