Browse Source

test(ui): Add types to test mocks (#79255)

Scott Cooper 4 months ago
parent
commit
17c7471185

+ 1 - 1
static/app/components/modals/widgetViewerModal.spec.tsx

@@ -26,7 +26,7 @@ jest.mock('echarts-for-react/lib/core', () => {
 
 
 const stubEl = (props: {children?: React.ReactNode}) => <div>{props.children}</div>;
 const stubEl = (props: {children?: React.ReactNode}) => <div>{props.children}</div>;
 
 
-let eventsMetaMock;
+let eventsMetaMock: jest.Mock;
 
 
 const waitForMetaToHaveBeenCalled = async () => {
 const waitForMetaToHaveBeenCalled = async () => {
   await waitFor(() => {
   await waitFor(() => {

+ 3 - 2
static/app/components/quickTrace/index.spec.tsx

@@ -3,11 +3,12 @@ import {render, screen} from 'sentry-test/reactTestingLibrary';
 
 
 import QuickTrace from 'sentry/components/quickTrace';
 import QuickTrace from 'sentry/components/quickTrace';
 import type {Event} from 'sentry/types/event';
 import type {Event} from 'sentry/types/event';
+import type {Organization} from 'sentry/types/organization';
 import type {QuickTraceEvent} from 'sentry/utils/performance/quickTrace/types';
 import type {QuickTraceEvent} from 'sentry/utils/performance/quickTrace/types';
 
 
 describe('Quick Trace', function () {
 describe('Quick Trace', function () {
-  let location;
-  let organization;
+  let location: any;
+  let organization: Organization;
 
 
   const initialize = () => {
   const initialize = () => {
     const context = initializeOrg();
     const context = initializeOrg();

+ 7 - 7
static/app/components/search/sources/apiSource.spec.tsx

@@ -15,13 +15,13 @@ import ConfigStore from 'sentry/stores/configStore';
 
 
 describe('ApiSource', function () {
 describe('ApiSource', function () {
   const {organization, router} = initializeOrg();
   const {organization, router} = initializeOrg();
-  let orgsMock;
-  let projectsMock;
-  let teamsMock;
-  let membersMock;
-  let shortIdMock;
-  let eventIdMock;
-  let configState;
+  let orgsMock: jest.Mock;
+  let projectsMock: jest.Mock;
+  let teamsMock: jest.Mock;
+  let membersMock: jest.Mock;
+  let shortIdMock: jest.Mock;
+  let eventIdMock: jest.Mock;
+  let configState: ReturnType<typeof ConfigStore.getState>;
 
 
   const defaultProps: ComponentProps<typeof ApiSource> = {
   const defaultProps: ComponentProps<typeof ApiSource> = {
     query: '',
     query: '',

+ 1 - 1
static/app/stores/groupingStore.spec.tsx

@@ -2,7 +2,7 @@ import * as GroupActionCreators from 'sentry/actionCreators/group';
 import GroupingStore from 'sentry/stores/groupingStore';
 import GroupingStore from 'sentry/stores/groupingStore';
 
 
 describe('Grouping Store', function () {
 describe('Grouping Store', function () {
-  let trigger;
+  let trigger!: jest.SpyInstance;
 
 
   beforeAll(function () {
   beforeAll(function () {
     MockApiClient.asyncDelay = 1;
     MockApiClient.asyncDelay = 1;

+ 1 - 1
static/app/utils/replays/playback/providers/replayPlayerEventsContext.spec.tsx

@@ -44,7 +44,7 @@ describe('replayPlayerEventsContext', () => {
       errors: [],
       errors: [],
       replayRecord: ReplayRecordFixture(),
       replayRecord: ReplayRecordFixture(),
     });
     });
-    const mockRRwebFrames = [];
+    const mockRRwebFrames: any[] = [];
     mockReplay!.getRRWebFrames = jest.fn().mockReturnValue(mockRRwebFrames);
     mockReplay!.getRRWebFrames = jest.fn().mockReturnValue(mockRRwebFrames);
 
 
     const {result} = renderHook(useReplayPlayerEvents, {
     const {result} = renderHook(useReplayPlayerEvents, {

+ 2 - 2
static/app/utils/replays/playback/providers/replayPlayerPluginsContextProvider.spec.tsx

@@ -39,7 +39,7 @@ describe('replayPlayerPluginsContext', () => {
 
 
   it('should return no plugins if you dont use the Provider', () => {
   it('should return no plugins if you dont use the Provider', () => {
     const mockOrganization = OrganizationFixture();
     const mockOrganization = OrganizationFixture();
-    const mockEvents = [];
+    const mockEvents: any[] = [];
 
 
     const {result} = renderHook(useReplayPlayerPlugins, {
     const {result} = renderHook(useReplayPlayerPlugins, {
       wrapper: ({children}: {children?: ReactNode}) => (
       wrapper: ({children}: {children?: ReactNode}) => (
@@ -57,7 +57,7 @@ describe('replayPlayerPluginsContext', () => {
     const mockOrganizationWithCanvas = OrganizationFixture({
     const mockOrganizationWithCanvas = OrganizationFixture({
       features: ['session-replay-enable-canvas-replayer'],
       features: ['session-replay-enable-canvas-replayer'],
     });
     });
-    const mockEvents = [];
+    const mockEvents: any[] = [];
 
 
     const {result: noCanvasResult} = renderHook(useReplayPlayerPlugins, {
     const {result: noCanvasResult} = renderHook(useReplayPlayerPlugins, {
       wrapper: makeWrapper(mockOrganizationNoCanvas),
       wrapper: makeWrapper(mockOrganizationNoCanvas),

+ 2 - 1
static/app/views/dashboards/dashboard.spec.tsx

@@ -59,7 +59,8 @@ describe('Dashboards > Dashboard', () => {
     ],
     ],
   };
   };
 
 
-  let initialData, tagsMock;
+  let initialData: ReturnType<typeof initializeOrg>;
+  let tagsMock: jest.Mock;
 
 
   beforeEach(() => {
   beforeEach(() => {
     initialData = initializeOrg({organization, router: {}, projects: []});
     initialData = initializeOrg({organization, router: {}, projects: []});

+ 5 - 2
static/app/views/dashboards/manage/dashboardList.spec.tsx

@@ -14,10 +14,13 @@ import {
 } from 'sentry-test/reactTestingLibrary';
 } from 'sentry-test/reactTestingLibrary';
 
 
 import DashboardList from 'sentry/views/dashboards/manage/dashboardList';
 import DashboardList from 'sentry/views/dashboards/manage/dashboardList';
-import {DisplayType} from 'sentry/views/dashboards/types';
+import {type DashboardListItem, DisplayType} from 'sentry/views/dashboards/types';
 
 
 describe('Dashboards - DashboardList', function () {
 describe('Dashboards - DashboardList', function () {
-  let dashboards, deleteMock, dashboardUpdateMock, createMock;
+  let dashboards: DashboardListItem[];
+  let deleteMock: jest.Mock;
+  let dashboardUpdateMock: jest.Mock;
+  let createMock: jest.Mock;
   const organization = OrganizationFixture({
   const organization = OrganizationFixture({
     features: ['global-views', 'dashboards-basic', 'dashboards-edit', 'discover-query'],
     features: ['global-views', 'dashboards-basic', 'dashboards-edit', 'discover-query'],
   });
   });

+ 1 - 1
static/app/views/dashboards/widgetCard/index.spec.tsx

@@ -78,7 +78,7 @@ describe('Dashboards > WidgetCard', function () {
   };
   };
 
 
   const api = new MockApiClient();
   const api = new MockApiClient();
-  let eventsMock;
+  let eventsMock: jest.Mock;
 
 
   beforeEach(function () {
   beforeEach(function () {
     MockApiClient.addMockResponse({
     MockApiClient.addMockResponse({

+ 9 - 9
static/app/views/discover/savedQuery/index.spec.tsx

@@ -3,7 +3,7 @@ import {OrganizationFixture} from 'sentry-fixture/organization';
 import {render, screen, userEvent, waitFor} from 'sentry-test/reactTestingLibrary';
 import {render, screen, userEvent, waitFor} from 'sentry-test/reactTestingLibrary';
 
 
 import {openAddToDashboardModal} from 'sentry/actionCreators/modal';
 import {openAddToDashboardModal} from 'sentry/actionCreators/modal';
-import type {NewQuery} from 'sentry/types/organization';
+import type {NewQuery, Organization, SavedQuery} from 'sentry/types/organization';
 import EventView from 'sentry/utils/discover/eventView';
 import EventView from 'sentry/utils/discover/eventView';
 import {DisplayModes, SavedQueryDatasets} from 'sentry/utils/discover/types';
 import {DisplayModes, SavedQueryDatasets} from 'sentry/utils/discover/types';
 import {WidgetType} from 'sentry/views/dashboards/types';
 import {WidgetType} from 'sentry/views/dashboards/types';
@@ -41,12 +41,12 @@ function mount(
 }
 }
 
 
 describe('Discover > SaveQueryButtonGroup', function () {
 describe('Discover > SaveQueryButtonGroup', function () {
-  let organization,
-    errorsView,
-    savedQuery,
-    errorsViewSaved,
-    errorsViewModified,
-    errorsQuery;
+  let organization: Organization;
+  let errorsView: EventView;
+  let savedQuery: SavedQuery;
+  let errorsViewSaved: EventView;
+  let errorsViewModified: EventView;
+  let errorsQuery: NewQuery;
   const location = {
   const location = {
     pathname: '/organization/eventsv2/',
     pathname: '/organization/eventsv2/',
     query: {},
     query: {},
@@ -272,7 +272,7 @@ describe('Discover > SaveQueryButtonGroup', function () {
   });
   });
 
 
   describe('viewing a saved query', () => {
   describe('viewing a saved query', () => {
-    let mockUtils;
+    let mockUtils: jest.SpyInstance;
 
 
     beforeEach(() => {
     beforeEach(() => {
       mockUtils = jest
       mockUtils = jest
@@ -362,7 +362,7 @@ describe('Discover > SaveQueryButtonGroup', function () {
   });
   });
 
 
   describe('modifying a saved query', () => {
   describe('modifying a saved query', () => {
-    let mockUtils;
+    let mockUtils: jest.SpyInstance;
 
 
     it('renders the correct set of buttons', async () => {
     it('renders the correct set of buttons', async () => {
       mount(
       mount(

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