Browse Source

ref(ts): Remove usage of `TestStubs.Group` (#62028)

This one needed some changes, but it's mostly just using the right enums
for types, and correct strings/integers.

Contributes to https://github.com/getsentry/frontend-tsc/issues/49
George Gritsouk 1 year ago
parent
commit
30752f258e

+ 4 - 3
static/app/components/group/assignedTo.spec.tsx

@@ -1,6 +1,7 @@
 import {Commit} from 'sentry-fixture/commit';
 import {CommitAuthor} from 'sentry-fixture/commitAuthor';
 import {Event as EventFixture} from 'sentry-fixture/event';
+import {Group as GroupFixture} from 'sentry-fixture/group';
 import {Organization} from 'sentry-fixture/organization';
 import {Project as ProjectFixture} from 'sentry-fixture/project';
 import {Team} from 'sentry-fixture/team';
@@ -55,12 +56,12 @@ describe('Group > AssignedTo', () => {
       teams: [TEAM_1],
     });
 
-    GROUP_1 = TestStubs.Group({
+    GROUP_1 = GroupFixture({
       id: '1337',
-      project: {
+      project: ProjectFixture({
         id: PROJECT_1.id,
         slug: PROJECT_1.slug,
-      },
+      }),
     });
     event = EventFixture();
 

+ 2 - 1
static/app/components/group/externalIssueForm.spec.tsx

@@ -1,4 +1,5 @@
 import styled from '@emotion/styled';
+import {Group as GroupFixture} from 'sentry-fixture/group';
 import {Organization} from 'sentry-fixture/organization';
 
 import {render, screen, userEvent} from 'sentry-test/reactTestingLibrary';
@@ -30,7 +31,7 @@ describe('ExternalIssueForm', () => {
   const onChange = jest.fn();
   beforeEach(() => {
     MockApiClient.clearMockResponses();
-    group = TestStubs.Group();
+    group = GroupFixture();
     integration = TestStubs.GitHubIntegration({externalIssues: []});
   });
 

+ 3 - 1
static/app/components/group/externalIssuesList/externalIssueActions.spec.tsx

@@ -1,3 +1,5 @@
+import {Group as GroupFixture} from 'sentry-fixture/group';
+
 import {
   render,
   renderGlobalModal,
@@ -8,7 +10,7 @@ import {
 import ExternalIssueActions from 'sentry/components/group/externalIssuesList/externalIssueActions';
 
 describe('ExternalIssueActions', function () {
-  const group = TestStubs.Group();
+  const group = GroupFixture();
 
   afterEach(() => {
     MockApiClient.clearMockResponses();

+ 4 - 3
static/app/components/group/releaseStats.spec.tsx

@@ -1,3 +1,4 @@
+import {Group as GroupFixture} from 'sentry-fixture/group';
 import {Organization} from 'sentry-fixture/organization';
 import {Project as ProjectFixture} from 'sentry-fixture/project';
 
@@ -8,12 +9,12 @@ import GroupReleaseStats from 'sentry/components/group/releaseStats';
 describe('GroupReleaseStats', function () {
   const organization = Organization();
   const project = ProjectFixture();
-  const group = TestStubs.Group();
+  const group = GroupFixture();
 
   beforeEach(() => {
     MockApiClient.addMockResponse({
       url: `/organizations/${organization.slug}/issues/${group.id}/first-last-release/`,
-      body: {firstRelease: group.firstRelease, lastRelease: group.lastRelease},
+      body: {id: group.id, firstRelease: undefined, lastRelease: undefined},
     });
   });
 
@@ -25,7 +26,7 @@ describe('GroupReleaseStats', function () {
         group={group}
         project={project}
         organization={organization}
-        allEnvironments={TestStubs.Group()}
+        allEnvironments={GroupFixture()}
         environments={[]}
         {...props}
       />

+ 2 - 1
static/app/components/group/sentryAppExternalIssueActions.spec.tsx

@@ -1,4 +1,5 @@
 import {Event as EventFixture} from 'sentry-fixture/event';
+import {Group as GroupFixture} from 'sentry-fixture/group';
 import {Organization} from 'sentry-fixture/organization';
 import {SentryApp} from 'sentry-fixture/sentryApp';
 import {SentryAppInstallation} from 'sentry-fixture/sentryAppInstallation';
@@ -13,7 +14,7 @@ import {
 import SentryAppExternalIssueActions from 'sentry/components/group/sentryAppExternalIssueActions';
 
 describe('SentryAppExternalIssueActions', () => {
-  const group = TestStubs.Group();
+  const group = GroupFixture();
   const sentryApp = SentryApp();
   const component = TestStubs.SentryAppComponent({
     sentryApp: {

+ 4 - 3
static/app/components/group/sentryAppExternalIssueForm.spec.tsx

@@ -1,5 +1,6 @@
 import selectEvent from 'react-select-event';
 import {Event as EventFixture} from 'sentry-fixture/event';
+import {Group as GroupFixture} from 'sentry-fixture/group';
 import {SentryApp} from 'sentry-fixture/sentryApp';
 import {SentryAppInstallation} from 'sentry-fixture/sentryAppInstallation';
 
@@ -9,7 +10,7 @@ import SentryAppExternalIssueForm from 'sentry/components/group/sentryAppExterna
 import {addQueryParamsToExistingUrl} from 'sentry/utils/queryString';
 
 describe('SentryAppExternalIssueForm', () => {
-  const group = TestStubs.Group({
+  const group = GroupFixture({
     title: 'ApiError: Broken',
     shortId: 'SEN123',
     permalink: 'https://sentry.io/organizations/sentry/issues/123/?project=1',
@@ -149,7 +150,7 @@ describe('SentryAppExternalIssueForm', () => {
 
 describe('SentryAppExternalIssueForm Async Field', () => {
   const component = TestStubs.SentryAppComponentAsync();
-  const group = TestStubs.Group({
+  const group = GroupFixture({
     title: 'ApiError: Broken',
     shortId: 'SEN123',
     permalink: 'https://sentry.io/organizations/sentry/issues/123/?project=1',
@@ -195,7 +196,7 @@ describe('SentryAppExternalIssueForm Async Field', () => {
 });
 
 describe('SentryAppExternalIssueForm Dependent fields', () => {
-  const group = TestStubs.Group({
+  const group = GroupFixture({
     title: 'ApiError: Broken',
     shortId: 'SEN123',
     permalink: 'https://sentry.io/organizations/sentry/issues/123/?project=1',

+ 11 - 5
static/app/components/stream/group.spec.tsx

@@ -1,3 +1,4 @@
+import {Group as GroupFixture} from 'sentry-fixture/group';
 import {Project as ProjectFixture} from 'sentry-fixture/project';
 
 import {initializeOrg} from 'sentry-test/initializeOrg';
@@ -6,7 +7,12 @@ import {act, render, screen, userEvent} from 'sentry-test/reactTestingLibrary';
 import StreamGroup from 'sentry/components/stream/group';
 import GroupStore from 'sentry/stores/groupStore';
 import GuideStore from 'sentry/stores/guideStore';
-import {GroupStatus, GroupStatusResolution, MarkReviewed} from 'sentry/types';
+import {
+  EventOrGroupType,
+  GroupStatus,
+  GroupStatusResolution,
+  MarkReviewed,
+} from 'sentry/types';
 import {trackAnalytics} from 'sentry/utils/analytics';
 
 jest.mock('sentry/utils/analytics');
@@ -15,13 +21,13 @@ describe('StreamGroup', function () {
   let group1;
 
   beforeEach(function () {
-    group1 = TestStubs.Group({
+    group1 = GroupFixture({
       id: '1337',
-      project: {
+      project: ProjectFixture({
         id: '13',
         slug: 'foo-project',
-      },
-      type: 'error',
+      }),
+      type: EventOrGroupType.ERROR,
       inbox: {
         date_added: '2020-11-24T13:17:42.248751Z',
         reason: 0,

+ 5 - 2
static/app/utils/dashboards/issueFieldRenderers.spec.tsx

@@ -1,3 +1,4 @@
+import {Group as GroupFixture} from 'sentry-fixture/group';
 import {Project as ProjectFixture} from 'sentry-fixture/project';
 import {User} from 'sentry-fixture/user';
 
@@ -84,11 +85,13 @@ describe('getIssueFieldRenderer', function () {
         }),
       ]);
 
-      const group = TestStubs.Group({project});
+      const group = GroupFixture({project});
       GroupStore.add([
         {
           ...group,
-          owners: [{owner: 'user:1', type: 'suspectCommit'}],
+          owners: [
+            {owner: 'user:1', type: 'suspectCommit', date_added: '2020-01-01T00:00:00'},
+          ],
           assignedTo: {
             email: 'test@sentry.io',
             type: 'user',

+ 3 - 2
static/app/views/alerts/rules/metric/details/index.spec.tsx

@@ -1,4 +1,5 @@
 import {EventsStats} from 'sentry-fixture/events';
+import {Group as GroupFixture} from 'sentry-fixture/group';
 import {Incident} from 'sentry-fixture/incident';
 import {Project as ProjectFixture} from 'sentry-fixture/project';
 
@@ -30,7 +31,7 @@ describe('MetricAlertDetails', () => {
     });
     MockApiClient.addMockResponse({
       url: '/organizations/org-slug/issues/?end=2017-10-17T02%3A41%3A20&groupStatsPeriod=auto&limit=5&project=2&query=event.type%3Aerror&sort=freq&start=2017-10-10T02%3A41%3A20',
-      body: [TestStubs.Group()],
+      body: [GroupFixture()],
     });
   });
 
@@ -101,7 +102,7 @@ describe('MetricAlertDetails', () => {
     // Related issues to the selected incident
     const issuesRequest = MockApiClient.addMockResponse({
       url: '/organizations/org-slug/issues/?end=2016-04-26T19%3A44%3A05&groupStatsPeriod=auto&limit=5&project=2&query=event.type%3Aerror&sort=freq&start=2016-03-29T19%3A44%3A05',
-      body: [TestStubs.Group()],
+      body: [GroupFixture()],
     });
 
     render(

+ 12 - 9
static/app/views/discover/table/quickContext/issueContext.spec.tsx

@@ -1,28 +1,31 @@
+import {Group as GroupFixture} from 'sentry-fixture/group';
 import {Organization} from 'sentry-fixture/organization';
+import {Project as ProjectFixture} from 'sentry-fixture/project';
 import {Repository} from 'sentry-fixture/repository';
 
 import {makeTestQueryClient} from 'sentry-test/queryClient';
 import {render, screen, userEvent} from 'sentry-test/reactTestingLibrary';
 
+import {GroupStatus} from 'sentry/types';
 import {EventData} from 'sentry/utils/discover/eventView';
 import {QueryClientProvider} from 'sentry/utils/queryClient';
 
 import IssueContext from './issueContext';
 import {defaultRow} from './testUtils';
 
-let mockedGroup = TestStubs.Group({
+const mockedGroup = GroupFixture({
   id: '3512441874',
-  project: {
+  project: ProjectFixture({
     id: '1',
     slug: 'cool-team',
-  },
-  status: 'ignored',
+  }),
+  status: GroupStatus.IGNORED,
   assignedTo: {
     id: '12312',
     name: 'ingest',
     type: 'team',
   },
-  count: 2500000,
+  count: '2500000',
   userCount: 64000,
   title: 'typeError: error description',
 });
@@ -75,11 +78,11 @@ describe('Quick Context Content Issue Column', function () {
   });
 
   it('Renders resolved issue status context', async () => {
-    mockedGroup = {...mockedGroup, status: 'resolved'};
+    const group = {...mockedGroup, status: GroupStatus.RESOLVED};
     MockApiClient.addMockResponse({
       url: '/issues/3512441874/',
       method: 'GET',
-      body: mockedGroup,
+      body: group,
     });
     renderIssueContext();
 
@@ -89,11 +92,11 @@ describe('Quick Context Content Issue Column', function () {
   });
 
   it('Renders unresolved issue status context', async () => {
-    mockedGroup = {...mockedGroup, status: 'unresolved'};
+    const group = {...mockedGroup, status: GroupStatus.UNRESOLVED};
     MockApiClient.addMockResponse({
       url: '/issues/3512441874/',
       method: 'GET',
-      body: mockedGroup,
+      body: group,
     });
 
     renderIssueContext();

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