mirror of
https://github.com/fleetdm/fleet
synced 2026-05-24 09:28:54 +00:00
* Creates new PackComposerPage at /packs/new * Creates PackForm component * Adds PackForm to PackComposerPage * Creates QueriesListItem * Creates QueriesList * Creates QueriesListWrapper * Get all queries when the Packs Composer Page loads * Form HOC handles updates to formData prop * Creates form to configure scheduled queries * QueriesListWrapper renders ConfigurePackQueryForm * search queries input filters queries list * Empty state text * create pack when user submits the new pack form * Adds Edit pack page to /packs/:pack_id/edit * API client - get scheduled queries for a pack * API client - create scheduled query * Redux config for scheduled queries * Remove scheduled queries from packs * Add labels to pack on create * Add disabled state to the select targets dropdown * Adds edit route and pushes to new route on edit click * Adds cancel button to edit pack form * Adds Checkbox that selects all scheduled queries in table
103 lines
2.5 KiB
JavaScript
103 lines
2.5 KiB
JavaScript
import expect from 'expect';
|
|
import { mount } from 'enzyme';
|
|
|
|
import { connectedComponent, reduxMockStore } from '../../../test/helpers';
|
|
import UserManagementPage from './UserManagementPage';
|
|
|
|
const currentUser = {
|
|
admin: true,
|
|
email: 'hi@gnar.dog',
|
|
enabled: true,
|
|
name: 'Gnar Dog',
|
|
position: 'Head of Gnar',
|
|
username: 'gnardog',
|
|
};
|
|
const loadUsersAction = { type: 'users_LOAD_REQUEST' };
|
|
const store = {
|
|
auth: {
|
|
user: {
|
|
...currentUser,
|
|
},
|
|
},
|
|
entities: {
|
|
users: {
|
|
loading: false,
|
|
data: {
|
|
1: {
|
|
...currentUser,
|
|
},
|
|
},
|
|
},
|
|
invites: {
|
|
loading: false,
|
|
data: {
|
|
1: {
|
|
admin: false,
|
|
email: 'other@user.org',
|
|
name: 'Other user',
|
|
},
|
|
},
|
|
},
|
|
},
|
|
};
|
|
|
|
describe('UserManagementPage - component', () => {
|
|
it('renders user blocks for users and invites', () => {
|
|
const mockStore = reduxMockStore(store);
|
|
const page = mount(connectedComponent(UserManagementPage, { mockStore }));
|
|
|
|
expect(page.find('UserBlock').length).toEqual(2);
|
|
});
|
|
|
|
it('displays a count of the number of users & invites', () => {
|
|
const mockStore = reduxMockStore(store);
|
|
const page = mount(connectedComponent(UserManagementPage, { mockStore }));
|
|
|
|
expect(page.text()).toInclude('Listing 2 users');
|
|
});
|
|
|
|
it('gets all users if there are no users in state', () => {
|
|
const mockStore = reduxMockStore({
|
|
...store,
|
|
entities: {
|
|
...store.entities,
|
|
users: {
|
|
...store.entities.users,
|
|
data: {},
|
|
},
|
|
},
|
|
});
|
|
|
|
mount(connectedComponent(UserManagementPage, { mockStore }));
|
|
|
|
expect(mockStore.getActions()).toInclude(loadUsersAction);
|
|
});
|
|
|
|
it('gets all users if the only user in state is the current user', () => {
|
|
const mockStore = reduxMockStore(store);
|
|
|
|
mount(connectedComponent(UserManagementPage, { mockStore }));
|
|
|
|
expect(mockStore.getActions()).toInclude(loadUsersAction);
|
|
});
|
|
|
|
it('does not get users if users are already loaded', () => {
|
|
const mockStore = reduxMockStore({
|
|
...store,
|
|
entities: {
|
|
...store.entities,
|
|
users: {
|
|
...store.entities.users,
|
|
data: {
|
|
1: { ...currentUser },
|
|
2: { id: 2, email: 'another@gnar.dog', full_name: 'GnarDog' },
|
|
},
|
|
},
|
|
},
|
|
});
|
|
|
|
mount(connectedComponent(UserManagementPage, { mockStore }));
|
|
|
|
expect(mockStore.getActions()).toNotInclude(loadUsersAction);
|
|
});
|
|
});
|