Browse Source

test(js): Remove all usages of routerContext (#72041)

This is replaced with `router`. We already had this and there were
simply two ways of doing things.
Evan Purkhiser 9 months ago
parent
commit
0cbffd69f8

+ 7 - 7
static/app/components/breadcrumbs.spec.tsx

@@ -1,11 +1,11 @@
-import {RouterContextFixture} from 'sentry-fixture/routerContextFixture';
+import {RouterFixture} from 'sentry-fixture/routerFixture';
 
 
 import {render, screen, userEvent} from 'sentry-test/reactTestingLibrary';
 import {render, screen, userEvent} from 'sentry-test/reactTestingLibrary';
 
 
 import {Breadcrumbs} from 'sentry/components/breadcrumbs';
 import {Breadcrumbs} from 'sentry/components/breadcrumbs';
 
 
 describe('Breadcrumbs', () => {
 describe('Breadcrumbs', () => {
-  const routerContext = RouterContextFixture();
+  const router = RouterFixture();
 
 
   afterEach(() => {
   afterEach(() => {
     jest.resetAllMocks();
     jest.resetAllMocks();
@@ -29,7 +29,7 @@ describe('Breadcrumbs', () => {
           },
           },
         ]}
         ]}
       />,
       />,
-      {context: routerContext}
+      {router}
     );
     );
   }
   }
 
 
@@ -46,15 +46,15 @@ describe('Breadcrumbs', () => {
   it('generates correct links', async () => {
   it('generates correct links', async () => {
     createWrapper();
     createWrapper();
     await userEvent.click(screen.getByText('Test 1'));
     await userEvent.click(screen.getByText('Test 1'));
-    expect(routerContext.context.router.push).toHaveBeenCalledWith('/test1');
+    expect(router.push).toHaveBeenCalledWith('/test1');
     await userEvent.click(screen.getByText('Test 2'));
     await userEvent.click(screen.getByText('Test 2'));
-    expect(routerContext.context.router.push).toHaveBeenCalledWith('/test2');
+    expect(router.push).toHaveBeenCalledWith('/test2');
   });
   });
 
 
   it('does not make links where no `to` is provided', async () => {
   it('does not make links where no `to` is provided', async () => {
     createWrapper();
     createWrapper();
     await userEvent.click(screen.getByText('Test 3'));
     await userEvent.click(screen.getByText('Test 3'));
-    expect(routerContext.context.router.push).not.toHaveBeenCalled();
+    expect(router.push).not.toHaveBeenCalled();
   });
   });
 
 
   it('renders a crumb dropdown', async () => {
   it('renders a crumb dropdown', async () => {
@@ -81,7 +81,7 @@ describe('Breadcrumbs', () => {
           },
           },
         ]}
         ]}
       />,
       />,
-      {context: routerContext}
+      {router}
     );
     );
     await userEvent.hover(screen.getByText('dropdown crumb'));
     await userEvent.hover(screen.getByText('dropdown crumb'));
 
 

+ 1 - 1
static/app/components/charts/optionSelector.spec.tsx

@@ -53,7 +53,7 @@ describe('Charts > OptionSelector (Multiple)', function () {
       projects: [],
       projects: [],
     });
     });
 
 
-    return render(<TestComponent />, {context: initialData.routerContext});
+    return render(<TestComponent />, {router: initialData.router});
   };
   };
 
 
   it('renders yAxisOptions with yAxisValue selected', async function () {
   it('renders yAxisOptions with yAxisValue selected', async function () {

+ 4 - 4
static/app/components/createAlertButton.spec.tsx

@@ -1,6 +1,6 @@
 import {OrganizationFixture} from 'sentry-fixture/organization';
 import {OrganizationFixture} from 'sentry-fixture/organization';
 import {ProjectFixture} from 'sentry-fixture/project';
 import {ProjectFixture} from 'sentry-fixture/project';
-import {RouterContextFixture} from 'sentry-fixture/routerContextFixture';
+import {RouterFixture} from 'sentry-fixture/routerFixture';
 
 
 import {render, screen, userEvent} from 'sentry-test/reactTestingLibrary';
 import {render, screen, userEvent} from 'sentry-test/reactTestingLibrary';
 
 
@@ -251,7 +251,7 @@ describe('CreateAlertFromViewButton', () => {
   });
   });
 
 
   it('removes a duplicate project filter', async () => {
   it('removes a duplicate project filter', async () => {
-    const context = RouterContextFixture();
+    const router = RouterFixture();
 
 
     const projects = [ProjectFixture()];
     const projects = [ProjectFixture()];
     jest.mocked(useProjects).mockReturnValue({
     jest.mocked(useProjects).mockReturnValue({
@@ -276,10 +276,10 @@ describe('CreateAlertFromViewButton', () => {
         projects={projects}
         projects={projects}
         onClick={onClickMock}
         onClick={onClickMock}
       />,
       />,
-      {context}
+      {router}
     );
     );
     await userEvent.click(screen.getByRole('button'));
     await userEvent.click(screen.getByRole('button'));
-    expect(context.context.router.push).toHaveBeenCalledWith({
+    expect(router.push).toHaveBeenCalledWith({
       pathname: `/organizations/org-slug/alerts/new/metric/`,
       pathname: `/organizations/org-slug/alerts/new/metric/`,
       query: expect.objectContaining({
       query: expect.objectContaining({
         query: 'event.type:error ',
         query: 'event.type:error ',

+ 6 - 15
static/app/components/eventOrGroupExtraDetails.spec.tsx

@@ -1,12 +1,9 @@
-import {initializeOrg} from 'sentry-test/initializeOrg';
 import {render} from 'sentry-test/reactTestingLibrary';
 import {render} from 'sentry-test/reactTestingLibrary';
 
 
 import EventOrGroupExtraDetails from 'sentry/components/eventOrGroupExtraDetails';
 import EventOrGroupExtraDetails from 'sentry/components/eventOrGroupExtraDetails';
 import type {Group} from 'sentry/types/group';
 import type {Group} from 'sentry/types/group';
 
 
 describe('EventOrGroupExtraDetails', function () {
 describe('EventOrGroupExtraDetails', function () {
-  const {routerContext} = initializeOrg();
-
   it('renders last and first seen', function () {
   it('renders last and first seen', function () {
     render(
     render(
       <EventOrGroupExtraDetails
       <EventOrGroupExtraDetails
@@ -18,8 +15,7 @@ describe('EventOrGroupExtraDetails', function () {
             firstSeen: '2017-07-01T02:06:02Z',
             firstSeen: '2017-07-01T02:06:02Z',
           } as Group
           } as Group
         }
         }
-      />,
-      {context: routerContext}
+      />
     );
     );
   });
   });
 
 
@@ -33,8 +29,7 @@ describe('EventOrGroupExtraDetails', function () {
             firstSeen: '2017-07-01T02:06:02Z',
             firstSeen: '2017-07-01T02:06:02Z',
           } as Group
           } as Group
         }
         }
-      />,
-      {context: routerContext}
+      />
     );
     );
   });
   });
 
 
@@ -48,8 +43,7 @@ describe('EventOrGroupExtraDetails', function () {
             lastSeen: '2017-07-25T22:56:12Z',
             lastSeen: '2017-07-25T22:56:12Z',
           } as Group
           } as Group
         }
         }
-      />,
-      {context: routerContext}
+      />
     );
     );
   });
   });
 
 
@@ -71,8 +65,7 @@ describe('EventOrGroupExtraDetails', function () {
             status: 'resolved',
             status: 'resolved',
           } as Group
           } as Group
         }
         }
-      />,
-      {context: routerContext}
+      />
     );
     );
   });
   });
 
 
@@ -95,8 +88,7 @@ describe('EventOrGroupExtraDetails', function () {
           } as Group
           } as Group
         }
         }
         showAssignee
         showAssignee
-      />,
-      {context: routerContext}
+      />
     );
     );
   });
   });
 
 
@@ -115,8 +107,7 @@ describe('EventOrGroupExtraDetails', function () {
             subscriptionDetails: {reason: 'mentioned'},
             subscriptionDetails: {reason: 'mentioned'},
           } as Group
           } as Group
         }
         }
-      />,
-      {context: routerContext}
+      />
     );
     );
   });
   });
 });
 });

+ 1 - 3
static/app/components/eventOrGroupHeader.spec.tsx

@@ -36,7 +36,7 @@ const event = EventFixture({
 });
 });
 
 
 describe('EventOrGroupHeader', function () {
 describe('EventOrGroupHeader', function () {
-  const {organization, router, routerContext} = initializeOrg();
+  const {organization, router} = initializeOrg();
 
 
   describe('Group', function () {
   describe('Group', function () {
     it('renders with `type = error`', function () {
     it('renders with `type = error`', function () {
@@ -181,7 +181,6 @@ describe('EventOrGroupHeader', function () {
           }}
           }}
         />,
         />,
         {
         {
-          context: routerContext,
           router: {
           router: {
             ...router,
             ...router,
             location: {
             location: {
@@ -211,7 +210,6 @@ describe('EventOrGroupHeader', function () {
           }}
           }}
         />,
         />,
         {
         {
-          context: routerContext,
           router: {
           router: {
             ...router,
             ...router,
             location: {
             location: {

+ 13 - 14
static/app/components/events/eventAttachments.spec.tsx

@@ -14,7 +14,7 @@ import {
 import {EventAttachments} from 'sentry/components/events/eventAttachments';
 import {EventAttachments} from 'sentry/components/events/eventAttachments';
 
 
 describe('EventAttachments', function () {
 describe('EventAttachments', function () {
-  const {routerContext, organization, project} = initializeOrg({
+  const {router, organization, project} = initializeOrg({
     organization: {
     organization: {
       features: ['event-attachments'],
       features: ['event-attachments'],
       orgRole: 'member',
       orgRole: 'member',
@@ -41,7 +41,7 @@ describe('EventAttachments', function () {
     });
     });
     const strippedCrashEvent = {...event, metadata: {stripped_crash: true}};
     const strippedCrashEvent = {...event, metadata: {stripped_crash: true}};
     render(<EventAttachments {...props} event={strippedCrashEvent} />, {
     render(<EventAttachments {...props} event={strippedCrashEvent} />, {
-      context: routerContext,
+      router,
       organization,
       organization,
     });
     });
 
 
@@ -77,7 +77,7 @@ describe('EventAttachments', function () {
         {...props}
         {...props}
         event={{...event, metadata: {stripped_crash: false}}}
         event={{...event, metadata: {stripped_crash: false}}}
       />,
       />,
-      {context: routerContext, organization}
+      {router, organization}
     );
     );
 
 
     // No loading state to wait for
     // No loading state to wait for
@@ -87,14 +87,13 @@ describe('EventAttachments', function () {
   });
   });
 
 
   it('displays message when user lacks permission to preview an attachment', async function () {
   it('displays message when user lacks permission to preview an attachment', async function () {
-    const {routerContext: newRouterContext, organization: orgWithWrongAttachmentRole} =
-      initializeOrg({
-        organization: {
-          features: ['event-attachments'],
-          orgRole: 'member',
-          attachmentsRole: 'admin',
-        },
-      } as any);
+    const {router: newRouter, organization: orgWithWrongAttachmentRole} = initializeOrg({
+      organization: {
+        features: ['event-attachments'],
+        orgRole: 'member',
+        attachmentsRole: 'admin',
+      },
+    } as any);
     const attachment = EventAttachmentFixture({
     const attachment = EventAttachmentFixture({
       name: 'some_file.txt',
       name: 'some_file.txt',
       headers: {
       headers: {
@@ -114,7 +113,7 @@ describe('EventAttachments', function () {
     });
     });
 
 
     render(<EventAttachments {...props} />, {
     render(<EventAttachments {...props} />, {
-      context: newRouterContext,
+      router: newRouter,
       organization: orgWithWrongAttachmentRole,
       organization: orgWithWrongAttachmentRole,
     });
     });
 
 
@@ -145,7 +144,7 @@ describe('EventAttachments', function () {
       body: 'file contents',
       body: 'file contents',
     });
     });
 
 
-    render(<EventAttachments {...props} />, {context: routerContext, organization});
+    render(<EventAttachments {...props} />, {router, organization});
 
 
     expect(await screen.findByText('Attachments (1)')).toBeInTheDocument();
     expect(await screen.findByText('Attachments (1)')).toBeInTheDocument();
 
 
@@ -172,7 +171,7 @@ describe('EventAttachments', function () {
       method: 'DELETE',
       method: 'DELETE',
     });
     });
 
 
-    render(<EventAttachments {...props} />, {context: routerContext, organization});
+    render(<EventAttachments {...props} />, {router, organization});
     renderGlobalModal();
     renderGlobalModal();
 
 
     expect(await screen.findByText('Attachments (2)')).toBeInTheDocument();
     expect(await screen.findByText('Attachments (2)')).toBeInTheDocument();

+ 2 - 2
static/app/components/events/eventReplay/replayClipPreview.spec.tsx

@@ -65,7 +65,7 @@ const render = (
   children: React.ReactElement,
   children: React.ReactElement,
   orgParams: Partial<DetailedOrganization> = {}
   orgParams: Partial<DetailedOrganization> = {}
 ) => {
 ) => {
-  const {routerContext, organization} = initializeOrg({
+  const {router, organization} = initializeOrg({
     organization: {slug: mockOrgSlug, ...orgParams},
     organization: {slug: mockOrgSlug, ...orgParams},
     router: {
     router: {
       routes: [
       routes: [
@@ -81,7 +81,7 @@ const render = (
   });
   });
 
 
   return baseRender(children, {
   return baseRender(children, {
-    context: routerContext,
+    router,
     organization,
     organization,
   });
   });
 };
 };

+ 2 - 2
static/app/components/events/eventReplay/replayPreview.spec.tsx

@@ -63,7 +63,7 @@ mockUseReplayReader.mockImplementation(() => {
 });
 });
 
 
 const render: typeof baseRender = children => {
 const render: typeof baseRender = children => {
-  const {routerContext} = initializeOrg({
+  const {router} = initializeOrg({
     router: {
     router: {
       routes: [
       routes: [
         {path: '/'},
         {path: '/'},
@@ -78,7 +78,7 @@ const render: typeof baseRender = children => {
   });
   });
 
 
   return baseRender(children, {
   return baseRender(children, {
-    context: routerContext,
+    router,
     organization: OrganizationFixture({slug: mockOrgSlug}),
     organization: OrganizationFixture({slug: mockOrgSlug}),
   });
   });
 };
 };

+ 4 - 4
static/app/components/events/eventTagsAndScreenshot/screenshot/modal.spec.tsx

@@ -14,7 +14,7 @@ import type {EventAttachment, Project} from 'sentry/types';
 const stubEl = (props: {children?: React.ReactNode}) => <div>{props.children}</div>;
 const stubEl = (props: {children?: React.ReactNode}) => <div>{props.children}</div>;
 
 
 function renderModal({
 function renderModal({
-  initialData: {organization, routerContext},
+  initialData: {organization, router},
   eventAttachment,
   eventAttachment,
   projectSlug,
   projectSlug,
   attachmentIndex,
   attachmentIndex,
@@ -53,7 +53,7 @@ function renderModal({
       enablePagination={enablePagination}
       enablePagination={enablePagination}
     />,
     />,
     {
     {
-      context: routerContext,
+      router,
       organization,
       organization,
     }
     }
   );
   );
@@ -172,7 +172,7 @@ describe('Modals -> ScreenshotModal', function () {
         enablePagination
         enablePagination
       />,
       />,
       {
       {
-        context: initialData.routerContext,
+        router: initialData.router,
         organization: initialData.organization,
         organization: initialData.organization,
       }
       }
     );
     );
@@ -209,7 +209,7 @@ describe('Modals -> ScreenshotModal', function () {
         enablePagination
         enablePagination
       />,
       />,
       {
       {
-        context: initialData.routerContext,
+        router: initialData.router,
         organization: initialData.organization,
         organization: initialData.organization,
       }
       }
     );
     );

+ 2 - 6
static/app/components/events/interfaces/crashContent/exception/content.spec.tsx

@@ -46,11 +46,7 @@ describe('Exception Content', function () {
       body: projectDetails,
       body: projectDetails,
     });
     });
 
 
-    const {
-      organization: org,
-      router,
-      routerContext,
-    } = initializeOrg({
+    const {organization: org, router} = initializeOrg({
       router: {
       router: {
         location: {query: {project: project.id}},
         location: {query: {project: project.id}},
       },
       },
@@ -145,7 +141,7 @@ describe('Exception Content', function () {
         meta={event._meta!.entries[0].data.values}
         meta={event._meta!.entries[0].data.values}
         projectSlug={project.slug}
         projectSlug={project.slug}
       />,
       />,
-      {organization: org, router, context: routerContext}
+      {organization: org, router}
     );
     );
 
 
     expect(screen.getAllByText(/redacted/)).toHaveLength(2);
     expect(screen.getAllByText(/redacted/)).toHaveLength(2);

Some files were not shown because too many files changed in this diff