Running comment post test w/ proper settings.

This commit is contained in:
David Jay
2016-11-21 15:27:31 -05:00
parent 87e06678dd
commit 15810e3ece
5 changed files with 60 additions and 9 deletions
+1 -1
View File
@@ -1,5 +1,5 @@
node_modules
npm-debug.log
npm-debug.log*
dist
!dist/coral-admin
dist/coral-admin/bundle.js
+2 -2
View File
@@ -97,6 +97,7 @@
"mocha": "^3.1.2",
"mocha-junit-reporter": "^1.12.1",
"nightwatch": "^0.9.9",
"node-fetch": "^1.6.3",
"postcss-loader": "^1.1.0",
"postcss-modules": "^0.5.2",
"postcss-smart-import": "^0.5.1",
@@ -117,8 +118,7 @@
"style-loader": "^0.13.1",
"supertest": "^2.0.1",
"timeago.js": "^2.0.3",
"webpack": "^1.13.3",
"whatwg-fetch": "^1.0.0"
"webpack": "^1.13.3"
},
"engines": {
"node": ">=7.0.0"
+2 -1
View File
@@ -1,4 +1,5 @@
node_modules/selenium-standalone/bin/selenium-standalone install
export TALK_PORT=3011
export TALK_MONGO_URL='mongodb://localhost/talk_test'
export TALK_MONGO_URL='mongodb://localhost/test'
export TALK_DEBUG='talk*'
npm start &
+16 -5
View File
@@ -1,24 +1,35 @@
require('../../utils/mongoose');
const utils = require('../../utils/e2e-mongoose');
const Setting = require('../../../models/setting');
const fetch = require('node-fetch');
const comment = 'This is a test comment.';
module.exports = {
'@tags': ['embed-stream', 'post'],
before: () => {
Setting.create({moderation: 'post'});
beforeEach: client => {
return fetch(`${client.globals.baseUrl}/api/v1/settings`, {
method: 'PUT',
headers: {
'Content-Type': 'application/json',
'Accept': 'application/json'
},
body: JSON.stringify({
moderation: 'post'
})
});
},
'User posts a comment': client => {
client.resizeWindow(1200, 800)
.url(client.globals.baseUrl)
.frame('coralStreamIframe')
.waitForElementVisible('#commentBox', 1000)
.waitForElementVisible('#commentBox', 2000)
.setValue('#commentBox .coral-plugin-commentbox-textarea', comment)
.click('#commentBox .coral-plugin-commentbox-button')
.waitForElementVisible('.comment', 1000)
.expect.element('.coral-plugin-comment').to.equal(comment);
.assert.containsText('.comment', comment);
},
after: client => {
utils.after();
client.end();
}
};
+39
View File
@@ -0,0 +1,39 @@
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() {
for (let i in mongoose.connection.collections) {
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!');
});
},
beforeEach: () => {
console.log('beforeEach', mongoose.connection.name);
if (mongoose.connection.readyState === 0) {
mongoose.on('open', function() {
if (err) {
throw err;
}
return clearDB();
});
} else {
return clearDB();
}
},
after: () => {
clearDB();
mongoose.disconnect();
}
};