From 2a19399b810296bfab6cb1edc898b7fc911de892 Mon Sep 17 00:00:00 2001 From: David Jay Date: Tue, 22 Nov 2016 16:01:50 -0500 Subject: [PATCH] Moving configuration setting to shared function --- tests/e2e/pages/embedStream.js | 12 +++++ tests/e2e/tests/EmbedStreamTests.js | 70 ++++++++++++++++------------- 2 files changed, 51 insertions(+), 31 deletions(-) diff --git a/tests/e2e/pages/embedStream.js b/tests/e2e/pages/embedStream.js index 605b42d74..cc584a656 100644 --- a/tests/e2e/pages/embedStream.js +++ b/tests/e2e/pages/embedStream.js @@ -1,3 +1,5 @@ +const fetch = require('node-fetch'); + const embedCommands = { ready() { return this.resizeWindow(1200, 800) @@ -5,6 +7,16 @@ const embedCommands = { .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 diff --git a/tests/e2e/tests/EmbedStreamTests.js b/tests/e2e/tests/EmbedStreamTests.js index 6ccc76415..63f2406cb 100644 --- a/tests/e2e/tests/EmbedStreamTests.js +++ b/tests/e2e/tests/EmbedStreamTests.js @@ -10,19 +10,11 @@ const mockUser = { }; module.exports = { - '@tags': ['embed-stream', 'post'], + '@tags': ['embed-stream', 'comment', 'premodoff', 'premodon'], 'User Registers and posts a comment with premod off': client => { client.perform((client, done) => { - return fetch(`${client.globals.baseUrl}/api/v1/settings`, { - method: 'PUT', - headers: { - 'Content-Type': 'application/json', - 'Accept': 'application/json' - }, - body: JSON.stringify({ - moderation: 'post' - }) - }).then(() => { + client.page.embedStream().setConfig({moderation: 'post'}, client.globals.baseUrl) + .then(() => { //Load Page client.resizeWindow(1200, 800) .url(client.globals.baseUrl) @@ -57,16 +49,8 @@ module.exports = { }, 'User Logs In and posts a comment with premod on': 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: 'pre' - }) - }).then(() => { + client.page.embedStream().setConfig({moderation: 'pre'}, client.globals.baseUrl) + .then(() => { //Load Page client.url(client.globals.baseUrl) .frame('coralStreamIframe'); @@ -94,16 +78,40 @@ 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(() => { + client.page.embedStream().setConfig({moderation: 'post'}, 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'); + + // 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(); + }); + }); + }, + 'User Logs In and 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)