mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
* update eslint, tsconfig + esbuild to handle new jsx transform * remove thing that breaks the new jsx transform * remove react imports * adjust grafana-icons build * is this the correct syntax? * try this * well this was much easier than expected... * change grafana-plugin-configs webpack config * fixes * fix lockfile * fix 2 more violations * use path.resolve instead of require.resolve * remove react import * fix react imports * more fixes * remove React import * remove import React from docs * remove another react import
92 lines
2.3 KiB
TypeScript
92 lines
2.3 KiB
TypeScript
import { screen } from '@testing-library/react';
|
|
import { Route, Router } from 'react-router-dom';
|
|
import { render } from 'test/test-utils';
|
|
|
|
import { locationService } from '@grafana/runtime';
|
|
|
|
import TeamPages from './TeamPages';
|
|
import { getMockTeam } from './__mocks__/teamMocks';
|
|
|
|
jest.mock('app/core/components/Select/UserPicker', () => {
|
|
return { UserPicker: () => null };
|
|
});
|
|
|
|
jest.mock('app/core/services/context_srv', () => ({
|
|
contextSrv: {
|
|
accessControlEnabled: () => true,
|
|
hasPermissionInMetadata: () => true,
|
|
user: {},
|
|
},
|
|
}));
|
|
|
|
jest.mock('@grafana/runtime', () => ({
|
|
...jest.requireActual('@grafana/runtime'),
|
|
getBackendSrv: () => ({
|
|
get: jest.fn().mockResolvedValue(getMockTeam()),
|
|
}),
|
|
config: {
|
|
...jest.requireActual('@grafana/runtime').config,
|
|
licenseInfo: {
|
|
enabledFeatures: { teamsync: true },
|
|
stateInfo: '',
|
|
licenseUrl: '',
|
|
},
|
|
featureToggles: { accesscontrol: true },
|
|
bootData: { navTree: [], user: {} },
|
|
buildInfo: {
|
|
edition: 'Open Source',
|
|
version: '7.5.0',
|
|
commit: 'abc123',
|
|
env: 'production',
|
|
latestVersion: '',
|
|
hasUpdate: false,
|
|
hideVersion: false,
|
|
},
|
|
appSubUrl: '',
|
|
},
|
|
featureEnabled: () => true,
|
|
}));
|
|
|
|
// Mock connected child components instead of rendering them
|
|
jest.mock('./TeamSettings', () => {
|
|
//eslint-disable-next-line
|
|
return () => <div>Team settings</div>;
|
|
});
|
|
|
|
jest.mock('./TeamGroupSync', () => {
|
|
//eslint-disable-next-line
|
|
return () => <div>Team group sync</div>;
|
|
});
|
|
|
|
const setup = (propOverrides: { teamId?: number; pageName?: string } = {}) => {
|
|
const pageName = propOverrides.pageName ?? 'members';
|
|
const teamId = propOverrides.teamId ?? 1;
|
|
locationService.push({ pathname: `/org/teams/edit/${teamId}/${pageName}` });
|
|
|
|
render(
|
|
<Router history={locationService.getHistory()}>
|
|
<Route path="/org/teams/edit/:id/:page?">
|
|
<TeamPages />
|
|
</Route>
|
|
</Router>
|
|
);
|
|
};
|
|
|
|
describe('TeamPages', () => {
|
|
it('should render settings and preferences page', async () => {
|
|
setup({
|
|
pageName: 'settings',
|
|
});
|
|
|
|
expect(await screen.findByText('Team settings')).toBeInTheDocument();
|
|
});
|
|
|
|
it('should render group sync page', async () => {
|
|
setup({
|
|
pageName: 'groupsync',
|
|
});
|
|
|
|
expect(await screen.findByText('Team group sync')).toBeInTheDocument();
|
|
});
|
|
});
|