mirror of
https://github.com/wassname/talk.git
synced 2026-07-18 12:40:13 +08:00
Setting env variables properly in tests.
This commit is contained in:
@@ -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;
|
||||
|
||||
+1
-1
@@ -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": {
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
node_modules/selenium-standalone/bin/selenium-standalone install
|
||||
source .env-test
|
||||
echo $TALK_MONGO_URL
|
||||
npm start &
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user