mirror of
https://github.com/wassname/talk.git
synced 2026-08-01 13:00:55 +08:00
tests
This commit is contained in:
+10
-3
@@ -1,8 +1,15 @@
|
||||
export default {
|
||||
waitForConditionTimeout: 20000,
|
||||
baseUrl: 'http://localhost:3000',
|
||||
testUser: {
|
||||
user: process.env.CORAL_TEST_USER,
|
||||
pass: process.env.CORAL_TEST_PASS
|
||||
users: {
|
||||
admin: {
|
||||
email: 'admin@test.com'
|
||||
},
|
||||
moderator: {
|
||||
email: 'moderator@test.com'
|
||||
},
|
||||
commenter: {
|
||||
email: 'commenter@test.com'
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
@@ -1,25 +0,0 @@
|
||||
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));
|
||||
|
||||
@@ -1,12 +1,18 @@
|
||||
const fetch = require('node-fetch');
|
||||
|
||||
const embedCommands = {
|
||||
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',
|
||||
@@ -28,12 +34,18 @@ const embedCommands = {
|
||||
validateComment(comment) {
|
||||
return this
|
||||
.assert.equal(comment, '.comment');
|
||||
}
|
||||
},
|
||||
};
|
||||
|
||||
export default {
|
||||
commands: [embedCommands],
|
||||
commands: [embedStreamCommands],
|
||||
elements: {
|
||||
signInButton: {
|
||||
selector: '#coralSignInButton'
|
||||
},
|
||||
signInDialog:{
|
||||
selector: '#signInDialog'
|
||||
},
|
||||
commentBox: {
|
||||
selector: '#commentBox'
|
||||
},
|
||||
|
||||
@@ -0,0 +1,31 @@
|
||||
const embedStreamCommands = {
|
||||
ready() {
|
||||
return this
|
||||
.waitForElementVisible('body', 2000)
|
||||
;
|
||||
},
|
||||
login() {
|
||||
return this
|
||||
.waitForElementVisible('@signInButton')
|
||||
.click('@signInButton')
|
||||
.waitForElementVisible('@signInDialog');
|
||||
}
|
||||
};
|
||||
|
||||
export default {
|
||||
commands: [embedStreamCommands],
|
||||
elements: {
|
||||
signInButton: {
|
||||
selector: '#coralSignInButton'
|
||||
},
|
||||
signInDialog:{
|
||||
selector: '#signInDialog'
|
||||
},
|
||||
commentBox: {
|
||||
selector: '#commentBox'
|
||||
},
|
||||
postButton: {
|
||||
selector: '#commentBox .coral-plugin-commentbox-button'
|
||||
}
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,20 @@
|
||||
module.exports = {
|
||||
'@tags': ['login'],
|
||||
before: client => {
|
||||
const {launchUrl} = client;
|
||||
|
||||
client
|
||||
.url(launchUrl)
|
||||
.frame('coralStreamIframe');
|
||||
},
|
||||
'Commenter logs in': client => {
|
||||
const embedStreamPage = client.page.embedStreamPage();
|
||||
|
||||
embedStreamPage
|
||||
.ready()
|
||||
.login();
|
||||
},
|
||||
after: client => {
|
||||
client.end();
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,5 @@
|
||||
export default {
|
||||
'@tags': ['sign-up'],
|
||||
'Commenter Sign Up': () => {
|
||||
}
|
||||
};
|
||||
@@ -1,15 +0,0 @@
|
||||
export default {
|
||||
'@tags': ['login'],
|
||||
'Commenter logs in': client => {
|
||||
const embedStream = client.page.embedStream();
|
||||
const { baseUrl, testUser } = client.globals;
|
||||
|
||||
|
||||
// loginPage
|
||||
// .navigate(baseUrl + '/login')
|
||||
// .ready()
|
||||
//
|
||||
// loginPage.login(testUser)
|
||||
// client.pause(2000);
|
||||
}
|
||||
}
|
||||
@@ -1,15 +0,0 @@
|
||||
export default {
|
||||
'@tags': ['sign-up'],
|
||||
'Commenter Sign Up': client => {
|
||||
const embedStream = client.page.embedStream();
|
||||
const { baseUrl, testUser } = client.globals;
|
||||
|
||||
|
||||
// loginPage
|
||||
// .navigate(baseUrl + '/login')
|
||||
// .ready()
|
||||
//
|
||||
// loginPage.login(testUser)
|
||||
// client.pause(2000);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user