Browse Source

test: Import from sentry-fixture inside test files [4] (#56813)

<!-- Describe your PR here. -->
Ryan Albrecht 1 year ago
parent
commit
eb0e851516

+ 1 - 24
fixtures/js-stubs/types.tsx

@@ -1,9 +1,5 @@
 import {EntryException} from 'sentry/types';
-import type {
-  ReplayError,
-  ReplayListRecord,
-  ReplayRecord,
-} from 'sentry/views/replays/types';
+import type {ReplayError, ReplayRecord} from 'sentry/views/replays/types';
 
 import type {Replay} from './replay';
 
@@ -54,32 +50,13 @@ type TestStubFixtures = {
   Release: (params?: any, healthParams?: any) => any;
   Replay: typeof Replay;
   ReplayError: OverridableStub<ReplayError>;
-  ReplayList: OverridableStubList<ReplayListRecord>;
   ReplayRecord: OverridableStub<ReplayRecord>;
   Repository: OverridableStub;
-  RepositoryProjectPathConfig: OverridableStub;
-  Search: OverridableStub;
-  Searches: OverridableStubList;
   SentryApp: OverridableStub;
   SentryAppComponent: OverridableStub;
   SentryAppComponentAsync: OverridableStub;
   SentryAppComponentDependent: OverridableStub;
   SentryAppInstallation: OverridableStub;
-  SentryAppInstalls: SimpleStub;
-  SentryAppToken: OverridableStub;
-  SentryAppWebhookRequest: OverridableStub;
-  ServiceIncident: OverridableStub;
-  SessionEmptyGroupedResponse: SimpleStub;
-  SessionStatusCountByProjectInPeriod: SimpleStub;
-  SessionStatusCountByReleaseInPeriod: SimpleStub;
-  SessionTotalCountByProjectIn24h: SimpleStub;
-  SessionUserCountByStatus: SimpleStub;
-  SessionUserCountByStatus2: SimpleStub;
-  SessionUserCountByStatusByRelease: SimpleStub;
-  SessionUserStatusCountByProjectInPeriod: SimpleStub;
-  SessionUserStatusCountByReleaseInPeriod: SimpleStub;
-  SessionsField: (field: string) => any;
-  SesssionTotalCountByReleaseIn24h: SimpleStub;
   ShortIdQueryResult: OverridableStub;
   SourceMapArchive: OverridableStub;
   SourceMapArtifact: OverridableStub;

+ 14 - 8
static/app/components/avatar/index.spec.tsx

@@ -1,3 +1,5 @@
+import {SentryApp} from 'sentry-fixture/sentryApp';
+
 import {render, screen} from 'sentry-test/reactTestingLibrary';
 
 import AvatarComponent from 'sentry/components/avatar';
@@ -210,10 +212,14 @@ describe('Avatar', function () {
     });
 
     it('renders the correct SentryApp depending on its props', async function () {
-      const colorAvatar = {avatarUuid: 'abc', avatarType: 'upload', color: true};
-      const simpleAvatar = {avatarUuid: 'def', avatarType: 'upload', color: false};
-
-      const sentryApp = TestStubs.SentryApp({
+      const colorAvatar = {avatarUuid: 'abc', avatarType: 'upload' as const, color: true};
+      const simpleAvatar = {
+        avatarUuid: 'def',
+        avatarType: 'upload' as const,
+        color: false,
+      };
+
+      const sentryApp = SentryApp({
         avatars: [colorAvatar, simpleAvatar],
       });
 
@@ -236,8 +242,8 @@ describe('Avatar', function () {
     });
 
     it('renders the correct fallbacks for SentryAppAvatars', async function () {
-      const colorAvatar = {avatarUuid: 'abc', avatarType: 'upload', color: true};
-      const sentryApp = TestStubs.SentryApp({avatars: []});
+      const colorAvatar = {avatarUuid: 'abc', avatarType: 'upload' as const, color: true};
+      const sentryApp = SentryApp({avatars: []});
 
       // No existing avatars
       const avatar1 = render(<AvatarComponent sentryApp={sentryApp} isColor />);
@@ -245,7 +251,7 @@ describe('Avatar', function () {
       avatar1.unmount();
 
       // No provided `isColor` attribute
-      sentryApp.avatars.push(colorAvatar);
+      sentryApp.avatars!.push(colorAvatar);
       const avatar2 = render(<AvatarComponent sentryApp={sentryApp} />);
       expect(await screen.findByRole('img')).toHaveAttribute(
         'src',
@@ -254,7 +260,7 @@ describe('Avatar', function () {
       avatar2.unmount();
 
       // avatarType of `default`
-      sentryApp.avatars[0].avatarType = 'default';
+      sentryApp.avatars![0].avatarType = 'default';
       render(<AvatarComponent sentryApp={sentryApp} isColor />);
       expect(screen.getByTestId('default-sentry-app-avatar')).toBeInTheDocument();
     });

+ 6 - 4
static/app/components/events/eventCause.spec.tsx

@@ -1,3 +1,5 @@
+import {Repository} from 'sentry-fixture/repository';
+
 import {render, screen, userEvent} from 'sentry-test/reactTestingLibrary';
 
 import {EventCause} from 'sentry/components/events/eventCause';
@@ -20,7 +22,7 @@ describe('EventCause', function () {
             'feat: Enhance suggested commits and add to alerts\n\n- Refactor components to use new shared CommitRow\n- Add Suspect Commits to alert emails\n- Refactor committers scanning code to handle various edge cases.',
           score: 4,
           id: 'ab2709293d0c9000829084ac7b1c9221fb18437c',
-          repository: TestStubs.Repository(),
+          repository: Repository(),
           dateCreated: '2018-03-02T18:30:26Z',
         },
         {
@@ -28,7 +30,7 @@ describe('EventCause', function () {
             'feat: Enhance suggested commits and add to alerts\n\n- Refactor components to use new shared CommitRow\n- Add Suspect Commits to alert emails\n- Refactor committers scanning code to handle various edge cases.',
           score: 4,
           id: 'ab2709293d0c9000829084ac7b1c9221fb18437c',
-          repository: TestStubs.Repository(),
+          repository: Repository(),
           dateCreated: '2018-03-02T18:30:26Z',
         },
       ],
@@ -40,7 +42,7 @@ describe('EventCause', function () {
           message: 'fix: Make things less broken',
           score: 2,
           id: 'zzzzzz3d0c9000829084ac7b1c9221fb18437c',
-          repository: TestStubs.Repository(),
+          repository: Repository(),
           dateCreated: '2018-03-02T16:30:26Z',
         },
       ],
@@ -174,7 +176,7 @@ describe('EventCause', function () {
                 message: 'fix: Make things less broken',
                 score: 2,
                 id: 'zzzzzz3d0c9000829084ac7b1c9221fb18437c',
-                repository: TestStubs.Repository(),
+                repository: Repository(),
                 dateCreated: '2018-03-02T16:30:26Z',
               },
             ],

+ 5 - 2
static/app/components/events/interfaces/frame/context.spec.tsx

@@ -1,3 +1,6 @@
+import {Repository} from 'sentry-fixture/repository';
+import {RepositoryProjectPathConfig} from 'sentry-fixture/repositoryProjectPathConfig';
+
 import {render} from 'sentry-test/reactTestingLibrary';
 
 import ProjectsStore from 'sentry/stores/projectsStore';
@@ -10,9 +13,9 @@ describe('Frame - Context', function () {
   const project = TestStubs.Project({});
   const event = TestStubs.Event({projectID: project.id});
   const integration = TestStubs.GitHubIntegration();
-  const repo = TestStubs.Repository({integrationId: integration.id});
+  const repo = Repository({integrationId: integration.id});
   const frame = {filename: '/sentry/app.py', lineNo: 233} as Frame;
-  const config = TestStubs.RepositoryProjectPathConfig({project, repo, integration});
+  const config = RepositoryProjectPathConfig({project, repo, integration});
 
   beforeEach(function () {
     jest.clearAllMocks();

+ 3 - 1
static/app/components/events/interfaces/frame/openInContextLine.spec.tsx

@@ -1,3 +1,5 @@
+import {SentryAppInstallation} from 'sentry-fixture/sentryAppInstallation';
+
 import {render, screen} from 'sentry-test/reactTestingLibrary';
 
 import {OpenInContextLine} from 'sentry/components/events/interfaces/frame/openInContextLine';
@@ -7,7 +9,7 @@ import {addQueryParamsToExistingUrl} from 'sentry/utils/queryString';
 describe('OpenInContextLine', function () {
   const filename = '/sentry/app.py';
   const group = TestStubs.Group();
-  const install = TestStubs.SentryAppInstallation();
+  const install = SentryAppInstallation();
   const components: SentryAppComponent<SentryAppSchemaStacktraceLink>[] = [
     {
       uuid: 'ed517da4-a324-44c0-aeea-1894cd9923fb',

+ 4 - 2
static/app/components/events/interfaces/frame/stacktraceLink.spec.tsx

@@ -1,4 +1,6 @@
 import {Commit} from 'sentry-fixture/commit';
+import {Repository} from 'sentry-fixture/repository';
+import {RepositoryProjectPathConfig} from 'sentry-fixture/repositoryProjectPathConfig';
 
 import {render, screen, userEvent, waitFor} from 'sentry-test/reactTestingLibrary';
 
@@ -19,10 +21,10 @@ describe('StacktraceLink', function () {
     platform,
   });
   const integration = TestStubs.GitHubIntegration();
-  const repo = TestStubs.Repository({integrationId: integration.id});
+  const repo = Repository({integrationId: integration.id});
 
   const frame = {filename: '/sentry/app.py', lineNo: 233} as Frame;
-  const config = TestStubs.RepositoryProjectPathConfig({project, repo, integration});
+  const config = RepositoryProjectPathConfig({project, repo, integration});
   let promptActivity: jest.Mock;
 
   const analyticsSpy = jest.spyOn(analytics, 'trackAnalytics');

+ 5 - 2
static/app/components/events/interfaces/frame/stacktraceLinkModal.spec.tsx

@@ -1,3 +1,6 @@
+import {Repository} from 'sentry-fixture/repository';
+import {RepositoryProjectPathConfig} from 'sentry-fixture/repositoryProjectPathConfig';
+
 import {
   act,
   renderGlobalModal,
@@ -17,8 +20,8 @@ describe('StacktraceLinkModal', () => {
   const project = TestStubs.Project();
   const integration = TestStubs.GitHubIntegration();
   const filename = '/sentry/app.py';
-  const repo = TestStubs.Repository({integrationId: integration.id});
-  const config = TestStubs.RepositoryProjectPathConfig({project, repo, integration});
+  const repo = Repository({integrationId: integration.id});
+  const config = RepositoryProjectPathConfig({project, repo, integration});
   const sourceUrl = 'https://github.com/getsentry/sentry/blob/master/src/sentry/app.py';
   const configData = {
     stackRoot: '',

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

@@ -1,3 +1,6 @@
+import {SentryApp} from 'sentry-fixture/sentryApp';
+import {SentryAppInstallation} from 'sentry-fixture/sentryAppInstallation';
+
 import {
   render,
   renderGlobalModal,
@@ -9,7 +12,7 @@ import SentryAppExternalIssueActions from 'sentry/components/group/sentryAppExte
 
 describe('SentryAppExternalIssueActions', () => {
   const group = TestStubs.Group();
-  const sentryApp = TestStubs.SentryApp();
+  const sentryApp = SentryApp();
   const component = TestStubs.SentryAppComponent({
     sentryApp: {
       uuid: sentryApp.uuid,
@@ -19,7 +22,7 @@ describe('SentryAppExternalIssueActions', () => {
   });
   // unable to use the selectByValue here so remove the select option
   component.schema.create.required_fields.pop();
-  const install = TestStubs.SentryAppInstallation({sentryApp});
+  const install = SentryAppInstallation({});
   const submitUrl = `/sentry-app-installations/${install.uuid}/external-issue-actions/`;
   const externalIssue = TestStubs.PlatformExternalIssue({
     groupId: group.id,

+ 8 - 6
static/app/components/group/sentryAppExternalIssueForm.spec.tsx

@@ -1,4 +1,6 @@
 import selectEvent from 'react-select-event';
+import {SentryApp} from 'sentry-fixture/sentryApp';
+import {SentryAppInstallation} from 'sentry-fixture/sentryAppInstallation';
 
 import {render, screen, userEvent} from 'sentry-test/reactTestingLibrary';
 
@@ -12,8 +14,8 @@ describe('SentryAppExternalIssueForm', () => {
     permalink: 'https://sentry.io/organizations/sentry/issues/123/?project=1',
   });
   const component = TestStubs.SentryAppComponent();
-  const sentryApp = TestStubs.SentryApp();
-  const sentryAppInstallation = TestStubs.SentryAppInstallation({sentryApp});
+  const sentryApp = SentryApp();
+  const sentryAppInstallation = SentryAppInstallation({});
   const submitUrl = `/sentry-app-installations/${sentryAppInstallation.uuid}/external-issue-actions/`;
   let externalIssueRequest;
 
@@ -151,8 +153,8 @@ describe('SentryAppExternalIssueForm Async Field', () => {
     shortId: 'SEN123',
     permalink: 'https://sentry.io/organizations/sentry/issues/123/?project=1',
   });
-  const sentryApp = TestStubs.SentryApp();
-  const sentryAppInstallation = TestStubs.SentryAppInstallation({sentryApp});
+  const sentryApp = SentryApp();
+  const sentryAppInstallation = SentryAppInstallation({});
 
   afterEach(() => {
     MockApiClient.clearMockResponses();
@@ -197,8 +199,8 @@ describe('SentryAppExternalIssueForm Dependent fields', () => {
     shortId: 'SEN123',
     permalink: 'https://sentry.io/organizations/sentry/issues/123/?project=1',
   });
-  const sentryApp = TestStubs.SentryApp();
-  const sentryAppInstallation = TestStubs.SentryAppInstallation({sentryApp});
+  const sentryApp = SentryApp();
+  const sentryAppInstallation = SentryAppInstallation({});
   const component = TestStubs.SentryAppComponentDependent();
 
   afterEach(() => {

+ 4 - 2
static/app/components/modals/sentryAppDetailsModal.spec.tsx

@@ -1,3 +1,5 @@
+import {SentryApp} from 'sentry-fixture/sentryApp';
+
 import {render, screen, userEvent} from 'sentry-test/reactTestingLibrary';
 
 import SentryAppDetailsModal from 'sentry/components/modals/sentryAppDetailsModal';
@@ -20,7 +22,7 @@ function renderMockRequests({sentryAppSlug}: {sentryAppSlug: string}) {
 }
 
 describe('SentryAppDetailsModal', function () {
-  const sentryApp = TestStubs.SentryApp();
+  const sentryApp = SentryApp();
 
   it('renders', function () {
     renderMockRequests({sentryAppSlug: sentryApp.slug});
@@ -75,7 +77,7 @@ describe('SentryAppDetailsModal', function () {
       />
     );
 
-    expect(screen.getByText(sentryApp.overview)).toBeInTheDocument();
+    expect(screen.getByText(String(sentryApp.overview))).toBeInTheDocument();
   });
 
   it('closes when Cancel is clicked', async function () {

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