MM-11942 Add deactivate user state to more users modal (#2079)
This commit is contained in:
parent
c13081ad34
commit
532e87f6dc
3 changed files with 1475 additions and 3 deletions
File diff suppressed because it is too large
Load diff
|
|
@ -8,13 +8,11 @@ import {
|
|||
Text,
|
||||
View,
|
||||
} from 'react-native';
|
||||
import {displayUsername} from 'mattermost-redux/utils/user_utils';
|
||||
import ProfilePicture from 'app/components/profile_picture';
|
||||
import {makeStyleSheetFromTheme, changeOpacity} from 'app/utils/theme';
|
||||
|
||||
import CustomListRow from 'app/components/custom_list/custom_list_row';
|
||||
|
||||
import {displayUsername} from 'mattermost-redux/utils/user_utils';
|
||||
|
||||
export default class UserListRow extends React.PureComponent {
|
||||
static propTypes = {
|
||||
id: PropTypes.string.isRequired,
|
||||
|
|
@ -58,6 +56,13 @@ export default class UserListRow extends React.PureComponent {
|
|||
}, {username});
|
||||
}
|
||||
|
||||
if (user.delete_at > 0) {
|
||||
usernameDisplay = formatMessage({
|
||||
id: 'more_direct_channels.directchannel.deactivated',
|
||||
defaultMessage: '{displayname} - Deactivated',
|
||||
}, {displayname: usernameDisplay});
|
||||
}
|
||||
|
||||
return (
|
||||
<CustomListRow
|
||||
id={id}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,89 @@
|
|||
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
|
||||
// See LICENSE.txt for license information.
|
||||
|
||||
import React from 'react';
|
||||
import {configure, shallow} from 'enzyme';
|
||||
import Adapter from 'enzyme-adapter-react-16';
|
||||
import UserListRow from './user_list_row';
|
||||
|
||||
configure({adapter: new Adapter()});
|
||||
|
||||
jest.mock('react-intl');
|
||||
jest.mock('app/utils/theme', () => {
|
||||
const original = require.requireActual('app/utils/theme');
|
||||
return {
|
||||
...original,
|
||||
changeOpacity: jest.fn(),
|
||||
};
|
||||
});
|
||||
|
||||
jest.mock('rn-fetch-blob', () => ({
|
||||
fs: {
|
||||
dirs: {
|
||||
DocumentDir: () => jest.fn(),
|
||||
CacheDir: () => jest.fn(),
|
||||
},
|
||||
},
|
||||
}));
|
||||
|
||||
jest.mock('rn-fetch-blob/fs', () => ({
|
||||
dirs: {
|
||||
DocumentDir: () => jest.fn(),
|
||||
CacheDir: () => jest.fn(),
|
||||
},
|
||||
}));
|
||||
|
||||
describe('UserListRow', () => {
|
||||
const formatMessage = jest.fn();
|
||||
const baseProps = {
|
||||
id: '123455',
|
||||
isMyUser: false,
|
||||
user: {
|
||||
id: '21345',
|
||||
username: 'user',
|
||||
delete_at: 0,
|
||||
},
|
||||
theme: {},
|
||||
teammateNameDisplay: 'test',
|
||||
};
|
||||
|
||||
test('should match snapshot', () => {
|
||||
const wrapper = shallow(
|
||||
<UserListRow {...baseProps}/>,
|
||||
{context: {intl: {formatMessage}}},
|
||||
);
|
||||
expect(wrapper).toMatchSnapshot();
|
||||
});
|
||||
|
||||
test('should match snapshot for deactivated user', () => {
|
||||
const deactivatedUser = {
|
||||
id: '21345',
|
||||
username: 'user',
|
||||
delete_at: 100,
|
||||
};
|
||||
|
||||
const newProps = {
|
||||
...baseProps,
|
||||
user: deactivatedUser,
|
||||
};
|
||||
|
||||
const wrapper = shallow(
|
||||
<UserListRow {...newProps}/>,
|
||||
{context: {intl: {formatMessage}}},
|
||||
);
|
||||
expect(wrapper).toMatchSnapshot();
|
||||
});
|
||||
|
||||
test('should match snapshot for currentUser with (you) populated in list', () => {
|
||||
const newProps = {
|
||||
...baseProps,
|
||||
isMyUser: true,
|
||||
};
|
||||
|
||||
const wrapper = shallow(
|
||||
<UserListRow {...newProps}/>,
|
||||
{context: {intl: {formatMessage}}},
|
||||
);
|
||||
expect(wrapper).toMatchSnapshot();
|
||||
});
|
||||
});
|
||||
Loading…
Reference in a new issue