From e40d5312da9ec2d5104c4ed768828f0635a30a46 Mon Sep 17 00:00:00 2001 From: David Jay Date: Tue, 22 Nov 2016 15:36:52 -0500 Subject: [PATCH] Adding premod off reply test. --- tests/e2e/tests/EmbedStreamTests.js | 46 +++++++++++++++++++++++++++-- tests/utils/e2e-mongoose.js | 1 + 2 files changed, 44 insertions(+), 3 deletions(-) diff --git a/tests/e2e/tests/EmbedStreamTests.js b/tests/e2e/tests/EmbedStreamTests.js index 3396f473d..6ccc76415 100644 --- a/tests/e2e/tests/EmbedStreamTests.js +++ b/tests/e2e/tests/EmbedStreamTests.js @@ -2,6 +2,7 @@ const utils = require('../../utils/e2e-mongoose'); const fetch = require('node-fetch'); const mockComment = 'This is a test comment.'; +const mockReply = 'This is a test reply'; const mockUser = { email: `${new Date().getTime()}@test.com`, name: 'Test User', @@ -54,7 +55,7 @@ module.exports = { }); }); }, - 'User Registers and posts a comment with premod on': client => { + 'User Logs In and posts a comment with premod on': client => { client.perform((client, done) => { fetch(`${client.globals.baseUrl}/api/v1/settings`, { method: 'PUT', @@ -67,8 +68,7 @@ module.exports = { }) }).then(() => { //Load Page - client.resizeWindow(1200, 800) - .url(client.globals.baseUrl) + client.url(client.globals.baseUrl) .frame('coralStreamIframe'); //Log In @@ -92,6 +92,46 @@ module.exports = { }); }); }, + 'User Logs In and Replies to a comment with premod off': client => { + client.perform((client, done) => { + fetch(`${client.globals.baseUrl}/api/v1/settings`, { + method: 'PUT', + headers: { + 'Content-Type': 'application/json', + 'Accept': 'application/json' + }, + body: JSON.stringify({ + moderation: 'post' + }) + }).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'); + + // Post a reply + client.waitForElementVisible('.coral-plugin-replies-reply-button', 2000) + .click('.coral-plugin-replies-reply-button') + .waitForElementVisible('#replyText') + .setValue('#replyText', mockReply) + .click('.coral-plugin-replies-textarea button') + .waitForElementVisible('.reply', 1000) + + //Verify that it appears + .assert.containsText('.reply', mockReply); + done(); + }); + }); + }, after: client => { utils.after(); client.end(); diff --git a/tests/utils/e2e-mongoose.js b/tests/utils/e2e-mongoose.js index e5a0cb568..402a55e36 100644 --- a/tests/utils/e2e-mongoose.js +++ b/tests/utils/e2e-mongoose.js @@ -3,6 +3,7 @@ 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'); for (let i in mongoose.connection.collections) { mongoose.connection.collections[i].remove(function() {}); }