Browse Source

test: Replace TestStubs.routerContext calls with RouterContextFixture imports (#61508)

Relates to https://github.com/getsentry/frontend-tsc/issues/49
Ryan Albrecht 1 year ago
parent
commit
f461c596fa

+ 4 - 3
static/app/components/acl/access.spec.tsx

@@ -1,4 +1,5 @@
 import {Organization} from 'sentry-fixture/organization';
+import RouterContextFixture from 'sentry-fixture/routerContextFixture';
 import {Team} from 'sentry-fixture/team';
 
 import {render, screen} from 'sentry-test/reactTestingLibrary';
@@ -10,7 +11,7 @@ describe('Access', function () {
   const organization = Organization({
     access: ['project:write', 'project:read'],
   });
-  const routerContext = TestStubs.routerContext([{organization}]);
+  const routerContext = RouterContextFixture([{organization}]);
 
   describe('as render prop', function () {
     const childrenMock = jest.fn().mockReturnValue(null);
@@ -45,7 +46,7 @@ describe('Access', function () {
 
     it('read access from team', function () {
       const org = Organization({access: []});
-      const nextRouterContext = TestStubs.routerContext([{organization: org}]);
+      const nextRouterContext = RouterContextFixture([{organization: org}]);
 
       const team1 = Team({access: []});
       render(
@@ -82,7 +83,7 @@ describe('Access', function () {
 
     it('read access from project', function () {
       const org = Organization({access: []});
-      const nextRouterContext = TestStubs.routerContext([{organization: org}]);
+      const nextRouterContext = RouterContextFixture([{organization: org}]);
 
       const proj1 = TestStubs.Project({access: []});
       render(

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

@@ -1,4 +1,5 @@
 import {Organization} from 'sentry-fixture/organization';
+import RouterContextFixture from 'sentry-fixture/routerContextFixture';
 
 import {render, screen} from 'sentry-test/reactTestingLibrary';
 
@@ -13,7 +14,7 @@ describe('Feature', function () {
   const project = TestStubs.Project({
     features: ['project-foo', 'project-bar'],
   });
-  const routerContext = TestStubs.routerContext([
+  const routerContext = RouterContextFixture([
     {
       organization,
       project,

+ 2 - 1
static/app/components/acl/role.spec.tsx

@@ -1,5 +1,6 @@
 import Cookies from 'js-cookie';
 import {Organization} from 'sentry-fixture/organization';
+import RouterContextFixture from 'sentry-fixture/routerContextFixture';
 
 import {render, screen} from 'sentry-test/reactTestingLibrary';
 
@@ -36,7 +37,7 @@ describe('Role', function () {
       },
     ],
   });
-  const routerContext = TestStubs.routerContext([
+  const routerContext = RouterContextFixture([
     {
       organization,
     },

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

@@ -1,3 +1,4 @@
+import RouterContextFixture from 'sentry-fixture/routerContextFixture';
 import {Team} from 'sentry-fixture/team';
 
 import {act, render, screen, userEvent, waitFor} from 'sentry-test/reactTestingLibrary';
@@ -286,7 +287,7 @@ describe('AssigneeSelector', () => {
   it('shows invite member button', async () => {
     MemberListStore.loadInitialData([USER_1, USER_2]);
     render(<AssigneeSelectorComponent id={GROUP_1.id} />, {
-      context: TestStubs.routerContext(),
+      context: RouterContextFixture(),
     });
     jest.spyOn(ConfigStore, 'get').mockImplementation(() => true);
 

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

@@ -1,9 +1,11 @@
+import RouterContextFixture from 'sentry-fixture/routerContextFixture';
+
 import {render, screen, userEvent} from 'sentry-test/reactTestingLibrary';
 
 import Breadcrumbs from 'sentry/components/breadcrumbs';
 
 describe('Breadcrumbs', () => {
-  const routerContext = TestStubs.routerContext();
+  const routerContext = RouterContextFixture();
 
   afterEach(() => {
     jest.resetAllMocks();

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

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

+ 6 - 5
static/app/components/createAlertButton.spec.tsx

@@ -1,4 +1,5 @@
 import {Organization} from 'sentry-fixture/organization';
+import RouterContextFixture from 'sentry-fixture/routerContextFixture';
 
 import {render, screen, userEvent} from 'sentry-test/reactTestingLibrary';
 
@@ -22,7 +23,7 @@ describe('CreateAlertFromViewButton', () => {
   });
 
   it('should trigger onClick callback', async () => {
-    const context = TestStubs.routerContext();
+    const context = RouterContextFixture();
 
     const eventView = EventView.fromSavedQuery({
       ...DEFAULT_EVENT_VIEW,
@@ -63,7 +64,7 @@ describe('CreateAlertFromViewButton', () => {
         onClick={onClickMock}
       />,
       {
-        context: TestStubs.routerContext([{organization: noAccessOrg}]),
+        context: RouterContextFixture([{organization: noAccessOrg}]),
         organization: noAccessOrg,
       }
     );
@@ -88,7 +89,7 @@ describe('CreateAlertFromViewButton', () => {
         onClick={onClickMock}
       />,
       {
-        context: TestStubs.routerContext([{organization}]),
+        context: RouterContextFixture([{organization}]),
         organization,
       }
     );
@@ -127,7 +128,7 @@ describe('CreateAlertFromViewButton', () => {
         onClick={onClickMock}
       />,
       {
-        context: TestStubs.routerContext([{organization: noAccessOrg}]),
+        context: RouterContextFixture([{organization: noAccessOrg}]),
         organization: noAccessOrg,
       }
     );
@@ -188,7 +189,7 @@ describe('CreateAlertFromViewButton', () => {
   });
 
   it('removes a duplicate project filter', async () => {
-    const context = TestStubs.routerContext();
+    const context = RouterContextFixture();
 
     const eventView = EventView.fromSavedQuery({
       ...DEFAULT_EVENT_VIEW,

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

@@ -1,4 +1,5 @@
 import {Organization} from 'sentry-fixture/organization';
+import RouterContextFixture from 'sentry-fixture/routerContextFixture';
 
 import {render, screen, userEvent, waitFor} from 'sentry-test/reactTestingLibrary';
 
@@ -22,7 +23,7 @@ const mockPayload = {
 };
 
 const mockRouterContext = (mockOrganization: TOrganization) =>
-  TestStubs.routerContext([
+  RouterContextFixture([
     {
       organization: mockOrganization,
     },

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

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

+ 3 - 1
static/app/components/discover/transactionsList.spec.tsx

@@ -1,3 +1,5 @@
+import RouterContextFixture from 'sentry-fixture/routerContextFixture';
+
 import {initializeOrg} from 'sentry-test/initializeOrg';
 import {
   render,
@@ -53,7 +55,7 @@ describe('TransactionsList', function () {
     let generateLink, routerContext;
 
     beforeEach(function () {
-      routerContext = TestStubs.routerContext([{organization}]);
+      routerContext = RouterContextFixture([{organization}]);
       initialize();
       eventView = EventView.fromSavedQuery({
         id: '',

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