diff --git a/nightwatch.conf.js b/nightwatch.conf.js
index 372c9a965..831b59701 100644
--- a/nightwatch.conf.js
+++ b/nightwatch.conf.js
@@ -47,3 +47,6 @@ module.exports = {
}
}
};
+// "chromeOptions" : {
+// "args" : ["start-fullscreen"]
+// }
diff --git a/tests/e2e/globals.js b/tests/e2e/globals.js
index a947a5ce3..7975a2c50 100644
--- a/tests/e2e/globals.js
+++ b/tests/e2e/globals.js
@@ -1,15 +1,18 @@
export default {
- waitForConditionTimeout: 20000,
+ waitForConditionTimeout: 8000,
baseUrl: 'http://localhost:3000',
users: {
admin: {
- email: 'admin@test.com'
+ email: 'admin@test.com',
+ pass: 'test'
},
moderator: {
- email: 'moderator@test.com'
+ email: 'moderator@test.com',
+ pass: 'test'
},
commenter: {
- email: 'commenter@test.com'
+ email: 'commenter@test.com',
+ pass: 'test'
}
}
};
diff --git a/tests/e2e/mocks.js b/tests/e2e/mocks.js
index e69de29bb..a4f430cd5 100644
--- a/tests/e2e/mocks.js
+++ b/tests/e2e/mocks.js
@@ -0,0 +1,25 @@
+const Comments = require('../../models/comment');
+const Users = require('../../models/user');
+const Actions = require('../../models/action');
+const Assets = require('../../models/asset');
+const Settings = require('../../models/setting');
+const globals = require('./globals');
+
+/* Create an array of comments */
+module.exports.comments = (comments) => Assets.findOrCreateByUrl(globals.baseUrl)
+ .then((asset) => {
+ comments = comments.map((comment) => {
+ comment.asset_id = asset.id;
+ return comment;
+ });
+ return Comments.create(comments);
+ });
+
+/* Create an array of users */
+module.exports.users = (users) => Users.createLocalUsers(users);
+
+/* Create an array of actions */
+module.exports.actions = (actions) => Actions.create(actions);
+
+/* Update a setting */
+module.exports.settings = (setting) => Settings.init().then(() => Settings.updateSettings(setting));
diff --git a/tests/e2e/pages/embedStream.js b/tests/e2e/pages/embedStream.js
deleted file mode 100644
index 95bf56b5f..000000000
--- a/tests/e2e/pages/embedStream.js
+++ /dev/null
@@ -1,56 +0,0 @@
-const fetch = require('node-fetch');
-
-const embedStreamCommands = {
- ready() {
- return this.resizeWindow(1200, 800)
- .url(client.globals.baseUrl)
- .waitForElementVisible('body', 2000)
- .frame('coralStreamIframe');
- },
- login(userData) {
- return this
- .waitForElementVisible('@signInButton')
- .click('@signInButton')
- .waitForElementVisible('@signInDialog');
- },
- 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
- .waitForElementVisible('@commentBox')
- .setValue('@commentBox', comment)
- .click('@postButton')
- .waitForElementVisible('.comment', 1000);
- },
- validateComment(comment) {
- return this
- .assert.equal(comment, '.comment');
- },
-};
-
-export default {
- commands: [embedStreamCommands],
- elements: {
- signInButton: {
- selector: '#coralSignInButton'
- },
- signInDialog:{
- selector: '#signInDialog'
- },
- commentBox: {
- selector: '#commentBox'
- },
- postButton: {
- selector: '#commentBox .coral-plugin-commentbox-button'
- }
- }
-};
diff --git a/tests/e2e/pages/embedStreamPage.js b/tests/e2e/pages/embedStreamPage.js
index 3891952bb..d952c782f 100644
--- a/tests/e2e/pages/embedStreamPage.js
+++ b/tests/e2e/pages/embedStreamPage.js
@@ -2,13 +2,20 @@ const embedStreamCommands = {
ready() {
return this
.waitForElementVisible('body', 2000)
- ;
+ .waitForElementVisible('iframe#coralStreamIframe')
+ api.frame('coralStreamIframe');
},
- login() {
+ login(user) {
return this
- .waitForElementVisible('@signInButton')
+ .waitForElementVisible('@signInButton', 2000)
.click('@signInButton')
- .waitForElementVisible('@signInDialog');
+ .waitForElementVisible('@signInDialog')
+ .waitForElementVisible('@signInDialogEmail')
+ .waitForElementVisible('@signInDialogPassword')
+ .setValue('@signInDialogEmail', user.email)
+ .setValue('@signInDialogPassword', user.pass)
+ .waitForElementVisible('@logInButton')
+ .click('@logInButton');
}
};
@@ -21,6 +28,15 @@ export default {
signInDialog:{
selector: '#signInDialog'
},
+ signInDialogEmail: {
+ selector: '#signInDialog #email'
+ },
+ signInDialogPassword: {
+ selector: '#signInDialog #password'
+ },
+ logInButton: {
+ selector: '#coralLogInButton'
+ },
commentBox: {
selector: '#commentBox'
},
diff --git a/tests/e2e/tests/LoginTest.js b/tests/e2e/tests/Admin/LoginTest.js
similarity index 64%
rename from tests/e2e/tests/LoginTest.js
rename to tests/e2e/tests/Admin/LoginTest.js
index 7d63349c5..215e88a5a 100644
--- a/tests/e2e/tests/LoginTest.js
+++ b/tests/e2e/tests/Admin/LoginTest.js
@@ -1,18 +1,22 @@
module.exports = {
'@tags': ['login'],
before: client => {
+ const embedStreamPage = client.page.embedStreamPage();
const {launchUrl} = client;
client
.url(launchUrl)
- .frame('coralStreamIframe');
+
+ embedStreamPage
+ .ready();
},
'Commenter logs in': client => {
+ const {users} = client.globals;
const embedStreamPage = client.page.embedStreamPage();
embedStreamPage
- .ready()
- .login();
+ .login(users.commenter);
+
},
after: client => {
client.end();
diff --git a/tests/e2e/tests/FlagCommentTest.js b/tests/e2e/tests/Commenter/FlagCommentTest.js
similarity index 100%
rename from tests/e2e/tests/FlagCommentTest.js
rename to tests/e2e/tests/Commenter/FlagCommentTest.js
diff --git a/tests/e2e/tests/FlagUsernameTest.js b/tests/e2e/tests/Commenter/FlagUsernameTest.js
similarity index 100%
rename from tests/e2e/tests/FlagUsernameTest.js
rename to tests/e2e/tests/Commenter/FlagUsernameTest.js
diff --git a/tests/e2e/tests/LikeCommentTest.js b/tests/e2e/tests/Commenter/LikeCommentTest.js
similarity index 100%
rename from tests/e2e/tests/LikeCommentTest.js
rename to tests/e2e/tests/Commenter/LikeCommentTest.js
diff --git a/tests/e2e/tests/Commenter/LoginTest.js b/tests/e2e/tests/Commenter/LoginTest.js
new file mode 100644
index 000000000..215e88a5a
--- /dev/null
+++ b/tests/e2e/tests/Commenter/LoginTest.js
@@ -0,0 +1,24 @@
+module.exports = {
+ '@tags': ['login'],
+ before: client => {
+ const embedStreamPage = client.page.embedStreamPage();
+ const {launchUrl} = client;
+
+ client
+ .url(launchUrl)
+
+ embedStreamPage
+ .ready();
+ },
+ 'Commenter logs in': client => {
+ const {users} = client.globals;
+ const embedStreamPage = client.page.embedStreamPage();
+
+ embedStreamPage
+ .login(users.commenter);
+
+ },
+ after: client => {
+ client.end();
+ }
+};
diff --git a/tests/e2e/tests/PermalinkTest.js b/tests/e2e/tests/Commenter/PermalinkTest.js
similarity index 100%
rename from tests/e2e/tests/PermalinkTest.js
rename to tests/e2e/tests/Commenter/PermalinkTest.js
diff --git a/tests/e2e/tests/SignUpTest.js b/tests/e2e/tests/Commenter/SignUpTest.js
similarity index 100%
rename from tests/e2e/tests/SignUpTest.js
rename to tests/e2e/tests/Commenter/SignUpTest.js
diff --git a/tests/e2e/tests/Moderator/LoginTest.js b/tests/e2e/tests/Moderator/LoginTest.js
new file mode 100644
index 000000000..215e88a5a
--- /dev/null
+++ b/tests/e2e/tests/Moderator/LoginTest.js
@@ -0,0 +1,24 @@
+module.exports = {
+ '@tags': ['login'],
+ before: client => {
+ const embedStreamPage = client.page.embedStreamPage();
+ const {launchUrl} = client;
+
+ client
+ .url(launchUrl)
+
+ embedStreamPage
+ .ready();
+ },
+ 'Commenter logs in': client => {
+ const {users} = client.globals;
+ const embedStreamPage = client.page.embedStreamPage();
+
+ embedStreamPage
+ .login(users.commenter);
+
+ },
+ after: client => {
+ client.end();
+ }
+};
diff --git a/views/article.ejs b/views/article.ejs
index f4d7ef910..302d76572 100644
--- a/views/article.ejs
+++ b/views/article.ejs
@@ -36,7 +36,7 @@