mirror of
https://github.com/fleetdm/fleet
synced 2026-04-21 13:37:30 +00:00
* use new data table in user manage page' * remove default empty array hiddenColumns props, was causing render performance problems * remove unused tooltip in hostcontainer * add search to user manage table * add query params to user GET requests * move createUserForm closer to user management page * starting to implement create user modal * starting to add team checking functionality to create user * styling of select team form * changing logic for selectedTeamsForm, simplifying * updated SelectedTeamsForm to handle own state and pass back relevant state to parent * created reusable infobanner component and use it in osquery options page * use infobanner in createuserform * create new Radio component and use in createuserform * create new Radio component and use in createuserform * added new radio buttons to createUserForm * finish custom radio button styling * finish styling of radio in createUserForm * fix and add entities/users#loadAll tests * remove unneeded tests and updated broken ones on UserManagementPage * remove unused modules
119 lines
3.6 KiB
JavaScript
119 lines
3.6 KiB
JavaScript
import React from 'react';
|
|
import { mount } from 'enzyme';
|
|
|
|
import { connectedComponent, reduxMockStore } from 'test/helpers';
|
|
import ConnectedUserManagementPage from 'pages/admin/UserManagementPage/UserManagementPage';
|
|
import inviteActions from 'redux/nodes/entities/invites/actions';
|
|
import userActions from 'redux/nodes/entities/users/actions';
|
|
|
|
const currentUser = {
|
|
admin: true,
|
|
email: 'hi@gnar.dog',
|
|
enabled: true,
|
|
name: 'Gnar Dog',
|
|
position: 'Head of Gnar',
|
|
username: 'gnardog',
|
|
};
|
|
const store = {
|
|
app: {
|
|
config: {
|
|
configured: true,
|
|
},
|
|
},
|
|
auth: {
|
|
user: {
|
|
...currentUser,
|
|
},
|
|
},
|
|
entities: {
|
|
users: {
|
|
loading: false,
|
|
data: {
|
|
1: {
|
|
...currentUser,
|
|
},
|
|
},
|
|
originalOrder: [1],
|
|
},
|
|
invites: {
|
|
loading: false,
|
|
data: {
|
|
1: {
|
|
admin: false,
|
|
email: 'other@user.org',
|
|
name: 'Other user',
|
|
},
|
|
},
|
|
originalOrder: [1],
|
|
},
|
|
},
|
|
};
|
|
|
|
describe('UserManagementPage - component', () => {
|
|
beforeEach(() => {
|
|
jest.spyOn(userActions, 'loadAll')
|
|
.mockImplementation(() => () => Promise.resolve([]));
|
|
|
|
jest.spyOn(inviteActions, 'loadAll')
|
|
.mockImplementation(() => () => Promise.resolve([]));
|
|
});
|
|
|
|
describe('rendering', () => {
|
|
it(
|
|
'displays a disabled "Create user" button if email is not configured',
|
|
() => {
|
|
const notConfiguredStore = { ...store, app: { config: { configured: false } } };
|
|
const notConfiguredMockStore = reduxMockStore(notConfiguredStore);
|
|
const notConfiguredPage = mount(connectedComponent(ConnectedUserManagementPage, {
|
|
mockStore: notConfiguredMockStore,
|
|
}));
|
|
|
|
const configuredStore = store;
|
|
const configuredMockStore = reduxMockStore(configuredStore);
|
|
const configuredPage = mount(connectedComponent(ConnectedUserManagementPage, {
|
|
mockStore: configuredMockStore,
|
|
}));
|
|
|
|
expect(notConfiguredPage.find('Button').at(1).prop('disabled')).toEqual(true);
|
|
expect(configuredPage.find('Button').first().prop('disabled')).toEqual(false);
|
|
},
|
|
);
|
|
|
|
it('displays a SmtpWarning if email is not configured', () => {
|
|
const notConfiguredStore = { ...store, app: { config: { configured: false } } };
|
|
const notConfiguredMockStore = reduxMockStore(notConfiguredStore);
|
|
const notConfiguredPage = mount(connectedComponent(ConnectedUserManagementPage, {
|
|
mockStore: notConfiguredMockStore,
|
|
}));
|
|
|
|
const configuredStore = store;
|
|
const configuredMockStore = reduxMockStore(configuredStore);
|
|
const configuredPage = mount(connectedComponent(ConnectedUserManagementPage, {
|
|
mockStore: configuredMockStore,
|
|
}));
|
|
|
|
expect(notConfiguredPage.find('WarningBanner').html()).toBeTruthy();
|
|
expect(configuredPage.find('WarningBanner').html()).toBeFalsy();
|
|
});
|
|
});
|
|
|
|
it(
|
|
'goes to the app settings page for the user to resolve their smtp settings',
|
|
() => {
|
|
const notConfiguredStore = { ...store, app: { config: { configured: false } } };
|
|
const mockStore = reduxMockStore(notConfiguredStore);
|
|
const page = mount(connectedComponent(ConnectedUserManagementPage, { mockStore }));
|
|
|
|
const smtpWarning = page.find('WarningBanner');
|
|
|
|
smtpWarning.find('Button').simulate('click');
|
|
|
|
const goToAppSettingsAction = {
|
|
type: '@@router/CALL_HISTORY_METHOD',
|
|
payload: { method: 'push', args: ['/settings/organization'] },
|
|
};
|
|
|
|
expect(mockStore.getActions()).toContainEqual(goToAppSettingsAction);
|
|
},
|
|
);
|
|
});
|