Login tests

This commit is contained in:
Belen Curcio
2016-12-18 13:07:16 -03:00
parent 428a62ffd4
commit 67aeb223d6
14 changed files with 111 additions and 68 deletions
+3
View File
@@ -47,3 +47,6 @@ module.exports = {
}
}
};
// "chromeOptions" : {
// "args" : ["start-fullscreen"]
// }
+7 -4
View File
@@ -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'
}
}
};
+25
View File
@@ -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));
-56
View File
@@ -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'
}
}
};
+20 -4
View File
@@ -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'
},
@@ -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();
+24
View File
@@ -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();
}
};
+24
View File
@@ -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();
}
};
+1 -1
View File
@@ -36,7 +36,7 @@
<script type='text/javascript' src='<%= basePath %>/pym.v1.min.js'></script>
<script>
var ready = false;
var pymParent = new pym.Parent('coralStreamEmbed', '/embed/stream', {title: 'Talk Comments', id:'coralStreamIframe'});
var pymParent = new pym.Parent('coralStreamEmbed', '/embed/stream', {title: 'Talk Comments', id:'coralStreamIframe', name: 'coralStreamIframe'});
pymParent.onMessage('height', function(height) {document.querySelector('#coralStreamEmbed iframe').height = height + 'px'})
pymParent.onMessage('childReady', function () {
var interval = setInterval(function () {