diff --git a/client/coral-embed-stream/src/CommentStream.js b/client/coral-embed-stream/src/CommentStream.js index 9887b46ac..5f0d9331d 100644 --- a/client/coral-embed-stream/src/CommentStream.js +++ b/client/coral-embed-stream/src/CommentStream.js @@ -59,29 +59,12 @@ class CommentStream extends Component { componentDidMount () { // Set up messaging between embedded Iframe an parent component - // Using recommended Pym init code which violates .eslint standards const pym = new Pym.Child({polling: 100}); const path = /https?\:\/\/([^?]+)/.exec(pym.parentUrl); this.props.getStream(path && path[1] || window.location); } render () { - if (Object.keys(this.props.items).length === 0) { - // Loading mock asset - this.props.postItem({ - comments: [], - url: 'http://coralproject.net' - }, 'asset', 'assetTest'); - - // Loading mock user - //this.props.postItem({name: 'Ban Ki-Moon'}, 'user', 'user_8989') - // .then((id) => { - // this.props.setLoggedInUser(id); - // }); - } - - // TODO: Replace teststream id with id from params - const rootItemId = this.props.items.assets && Object.keys(this.props.items.assets)[0]; const rootItem = this.props.items.assets && this.props.items.assets[rootItemId]; const {actions, users, comments} = this.props.items; diff --git a/package.json b/package.json index 48c66d564..c2b98b0c5 100644 --- a/package.json +++ b/package.json @@ -12,7 +12,7 @@ "test": "mocha --compilers js:babel-core/register --recursive tests", "test-watch": "mocha --compilers js:babel-core/register --recursive -w tests", "pree2e": "./pree2e.sh", - "e2e": "node_modules/.bin/nightwatch", + "e2e": "source .env-test && node_modules/.bin/nightwatch", "embed-start": "NODE_ENV=development npm run build && ./bin/www" }, "config": { diff --git a/pree2e.sh b/pree2e.sh index 269e7cdb5..fbe3b1a87 100755 --- a/pree2e.sh +++ b/pree2e.sh @@ -1,3 +1,4 @@ node_modules/selenium-standalone/bin/selenium-standalone install source .env-test +echo $TALK_MONGO_URL npm start & diff --git a/tests/e2e/tests/EmbedStreamTests.js b/tests/e2e/tests/EmbedStreamTests.js index 37d69c2ef..15125b14c 100644 --- a/tests/e2e/tests/EmbedStreamTests.js +++ b/tests/e2e/tests/EmbedStreamTests.js @@ -10,7 +10,10 @@ const mockUser = { module.exports = { '@tags': ['embed-stream', 'comment', 'premodoff', 'premodon'], - 'User Registers and posts a comment with premod off': client => { + before: () => { + utils.before(); + }, + 'User registers and posts a comment with premod off': client => { client.perform((client, done) => { client.page.embedStream().setConfig({moderation: 'post'}, client.globals.baseUrl) .then(() => { @@ -46,22 +49,14 @@ module.exports = { }); }); }, - 'User Logs In and posts a comment with premod on': client => { + 'User posts a comment with premod on': client => { client.perform((client, done) => { client.page.embedStream().setConfig({moderation: 'pre'}, client.globals.baseUrl) .then(() => { //Load Page client.url(client.globals.baseUrl) - .frame('coralStreamIframe'); - - //Log In - client.waitForElementVisible('#commentBox', 10000) - .waitForElementVisible('#coralSignInButton', 2000) - .click('#coralSignInButton') - .waitForElementVisible('#coralLogInButton', 1000) - .setValue('#email', mockUser.email) - .setValue('#password', mockUser.pw) - .click('#coralLogInButton'); + .frame('coralStreamIframe') + .pause(10000); // Post a comment client.waitForElementVisible('#commentBox .coral-plugin-commentbox-button', 2000) @@ -75,7 +70,7 @@ module.exports = { }); }); }, - 'User Logs In and Replies to a comment with premod off': client => { + 'User replies to a comment with premod off': client => { client.perform((client, done) => { client.page.embedStream().setConfig({moderation: 'post'}, client.globals.baseUrl) .then(() => { @@ -84,17 +79,8 @@ module.exports = { .url(client.globals.baseUrl) .frame('coralStreamIframe'); - //Log In - client.waitForElementVisible('#commentBox', 10000) - .waitForElementVisible('#coralSignInButton', 2000) - .click('#coralSignInButton') - .waitForElementVisible('#coralLogInButton', 1000) - .setValue('#email', mockUser.email) - .setValue('#password', mockUser.pw) - .click('#coralLogInButton'); - // Post a reply - client.waitForElementVisible('.coral-plugin-replies-reply-button', 2000) + client.waitForElementVisible('.coral-plugin-replies-reply-button', 5000) .click('.coral-plugin-replies-reply-button') .waitForElementVisible('#replyText') .setValue('#replyText', mockReply) @@ -107,26 +93,18 @@ module.exports = { }); }); }, - 'User Logs In and Replies to a comment with premod on': client => { + 'User replies to a comment with premod on': client => { client.perform((client, done) => { client.page.embedStream().setConfig({moderation: 'pre'}, client.globals.baseUrl) .then(() => { //Load Page client.resizeWindow(1200, 800) .url(client.globals.baseUrl) - .frame('coralStreamIframe'); - - //Log In - client.waitForElementVisible('#commentBox', 10000) - .waitForElementVisible('#coralSignInButton', 2000) - .click('#coralSignInButton') - .waitForElementVisible('#coralLogInButton', 1000) - .setValue('#email', mockUser.email) - .setValue('#password', mockUser.pw) - .click('#coralLogInButton'); + .frame('coralStreamIframe') + .pause(60000); // Post a reply - client.waitForElementVisible('.coral-plugin-replies-reply-button', 2000) + client.waitForElementVisible('.coral-plugin-replies-reply-button', 5000) .click('.coral-plugin-replies-reply-button') .waitForElementVisible('#replyText') .setValue('#replyText', mockReply) diff --git a/tests/utils/e2e-mongoose.js b/tests/utils/e2e-mongoose.js index 402a55e36..27aafb921 100644 --- a/tests/utils/e2e-mongoose.js +++ b/tests/utils/e2e-mongoose.js @@ -3,24 +3,18 @@ const mongoose = require('../../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'); + console.log('Clearing DB', mongoose.connection); for (let i in mongoose.connection.collections) { + console.log('Clearing', i); mongoose.connection.collections[i].remove(function() {}); } } module.exports = { before: () => { - const url = process.env.TALK_MONGO_URL || 'mongodb://localhost'; - return mongoose.connect(url, (err) => { - if (err) { - throw err; - } - debug('Connected to MongoDB!'); - }); + clearDB(); }, beforeEach: () => { - console.log('beforeEach', mongoose.connection.name); if (mongoose.connection.readyState === 0) { mongoose.on('open', function() { if (err) {