minial best button uionly and e2e

This commit is contained in:
Benjamin Goering
2017-02-28 19:57:50 +08:00
parent 303148e5ba
commit a26a60cc67
7 changed files with 138 additions and 2 deletions
+5
View File
@@ -17,6 +17,7 @@ import PubDate from 'coral-plugin-pubdate/PubDate';
import {ReplyBox, ReplyButton} from 'coral-plugin-replies';
import FlagComment from 'coral-plugin-flags/FlagComment';
import LikeButton from 'coral-plugin-likes/LikeButton';
import BestButton from 'coral-plugin-best/BestButton';
import LoadMore from 'coral-embed-stream/src/LoadMore';
import styles from './Comment.css';
@@ -125,6 +126,10 @@ class Comment extends React.Component {
parentCommentId={parentId || comment.id}
currentUserId={currentUser && currentUser.id}
banned={false} />
<BestButton
isBest={false}
setBestTag={() => {}}
removeBestTag={() => {}} />
</div>
<div className="commentActionsRight">
<PermalinkButton articleURL={asset.url} commentId={comment.id} />
@@ -213,10 +213,20 @@ hr {
width: 50%;
}
.comment__action-button {
cursor: pointer;
}
.comment__action-button--nowrap {
white-space: nowrap;
}
.material-icons {
font-size: 12px !important;
margin-left: 3px;
vertical-align: middle;
width: 1em;
overflow: hidden;
}
.likedButton {
+65
View File
@@ -0,0 +1,65 @@
import React, {Component, PropTypes} from 'react';
import {I18n} from '../coral-framework';
import translations from './translations.json';
import classnames from 'classnames';
const name = 'coral-plugin-best';
const lang = new I18n(translations);
/**
* Button that lets a moderator tag a comment as "Best".
* Used to recognize really good comments.
*/
class BestButton extends Component {
static propTypes = {
// whether the comment is already tagged as best
isBest: PropTypes.bool.isRequired,
// set that this comment is best
setBestTag: PropTypes.func.isRequired,
// remove the best status
removeBestTag: PropTypes.func.isRequired,
}
state = {
best: false
}
constructor(props) {
super(props);
this.onClickSetBest = this.onClickSetBest.bind(this);
this.onClickUnsetBest = this.onClickUnsetBest.bind(this);
}
onClickSetBest(e) {
e.preventDefault();
this.setState({isBest: true});
}
onClickUnsetBest(e) {
e.preventDefault();
this.setState({isBest: false});
}
render() {
// @TODO(bengo) Consider adding the comment__action classes to other buttons to add cursor:pointer and never wrap the icons
// @TODO(bengo) Should I reuse another element like coral-ui button? Just doing what LikeButton does for now
// Oh. I think that's styled for the admin. Don't use coral-ui button until the whole comment bottom bar does.
const {isBest} = this.state;
return <div className={classnames(`${name}-container`, `${name}-button`, 'comment__action-button--nowrap',
`e2e__${isBest ? 'unset' : 'set'}-best-comment`)}>
<button onClick={isBest ? this.onClickUnsetBest : this.onClickSetBest}
className='comment__action-button'>
<span className={`${name}-button-text`}>{lang.t(isBest ? 'unsetBest' : 'setBest')}</span>
<i className={`${name}-icon material-icons`} aria-hidden={true}>
{ isBest ? 'favorite' : 'favorite_border' }
</i>
</button>
</div>;
}
}
export default BestButton;
@@ -0,0 +1,10 @@
{
"en": {
"setBest": "Tag as Best",
"unsetBest": "Untag as Best"
},
"es": {
"like": "Establecer como mejor",
"liked": "Desarmado como mejor"
}
}
+2 -1
View File
@@ -1,13 +1,14 @@
import React, {PropTypes} from 'react';
import {I18n} from '../coral-framework';
import translations from './translations.json';
import classnames from 'classnames';
const name = 'coral-plugin-replies';
const ReplyButton = ({banned, onClick}) => {
return (
<button
className={`${name}-reply-button`}
className={classnames(`${name}-reply-button`, 'comment__action-button--nowrap')}
onClick={onClick}>
{lang.t('reply')}
<i className={`${name}-icon material-icons`}
+4 -1
View File
@@ -38,7 +38,10 @@ const embedStreamCommands = {
.setValue('@signInDialogEmail', user.email)
.setValue('@signInDialogPassword', user.pass)
.waitForElementVisible('@logInButton')
.click('@logInButton')
.click('@logInButton', () => {
// this.api.pause()
})
.waitForElementVisible('@logoutButton', 5000);
},
logout() {
@@ -0,0 +1,42 @@
module.exports = {
'@tags': ['like', 'comments', 'commenter'],
before: client => {
const embedStreamPage = client.page.embedStreamPage();
const {users} = client.globals;
embedStreamPage
.navigate()
.ready();
embedStreamPage
.login(users.commenter);
},
'Moderator marks their comment as BEST': client => {
const embedStreamPage = client.page.embedStreamPage();
const setBestCommentButton = '.comment:nth-of-type(1) .e2e__set-best-comment';
const unsetBestCommentButton = '.comment:nth-of-type(1) .e2e__unset-best-comment';
embedStreamPage
.postComment('Hi everyone. Isn\'t this the BEST comment!?')
.waitForElementVisible(setBestCommentButton, 2000, () => {
client.expect.element(setBestCommentButton).text.to.contain('Tag as Best');
})
.click(setBestCommentButton)
.waitForElementVisible(unsetBestCommentButton, 2000, () => {
client.assert.elementNotPresent(setBestCommentButton);
client.expect.element(unsetBestCommentButton).text.to.contain('Untag as Best');
});
// on refresh, it should still be tagged as best :)
// client
// .refresh(() => {
// })
// .waitForElementVisible(unsetBestCommentButton, 2000)
// client.pause()
},
after: client => {
client.end();
}
};