Skip to content
This repository has been archived by the owner on Mar 13, 2024. It is now read-only.

Commit

Permalink
[MM-14242] Remove props such as lastPostCount, idCount and idPrefix w…
Browse files Browse the repository at this point in the history
…hich were previously used for Se E2E (#2410)

* Remove props such as lastPostCount, idCount and idPrefix which were previously used for Se E2E

* revert commented out test setup
  • Loading branch information
saturninoabril committed Feb 28, 2019
1 parent 9f99e56 commit 4dce36d
Show file tree
Hide file tree
Showing 34 changed files with 117 additions and 193 deletions.
19 changes: 6 additions & 13 deletions components/common/comment_icon.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@ import React from 'react';
import {OverlayTrigger, Tooltip} from 'react-bootstrap';
import {FormattedMessage} from 'react-intl';

import {Locations} from 'utils/constants.jsx';

import ReplyIcon from 'components/svg/reply_icon';
import * as Utils from 'utils/utils.jsx';

export default class CommentIcon extends React.PureComponent {
static propTypes = {
idPrefix: PropTypes.string.isRequired,
idCount: PropTypes.number,
location: PropTypes.oneOf([Locations.CENTER, Locations.SEARCH]).isRequired,
handleCommentClick: PropTypes.func.isRequired,
searchStyle: PropTypes.string,
commentCount: PropTypes.number,
Expand All @@ -21,10 +21,10 @@ export default class CommentIcon extends React.PureComponent {
};

static defaultProps = {
idCount: -1,
searchStyle: '',
commentCount: 0,
extraClass: '',
location: Locations.CENTER,
};

render() {
Expand All @@ -41,13 +41,6 @@ export default class CommentIcon extends React.PureComponent {
iconStyle = iconStyle + ' ' + this.props.searchStyle;
}

let selectorId = this.props.idPrefix;
if (this.props.idCount > -1) {
selectorId += this.props.idCount;
}

const id = Utils.createSafeId(this.props.idPrefix + '_' + this.props.postId);

const tooltip = (
<Tooltip
id='comment-icon-tooltip'
Expand All @@ -68,8 +61,8 @@ export default class CommentIcon extends React.PureComponent {
overlay={tooltip}
>
<button
id={id}
className={iconStyle + ' color--link style--none ' + selectorId + ' ' + this.props.extraClass}
id={`${this.props.location}_commentIcon_${this.props.postId}`}
className={iconStyle + ' color--link style--none ' + this.props.extraClass}
onClick={this.props.handleCommentClick}
>
<ReplyIcon className='comment-icon'/>
Expand Down
13 changes: 7 additions & 6 deletions components/dot_menu/dot_menu.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import {OverlayTrigger, Tooltip} from 'react-bootstrap';
import Permissions from 'mattermost-redux/constants/permissions';

import {showGetPostLinkModal} from 'actions/global_actions.jsx';
import {ModalIdentifiers, UNSET_POST_EDIT_TIME_LIMIT} from 'utils/constants.jsx';
import {Locations, ModalIdentifiers, UNSET_POST_EDIT_TIME_LIMIT} from 'utils/constants.jsx';
import DeletePostModal from 'components/delete_post_modal';
import DelayedAction from 'utils/delayed_action.jsx';
import * as PostUtils from 'utils/post_utils.jsx';
Expand All @@ -28,7 +28,7 @@ export default class DotMenu extends Component {
static propTypes = {
post: PropTypes.object.isRequired,
teamId: PropTypes.string,
location: PropTypes.oneOf(['CENTER', 'RHS_ROOT', 'RHS_COMMENT', 'SEARCH']).isRequired,
location: PropTypes.oneOf([Locations.CENTER, Locations.RHS_ROOT, Locations.RHS_COMMENT, Locations.SEARCH]).isRequired,
commentCount: PropTypes.number,
isFlagged: PropTypes.bool,
handleCommentClick: PropTypes.func,
Expand Down Expand Up @@ -79,6 +79,7 @@ export default class DotMenu extends Component {
isFlagged: false,
isReadOnly: false,
pluginMenuItems: [],
location: Locations.CENTER,
}

constructor(props) {
Expand Down Expand Up @@ -167,7 +168,7 @@ export default class DotMenu extends Component {
dialogProps: {
post: this.props.post,
commentCount: this.props.commentCount,
isRHS: this.props.location === 'RHS_ROOT' || this.props.location === 'RHS_COMMENT',
isRHS: this.props.location === Locations.RHS_ROOT || this.props.location === Locations.RHS_COMMENT,
},
};

Expand All @@ -178,9 +179,9 @@ export default class DotMenu extends Component {
this.props.actions.setEditingPost(
this.props.post.id,
this.props.commentCount,
this.props.location === 'CENTER' ? 'post_textbox' : 'reply_textbox',
this.props.location === Locations.CENTER ? 'post_textbox' : 'reply_textbox',
this.props.post.root_id ? Utils.localizeMessage('rhs_comment.comment', 'Comment') : Utils.localizeMessage('create_post.post', 'Post'),
this.props.location === 'RHS_ROOT' || this.props.location === 'RHS_COMMENT',
this.props.location === Locations.RHS_ROOT || this.props.location === Locations.RHS_COMMENT,
);
}

Expand Down Expand Up @@ -276,7 +277,7 @@ export default class DotMenu extends Component {
onClick={this.handleFlagMenuItemActivated}
/>
<MenuItemAction
show={!isSystemMessage && this.props.location === 'CENTER'}
show={!isSystemMessage && this.props.location === Locations.CENTER}
text={Utils.localizeMessage('post_info.reply', 'Reply')}
onClick={this.props.handleCommentClick}
/>
Expand Down
1 change: 0 additions & 1 deletion components/dot_menu/dot_menu.test.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ jest.mock('utils/post_utils', () => {
describe('components/dot_menu/DotMenu', () => {
const baseProps = {
post: {id: 'post_id_1', is_pinned: false},
location: 'CENTER',
isLicensed: false,
postEditTimeLimit: '-1',
handleCommentClick: jest.fn(),
Expand Down
1 change: 0 additions & 1 deletion components/dot_menu/dot_menu_empty.test.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ jest.mock('utils/post_utils', () => {
describe('components/dot_menu/DotMenu returning empty ("")', () => {
test('should match snapshot, return empty ("") on Center', () => {
const baseProps = {
location: 'CENTER',
post: {id: 'post_id_1'},
isLicensed: false,
postEditTimeLimit: '-1',
Expand Down
1 change: 0 additions & 1 deletion components/dot_menu/dot_menu_mobile.test.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ jest.mock('utils/post_utils', () => {
describe('components/dot_menu/DotMenu on mobile view', () => {
test('should match snapshot', () => {
const baseProps = {
location: 'CENTER',
post: {id: 'post_id_1'},
isLicensed: false,
postEditTimeLimit: '-1',
Expand Down
1 change: 0 additions & 1 deletion components/post_view/post/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ function mapStateToProps(state, ownProps) {

return {
post: getPost(state, detailedPost.id),
lastPostCount: ownProps.lastPostCount,
currentUserId: getCurrentUserId(state),
isFirstReply: Boolean(detailedPost.isFirstReply && detailedPost.commentedOnPost),
highlight: detailedPost.highlight,
Expand Down
7 changes: 0 additions & 7 deletions components/post_view/post/post.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -63,11 +63,6 @@ export default class Post extends React.PureComponent {
*/
replyCount: PropTypes.number,

/**
* The post count used for selenium tests
*/
lastPostCount: PropTypes.number,

/**
* Function to get the post list HTML element
*/
Expand Down Expand Up @@ -257,7 +252,6 @@ export default class Post extends React.PureComponent {
handleCommentClick={this.handleCommentClick}
handleDropdownOpened={this.handleDropdownOpened}
compactDisplay={this.props.compactDisplay}
lastPostCount={this.props.lastPostCount}
isFirstReply={this.props.isFirstReply}
replyCount={this.props.replyCount}
showTimeWithoutHover={!hideProfilePicture}
Expand All @@ -268,7 +262,6 @@ export default class Post extends React.PureComponent {
post={post}
handleCommentClick={this.handleCommentClick}
compactDisplay={this.props.compactDisplay}
lastPostCount={this.props.lastPostCount}
isCommentMention={this.props.isCommentMention}
isFirstReply={this.props.isFirstReply}
/>
Expand Down
6 changes: 0 additions & 6 deletions components/post_view/post_body/post_body.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -62,11 +62,6 @@ export default class PostBody extends React.PureComponent {
*/
previewEnabled: PropTypes.bool,

/**
* Post identifiers for selenium tests
*/
lastPostCount: PropTypes.number,

/*
* Post type components from plugins
*/
Expand Down Expand Up @@ -171,7 +166,6 @@ export default class PostBody extends React.PureComponent {
{failedOptions}
{this.state.sending && <LoadingBars/>}
<PostMessageView
lastPostCount={this.props.lastPostCount}
post={this.props.post}
compactDisplay={this.props.compactDisplay}
hasMention={true}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ exports[`components/post_view/PostFlagIcon should match snapshot 1`] = `
>
<button
className="style--none flag-icon__container "
id="centerPostFlag_post_id"
id="CENTER_flagIcon_post_id"
onClick={[Function]}
>
<FlagIcon
Expand Down Expand Up @@ -66,7 +66,7 @@ exports[`components/post_view/PostFlagIcon should match snapshot 2`] = `
>
<button
className="style--none flag-icon__container visible"
id="centerPostFlag_post_id"
id="CENTER_flagIcon_post_id"
onClick={[Function]}
>
<FlagIconFilled
Expand Down
15 changes: 4 additions & 11 deletions components/post_view/post_flag_icon/post_flag_icon.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,12 @@ import {FormattedMessage} from 'react-intl';

import FlagIcon from 'components/svg/flag_icon';
import FlagIconFilled from 'components/svg/flag_icon_filled';
import Constants from 'utils/constants.jsx';
import * as Utils from 'utils/utils.jsx';
import Constants, {Locations} from 'utils/constants.jsx';
import {t} from 'utils/i18n';

export default class PostFlagIcon extends React.PureComponent {
static propTypes = {
idPrefix: PropTypes.string.isRequired,
idCount: PropTypes.number,
location: PropTypes.oneOf([Locations.CENTER, Locations.RHS_ROOT, Locations.RHS_COMMENT, Locations.SEARCH]).isRequired,
postId: PropTypes.string.isRequired,
isFlagged: PropTypes.bool.isRequired,
isEphemeral: PropTypes.bool,
Expand All @@ -26,8 +24,8 @@ export default class PostFlagIcon extends React.PureComponent {
};

static defaultProps = {
idCount: -1,
isEphemeral: false,
location: Locations.CENTER,
};

handlePress = (e) => {
Expand Down Expand Up @@ -55,11 +53,6 @@ export default class PostFlagIcon extends React.PureComponent {

const flagVisible = isFlagged ? 'visible' : '';

let flagIconId = null;
if (this.props.idCount > -1) {
flagIconId = Utils.createSafeId(this.props.idPrefix + this.props.idCount);
}

let flagIcon;
if (isFlagged) {
flagIcon = <FlagIconFilled className='icon'/>;
Expand All @@ -83,7 +76,7 @@ export default class PostFlagIcon extends React.PureComponent {
}
>
<button
id={flagIconId || `${this.props.idPrefix}_${this.props.postId}`}
id={`${this.props.location}_flagIcon_${this.props.postId}`}
className={'style--none flag-icon__container ' + flagVisible}
onClick={this.handlePress}
>
Expand Down
1 change: 0 additions & 1 deletion components/post_view/post_flag_icon/post_flag_icon.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import PostFlagIcon from 'components/post_view/post_flag_icon/post_flag_icon';

describe('components/post_view/PostFlagIcon', () => {
const baseProps = {
idPrefix: 'centerPostFlag',
postId: 'post_id',
isFlagged: false,
isEphemeral: false,
Expand Down
6 changes: 0 additions & 6 deletions components/post_view/post_header/post_header.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,6 @@ export default class PostHeader extends React.PureComponent {
*/
isFirstReply: PropTypes.bool,

/*
* Post identifiers for selenium tests
*/
lastPostCount: PropTypes.number,

/**
* Function to get the post list HTML element
*/
Expand Down Expand Up @@ -156,7 +151,6 @@ export default class PostHeader extends React.PureComponent {
handleCommentClick={this.props.handleCommentClick}
handleDropdownOpened={this.props.handleDropdownOpened}
compactDisplay={this.props.compactDisplay}
lastPostCount={this.props.lastPostCount}
replyCount={this.props.replyCount}
isFirstReply={this.props.isFirstReply}
showTimeWithoutHover={this.props.showTimeWithoutHover}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,8 +112,6 @@ exports[`components/post_view/PostInfo should match snapshot, flagged post 1`] =
className="col"
>
<Connect(PostFlagIcon)
idCount={-1}
idPrefix="centerPostFlag"
isEphemeral={false}
isFlagged={true}
postId="e584uzbwwpny9kengqayx5ayzw"
Expand All @@ -138,8 +136,6 @@ exports[`components/post_view/PostInfo should match snapshot, hover 1`] = `
postId="e584uzbwwpny9kengqayx5ayzw"
/>
<Connect(PostFlagIcon)
idCount={-1}
idPrefix="centerPostFlag"
isEphemeral={false}
isFlagged={false}
postId="e584uzbwwpny9kengqayx5ayzw"
Expand All @@ -155,7 +151,6 @@ exports[`components/post_view/PostInfo should match snapshot, hover 1`] = `
handleCommentClick={[MockFunction]}
handleDropdownOpened={[Function]}
isFlagged={false}
location="CENTER"
post={
Object {
"channel_id": "g6139tbospd18cmxroesdk3kkc",
Expand All @@ -181,8 +176,7 @@ exports[`components/post_view/PostInfo should match snapshot, hover 1`] = `
commentCount={0}
extraClass="pull-right"
handleCommentClick={[MockFunction]}
idCount={-1}
idPrefix="commentIcon"
location="CENTER"
postId="e584uzbwwpny9kengqayx5ayzw"
searchStyle=""
/>
Expand Down Expand Up @@ -262,7 +256,6 @@ exports[`components/post_view/PostInfo toggleEmojiPicker, should have called pro
handleCommentClick={[MockFunction]}
handleDropdownOpened={[Function]}
isFlagged={false}
location="CENTER"
post={
Object {
"channel_id": "g6139tbospd18cmxroesdk3kkc",
Expand Down Expand Up @@ -295,8 +288,7 @@ exports[`components/post_view/PostInfo toggleEmojiPicker, should have called pro
commentCount={0}
extraClass="pull-right"
handleCommentClick={[MockFunction]}
idCount={-1}
idPrefix="commentIcon"
location="CENTER"
postId="e584uzbwwpny9kengqayx5ayzw"
searchStyle=""
/>
Expand Down
Loading

0 comments on commit 4dce36d

Please sign in to comment.