Merge branch 'add-flag-option' of github.com:coralproject/talk into add-flag-option

This commit is contained in:
David Jay
2016-12-20 11:31:57 -08:00
53 changed files with 7976 additions and 111 deletions
+7 -8
View File
@@ -1,16 +1,15 @@
{
"sourceMaps": true,
"presets": [
"stage-0",
"es2015"
],
"plugins": [
["transform-decorators-legacy"],
["transform-react-jsx"],
["transform-object-assign"],
["transform-class-properties"],
["transform-async-to-generator"],
["transform-object-rest-spread"],
["transform-class-properties"]
"add-module-exports",
"transform-async-to-generator",
"transform-class-properties",
"transform-decorators-legacy",
"transform-object-assign",
"transform-object-rest-spread",
"transform-react-jsx"
]
}
+2
View File
@@ -21,6 +21,8 @@
"no-eval": [2],
"no-global-assign": [2],
"no-implied-eval": [2],
"lines-around-comment": ["warn", {"beforeLineComment": true}],
"spaced-comment": ["warn", "always", { "line": { "exceptions": ["-", "="] } }],
"no-script-url": [2],
"no-throw-literal": [2],
"yoda": [1],
+1
View File
@@ -22,6 +22,7 @@ if (app.get('env') !== 'test') {
//==============================================================================
app.set('trust proxy', 1);
// We disable frameward on helmet to allow crossdomain injection of the embed
app.use(helmet({
frameguard: false
+2
View File
@@ -60,11 +60,13 @@ function normalizePort(val) {
let port = parseInt(val, 10);
if (isNaN(port)) {
// named pipe
return val;
}
if (port >= 0) {
// port number
return port;
}
+7 -5
View File
@@ -30,7 +30,7 @@ export default props => {
<div>
{links ?
<span className={styles.hasLinks}><Icon name='error_outline'/> Contains Link</span> : null}
<div className={styles.actions}>
<div className={`actions ${styles.actions}`}>
{props.actions.map((action, i) => getActionButton(action, i, props))}
</div>
</div>
@@ -63,19 +63,21 @@ const getActionButton = (action, i, props) => {
if (action === 'ban') {
return (
<Button
disabled={banned ? 'disabled' : ''}
className='ban'
cStyle='black'
disabled={banned ? 'disabled' : ''}
onClick={() => props.onClickShowBanDialog(author.id, author.displayName, comment.id)}
key={i} >
key={i}
>
{lang.t('comment.ban_user')}
</Button>
);
}
return (
<FabButton
className={styles.actionButton}
icon={props.actionsMap[action].icon}
className={`${action} ${styles.actionButton}`}
cStyle={action}
icon={props.actionsMap[action].icon}
key={i}
onClick={() => props.onClickAction(props.actionsMap[action].status, comment.id)}
/>
@@ -31,6 +31,7 @@ export default class CommentList extends React.Component {
// add key handlers and gestures
componentDidMount () {
this.bindKeyHandlers();
// this.bindGestures() // need to check whether we're on a mobile device or this throws an Error
}
@@ -80,6 +81,7 @@ export default class CommentList extends React.Component {
const {commentIds} = this.props;
const {active} = this.state;
// check boundaries
if (active === null || !commentIds.length) {
this.setState({active: commentIds[0]});
@@ -102,6 +104,7 @@ export default class CommentList extends React.Component {
// TODO: In the future this can be improved and look at the actual state to
// resolve since the content of the list could change externally. For now it works as expected
onClickAction (action, id, author_id) {
// activate the next comment
if (id === this.state.active) {
const {commentIds} = this.props;
@@ -123,7 +126,10 @@ export default class CommentList extends React.Component {
const {active} = this.state;
return (
<ul className={`${styles.list} ${singleView ? styles.singleView : ''}`} {...key}>
<ul
className={`${styles.list} ${singleView ? styles.singleView : ''}`} {...key}
id='commentList'
>
{commentIds.map((commentId, index) => {
const comment = comments[commentId];
const author = users[comment.author_id];
@@ -69,11 +69,17 @@ const updateClosedTimeout = (updateSettings, ts, isMeasure) => (event) => {
}
};
const CommentSettings = ({updateSettings, settingsError, settings, errors}) => <List>
const CommentSettings = ({fetchingSettings, updateSettings, settingsError, settings, errors}) => {
if (fetchingSettings) {
/* maybe a spinner here at some point */
return <p>Loading settings...</p>;
}
return <List>
<ListItem className={`${styles.configSetting} ${settings.moderation === 'pre' ? styles.enabledSetting : styles.disabledSetting}`}>
<ListItemAction>
<Checkbox
onClick={updateModeration(updateSettings, settings.moderation)}
onChange={updateModeration(updateSettings, settings.moderation)}
checked={settings.moderation === 'pre'} />
</ListItemAction>
<ListItemContent>
@@ -86,7 +92,7 @@ const CommentSettings = ({updateSettings, settingsError, settings, errors}) => <
<ListItem className={`${styles.configSetting} ${settings.charCountEnable ? styles.enabledSetting : styles.disabledSetting}`}>
<ListItemAction>
<Checkbox
onClick={updateCharCountEnable(updateSettings, settings.charCountEnable)}
onChange={updateCharCountEnable(updateSettings, settings.charCountEnable)}
checked={settings.charCountEnable} />
</ListItemAction>
<ListItemContent>
@@ -113,7 +119,7 @@ const CommentSettings = ({updateSettings, settingsError, settings, errors}) => <
<ListItem threeLine className={`${styles.configSettingInfoBox} ${settings.infoBoxEnable ? styles.enabledSetting : styles.disabledSetting}`}>
<ListItemAction>
<Checkbox
onClick={updateInfoBoxEnable(updateSettings, settings.infoBoxEnable)}
onChange={updateInfoBoxEnable(updateSettings, settings.infoBoxEnable)}
checked={settings.infoBoxEnable} />
</ListItemAction>
<ListItemContent>
@@ -144,7 +150,9 @@ const CommentSettings = ({updateSettings, settingsError, settings, errors}) => <
value={getTimeoutAmount(settings.closedTimeout)}
label={lang.t('configure.closed-comments-label')} />
<div className={styles.configTimeoutSelect}>
<SelectField value={getTimeoutMeasure(settings.closedTimeout)}
<SelectField
label="comments closed time window"
value={getTimeoutMeasure(settings.closedTimeout)}
onChange={updateClosedTimeout(updateSettings, settings.closedTimeout, true)}>
<Option value={'hours'}>{lang.t('configure.hours')}</Option>
<Option value={'days'}>{lang.t('configure.days')}</Option>
@@ -164,6 +172,7 @@ const CommentSettings = ({updateSettings, settingsError, settings, errors}) => <
</ListItemContent>
</ListItem>
</List>;
};
export default CommentSettings;
@@ -78,6 +78,7 @@ class Configure extends React.Component {
switch(section){
case 'comments':
return <CommentSettings
fetchingSettings={this.props.fetchingSettings}
settings={this.props.settings}
updateSettings={this.onSettingUpdate}
errors={this.state.errors}
@@ -1,6 +1,5 @@
import React from 'react';
import {connect} from 'react-redux';
import {Icon} from 'react-mdl';
import key from 'keymaster';
import ModerationKeysModal from 'components/ModerationKeysModal';
@@ -71,10 +70,6 @@ class ModerationQueue extends React.Component {
this.props.dispatch(banUser('banned', userId, commentId));
}
showShortcuts = () => {
this.setState({modalOpen: true});
}
onTabClick (activeTab) {
this.setState({activeTab});
}
@@ -98,11 +93,6 @@ class ModerationQueue extends React.Component {
className={`mdl-tabs__tab ${styles.tab}`}>{lang.t('modqueue.rejected')}</a>
<a href='#flagged' onClick={() => this.onTabClick('flagged')}
className={`mdl-tabs__tab ${styles.tab}`}>{lang.t('modqueue.flagged')}</a>
<a href='#' onClick={this.showShortcuts}
className={`mdl-tabs__tab ${styles.tab} ${styles.showShortcuts}`}>
<Icon name='keyboard' />
<span>{lang.t('modqueue.showshortcuts')}</span>
</a>
</div>
<div className={`mdl-tabs__panel is-active ${styles.listContainer}`} id='pending'>
<CommentList
@@ -38,6 +38,7 @@ Promise.all([
coralApi('/comments?action_type=flag')
])
.then(([pending, rejected, flagged]) => {
/* Combine seperate calls into a single object */
let all = {};
all.comments = pending.comments
@@ -55,6 +56,7 @@ Promise.all([
return all;
})
.then(all => {
/* Post comments and users to redux store. Actions will be posted when they are needed. */
store.dispatch({type: 'USERS_MODERATION_QUEUE_FETCH_SUCCESS',
users: all.users});
@@ -62,6 +64,7 @@ Promise.all([
comments: all.comments});
});
// .catch(error => store.dispatch({type: 'COMMENTS_MODERATION_QUEUE_FETCH_FAILED', error}));
// Update a comment. Now to update a comment we need to send back the whole object
@@ -58,6 +58,7 @@ class CommentStream extends Component {
}
componentDidMount () {
// Set up messaging between embedded Iframe an parent component
this.pym = new Pym.Child({polling: 100});
+1
View File
@@ -118,6 +118,7 @@ export function getStream (assetUrl) {
/* Sort comments by date*/
json.comments.sort((a, b) => new Date(b.created_at).getTime() - new Date(a.created_at).getTime());
const rels = json.comments.reduce((h, item) => {
/* Check for root and child comments. */
if (
item.asset_id === assetId &&
@@ -9,6 +9,7 @@ import get from 'lodash/get';
class i18n {
constructor (translations) {
/**
* Register locales
*/
@@ -16,6 +17,7 @@ class i18n {
this.locales = {'en': 'en', 'es': 'es'};
timeago.register('es_ES', esTA);
this.timeagoInstance = new timeago();
/**
* Load translations
*/
@@ -55,6 +57,7 @@ class i18n {
this.t = (key, ...replacements) => {
if (has(this.translations, key)) {
let translation = get(this.translations, key);
// replace any {n} with the arguments passed to this method
replacements.forEach((str, i) => {
translation = translation.replace(new RegExp(`\\{${i}\\}`, 'g'), str);
+2 -1
View File
@@ -31,7 +31,7 @@ class FlagButton extends Component {
const {postAction, addItem, updateItem, flag, id, author_id} = this.props;
const {itemType, field, reason, step, note, posted} = this.state;
//Proceed to the next step or close the menu if we've reached the end
// Proceed to the next step or close the menu if we've reached the end
if (step + 1 >= this.props.getPopupMenu.length) {
this.setState({showMenu: false});
} else {
@@ -40,6 +40,7 @@ class FlagButton extends Component {
// If itemType and reason are both set, post the action
if (itemType && reason && !posted) {
// Set the text from the "other" field if it exists.
let item_id;
switch(itemType) {
+1 -1
View File
@@ -2,7 +2,7 @@ import React from 'react';
import {I18n} from '../coral-framework';
import translations from './translations.json';
const name = 'coral-plugin-flags';
const name = 'coral-plugin-likes';
const LikeButton = ({like, id, postAction, deleteAction, addItem, showSignInDialog, updateItem, currentUser, banned}) => {
const liked = like && like.current_user;
@@ -21,6 +21,7 @@ class SignInContainer extends Component {
}
componentWillMount () {
// Fetch commentHistory
this.props.fetchCommentsByUserId(this.props.userData.id);
}
@@ -38,6 +39,7 @@ class SignInContainer extends Component {
const commentsMostRecentFirst = user
.myComments.map(id => items.comments[id])
.sort(({created_at:a}, {created_at:b}) => {
// descending order, created_at
// js date strings can be sorted lexigraphically.
const aLessThanB = a < b ? 1 : 0;
@@ -9,10 +9,11 @@ import ForgotContent from './ForgotContent';
const SignDialog = ({open, view, handleClose, offset, ...props}) => (
<Dialog
className={styles.dialog}
id="signInDialog"
open={open}
style={{
position: 'relative',
top: offset !== 0 && offset
top: offset !== 0 && offset
}}>
<span className={styles.close} onClick={handleClose}>×</span>
{view === 'SIGNIN' && <SignInContent {...props} />}
+3 -1
View File
@@ -9,7 +9,9 @@ const UserBox = ({className, user, logout, ...props}) => (
className={`${styles.userBox} ${className ? className : ''}`}
{...props}
>
{lang.t('signIn.loggedInAs')} <a>{user.displayName}</a>. {lang.t('signIn.notYou')} <a onClick={logout}>{lang.t('signIn.logout')}</a>
{lang.t('signIn.loggedInAs')}
<a>{user.displayName}</a>. {lang.t('signIn.notYou')}
<a onClick={logout} id='logout'>{lang.t('signIn.logout')}</a>
</div>
);
@@ -113,6 +113,7 @@ input.error{
font-weight: bold;
cursor: pointer;
margin: 0px;
margin-left: 4px;
padding-bottom: 2px;
border-bottom: solid 1px black;
}
+1
View File
@@ -7,6 +7,7 @@ const maxRecursion = 3;
* payload response first based on user and role.
*/
module.exports = (req, res, next) => {
/**
* Updates the original document based on filtering out for roles.
* @param {Mixed} o original object to be modified
+3
View File
@@ -88,6 +88,7 @@ const UserSchema = new mongoose.Schema({
// Status provides a string that says in which state the account is.
// When the account is banned, the user login is disabled.
status: {type: String, enum: USER_STATUS, default: 'active'},
// User's settings
settings: {
bio: {
@@ -501,6 +502,7 @@ UserService.createPasswordResetToken = function (email) {
.then(user => {
if (user === null) {
// since we don't want to reveal that the email does/doesn't exist
// just go ahead and resolve the Promise with null and check in the endpoint
return Promise.resolve(null);
@@ -528,6 +530,7 @@ UserService.verifyPasswordResetToken = token => {
});
})
.then(decoded => {
/**
* TODO: check the jti from this decoded token in redis
* and make an entry if it does not exist.
+17 -8
View File
@@ -19,6 +19,7 @@ module.exports = {
},
'test_settings': {
'default': {
'launch_url' : 'http://localhost:3000',
'selenium_port': 6666,
'selenium_host': 'localhost',
'silent': true,
@@ -26,19 +27,27 @@ module.exports = {
'browserName': 'chrome',
'javascriptEnabled': true,
'acceptSslCerts': true,
'webStorageEnabled' : true,
'databaseEnabled' : true,
'applicationCacheEnabled' : false,
'nativeEvents' : true
'webStorageEnabled': true,
'databaseEnabled': true,
'applicationCacheEnabled': false,
'nativeEvents': true
},
'screenshots' : {
'enabled' : true,
'on_failure' : true,
'on_error' : true,
'path' : './tests/e2e/reports'
'enabled': true,
'on_failure': true,
'on_error': true,
'path': './tests/e2e/reports'
},
'exclude': [
'./tests/e2e/tests/EmbedStreamTests.js'
]
},
'integration': {
'launch_url': 'http://localhost:3000'
}
}
};
// "chromeOptions" : {
// "args" : ["start-fullscreen"]
// }
+6 -5
View File
@@ -11,8 +11,8 @@
"lint-fix": "./node_modules/.bin/eslint bin/* . --fix",
"test": "NODE_ENV=test ./node_modules/.bin/mocha --compilers js:babel-core/register tests/helpers/*.js --require ignore-styles --recursive tests",
"test-watch": "NODE_ENV=test ./node_modules/.bin/mocha --compilers js:babel-core/register --recursive -w tests",
"pree2e": "NODE_ENV=test ./scripts/pree2e.sh",
"e2e": "NODE_ENV=test ./node_modules/.bin/nightwatch",
"pree2e": "NODE_ENV=test scripts/pree2e.sh",
"e2e": "NODE_ENV=test nightwatch",
"embed-start": "NODE_ENV=development npm run build && ./bin/cli serve --jobs"
},
"config": {
@@ -74,10 +74,11 @@
},
"devDependencies": {
"autoprefixer": "^6.5.2",
"babel-core": "^6.18.2",
"babel-core": "^6.21.0",
"babel-eslint": "^7.1.0",
"babel-jest": "^15.0.0",
"babel-loader": "^6.2.7",
"babel-plugin-add-module-exports": "^0.2.1",
"babel-plugin-transform-async-to-generator": "^6.16.0",
"babel-plugin-transform-class-properties": "^6.18.0",
"babel-plugin-transform-decorators-legacy": "^1.3.4",
@@ -115,7 +116,7 @@
"material-design-lite": "^1.2.1",
"mocha": "^3.1.2",
"mocha-junit-reporter": "^1.12.1",
"nightwatch": "^0.9.9",
"nightwatch": "^0.9.11",
"node-fetch": "^1.6.3",
"postcss-loader": "^1.1.0",
"postcss-modules": "^0.5.2",
@@ -136,7 +137,7 @@
"redux-mock-store": "^1.2.1",
"redux-thunk": "^2.1.0",
"regenerator": "^0.8.46",
"selenium-standalone": "^5.8.0",
"selenium-standalone": "latest",
"style-loader": "^0.13.1",
"supertest": "^2.0.1",
"timeago.js": "^2.0.3",
+1
View File
@@ -4,6 +4,7 @@ const router = express.Router();
// Get /password-reset expects a signed token (JWT) in the hash.
// Links to this endpoint are generated by /views/password-reset-email.ejs.
router.get('/password-reset', (req, res, next) => {
// TODO: store the redirect uri in the token or something fancy.
// admins and regular users should probably be redirected to different places.
res.render('password-reset', {redirectUri: process.env.TALK_ROOT_URL});
+1
View File
@@ -82,6 +82,7 @@ router.post('/:asset_id/scrape', (req, res, next) => {
});
router.put('/:asset_id/settings', (req, res, next) => {
// Override the settings for the asset.
Asset
.overrideSettings(req.params.asset_id, req.body)
+3
View File
@@ -107,6 +107,7 @@ router.post('/', wordlist.filter('body'), (req, res, next) => {
// Check to see if the asset has closed commenting...
if (asset.isClosed) {
// They have, ensure that we send back an error.
return Promise.reject(new Error(`asset has commenting closed because: ${asset.closedMessage}`));
}
@@ -117,6 +118,7 @@ router.post('/', wordlist.filter('body'), (req, res, next) => {
// Return `premod` if pre-moderation is enabled and an empty "new" status
// in the event that it is not in pre-moderation mode.
.then(({moderation, charCountEnable, charCount}) => {
// Reject if the comment is too long
if (charCountEnable && body.length > charCount) {
return 'rejected';
@@ -133,6 +135,7 @@ router.post('/', wordlist.filter('body'), (req, res, next) => {
author_id: req.user.id
}))
.then((comment) => {
// The comment was created! Send back the created comment.
res.status(201).json(comment);
})
+2
View File
@@ -25,6 +25,7 @@ router.get('/', (req, res, next) => {
// Get the asset_id for this url (or create it if it doesn't exist)
Promise.all([
// Find or create the asset by url.
Asset.findOrCreateByUrl(asset_url)
@@ -70,6 +71,7 @@ router.get('/', (req, res, next) => {
settings
]);
})
// Get all the users and actions for those comments.
.then(([comments, asset, settings]) => {
+1
View File
@@ -123,6 +123,7 @@ router.post('/request-password-reset', (req, res, next) => {
to: email,
html: resetEmailTemplate({
token,
// probably more clear to explicitly pass this
rootURL: process.env.TALK_ROOT_URL
})
+1
View File
@@ -6,6 +6,7 @@ router.use('/:embed', (req, res, next) => {
case 'stream':
return res.render('embed/stream', {});
default:
// will return a 404.
return next();
}
+11 -3
View File
@@ -1,7 +1,15 @@
#!/bin/bash
# install selenium
../node_modules/selenium-standalone/bin/selenium-standalone install
selenium-standalone install
# start the app server
npm start &
# Creating Admin Test User
{ echo admin@test.com; echo test; echo test; echo Admin Test User; echo admin;} | dotenv ./bin/cli-users create
# Creating Moderator Test User
{ echo moderator@test.com; echo test; echo test; echo Moderator Test User; echo moderator;} | dotenv ./bin/cli-users create
# Creating Commenter Test User
{ echo commenter@test.com; echo test; echo test; echo Commenter Test User; echo ;} | dotenv ./bin/cli-users create
npm start
+1 -1
View File
@@ -2,7 +2,7 @@ const mongoose = require('mongoose');
const debug = require('debug')('talk:db');
const enabled = require('debug').enabled;
//Append '-test' to the db if node_env === 'test'
// Append '-test' to the db if node_env === 'test'
let url = process.env.TALK_MONGO_URL || 'mongodb://localhost/coral-talk';
if (process.env.NODE_ENV === 'test') {
@@ -74,7 +74,7 @@ describe('itemActions', () => {
});
});
//Disabling tests for this function until is is used again.
// Disabling tests for this function until is is used again.
xdescribe('getItemsArray', () => {
const response = {items: [{type: 'comment', id: '123'}, {type: 'comment', id: '456'}]};
const ids = [1, 2];
+16 -2
View File
@@ -1,4 +1,18 @@
module.exports = {
waitForConditionTimeout: 20000,
baseUrl: 'localhost:3011/'
waitForConditionTimeout: 8000,
baseUrl: 'http://localhost:3000',
users: {
admin: {
email: 'admin@test.com',
pass: 'test'
},
moderator: {
email: 'moderator@test.com',
pass: 'test'
},
commenter: {
email: 'commenter@test.com',
pass: 'test'
}
},
};
+33
View File
@@ -0,0 +1,33 @@
const embedStreamCommands = {
url: function () {
return `${this.api.launchUrl}/admin`;
},
ready() {
return this
.waitForElementVisible('body', 2000);
},
approveComment() {
return this
.waitForElementVisible('@commentList')
.waitForElementVisible('@approveButton')
.click('@approveButton');
}
};
module.exports = {
commands: [embedStreamCommands],
elements: {
commentList: {
selector: '#commentList'
},
banButton: {
selector: '#commentList .actions:first-child .ban'
},
rejectButton: {
selector: '#commentList .actions:first-child .reject'
},
approveButton: {
selector: '#commentList .actions:first-child .approve'
}
}
};
-45
View File
@@ -1,45 +0,0 @@
const fetch = require('node-fetch');
const embedCommands = {
ready() {
return this.resizeWindow(1200, 800)
.url(client.globals.baseUrl)
.waitForElementVisible('body', 2000)
.frame('coralStreamIframe');
},
setConfig(config, baseUrl) {
return fetch(`${baseUrl}/api/v1/settings`, {
method: 'PUT',
headers: {
'Content-Type': 'application/json',
'Accept': 'application/json'
},
body: JSON.stringify(config)
});
},
enterComment() {
const comment = 'This is a test comment';
return this
.waitForElementVisible('@commentBox')
.setValue('@commentBox', comment)
.click('@postButton')
.waitForElementVisible('.comment', 1000);
},
validateComment(comment) {
return this
.assert.equal(comment, '.comment');
}
};
module.exports = {
commands: [embedCommands],
elements: {
commentBox: {
selector: '#commentBox'
},
postButton: {
selector: '#commentBox .coral-plugin-commentbox-button'
}
}
};
+160
View File
@@ -0,0 +1,160 @@
const embedStreamCommands = {
url: function () {
return this
.api.launchUrl;
},
ready() {
return this
.waitForElementVisible('body', 4000)
.waitForElementVisible('iframe#coralStreamIframe')
.api.frame('coralStreamIframe');
},
signUp(user) {
return this
.waitForElementVisible('@signInButton', 2000)
.click('@signInButton')
.waitForElementVisible('@signInDialog')
.waitForElementVisible('@registerButton')
.click('@registerButton')
.setValue('@signInDialogEmail', user.email)
.setValue('@signInDialogPassword', user.pass)
.setValue('@signUpDialogConfirmPassword', user.pass)
.setValue('@signUpDialogDisplayName', user.displayName)
.waitForElementVisible('@signUpButton')
.click('@signUpButton')
.waitForElementVisible('@logInButton')
.click('@logInButton')
.waitForElementVisible('@logoutButton', 5000);
},
login(user) {
return this
.waitForElementVisible('@signInButton', 2000)
.click('@signInButton')
.waitForElementVisible('@signInDialog')
.waitForElementVisible('@signInDialogEmail')
.waitForElementVisible('@signInDialogPassword')
.setValue('@signInDialogEmail', user.email)
.setValue('@signInDialogPassword', user.pass)
.waitForElementVisible('@logInButton')
.click('@logInButton')
.waitForElementVisible('@logoutButton', 5000);
},
logout() {
return this
.waitForElementVisible('@logoutButton')
.click('@logoutButton')
.waitForElementVisible('@signInButton', 2000);
},
postComment(comment = 'Test Comment') {
return this
.waitForElementVisible('@commentBox', 2000)
.setValue('@commentBox', comment)
.click('@postButton');
},
likeComment() {
return this
.waitForElementVisible('@likeButton')
.click('@likeButton');
},
flagComment() {
return this
.waitForElementVisible('@flagButton')
.click('@flagButton');
},
flagUsername() {
return this
.waitForElementVisible('@flagButton')
.click('@flagButton');
},
getPermalink(fn) {
return this
.waitForElementVisible('@permalinkButton')
.click('@permalinkButton')
.waitForElementVisible('@permalinkPopUp')
.getValue('@permalinkInput', result => fn(result.value));
}
};
module.exports = {
commands: [embedStreamCommands],
elements: {
signInButton: {
selector: '#coralSignInButton'
},
signInDialog:{
selector: '#signInDialog'
},
signInDialogEmail: {
selector: '#signInDialog #email'
},
signInDialogPassword: {
selector: '#signInDialog #password'
},
signUpDialogConfirmPassword: {
selector: '#signInDialog #confirmPassword'
},
signUpDialogDisplayName: {
selector: '#signInDialog #displayName'
},
logInButton: {
selector: '#coralLogInButton'
},
signUpButton: {
selector: '#coralSignUpButton'
},
logoutButton: {
selector: '.commentStream #logout'
},
commentBox: {
selector: '.coral-plugin-commentbox-textarea'
},
postButton: {
selector: '#commentBox .coral-plugin-commentbox-button'
},
likeButton: {
selector: '.comment .coral-plugin-likes-container .coral-plugin-likes-button'
},
likeText: {
selector: '.comment .coral-plugin-likes-container .coral-plugin-likes-button .coral-plugin-likes-button-text'
},
likesCount: {
selector: '.comment .coral-plugin-likes-container .coral-plugin-likes-button .coral-plugin-likes-like-count'
},
flagButton: {
selector: '.comment .coral-plugin-flags-container .coral-plugin-flags-button'
},
flagPopUp: {
selector: '.comment .coral-plugin-flags-popup'
},
flagCommentOption: {
selector: '.comment .coral-plugin-flags-popup .coral-plugin-flags-popup-radio-label[for="comments"]'
},
flagUsernameOption: {
selector: '.comment .coral-plugin-flags-popup .coral-plugin-flags-popup-radio-label[for="user"]'
},
flagOtherOption: {
selector: '.comment .coral-plugin-flags-popup .coral-plugin-flags-popup-radio-label[for="other"]'
},
flagHeaderMessage: {
selector: '.comment .coral-plugin-flags-popup .coral-plugin-flags-popup-header'
},
flagButtonText: {
selector: '.comment .coral-plugin-flags-button-text'
},
flagDoneButton: {
selector: '.comment .coral-plugin-flags-popup .coral-plugin-flags-popup-button'
},
permalinkButton: {
selector: '.comment .coral-plugin-permalinks-button'
},
permalinkPopUp: {
selector: '.comment .coral-plugin-permalinks-popover.active'
},
permalinkInput: {
selector: '.comment .coral-plugin-permalinks-popover.active input'
},
registerButton: {
selector: '#signInDialog #coralRegister'
}
}
};
@@ -6,8 +6,5 @@ module.exports = {
.url(baseUrl)
.assert.title('Coral Talk')
.waitForElementPresent('body', 1000);
},
after: client => {
client.end();
}
};
+44
View File
@@ -0,0 +1,44 @@
module.exports = {
'@tags': ['embedStream'],
before: client => {
const embedStreamPage = client.page.embedStreamPage();
embedStreamPage
.navigate()
.ready();
},
'Login as commenter': client => {
const embedStreamPage = client.page.embedStreamPage();
const {users} = client.globals;
embedStreamPage
.login(users.commenter);
},
'Add test comment': client => {
const embedStreamPage = client.page.embedStreamPage();
embedStreamPage
.postComment('Test Comment');
},
'Logout': client => {
const embedStreamPage = client.page.embedStreamPage();
embedStreamPage
.logout();
},
'Login as admin': client => {
const embedStreamPage = client.page.embedStreamPage();
const {users} = client.globals;
embedStreamPage
.login(users.admin);
},
'Approve test comment': client => {
const adminPage = client.page.adminPage();
adminPage
.navigate()
.ready();
adminPage
.approveComment();
},
after: client => {
client.end();
}
};
+23
View File
@@ -0,0 +1,23 @@
module.exports = {
'@tags': ['login', 'admin'],
before(client) {
const embedStreamPage = client.page.embedStreamPage();
const {launchUrl} = client;
client
.url(launchUrl);
embedStreamPage
.ready();
},
'Admin logs in': client => {
const {users} = client.globals;
const embedStreamPage = client.page.embedStreamPage();
embedStreamPage
.login(users.admin);
},
after: client => {
client.end();
}
};
@@ -0,0 +1,34 @@
module.exports = {
'@tags': ['flag', 'comments', 'commenter'],
before: client => {
const embedStreamPage = client.page.embedStreamPage();
const {users} = client.globals;
embedStreamPage
.navigate()
.ready();
embedStreamPage
.login(users.commenter);
},
'Commenter flags a comment': client => {
const embedStreamPage = client.page.embedStreamPage();
embedStreamPage
.flagComment()
.waitForElementVisible('@flagPopUp')
.waitForElementVisible('@flagCommentOption')
.click('@flagCommentOption')
.waitForElementVisible('@flagDoneButton')
.click('@flagDoneButton')
.waitForElementVisible('@flagOtherOption')
.click('@flagOtherOption')
.waitForElementVisible('@flagDoneButton')
.click('@flagDoneButton')
.click('@flagDoneButton')
.expect.element('@flagButtonText').text.to.equal('Reported');
},
after: client => {
client.end();
}
};
@@ -0,0 +1,33 @@
module.exports = {
'@tags': ['flag', 'commenter'],
before: client => {
const embedStreamPage = client.page.embedStreamPage();
const {users} = client.globals;
embedStreamPage
.navigate()
.ready();
embedStreamPage
.login(users.commenter);
},
'Commenter flags a username': client => {
const embedStreamPage = client.page.embedStreamPage();
embedStreamPage
.flagUsername()
.waitForElementVisible('@flagPopUp')
.waitForElementVisible('@flagUsernameOption')
.click('@flagUsernameOption')
.waitForElementVisible('@flagDoneButton')
.click('@flagDoneButton')
.waitForElementVisible('@flagOtherOption')
.click('@flagOtherOption')
.waitForElementVisible('@flagDoneButton')
.click('@flagDoneButton')
.click('@flagDoneButton');
},
after: client => {
client.end();
}
};
@@ -0,0 +1,26 @@
module.exports = {
'@tags': ['like', 'comments', 'commenter'],
before: client => {
const embedStreamPage = client.page.embedStreamPage();
const {users} = client.globals;
embedStreamPage
.navigate()
.ready();
embedStreamPage
.login(users.commenter);
},
'Commenter likes a comment': client => {
const embedStreamPage = client.page.embedStreamPage();
embedStreamPage
.likeComment()
.waitForElementVisible('@likesCount', 2000)
.expect.element('@likeText').text.to.equal('Liked');
},
after: client => {
client.end();
}
};
+20
View File
@@ -0,0 +1,20 @@
module.exports = {
'@tags': ['login', 'commenter'],
before: client => {
const embedStreamPage = client.page.embedStreamPage();
embedStreamPage
.navigate()
.ready();
},
'Commenter logs in': client => {
const {users} = client.globals;
const embedStreamPage = client.page.embedStreamPage();
embedStreamPage
.login(users.commenter);
},
after: client => {
client.end();
}
};
@@ -0,0 +1,34 @@
let permalink = '';
module.exports = {
'@tags': ['permalink', 'commenter'],
before: client => {
const embedStreamPage = client.page.embedStreamPage();
const {users} = client.globals;
embedStreamPage
.navigate()
.ready();
embedStreamPage
.login(users.commenter);
},
'Commenter gets the permalink of a comment': client => {
const embedStreamPage = client.page.embedStreamPage();
embedStreamPage
.getPermalink(value => {
permalink = value;
});
},
'Commenter navigates to the permalink': client => {
const embedStreamPage = client.page.embedStreamPage();
embedStreamPage
.navigate(permalink);
client.assert.urlContains(permalink);
},
after: client => {
client.end();
}
};
+38
View File
@@ -0,0 +1,38 @@
module.exports = {
'@tags': ['write', 'commenter'],
before: client => {
const embedStreamPage = client.page.embedStreamPage();
const {users} = client.globals;
embedStreamPage
.navigate()
.ready();
embedStreamPage
.login(users.commenter);
},
'Commenter posts a comment': client => {
const embedStreamPage = client.page.embedStreamPage();
embedStreamPage
.postComment('I read the comments');
},
after: client => {
const adminPage = client.page.adminPage();
const embedStreamPage = client.page.embedStreamPage();
const {users} = client.globals;
embedStreamPage
.logout()
.login(users.admin);
adminPage
.navigate()
.ready();
adminPage
.approveComment();
client.end();
}
};
+13 -9
View File
@@ -18,12 +18,13 @@ module.exports = {
client.perform((client, done) => {
mocks.settings({moderation: 'post'})
.then(() => {
//Load Page
// Load Page
client.resizeWindow(1200, 800)
.url(client.globals.baseUrl)
.frame('coralStreamIframe')
//Register and Log In
// Register and Log In
.waitForElementVisible('#commentBox', 1000)
.waitForElementVisible('#coralSignInButton', 2000)
.click('#coralSignInButton')
@@ -44,7 +45,7 @@ module.exports = {
.click('.coral-plugin-commentbox-button')
.waitForElementVisible('.comment', 1000)
//Verify that it appears
// Verify that it appears
.assert.containsText('.comment', mockComment);
done();
})
@@ -58,7 +59,8 @@ module.exports = {
client.perform((client, done) => {
mocks.settings({moderation: 'pre'})
.then(() => {
//Load Page
// Load Page
client.url(client.globals.baseUrl)
.frame('coralStreamIframe');
@@ -68,7 +70,7 @@ module.exports = {
.click('.coral-plugin-commentbox-button')
.waitForElementVisible('#coral-notif', 1000)
//Verify that it appears
// Verify that it appears
.assert.containsText('#coral-notif', 'moderation team');
done();
})
@@ -82,7 +84,8 @@ module.exports = {
client.perform((client, done) => {
mocks.settings({moderation: 'post'})
.then(() => {
//Load Page
// Load Page
client.resizeWindow(1200, 800)
.url(client.globals.baseUrl)
.frame('coralStreamIframe');
@@ -100,7 +103,7 @@ module.exports = {
.click('.coral-plugin-replies-textarea button')
.waitForElementVisible('.reply', 2000)
//Verify that it appears
// Verify that it appears
.assert.containsText('.reply', mockReply);
done();
})
@@ -132,7 +135,8 @@ module.exports = {
}]);
})
.then(() => {
//Load Page
// Load Page
client.resizeWindow(1200, 800)
.url(client.globals.baseUrl)
.frame('coralStreamIframe');
@@ -145,7 +149,7 @@ module.exports = {
.click('.coral-plugin-replies-textarea button')
.waitForElementVisible('#coral-notif', 1000)
//Verify that it appears
// Verify that it appears
.assert.containsText('#coral-notif', 'moderation team');
done();
})
+23
View File
@@ -0,0 +1,23 @@
module.exports = {
'@tags': ['login', 'moderator'],
before: client => {
const embedStreamPage = client.page.embedStreamPage();
const {launchUrl} = client;
client
.url(launchUrl);
embedStreamPage
.ready();
},
'Moderator logs in': client => {
const {users} = client.globals;
const embedStreamPage = client.page.embedStreamPage();
embedStreamPage
.login(users.moderator);
},
after: client => {
client.end();
}
};
@@ -0,0 +1,20 @@
module.exports = {
'@tags': ['flag', 'comments', 'visitor'],
before: client => {
const embedStreamPage = client.page.embedStreamPage();
embedStreamPage
.navigate()
.ready();
},
'Visitor tries to flag a comment': client => {
const embedStreamPage = client.page.embedStreamPage();
embedStreamPage
.flagComment()
.waitForElementVisible('@signInDialog', 2000);
},
after: client => {
client.end();
}
};
@@ -0,0 +1,20 @@
module.exports = {
'@tags': ['like', 'comments', 'visitor'],
before: client => {
const embedStreamPage = client.page.embedStreamPage();
embedStreamPage
.navigate()
.ready();
},
'Visitor tries to like a comment': client => {
const embedStreamPage = client.page.embedStreamPage();
embedStreamPage
.likeComment()
.waitForElementVisible('@signInDialog', 2000);
},
after: client => {
client.end();
}
};
+24
View File
@@ -0,0 +1,24 @@
module.exports = {
'@tags': ['signup', 'visitor'],
before: client => {
const embedStreamPage = client.page.embedStreamPage();
embedStreamPage
.navigate()
.ready();
},
'Visitor signs up': client => {
const embedStreamPage = client.page.embedStreamPage();
const hash = Math.floor(Math.random() * (999 - 0));
embedStreamPage
.signUp({
email: `visitor_${hash}@test.com`,
displayName: 'Visitor',
pass: 'testtest'
});
},
after: client => {
client.end();
}
};
+2
View File
@@ -3,8 +3,10 @@ const mongoose = require('../../services/mongoose');
// Ensure the NODE_ENV is set to 'test',
// this is helpful when you would like to change behavior when testing.
function clearDB() {
// console.log('Clearing DB', mongoose.connection);
for (let i in mongoose.connection.collections) {
// console.log('Clearing', i);
mongoose.connection.collections[i].remove(function() {});
}
+1 -1
View File
@@ -36,7 +36,7 @@
<script type='text/javascript' src='<%= basePath %>/pym.v1.min.js'></script>
<script>
var ready = false;
var pymParent = new pym.Parent('coralStreamEmbed', '/embed/stream', {title: 'Talk Comments', id:'coralStreamIframe'});
var pymParent = new pym.Parent('coralStreamEmbed', '/embed/stream', {title: 'Talk Comments', id:'coralStreamIframe', name: 'coralStreamIframe'});
pymParent.onMessage('height', function(height) {document.querySelector('#coralStreamEmbed iframe').height = height + 'px'})
pymParent.onMessage('childReady', function () {
var interval = setInterval(function () {
+7303
View File
File diff suppressed because it is too large Load Diff