From 6da8c5d1bb2ab0a2fb7752d90382ccc7f78162bb Mon Sep 17 00:00:00 2001 From: Mihaly Gyongyosi Date: Mon, 5 Jan 2026 16:54:52 +0100 Subject: [PATCH] Fix typecheck --- .../apis/iam.grafana.app/v0alpha1/handlers.ts | 30 ++++++++++--------- .../app/features/teams/TeamGroupSync.test.tsx | 10 ++----- 2 files changed, 18 insertions(+), 22 deletions(-) diff --git a/packages/grafana-test-utils/src/handlers/apis/iam.grafana.app/v0alpha1/handlers.ts b/packages/grafana-test-utils/src/handlers/apis/iam.grafana.app/v0alpha1/handlers.ts index e926cd025bc..e31819f5365 100644 --- a/packages/grafana-test-utils/src/handlers/apis/iam.grafana.app/v0alpha1/handlers.ts +++ b/packages/grafana-test-utils/src/handlers/apis/iam.grafana.app/v0alpha1/handlers.ts @@ -1,7 +1,5 @@ import { HttpResponse, http } from 'msw'; -import { ExternalGroupMapping } from '@grafana/api-clients/rtkq/iam/v0alpha1'; - import { mockTeamsMap } from '../../../../fixtures/teams'; const getDisplayMapping = () => @@ -31,7 +29,7 @@ const getDisplayMapping = () => }); const listExternalGroupMappings = () => - http.get('/apis/iam.grafana.app/v0alpha1/namespaces/:namespace/externalgroupmappings', () => { + http.get<{ namespace: string }>('/apis/iam.grafana.app/v0alpha1/namespaces/:namespace/externalgroupmappings', () => { const items = []; for (const [teamName, data] of mockTeamsMap.entries()) { for (const group of data.groups) { @@ -55,7 +53,8 @@ const listExternalGroupMappings = () => }); const createExternalGroupMapping = () => - http.post<{ namespace: string }, ExternalGroupMapping>( + // eslint-disable-next-line @typescript-eslint/no-explicit-any + http.post<{ namespace: string }, any>( '/apis/iam.grafana.app/v0alpha1/namespaces/:namespace/externalgroupmappings', async ({ request }) => { const body = await request.json(); @@ -79,19 +78,22 @@ const createExternalGroupMapping = () => ); const deleteExternalGroupMapping = () => - http.delete('/apis/iam.grafana.app/v0alpha1/namespaces/:namespace/externalgroupmappings/:name', ({ params }) => { - const { name } = params; + http.delete<{ namespace: string; name: string }>( + '/apis/iam.grafana.app/v0alpha1/namespaces/:namespace/externalgroupmappings/:name', + ({ params }) => { + const { name } = params; - for (const [teamName, data] of mockTeamsMap.entries()) { - const groupIndex = data.groups.findIndex((g) => `mapping-${teamName}-${g.groupId}` === name); - if (groupIndex !== -1) { - data.groups.splice(groupIndex, 1); - return HttpResponse.json({ status: 'Success' }); + for (const [teamName, data] of mockTeamsMap.entries()) { + const groupIndex = data.groups.findIndex((g) => `mapping-${teamName}-${g.groupId}` === name); + if (groupIndex !== -1) { + data.groups.splice(groupIndex, 1); + return HttpResponse.json({ status: 'Success' }); + } } - } - return HttpResponse.json({ status: 'Failure', message: 'Not found' }, { status: 404 }); - }); + return HttpResponse.json({ status: 'Failure', message: 'Not found' }, { status: 404 }); + } + ); export default [ getDisplayMapping(), diff --git a/public/app/features/teams/TeamGroupSync.test.tsx b/public/app/features/teams/TeamGroupSync.test.tsx index eb09e653640..0cf77d16708 100644 --- a/public/app/features/teams/TeamGroupSync.test.tsx +++ b/public/app/features/teams/TeamGroupSync.test.tsx @@ -25,9 +25,8 @@ describe('TeamGroupSync', () => { expect(await screen.findAllByRole('row')).toHaveLength(MOCK_TEAM_GROUPS.length + 1); // items plus table header }); - it('should call add group', async () => { + it('should add group', async () => { const { user } = setup(); - // Wait for the groups to load so the "Add group" button appears await screen.findAllByRole('row'); await user.click(screen.getAllByRole('button', { name: /add group/i })[0]); @@ -43,10 +42,8 @@ describe('TeamGroupSync', () => { const { user } = setup(); const groupToRemove = MOCK_TEAM_GROUPS[0].groupId; - // Wait for group to be rendered await screen.findByRole('row', { name: new RegExp(groupToRemove, 'i') }); - // Remove group await user.click(screen.getByRole('button', { name: `Remove group ${groupToRemove}` })); await waitFor(() => @@ -74,9 +71,8 @@ describe('TeamGroupSync with kubernetesExternalGroupMapping enabled', () => { expect(await screen.findAllByRole('row')).toHaveLength(MOCK_TEAM_GROUPS.length + 1); // items plus table header }); - it('should call add group', async () => { + it('should add group', async () => { const { user } = setup(); - // Wait for the groups to load so the "Add group" button appears await screen.findAllByRole('row'); await user.click(screen.getAllByRole('button', { name: /add group/i })[0]); @@ -92,10 +88,8 @@ describe('TeamGroupSync with kubernetesExternalGroupMapping enabled', () => { const { user } = setup(); const groupToRemove = MOCK_TEAM_GROUPS[0].groupId; - // Wait for group to be rendered await screen.findByRole('row', { name: new RegExp(groupToRemove, 'i') }); - // Remove group await user.click(screen.getByRole('button', { name: `Remove group ${groupToRemove}` })); await waitFor(() =>