Skip to content

Commit

Permalink
Fixing cancel ids for selenium (mattermost#5896)
Browse files Browse the repository at this point in the history
* Fixing ids for selenium

* Fixing ids

* Fixing prop
  • Loading branch information
coreyhulen committed Mar 28, 2017
1 parent c7d4f39 commit 6d58c2a
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 5 deletions.
4 changes: 3 additions & 1 deletion components/setting_item_max.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,10 @@ export default class SettingItemMax extends React.Component {
}

let title;
let titleProp = 'unknownTitle';
if (this.props.title) {
title = <li className='col-sm-12 section-title'>{this.props.title}</li>;
titleProp = this.props.title;
}

return (
Expand All @@ -107,7 +109,7 @@ export default class SettingItemMax extends React.Component {
{clientError}
{submit}
<a
id={Utils.createSafeId(this.props.title.toString() + 'Cancel')}
id={Utils.createSafeId(titleProp) + 'Cancel'}
className='btn btn-sm'
href='#'
onClick={this.props.updateSection}
Expand Down
4 changes: 2 additions & 2 deletions components/setting_item_min.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ export default class SettingItemMin extends React.Component {
editButton = (
<li className='col-xs-12 col-sm-3 section-edit'>
<a
id={Utils.createSafeId(this.props.title.toString() + 'Edit')}
id={Utils.createSafeId(this.props.title) + 'Edit'}
className='theme'
href='#'
onClick={this.props.updateSection}
Expand All @@ -36,7 +36,7 @@ export default class SettingItemMin extends React.Component {
<li className='col-xs-12 col-sm-9 section-title'>{this.props.title}</li>
{editButton}
<li
id={Utils.createSafeId(this.props.title.toString() + 'Desc')}
id={Utils.createSafeId(this.props.title) + 'Desc'}
className='col-xs-12 section-describe'
>
{this.props.describe}
Expand Down
12 changes: 10 additions & 2 deletions utils/utils.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,19 @@ export function isMac() {
return navigator.platform.toUpperCase().indexOf('MAC') >= 0;
}

export function createSafeId(str) {
if (str === null) {
export function createSafeId(prop) {
if (prop === null) {
return null;
}

var str = '';

if (prop.props && prop.props.defaultMessage) {
str = prop.props.defaultMessage;
} else {
str = prop.toString();
}

return str.replace(new RegExp(' ', 'g'), '_');
}

Expand Down

0 comments on commit 6d58c2a

Please sign in to comment.