Skip to content

Commit a7fdb6e

Browse files
committed
Fix lint errors in test files
- Add eslint-disable for no-explicit-any in useQueryState tests (test mocks) - Add eslint-disable for import/named on waitFor import - Fix type annotations for mock helpers (return types, parameter types) - Extract MockProfileTypesData type to avoid no-undef-init warning - Fix toHaveProperty('value', x) to use filter.value assertion
1 parent 7e91f07 commit a7fdb6e

File tree

2 files changed

+19
-13
lines changed

2 files changed

+19
-13
lines changed

ui/packages/shared/profile/src/ProfileView/components/ProfileFilters/useProfileFiltersUrlState.test.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -629,7 +629,7 @@ describe('useProfileFiltersUrlState', () => {
629629
expect(filter).toHaveProperty('type', 'stack');
630630
expect(filter).toHaveProperty('field', 'function_name');
631631
expect(filter).toHaveProperty('matchType', 'equal');
632-
expect(filter).toHaveProperty('value', 'testFunc');
632+
expect(filter.value).toBe('testFunc');
633633
});
634634
});
635635

ui/packages/shared/profile/src/hooks/useQueryState.test.tsx

Lines changed: 18 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,13 @@
1111
// See the License for the specific language governing permissions and
1212
// limitations under the License.
1313

14+
/* eslint-disable @typescript-eslint/no-explicit-any */
15+
1416
import {ReactNode, act} from 'react';
1517

1618
// eslint-disable-next-line import/named
1719
import {QueryClient, QueryClientProvider} from '@tanstack/react-query';
20+
// eslint-disable-next-line import/named
1821
import {renderHook, waitFor} from '@testing-library/react';
1922
import {beforeEach, describe, expect, it, vi} from 'vitest';
2023

@@ -78,12 +81,12 @@ vi.mock('../useSumBy', async () => {
7881
return {
7982
...actual,
8083
useSumBy: (
81-
_queryClient: any,
82-
_profileType: any,
83-
_timeRange: any,
84-
_draftProfileType: any,
85-
_draftTimeRange: any,
86-
defaultValue: any
84+
_queryClient: unknown,
85+
_profileType: unknown,
86+
_timeRange: unknown,
87+
_draftProfileType: unknown,
88+
_draftTimeRange: unknown,
89+
defaultValue: string[] | undefined
8790
) => {
8891
const [draftSumBy, setDraftSumBy] = react.useState<string[] | undefined>(defaultValue);
8992
const [sumBy, setSumBy] = react.useState<string[] | undefined>(defaultValue);
@@ -100,9 +103,8 @@ vi.mock('../useSumBy', async () => {
100103
};
101104
});
102105

103-
// Track profile types loading state for tests
104-
let mockProfileTypesLoading = false;
105-
let mockProfileTypesData:
106+
// Type for mock profile types data
107+
type MockProfileTypesData =
106108
| {
107109
types: Array<{
108110
name: string;
@@ -113,7 +115,11 @@ let mockProfileTypesData:
113115
delta: boolean;
114116
}>;
115117
}
116-
| undefined = undefined;
118+
| undefined;
119+
120+
// Track profile types loading state for tests
121+
let mockProfileTypesLoading = false;
122+
let mockProfileTypesData: MockProfileTypesData;
117123

118124
// Mock useProfileTypes to control loading state in tests
119125
vi.mock('../ProfileSelector', async () => {
@@ -129,11 +135,11 @@ vi.mock('../ProfileSelector', async () => {
129135
});
130136

131137
// Helper to set profile types loading state for tests
132-
const setProfileTypesLoading = (loading: boolean) => {
138+
const setProfileTypesLoading = (loading: boolean): void => {
133139
mockProfileTypesLoading = loading;
134140
};
135141

136-
const setProfileTypesData = (data: typeof mockProfileTypesData) => {
142+
const setProfileTypesData = (data: MockProfileTypesData): void => {
137143
mockProfileTypesData = data;
138144
};
139145

0 commit comments

Comments
 (0)