Browse Source

ref(ts): Remove usage of `TestStubs.route*` (#62274)

No actual test changes were needed, sweet.

- Replace `TestStubs.router` with import
- Replace `TestStubs.routeComponentProps` with import

https://github.com/getsentry/frontend-tsc/issues/49
George Gritsouk 1 year ago
parent
commit
3b303ee3cd

+ 16 - 14
static/app/actionCreators/pageFilters.spec.tsx

@@ -1,3 +1,5 @@
+import RouterFixture from 'sentry-fixture/routerFixture';
+
 import {initializeOrg} from 'sentry-test/initializeOrg';
 import {act} from 'sentry-test/reactTestingLibrary';
 
@@ -34,7 +36,7 @@ describe('PageFilters ActionCreators', function () {
     const key = `global-selection:${organization.slug}`;
 
     beforeEach(() => {
-      router = TestStubs.router();
+      router = RouterFixture();
       localStorage.setItem(
         key,
         JSON.stringify({
@@ -424,7 +426,7 @@ describe('PageFilters ActionCreators', function () {
     });
 
     it('updates history when queries are different', function () {
-      const router = TestStubs.router({
+      const router = RouterFixture({
         location: {
           pathname: '/test/',
           query: {project: '2'},
@@ -440,7 +442,7 @@ describe('PageFilters ActionCreators', function () {
       });
     });
     it('does not update history when queries are the same', function () {
-      const router = TestStubs.router({
+      const router = RouterFixture({
         location: {
           pathname: '/test/',
           query: {project: '1'},
@@ -455,7 +457,7 @@ describe('PageFilters ActionCreators', function () {
     });
 
     it('updates history when queries are different with replace', function () {
-      const router = TestStubs.router({
+      const router = RouterFixture({
         location: {
           pathname: '/test/',
           query: {project: '2'},
@@ -470,7 +472,7 @@ describe('PageFilters ActionCreators', function () {
     });
 
     it('does not update history when queries are the same with replace', function () {
-      const router = TestStubs.router({
+      const router = RouterFixture({
         location: {
           pathname: '/test/',
           query: {project: '1'},
@@ -482,7 +484,7 @@ describe('PageFilters ActionCreators', function () {
     });
 
     it('does not override an absolute date selection', function () {
-      const router = TestStubs.router({
+      const router = RouterFixture({
         location: {
           pathname: '/test/',
           query: {project: '1', start: '2020-03-22T00:53:38', end: '2020-04-21T00:53:38'},
@@ -499,7 +501,7 @@ describe('PageFilters ActionCreators', function () {
 
   describe('updateEnvironments()', function () {
     it('updates single', function () {
-      const router = TestStubs.router({
+      const router = RouterFixture({
         location: {
           pathname: '/test/',
           query: {environment: 'test'},
@@ -514,7 +516,7 @@ describe('PageFilters ActionCreators', function () {
     });
 
     it('updates multiple', function () {
-      const router = TestStubs.router({
+      const router = RouterFixture({
         location: {
           pathname: '/test/',
           query: {environment: 'test'},
@@ -529,7 +531,7 @@ describe('PageFilters ActionCreators', function () {
     });
 
     it('removes environment', function () {
-      const router = TestStubs.router({
+      const router = RouterFixture({
         location: {
           pathname: '/test/',
           query: {environment: 'test'},
@@ -543,7 +545,7 @@ describe('PageFilters ActionCreators', function () {
     });
 
     it('does not override an absolute date selection', function () {
-      const router = TestStubs.router({
+      const router = RouterFixture({
         location: {
           pathname: '/test/',
           query: {
@@ -568,7 +570,7 @@ describe('PageFilters ActionCreators', function () {
 
   describe('updateDateTime()', function () {
     it('updates statsPeriod when there is no existing stats period', function () {
-      const router = TestStubs.router({
+      const router = RouterFixture({
         location: {
           pathname: '/test/',
           query: {},
@@ -585,7 +587,7 @@ describe('PageFilters ActionCreators', function () {
     });
 
     it('updates statsPeriod when there is an existing stats period', function () {
-      const router = TestStubs.router({
+      const router = RouterFixture({
         location: {
           pathname: '/test/',
           query: {statsPeriod: '14d'},
@@ -602,7 +604,7 @@ describe('PageFilters ActionCreators', function () {
     });
 
     it('changes to absolute date', function () {
-      const router = TestStubs.router({
+      const router = RouterFixture({
         location: {
           pathname: '/test/',
           query: {statsPeriod: '24h'},
@@ -622,7 +624,7 @@ describe('PageFilters ActionCreators', function () {
 
   describe('revertToPinnedFilters()', function () {
     it('reverts all filters that are desynced from localStorage', function () {
-      const router = TestStubs.router({
+      const router = RouterFixture({
         location: {
           pathname: '/test/',
           query: {},

+ 2 - 1
static/app/components/charts/releaseSeries.spec.tsx

@@ -1,4 +1,5 @@
 import {Organization} from 'sentry-fixture/organization';
+import RouterFixture from 'sentry-fixture/routerFixture';
 
 import {render, waitFor} from 'sentry-test/reactTestingLibrary';
 
@@ -25,7 +26,7 @@ describe('ReleaseSeries', function () {
     });
   });
 
-  const router = TestStubs.router();
+  const router = RouterFixture();
   const baseSeriesProps: ReleaseSeriesProps = {
     api: new MockApiClient(),
     organization: Organization(),

+ 2 - 1
static/app/components/globalSelectionLink.spec.tsx

@@ -1,4 +1,5 @@
 import RouterContextFixture from 'sentry-fixture/routerContextFixture';
+import RouterFixture from 'sentry-fixture/routerFixture';
 
 import {render, screen, userEvent} from 'sentry-test/reactTestingLibrary';
 
@@ -10,7 +11,7 @@ describe('GlobalSelectionLink', function () {
   const getContext = (query?: {environment: string; project: string[]}) =>
     RouterContextFixture([
       {
-        router: TestStubs.router({
+        router: RouterFixture({
           location: {query},
         }),
       },

+ 2 - 1
static/app/components/modals/commandPalette.spec.tsx

@@ -2,6 +2,7 @@ import {Members} from 'sentry-fixture/members';
 import {Organization} from 'sentry-fixture/organization';
 import {Project as ProjectFixture} from 'sentry-fixture/project';
 import RouterContextFixture from 'sentry-fixture/routerContextFixture';
+import RouterFixture from 'sentry-fixture/routerFixture';
 import {Team} from 'sentry-fixture/team';
 
 import {render, screen, userEvent} from 'sentry-test/reactTestingLibrary';
@@ -97,7 +98,7 @@ describe('Command Palette Modal', function () {
       {
         context: RouterContextFixture([
           {
-            router: TestStubs.router({
+            router: RouterFixture({
               params: {orgId: 'org-slug'},
             }),
           },

+ 11 - 10
static/app/views/acceptOrganizationInvite/index.spec.tsx

@@ -1,6 +1,7 @@
 import {browserHistory} from 'react-router';
 import {Config as ConfigFixture} from 'sentry-fixture/config';
 import {Organization} from 'sentry-fixture/organization';
+import RouteComponentPropsFixture from 'sentry-fixture/routeComponentPropsFixture';
 
 import {render, screen, userEvent, waitFor} from 'sentry-test/reactTestingLibrary';
 
@@ -43,7 +44,7 @@ describe('AcceptOrganizationInvite', function () {
 
     render(
       <AcceptOrganizationInvite
-        {...TestStubs.routeComponentProps()}
+        {...RouteComponentPropsFixture()}
         params={{orgId: 'org-slug', memberId: '1', token: 'abc'}}
       />
     );
@@ -84,7 +85,7 @@ describe('AcceptOrganizationInvite', function () {
 
     render(
       <AcceptOrganizationInvite
-        {...TestStubs.routeComponentProps()}
+        {...RouteComponentPropsFixture()}
         params={{memberId: '1', token: 'abc'}}
       />
     );
@@ -113,7 +114,7 @@ describe('AcceptOrganizationInvite', function () {
 
     render(
       <AcceptOrganizationInvite
-        {...TestStubs.routeComponentProps()}
+        {...RouteComponentPropsFixture()}
         params={{orgId: 'org-slug', memberId: '1', token: 'abc'}}
       />
     );
@@ -144,7 +145,7 @@ describe('AcceptOrganizationInvite', function () {
 
     render(
       <AcceptOrganizationInvite
-        {...TestStubs.routeComponentProps()}
+        {...RouteComponentPropsFixture()}
         params={{orgId: 'org-slug', memberId: '1', token: 'abc'}}
       />
     );
@@ -176,7 +177,7 @@ describe('AcceptOrganizationInvite', function () {
 
     render(
       <AcceptOrganizationInvite
-        {...TestStubs.routeComponentProps()}
+        {...RouteComponentPropsFixture()}
         params={{orgId: 'org-slug', memberId: '1', token: 'abc'}}
       />
     );
@@ -208,7 +209,7 @@ describe('AcceptOrganizationInvite', function () {
 
     render(
       <AcceptOrganizationInvite
-        {...TestStubs.routeComponentProps()}
+        {...RouteComponentPropsFixture()}
         params={{orgId: 'org-slug', memberId: '1', token: 'abc'}}
       />
     );
@@ -240,7 +241,7 @@ describe('AcceptOrganizationInvite', function () {
 
     render(
       <AcceptOrganizationInvite
-        {...TestStubs.routeComponentProps()}
+        {...RouteComponentPropsFixture()}
         params={{orgId: 'org-slug', memberId: '1', token: 'abc'}}
       />
     );
@@ -266,7 +267,7 @@ describe('AcceptOrganizationInvite', function () {
 
     render(
       <AcceptOrganizationInvite
-        {...TestStubs.routeComponentProps()}
+        {...RouteComponentPropsFixture()}
         params={{orgId: 'org-slug', memberId: '1', token: 'abc'}}
       />
     );
@@ -288,7 +289,7 @@ describe('AcceptOrganizationInvite', function () {
 
     render(
       <AcceptOrganizationInvite
-        {...TestStubs.routeComponentProps()}
+        {...RouteComponentPropsFixture()}
         params={{orgId: 'org-slug', memberId: '1', token: 'abc'}}
       />
     );
@@ -312,7 +313,7 @@ describe('AcceptOrganizationInvite', function () {
 
     render(
       <AcceptOrganizationInvite
-        {...TestStubs.routeComponentProps()}
+        {...RouteComponentPropsFixture()}
         params={{orgId: 'org-slug', memberId: '1', token: 'abc'}}
       />
     );

+ 3 - 2
static/app/views/alerts/create.spec.tsx

@@ -5,6 +5,7 @@ import LocationFixture from 'sentry-fixture/locationFixture';
 import {Organization} from 'sentry-fixture/organization';
 import {ProjectAlertRule} from 'sentry-fixture/projectAlertRule';
 import {ProjectAlertRuleConfiguration} from 'sentry-fixture/projectAlertRuleConfiguration';
+import RouteComponentPropsFixture from 'sentry-fixture/routeComponentPropsFixture';
 
 import {initializeOrg} from 'sentry-test/initializeOrg';
 import {render, screen, userEvent, waitFor} from 'sentry-test/reactTestingLibrary';
@@ -86,13 +87,13 @@ describe('ProjectAlertsCreate', function () {
     const wrapper = render(
       <AlertsContainer>
         <AlertBuilderProjectProvider
-          {...TestStubs.routeComponentProps()}
+          {...RouteComponentPropsFixture()}
           params={params}
           organization={organization}
           hasMetricAlerts={false}
         >
           <ProjectAlertsCreate
-            {...TestStubs.routeComponentProps()}
+            {...RouteComponentPropsFixture()}
             hasMetricAlerts={false}
             members={[]}
             params={params}

+ 2 - 1
static/app/views/alerts/list/header.spec.tsx

@@ -1,4 +1,5 @@
 import {Project as ProjectFixture} from 'sentry-fixture/project';
+import RouterFixture from 'sentry-fixture/routerFixture';
 
 import {initializeOrg} from 'sentry-test/initializeOrg';
 import {render, screen} from 'sentry-test/reactTestingLibrary';
@@ -30,7 +31,7 @@ describe('AlertHeader', () => {
   });
 
   it('should pass global selection project to create alert button', () => {
-    render(<AlertHeader activeTab="stream" router={TestStubs.router()} />, {
+    render(<AlertHeader activeTab="stream" router={RouterFixture()} />, {
       context: routerContext,
       organization,
     });

+ 4 - 3
static/app/views/alerts/rules/issue/index.spec.tsx

@@ -5,6 +5,7 @@ import {Environments as EnvironmentsFixture} from 'sentry-fixture/environments';
 import {Project as ProjectFixture} from 'sentry-fixture/project';
 import {ProjectAlertRule} from 'sentry-fixture/projectAlertRule';
 import {ProjectAlertRuleConfiguration} from 'sentry-fixture/projectAlertRuleConfiguration';
+import RouteComponentPropsFixture from 'sentry-fixture/routeComponentPropsFixture';
 
 import {initializeOrg} from 'sentry-test/initializeOrg';
 import {
@@ -88,14 +89,14 @@ const createWrapper = (props = {}) => {
   const onChangeTitleMock = jest.fn();
   const wrapper = render(
     <ProjectAlerts
-      {...TestStubs.routeComponentProps()}
+      {...RouteComponentPropsFixture()}
       organization={organization}
       project={project}
       params={params}
     >
       <IssueRuleEditor
-        route={TestStubs.routeComponentProps().route}
-        routeParams={TestStubs.routeComponentProps().routeParams}
+        route={RouteComponentPropsFixture().route}
+        routeParams={RouteComponentPropsFixture().routeParams}
         params={params}
         location={router.location}
         routes={projectAlertRuleDetailsRoutes}

+ 2 - 1
static/app/views/alerts/rules/metric/create.spec.tsx

@@ -1,5 +1,6 @@
 import {EventsStats} from 'sentry-fixture/events';
 import LocationFixture from 'sentry-fixture/locationFixture';
+import RouteComponentPropsFixture from 'sentry-fixture/routeComponentPropsFixture';
 
 import {initializeOrg} from 'sentry-test/initializeOrg';
 import {render} from 'sentry-test/reactTestingLibrary';
@@ -50,7 +51,7 @@ describe('Incident Rules Create', function () {
 
     render(
       <MetricRulesCreate
-        {...TestStubs.routeComponentProps()}
+        {...RouteComponentPropsFixture()}
         eventView={EventView.fromLocation(LocationFixture())}
         params={{projectId: project.slug}}
         organization={organization}

+ 4 - 3
static/app/views/alerts/rules/metric/edit.spec.tsx

@@ -1,5 +1,6 @@
 import {Member as MemberFixture} from 'sentry-fixture/member';
 import {MetricRule as MetricRuleFixture} from 'sentry-fixture/metricRule';
+import RouteComponentPropsFixture from 'sentry-fixture/routeComponentPropsFixture';
 
 import {initializeOrg} from 'sentry-test/initializeOrg';
 import {render, screen, userEvent} from 'sentry-test/reactTestingLibrary';
@@ -81,7 +82,7 @@ describe('MetricRulesEdit', function () {
 
     render(
       <MetricRulesEdit
-        {...TestStubs.routeComponentProps()}
+        {...RouteComponentPropsFixture()}
         params={{
           projectId: project.slug,
           ruleId: rule.id!,
@@ -176,7 +177,7 @@ describe('MetricRulesEdit', function () {
 
     render(
       <MetricRulesEdit
-        {...TestStubs.routeComponentProps()}
+        {...RouteComponentPropsFixture()}
         params={{
           projectId: project.slug,
           ruleId: rule.id!,
@@ -235,7 +236,7 @@ describe('MetricRulesEdit', function () {
 
     render(
       <MetricRulesEdit
-        {...TestStubs.routeComponentProps()}
+        {...RouteComponentPropsFixture()}
         userTeamIds={[]}
         onChangeTitle={() => {}}
         params={{

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