grafana/public/app/features/users/UsersListPage.test.tsx
Alexander Zobnin f1b5014efd
Preferences: Add pagination to org configuration page (#60896)
* Add auth labels and access control metadata to org users search results

* Fix search result JSON model

* Org users: Use API for pagination

* Fix default page size

* Refactor: UsersListPage to functional component

* Refactor: update UsersTable component code style

* Add pagination to the /orgs/{org_id}/users endpoint

* Use pagination on the AdminEditOrgPage

* Add /orgs/{org_id}/users/search endpoint to prevent breaking API

* Use existing search store method

* Remove unnecessary error

* Remove unused

* Add query param to search endpoint

* Fix endpoint docs

* Minor refactor

* Fix number of pages calculation

* Use SearchOrgUsers for all org users methods

* Refactor: GetOrgUsers as a service method

* Minor refactor: rename orgId => orgID

* Fix integration tests

* Fix tests
2023-01-09 11:54:33 +03:00

64 lines
1.4 KiB
TypeScript

import { render } from '@testing-library/react';
import React from 'react';
import { Provider } from 'react-redux';
import { mockToolkitActionCreator } from 'test/core/redux/mocks';
import { configureStore } from 'app/store/configureStore';
import { Invitee, OrgUser } from 'app/types';
import { Props, UsersListPageUnconnected } from './UsersListPage';
import { pageChanged } from './state/reducers';
jest.mock('../../core/app_events', () => ({
emit: jest.fn(),
}));
jest.mock('app/core/core', () => ({
contextSrv: {
user: { orgId: 1 },
hasAccess: () => false,
licensedAccessControlEnabled: () => false,
},
}));
const setup = (propOverrides?: object) => {
const store = configureStore();
const props: Props = {
users: [] as OrgUser[],
invitees: [] as Invitee[],
searchQuery: '',
page: 1,
totalPages: 1,
perPage: 30,
externalUserMngInfo: '',
fetchInvitees: jest.fn(),
loadUsers: jest.fn(),
updateUser: jest.fn(),
removeUser: jest.fn(),
changePage: mockToolkitActionCreator(pageChanged),
isLoading: false,
};
Object.assign(props, propOverrides);
render(
<Provider store={store}>
<UsersListPageUnconnected {...props} />
</Provider>
);
};
describe('Render', () => {
it('should render component', () => {
expect(setup).not.toThrow();
});
it('should render List page', () => {
expect(() =>
setup({
hasFetched: true,
})
).not.toThrow();
});
});