Browse Source

test(ts): Remove a ton of RouterContextFixture (#71814)

This is almost never needed anymore.

 1. This was a misnomer from the start, as it also injects organization
    and proejct legacy context, not just the react router context.

 2. Organization legacy context is no more, so any place where it was
    being used to customize the legacy organization context it was
    simply no longer needed

 3. It's already by default inected into legacy context when using
    render. There were a number of places passing it through with no
    modifications. This is simply unnecessary.

---------

Co-authored-by: getsantry[bot] <66042841+getsantry[bot]@users.noreply.github.com>
Evan Purkhiser 9 months ago
parent
commit
df031c852a

+ 9 - 18
static/app/components/acl/access.spec.tsx

@@ -1,7 +1,6 @@
 import {ConfigFixture} from 'sentry-fixture/config';
 import {OrganizationFixture} from 'sentry-fixture/organization';
 import {ProjectFixture} from 'sentry-fixture/project';
-import {RouterContextFixture} from 'sentry-fixture/routerContextFixture';
 import {TeamFixture} from 'sentry-fixture/team';
 import {UserFixture} from 'sentry-fixture/user';
 
@@ -14,7 +13,6 @@ describe('Access', function () {
   const organization = OrganizationFixture({
     access: ['project:write', 'project:read'],
   });
-  const routerContext = RouterContextFixture([{organization}]);
 
   describe('as render prop', function () {
     const childrenMock = jest.fn().mockReturnValue(null);
@@ -25,7 +23,6 @@ describe('Access', function () {
 
     it('has access', function () {
       render(<Access access={['project:write', 'project:read']}>{childrenMock}</Access>, {
-        context: routerContext,
         organization,
       });
 
@@ -37,7 +34,6 @@ describe('Access', function () {
 
     it('has no access', function () {
       render(<Access access={['org:write']}>{childrenMock}</Access>, {
-        context: routerContext,
         organization,
       });
 
@@ -49,14 +45,13 @@ describe('Access', function () {
 
     it('read access from team', function () {
       const org = OrganizationFixture({access: []});
-      const nextRouterContext = RouterContextFixture([{organization: org}]);
 
       const team1 = TeamFixture({access: []});
       render(
         <Access access={['team:admin']} team={team1}>
           {childrenMock}
         </Access>,
-        {context: nextRouterContext, organization: org}
+        {organization: org}
       );
 
       expect(childrenMock).toHaveBeenCalledWith(
@@ -73,7 +68,7 @@ describe('Access', function () {
         <Access access={['team:admin']} team={team2}>
           {childrenMock}
         </Access>,
-        {context: nextRouterContext, organization: org}
+        {organization: org}
       );
 
       expect(childrenMock).toHaveBeenCalledWith(
@@ -86,14 +81,13 @@ describe('Access', function () {
 
     it('read access from project', function () {
       const org = OrganizationFixture({access: []});
-      const nextRouterContext = RouterContextFixture([{organization: org}]);
 
       const proj1 = ProjectFixture({access: []});
       render(
         <Access access={['project:read']} project={proj1}>
           {childrenMock}
         </Access>,
-        {context: nextRouterContext, organization: org}
+        {organization: org}
       );
 
       expect(childrenMock).toHaveBeenCalledWith(
@@ -108,7 +102,7 @@ describe('Access', function () {
         <Access access={['project:read']} project={proj2}>
           {childrenMock}
         </Access>,
-        {context: nextRouterContext, organization: org}
+        {organization: org}
       );
 
       expect(childrenMock).toHaveBeenCalledWith(
@@ -121,7 +115,6 @@ describe('Access', function () {
 
     it('handles no org', function () {
       render(<Access access={['org:write']}>{childrenMock}</Access>, {
-        context: routerContext,
         organization,
       });
 
@@ -139,7 +132,7 @@ describe('Access', function () {
         user: undefined,
       });
 
-      render(<Access>{childrenMock}</Access>, {context: routerContext, organization});
+      render(<Access>{childrenMock}</Access>, {organization});
 
       expect(childrenMock).toHaveBeenCalledWith({
         hasAccess: true,
@@ -153,7 +146,6 @@ describe('Access', function () {
       });
 
       render(<Access isSuperuser>{childrenMock}</Access>, {
-        context: routerContext,
         organization,
       });
 
@@ -169,7 +161,6 @@ describe('Access', function () {
       });
 
       render(<Access isSuperuser>{childrenMock}</Access>, {
-        context: routerContext,
         organization,
       });
 
@@ -186,7 +177,7 @@ describe('Access', function () {
         <Access access={['project:write']}>
           <p>The Child</p>
         </Access>,
-        {context: routerContext, organization}
+        {organization}
       );
 
       expect(screen.getByText('The Child')).toBeInTheDocument();
@@ -197,7 +188,7 @@ describe('Access', function () {
         <Access access={['org:write']}>
           <p>The Child</p>
         </Access>,
-        {context: routerContext, organization}
+        {organization}
       );
 
       expect(screen.queryByText('The Child')).not.toBeInTheDocument();
@@ -212,7 +203,7 @@ describe('Access', function () {
         <Access isSuperuser>
           <p>The Child</p>
         </Access>,
-        {context: routerContext, organization}
+        {organization}
       );
 
       expect(screen.getByText('The Child')).toBeInTheDocument();
@@ -227,7 +218,7 @@ describe('Access', function () {
         <Access isSuperuser>
           <p>The Child</p>
         </Access>,
-        {context: routerContext, organization}
+        {organization}
       );
       expect(screen.queryByRole('The Child')).not.toBeInTheDocument();
     });

+ 1 - 6
static/app/components/acl/feature.spec.tsx

@@ -16,12 +16,7 @@ describe('Feature', function () {
   const project = ProjectFixture({
     features: ['project-foo', 'project-bar'],
   });
-  const routerContext = RouterContextFixture([
-    {
-      organization,
-      project,
-    },
-  ]);
+  const routerContext = RouterContextFixture([{project}]);
 
   describe('as render prop', function () {
     const childrenMock = jest.fn().mockReturnValue(null);

+ 3 - 15
static/app/components/acl/role.spec.tsx

@@ -1,5 +1,4 @@
 import {OrganizationFixture} from 'sentry-fixture/organization';
-import {RouterContextFixture} from 'sentry-fixture/routerContextFixture';
 
 import {render, screen} from 'sentry-test/reactTestingLibrary';
 
@@ -41,11 +40,6 @@ describe('Role', function () {
       },
     ],
   });
-  const routerContext = RouterContextFixture([
-    {
-      organization,
-    },
-  ]);
 
   describe('as render prop', function () {
     const childrenMock = jest.fn().mockReturnValue(null);
@@ -56,7 +50,6 @@ describe('Role', function () {
 
     it('has a sufficient role', function () {
       render(<Role role="admin">{childrenMock}</Role>, {
-        context: routerContext,
         organization,
       });
 
@@ -67,7 +60,6 @@ describe('Role', function () {
 
     it('has an insufficient role', function () {
       render(<Role role="manager">{childrenMock}</Role>, {
-        context: routerContext,
         organization,
       });
 
@@ -81,7 +73,6 @@ describe('Role', function () {
       OrganizationStore.onUpdate(organization, {replace: true});
 
       render(<Role role="owner">{childrenMock}</Role>, {
-        context: routerContext,
         organization,
       });
 
@@ -92,7 +83,6 @@ describe('Role', function () {
 
     it('does not give access to a made up role', function () {
       render(<Role role="abcdefg">{childrenMock}</Role>, {
-        context: routerContext,
         organization,
       });
 
@@ -105,7 +95,6 @@ describe('Role', function () {
       const user = {...ConfigStore.config.user};
       ConfigStore.config.user = undefined as any;
       render(<Role role="member">{childrenMock}</Role>, {
-        context: routerContext,
         organization,
       });
 
@@ -119,7 +108,6 @@ describe('Role', function () {
       const user = {...ConfigStore.config.user};
       ConfigStore.config.user = undefined as any;
       const {rerender} = render(<Role role="member">{childrenMock}</Role>, {
-        context: routerContext,
         organization,
       });
 
@@ -139,7 +127,7 @@ describe('Role', function () {
         <Role role="member" organization={{...organization, orgRoleList: []}}>
           {childrenMock}
         </Role>,
-        {context: routerContext, organization}
+        {organization}
       );
 
       expect(childrenMock).toHaveBeenCalledWith({
@@ -154,7 +142,7 @@ describe('Role', function () {
         <Role role="member">
           <div>The Child</div>
         </Role>,
-        {context: routerContext, organization}
+        {organization}
       );
 
       expect(screen.getByText('The Child')).toBeInTheDocument();
@@ -165,7 +153,7 @@ describe('Role', function () {
         <Role role="owner">
           <div>The Child</div>
         </Role>,
-        {context: routerContext, organization}
+        {organization}
       );
 
       expect(screen.queryByText('The Child')).not.toBeInTheDocument();

+ 1 - 5
static/app/components/assigneeSelectorDropdown.spec.tsx

@@ -1,7 +1,6 @@
 import {GroupFixture} from 'sentry-fixture/group';
 import {MemberFixture} from 'sentry-fixture/member';
 import {ProjectFixture} from 'sentry-fixture/project';
-import {RouterContextFixture} from 'sentry-fixture/routerContextFixture';
 import {TeamFixture} from 'sentry-fixture/team';
 import {UserFixture} from 'sentry-fixture/user';
 
@@ -609,10 +608,7 @@ describe('AssigneeSelectorDropdown', () => {
         group={GROUP_1}
         loading={false}
         onAssign={newAssignee => updateGroup(GROUP_1, newAssignee)}
-      />,
-      {
-        context: RouterContextFixture(),
-      }
+      />
     );
     jest.spyOn(ConfigStore, 'get').mockImplementation(() => true);
 

+ 1 - 4
static/app/components/badge/deployBadge.spec.tsx

@@ -1,5 +1,3 @@
-import {RouterContextFixture} from 'sentry-fixture/routerContextFixture';
-
 import {render, screen} from 'sentry-test/reactTestingLibrary';
 
 import DeployBadge from 'sentry/components/badge/deployBadge';
@@ -24,8 +22,7 @@ describe('DeployBadge', () => {
         orgSlug="sentry"
         version="1.2.3"
         projectId={projectId}
-      />,
-      {context: RouterContextFixture()}
+      />
     );
 
     expect(screen.queryByRole('link')).toHaveAttribute(

+ 1 - 5
static/app/components/badge/tag.spec.tsx

@@ -1,12 +1,9 @@
-import {RouterContextFixture} from 'sentry-fixture/routerContextFixture';
-
 import {render, screen, userEvent} from 'sentry-test/reactTestingLibrary';
 
 import Tag from 'sentry/components/badge/tag';
 import {IconFire} from 'sentry/icons';
 
 describe('Tag', () => {
-  const routerContext = RouterContextFixture();
   it('basic', () => {
     render(<Tag>Text</Tag>);
     expect(screen.getByText('Text')).toBeInTheDocument();
@@ -55,8 +52,7 @@ describe('Tag', () => {
     render(
       <Tag type="highlight" to={to}>
         Internal link
-      </Tag>,
-      {context: routerContext}
+      </Tag>
     );
     expect(screen.getByText('Internal link')).toBeInTheDocument();
     expect(screen.getByRole('link', {name: 'Internal link'})).toBeInTheDocument();

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

@@ -1,5 +1,3 @@
-import {RouterContextFixture} from 'sentry-fixture/routerContextFixture';
-
 import {render, screen, userEvent} from 'sentry-test/reactTestingLibrary';
 import {textWithMarkupMatcher} from 'sentry-test/utils';
 
@@ -62,7 +60,7 @@ describe('commitRow', () => {
       },
     } as Commit;
 
-    render(<CommitRow commit={commit} />, {context: RouterContextFixture()});
+    render(<CommitRow commit={commit} />);
     expect(
       screen.getByText(
         textWithMarkupMatcher(

+ 1 - 7
static/app/components/createAlertButton.spec.tsx

@@ -38,8 +38,6 @@ describe('CreateAlertFromViewButton', () => {
   });
 
   it('should trigger onClick callback', async () => {
-    const context = RouterContextFixture();
-
     const eventView = EventView.fromSavedQuery({
       ...DEFAULT_EVENT_VIEW,
       query: 'event.type:error',
@@ -51,8 +49,7 @@ describe('CreateAlertFromViewButton', () => {
         eventView={eventView}
         projects={[ProjectFixture()]}
         onClick={onClickMock}
-      />,
-      {context}
+      />
     );
     await userEvent.click(screen.getByRole('button', {name: 'Create Alert'}));
     expect(onClickMock).toHaveBeenCalledTimes(1);
@@ -90,7 +87,6 @@ describe('CreateAlertFromViewButton', () => {
         onClick={onClickMock}
       />,
       {
-        context: RouterContextFixture([{organization: noAccessOrg}]),
         organization: noAccessOrg,
       }
     );
@@ -126,7 +122,6 @@ describe('CreateAlertFromViewButton', () => {
         onClick={onClickMock}
       />,
       {
-        context: RouterContextFixture([{organization}]),
         organization,
       }
     );
@@ -175,7 +170,6 @@ describe('CreateAlertFromViewButton', () => {
         onClick={onClickMock}
       />,
       {
-        context: RouterContextFixture([{organization: noAccessOrg}]),
         organization: noAccessOrg,
       }
     );

+ 1 - 4
static/app/components/dataExport.spec.tsx

@@ -1,5 +1,4 @@
 import {OrganizationFixture} from 'sentry-fixture/organization';
-import {RouterContextFixture} from 'sentry-fixture/routerContextFixture';
 
 import {render, screen, userEvent, waitFor} from 'sentry-test/reactTestingLibrary';
 
@@ -23,9 +22,7 @@ const mockPayload = {
 };
 
 const mockContext = (organization: Organization) => {
-  const routerContext = RouterContextFixture([{organization}]);
-
-  return {context: routerContext, organization};
+  return {organization};
 };
 
 describe('DataExport', function () {

+ 1 - 4
static/app/components/deprecatedAssigneeSelector.spec.tsx

@@ -1,7 +1,6 @@
 import {GroupFixture} from 'sentry-fixture/group';
 import {MemberFixture} from 'sentry-fixture/member';
 import {ProjectFixture} from 'sentry-fixture/project';
-import {RouterContextFixture} from 'sentry-fixture/routerContextFixture';
 import {TeamFixture} from 'sentry-fixture/team';
 import {UserFixture} from 'sentry-fixture/user';
 
@@ -282,9 +281,7 @@ describe('DeprecatedAssigneeSelector', () => {
 
   it('shows invite member button', async () => {
     MemberListStore.loadInitialData([USER_1, USER_2]);
-    render(<DeprecatedAssigneeSelector id={GROUP_1.id} />, {
-      context: RouterContextFixture(),
-    });
+    render(<DeprecatedAssigneeSelector id={GROUP_1.id} />);
     jest.spyOn(ConfigStore, 'get').mockImplementation(() => true);
 
     await openMenu();

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