Browse Source

ref(ts): Remove most usage of `TestStubs.Project` (#62014)

I ran out of steam before finishing them all, there's a couple hundred
left. This makes a good dent, though! Adds to
https://github.com/getsentry/frontend-tsc/issues/49

## Changes

- Replace `TestStubs.Project` with fixture import
- Always pass string project ID
- Replace incorrect `firstEvent`
- Parse project ID to integer where needed
- Always pass as string
- Remove unnecessary key
- Use full `Organization` fixture
George Gritsouk 1 year ago
parent
commit
78a6d86381

+ 4 - 3
static/app/actionCreators/onboardingTasks.spec.tsx

@@ -1,4 +1,5 @@
 import {Organization} from 'sentry-fixture/organization';
 import {Organization} from 'sentry-fixture/organization';
+import {Project as ProjectFixture} from 'sentry-fixture/project';
 import {Team} from 'sentry-fixture/team';
 import {Team} from 'sentry-fixture/team';
 
 
 import {updateOnboardingTask} from 'sentry/actionCreators/onboardingTasks';
 import {updateOnboardingTask} from 'sentry/actionCreators/onboardingTasks';
@@ -16,7 +17,7 @@ describe('actionCreators/onboardingTasks', function () {
     it('Adds the task to the organization when task does not exists', async function () {
     it('Adds the task to the organization when task does not exists', async function () {
       const detailedOrg = Organization({
       const detailedOrg = Organization({
         teams: [Team()],
         teams: [Team()],
-        projects: [TestStubs.Project()],
+        projects: [ProjectFixture()],
       });
       });
 
 
       // User is not passed into the update request
       // User is not passed into the update request
@@ -44,7 +45,7 @@ describe('actionCreators/onboardingTasks', function () {
     it('Updates existing onboarding task', async function () {
     it('Updates existing onboarding task', async function () {
       const detailedOrg = Organization({
       const detailedOrg = Organization({
         teams: [Team()],
         teams: [Team()],
-        projects: [TestStubs.Project()],
+        projects: [ProjectFixture()],
         onboardingTasks: [{task: OnboardingTaskKey.FIRST_EVENT, status: 'skipped'}],
         onboardingTasks: [{task: OnboardingTaskKey.FIRST_EVENT, status: 'skipped'}],
       });
       });
 
 
@@ -75,7 +76,7 @@ describe('actionCreators/onboardingTasks', function () {
     it('Does not make API request without api object', async function () {
     it('Does not make API request without api object', async function () {
       const detailedOrg = Organization({
       const detailedOrg = Organization({
         teams: [Team()],
         teams: [Team()],
-        projects: [TestStubs.Project()],
+        projects: [ProjectFixture()],
       });
       });
 
 
       const testTask = {
       const testTask = {

+ 2 - 1
static/app/actionCreators/organization.spec.tsx

@@ -1,4 +1,5 @@
 import {Organization} from 'sentry-fixture/organization';
 import {Organization} from 'sentry-fixture/organization';
+import {Project as ProjectFixture} from 'sentry-fixture/project';
 import {Team} from 'sentry-fixture/team';
 import {Team} from 'sentry-fixture/team';
 
 
 import {fetchOrganizationDetails} from 'sentry/actionCreators/organization';
 import {fetchOrganizationDetails} from 'sentry/actionCreators/organization';
@@ -12,7 +13,7 @@ describe('OrganizationActionCreator', function () {
   const org = Organization();
   const org = Organization();
 
 
   const teams = [Team()];
   const teams = [Team()];
-  const projects = [TestStubs.Project()];
+  const projects = [ProjectFixture()];
 
 
   const api = new MockApiClient();
   const api = new MockApiClient();
 
 

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

@@ -1,4 +1,5 @@
 import {Organization} from 'sentry-fixture/organization';
 import {Organization} from 'sentry-fixture/organization';
+import {Project as ProjectFixture} from 'sentry-fixture/project';
 import RouterContextFixture from 'sentry-fixture/routerContextFixture';
 import RouterContextFixture from 'sentry-fixture/routerContextFixture';
 import {Team} from 'sentry-fixture/team';
 import {Team} from 'sentry-fixture/team';
 import {User} from 'sentry-fixture/user';
 import {User} from 'sentry-fixture/user';
@@ -86,7 +87,7 @@ describe('Access', function () {
       const org = Organization({access: []});
       const org = Organization({access: []});
       const nextRouterContext = RouterContextFixture([{organization: org}]);
       const nextRouterContext = RouterContextFixture([{organization: org}]);
 
 
-      const proj1 = TestStubs.Project({access: []});
+      const proj1 = ProjectFixture({access: []});
       render(
       render(
         <Access access={['project:read']} project={proj1}>
         <Access access={['project:read']} project={proj1}>
           {childrenMock}
           {childrenMock}
@@ -101,7 +102,7 @@ describe('Access', function () {
         })
         })
       );
       );
 
 
-      const proj2 = TestStubs.Project({access: ['project:read']});
+      const proj2 = ProjectFixture({access: ['project:read']});
       render(
       render(
         <Access access={['project:read']} project={proj2}>
         <Access access={['project:read']} project={proj2}>
           {childrenMock}
           {childrenMock}

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

@@ -1,4 +1,5 @@
 import {Organization} from 'sentry-fixture/organization';
 import {Organization} from 'sentry-fixture/organization';
+import {Project as ProjectFixture} from 'sentry-fixture/project';
 import RouterContextFixture from 'sentry-fixture/routerContextFixture';
 import RouterContextFixture from 'sentry-fixture/routerContextFixture';
 
 
 import {render, screen} from 'sentry-test/reactTestingLibrary';
 import {render, screen} from 'sentry-test/reactTestingLibrary';
@@ -11,7 +12,7 @@ describe('Feature', function () {
   const organization = Organization({
   const organization = Organization({
     features: ['org-foo', 'org-bar', 'bar'],
     features: ['org-foo', 'org-bar', 'bar'],
   });
   });
-  const project = TestStubs.Project({
+  const project = ProjectFixture({
     features: ['project-foo', 'project-bar'],
     features: ['project-foo', 'project-bar'],
   });
   });
   const routerContext = RouterContextFixture([
   const routerContext = RouterContextFixture([
@@ -114,7 +115,7 @@ describe('Feature', function () {
     });
     });
 
 
     it('can specify project from props', function () {
     it('can specify project from props', function () {
-      const customProject = TestStubs.Project({features: ['project-baz']});
+      const customProject = ProjectFixture({features: ['project-baz']});
       render(
       render(
         <Feature project={customProject} features="project-baz">
         <Feature project={customProject} features="project-baz">
           {childrenMock}
           {childrenMock}

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

@@ -1,3 +1,4 @@
+import {Project as ProjectFixture} from 'sentry-fixture/project';
 import RouterContextFixture from 'sentry-fixture/routerContextFixture';
 import RouterContextFixture from 'sentry-fixture/routerContextFixture';
 import {Team} from 'sentry-fixture/team';
 import {Team} from 'sentry-fixture/team';
 import {User} from 'sentry-fixture/user';
 import {User} from 'sentry-fixture/user';
@@ -56,7 +57,7 @@ describe('AssigneeSelector', () => {
       slug: 'cool-team',
       slug: 'cool-team',
     });
     });
 
 
-    PROJECT_1 = TestStubs.Project({
+    PROJECT_1 = ProjectFixture({
       teams: [TEAM_1],
       teams: [TEAM_1],
     });
     });
 
 

+ 4 - 4
static/app/components/avatar/index.spec.tsx

@@ -1,4 +1,5 @@
 import {Organization} from 'sentry-fixture/organization';
 import {Organization} from 'sentry-fixture/organization';
+import {Project as ProjectFixture} from 'sentry-fixture/project';
 import {SentryApp} from 'sentry-fixture/sentryApp';
 import {SentryApp} from 'sentry-fixture/sentryApp';
 import {Team} from 'sentry-fixture/team';
 import {Team} from 'sentry-fixture/team';
 
 
@@ -174,8 +175,7 @@ describe('Avatar', function () {
     });
     });
 
 
     it('displays platform list icons for project Avatar', function () {
     it('displays platform list icons for project Avatar', function () {
-      const project = TestStubs.Project({
-        platforms: ['python', 'javascript'],
+      const project = ProjectFixture({
         platform: 'java',
         platform: 'java',
       });
       });
 
 
@@ -190,7 +190,7 @@ describe('Avatar', function () {
     });
     });
 
 
     it('displays a fallback platform list for project Avatar using the `platform` specified during onboarding', function () {
     it('displays a fallback platform list for project Avatar using the `platform` specified during onboarding', function () {
-      const project = TestStubs.Project({platform: 'java'});
+      const project = ProjectFixture({platform: 'java'});
 
 
       render(<AvatarComponent project={project} />);
       render(<AvatarComponent project={project} />);
 
 
@@ -203,7 +203,7 @@ describe('Avatar', function () {
     });
     });
 
 
     it('uses onboarding project when platforms is an empty array', function () {
     it('uses onboarding project when platforms is an empty array', function () {
-      const project = TestStubs.Project({platforms: [], platform: 'java'});
+      const project = ProjectFixture({platform: 'java'});
 
 
       render(<AvatarComponent project={project} />);
       render(<AvatarComponent project={project} />);
 
 

+ 4 - 2
static/app/components/charts/intervalSelector.spec.tsx

@@ -1,3 +1,5 @@
+import {Project as ProjectFixture} from 'sentry-fixture/project';
+
 import {render} from 'sentry-test/reactTestingLibrary';
 import {render} from 'sentry-test/reactTestingLibrary';
 
 
 import IntervalSelector from 'sentry/components/charts/intervalSelector';
 import IntervalSelector from 'sentry/components/charts/intervalSelector';
@@ -5,13 +7,13 @@ import EventView from 'sentry/utils/discover/eventView';
 import {DisplayModes} from 'sentry/utils/discover/types';
 import {DisplayModes} from 'sentry/utils/discover/types';
 
 
 describe('IntervalSelector', function () {
 describe('IntervalSelector', function () {
-  const project = TestStubs.Project();
+  const project = ProjectFixture();
   const eventView = EventView.fromSavedQuery({
   const eventView = EventView.fromSavedQuery({
     id: '',
     id: '',
     name: 'test query',
     name: 'test query',
     version: 2,
     version: 2,
     fields: ['transaction', 'count()'],
     fields: ['transaction', 'count()'],
-    projects: [project.id],
+    projects: [parseInt(project.id, 10)],
   });
   });
   it('resets small interval', function () {
   it('resets small interval', function () {
     let interval: string | undefined = '1s';
     let interval: string | undefined = '1s';

+ 5 - 4
static/app/components/contextPickerModal.spec.tsx

@@ -1,5 +1,6 @@
 import selectEvent from 'react-select-event';
 import selectEvent from 'react-select-event';
 import {Organization} from 'sentry-fixture/organization';
 import {Organization} from 'sentry-fixture/organization';
+import {Project as ProjectFixture} from 'sentry-fixture/project';
 import {User} from 'sentry-fixture/user';
 import {User} from 'sentry-fixture/user';
 
 
 import {render, screen, waitFor} from 'sentry-test/reactTestingLibrary';
 import {render, screen, waitFor} from 'sentry-test/reactTestingLibrary';
@@ -23,14 +24,14 @@ describe('ContextPickerModal', function () {
     ProjectsStore.reset();
     ProjectsStore.reset();
     MockApiClient.clearMockResponses();
     MockApiClient.clearMockResponses();
 
 
-    project = TestStubs.Project();
+    project = ProjectFixture();
     org = Organization({projects: [project]});
     org = Organization({projects: [project]});
-    project2 = TestStubs.Project({slug: 'project2'});
+    project2 = ProjectFixture({slug: 'project2'});
     org2 = Organization({
     org2 = Organization({
       slug: 'org2',
       slug: 'org2',
       id: '21',
       id: '21',
     });
     });
-    project4 = TestStubs.Project({slug: 'project4', isMember: false});
+    project4 = ProjectFixture({slug: 'project4', isMember: false});
 
 
     OrganizationsStore.load([]);
     OrganizationsStore.load([]);
     OrganizationStore.reset();
     OrganizationStore.reset();
@@ -151,7 +152,7 @@ describe('ContextPickerModal', function () {
       },
       },
       {
       {
         ...org2,
         ...org2,
-        projects: [project2, TestStubs.Project({slug: 'project3'})],
+        projects: [project2, ProjectFixture({slug: 'project3'})],
       },
       },
     ];
     ];
     const fetchProjectsForOrg = MockApiClient.addMockResponse({
     const fetchProjectsForOrg = MockApiClient.addMockResponse({

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

@@ -1,4 +1,5 @@
 import {Organization} from 'sentry-fixture/organization';
 import {Organization} from 'sentry-fixture/organization';
+import {Project as ProjectFixture} from 'sentry-fixture/project';
 import RouterContextFixture from 'sentry-fixture/routerContextFixture';
 import RouterContextFixture from 'sentry-fixture/routerContextFixture';
 
 
 import {render, screen, userEvent} from 'sentry-test/reactTestingLibrary';
 import {render, screen, userEvent} from 'sentry-test/reactTestingLibrary';
@@ -25,7 +26,7 @@ describe('ErrorRobot', function () {
 
 
   describe('with a project', function () {
   describe('with a project', function () {
     function createWrapper() {
     function createWrapper() {
-      return render(<ErrorRobot org={Organization()} project={TestStubs.Project()} />, {
+      return render(<ErrorRobot org={Organization()} project={ProjectFixture()} />, {
         context: routerContext,
         context: routerContext,
       });
       });
     }
     }

+ 2 - 1
static/app/components/events/contexts/profile/index.spec.tsx

@@ -1,5 +1,6 @@
 import {Event as EventFixture} from 'sentry-fixture/event';
 import {Event as EventFixture} from 'sentry-fixture/event';
 import {Organization} from 'sentry-fixture/organization';
 import {Organization} from 'sentry-fixture/organization';
+import {Project as ProjectFixture} from 'sentry-fixture/project';
 
 
 import {act, render, screen} from 'sentry-test/reactTestingLibrary';
 import {act, render, screen} from 'sentry-test/reactTestingLibrary';
 
 
@@ -17,7 +18,7 @@ const profileContext = {
 };
 };
 
 
 const event = EventFixture();
 const event = EventFixture();
-const project = TestStubs.Project();
+const project = ProjectFixture();
 
 
 describe('profile event context', function () {
 describe('profile event context', function () {
   beforeEach(function () {
   beforeEach(function () {

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