Merge branch 'master' of github.com:coralproject/talk into load-more-comments

This commit is contained in:
David Jay
2017-02-13 18:26:05 -05:00
107 changed files with 1380 additions and 878 deletions
+2 -2
View File
@@ -19,7 +19,7 @@ const embedStreamCommands = {
.setValue('@signInDialogEmail', user.email)
.setValue('@signInDialogPassword', user.pass)
.setValue('@signUpDialogConfirmPassword', user.pass)
.setValue('@signUpDialogDisplayName', user.displayName)
.setValue('@signUpDialogDisplayName', user.username)
.waitForElementVisible('@signUpButton')
.click('@signUpButton')
.waitForElementVisible('@signInViewTrigger')
@@ -96,7 +96,7 @@ module.exports = {
selector: '#signInDialog #confirmPassword'
},
signUpDialogDisplayName: {
selector: '#signInDialog #displayName'
selector: '#signInDialog #username'
},
logInButton: {
selector: '#coralLogInButton'
+2 -2
View File
@@ -37,7 +37,7 @@ module.exports = {
.click('#coralRegister')
.waitForElementVisible('#email', 1000)
.setValue('#email', mockUser.email)
.setValue('#displayName', mockUser.name)
.setValue('#username', mockUser.name)
.setValue('#password', mockUser.pw)
.setValue('#confirmPassword', mockUser.pw)
.click('#coralSignUpButton')
@@ -125,7 +125,7 @@ module.exports = {
// Add a mock user
.then(() => mocks.users([{
displayName: 'BabyBlue',
username: 'BabyBlue',
email: 'whale@tale.sea',
password: 'krillaretasty'
}]))
+1 -1
View File
@@ -13,7 +13,7 @@ module.exports = {
embedStreamPage
.signUp({
email: `visitor_${Date.now()}@test.com`,
displayName: `visitor${Date.now()}`,
username: `visitor${Date.now()}`,
pass: 'testtest'
});
},
+6 -6
View File
@@ -13,7 +13,7 @@ chai.use(require('chai-http'));
const UsersService = require('../../../../services/users');
describe('/api/v1/account/displayname', () => {
describe('/api/v1/account/username', () => {
let mockUser;
beforeEach(() => SettingsService.init(settings).then(() => {
@@ -29,9 +29,9 @@ describe('/api/v1/account/displayname', () => {
.post(`/api/v1/users/${mockUser.id}/username-enable`)
.set(passport.inject({id: '456', roles: ['ADMIN']}))
.then(() => chai.request(app)
.put('/api/v1/account/displayname')
.put('/api/v1/account/username')
.set(passport.inject({id: mockUser.id, roles: []}))
.send({displayName: 'MojoJojo'}))
.send({username: 'MojoJojo'}))
.then((res) => {
expect(res).to.have.status(204);
});
@@ -42,9 +42,9 @@ describe('/api/v1/account/displayname', () => {
.post(`/api/v1/users/${mockUser.id}/username-enable`)
.set(passport.inject({id: '456', roles: ['ADMIN']}))
.then(() => chai.request(app)
.put('/api/v1/account/displayname')
.put('/api/v1/account/username')
.set(passport.inject({id: 'wrongid', roles: []}))
.send({displayName: 'MojoJojo'}))
.send({username: 'MojoJojo'}))
.then(() => {
done(new Error('Exected Error'));
})
@@ -56,7 +56,7 @@ describe('/api/v1/account/displayname', () => {
it('it should return an error when the user tries to edit their username if canEditName is disabled', (done) => {
chai.request(app)
.put('/api/v1/account/displayname')
.put('/api/v1/account/username')
.set(passport.inject({id: mockUser.id, roles: []}))
.send({username: 'MojoJojo'})
.then(() => {
+2 -2
View File
@@ -45,7 +45,7 @@ describe('/api/v1/auth/local', () => {
expect(res2).to.have.status(200);
expect(res2).to.be.json;
expect(res2.body).to.have.property('user');
expect(res2.body.user).to.have.property('displayName', 'maria');
expect(res2.body.user).to.have.property('username', 'Maria');
});
});
@@ -91,7 +91,7 @@ describe('/api/v1/auth/local', () => {
expect(res).to.have.status(200);
expect(res).to.be.json;
expect(res.body).to.have.property('user');
expect(res.body.user).to.have.property('displayName', 'maria');
expect(res.body.user).to.have.property('username', 'Maria');
});
});
});
+4 -4
View File
@@ -49,11 +49,11 @@ describe('/api/v1/comments', () => {
}];
const users = [{
displayName: 'Ana',
username: 'Ana',
email: 'ana@gmail.com',
password: '123456789'
}, {
displayName: 'Maria',
username: 'Maria',
email: 'maria@gmail.com',
password: '123456789'
}];
@@ -183,11 +183,11 @@ describe('/api/v1/comments/:comment_id', () => {
}];
const users = [{
displayName: 'Ana',
username: 'Ana',
email: 'ana@gmail.com',
password: '123456789'
}, {
displayName: 'Maria',
username: 'Maria',
email: 'maria@gmail.com',
password: '123456789'
}];
+4 -4
View File
@@ -45,11 +45,11 @@ describe('/api/v1/queue', () => {
}];
const users = [{
displayName: 'Ana',
username: 'Ana',
email: 'ana@gmail.com',
password: '123456789'
}, {
displayName: 'Maria',
username: 'Maria',
email: 'maria@gmail.com',
password: '123456789'
}];
@@ -103,7 +103,7 @@ describe('/api/v1/queue', () => {
expect(res).to.have.status(200);
expect(res.body.comments).to.have.length(1);
expect(res.body.comments[0]).to.have.property('body');
expect(res.body.users[0]).to.have.property('displayName');
expect(res.body.users[0]).to.have.property('username');
expect(res.body.actions[0]).to.have.property('action_type');
});
});
@@ -115,7 +115,7 @@ describe('/api/v1/queue', () => {
.end(function(err, res){
expect(err).to.be.null;
expect(res).to.have.status(200);
expect(res.body.users[0]).to.have.property('displayName');
expect(res.body.users[0]).to.have.property('username');
expect(res.body.actions[0]).to.have.property('action_type');
done();
});
+4 -44
View File
@@ -69,15 +69,12 @@ describe('services.CommentsService', () => {
const users = [{
email: 'stampi@gmail.com',
displayName: 'Stampi',
password: '1Coral!!',
roles: ['ADMIN'],
_id: '1'
username: 'Stampi',
password: '1Coral!!'
}, {
email: 'sockmonster@gmail.com',
displayName: 'Sockmonster',
password: '2Coral!!',
_id : '2'
username: 'Sockmonster',
password: '2Coral!!'
}];
const actions = [{
@@ -257,42 +254,5 @@ describe('services.CommentsService', () => {
expect(c.status_history[1]).to.have.property('assigned_by', '123');
});
});
});
describe('#tagByStaff()', () => {
it('creates a new comment by admin', () => {
return UsersService.findLocalUser('stampi@gmail.com', '1Coral!!').then((user) => {
return UsersService.addRoleToUser(user.id, 'ADMIN').then(() => {
UsersService.findById(user.id).then((u) => {
return CommentsService
.publicCreate({
body: 'This is a comment!',
status: 'ACCEPTED',
author_id: u.id
}).then((c) => {
expect(c).to.not.be.null;
expect(c.tags).to.not.have.length(0);
expect(c.tags[0].name).to.be.equal('STAFF');
});
});
});
});
});
it('creates a new comment by non admin', () => {
return UsersService.findLocalUser('sockmonster@gmail.com', '2Coral!!').then((user) => {
return CommentsService
.publicCreate({
body: 'This is a comment!',
status: 'ACCEPTED',
author_id: user.id
}).then((c) => {
expect(c).to.not.be.null;
expect(c.tags).to.have.length(0);
});
});
});
});
});
+11 -12
View File
@@ -12,15 +12,15 @@ describe('services.UsersService', () => {
return SettingsService.init(settings).then(() => {
return UsersService.createLocalUsers([{
email: 'stampi@gmail.com',
displayName: 'Stampi',
username: 'Stampi',
password: '1Coral!-'
}, {
email: 'sockmonster@gmail.com',
displayName: 'Sockmonster',
username: 'Sockmonster',
password: '2Coral!2'
}, {
email: 'marvel@gmail.com',
displayName: 'Marvel',
username: 'Marvel',
password: '3Coral!3'
}]).then((users) => {
mockUsers = users;
@@ -33,7 +33,7 @@ describe('services.UsersService', () => {
return UsersService
.findById(mockUsers[0].id)
.then((user) => {
expect(user).to.have.property('displayName', 'stampi');
expect(user).to.have.property('username', 'Stampi');
});
});
});
@@ -53,11 +53,11 @@ describe('services.UsersService', () => {
return UsersService.findPublicByIdArray(ids).then((result) => {
expect(result).to.have.length(3);
const sorted = result.sort((a, b) => {
if(a.displayName < b.displayName) {return -1;}
if(a.displayName > b.displayName) {return 1;}
if(a.username < b.username) {return -1;}
if(a.username > b.username) {return 1;}
return 0;
});
expect(sorted[0]).to.have.property('displayName', 'marvel');
expect(sorted[0]).to.have.property('username', 'Marvel');
});
});
});
@@ -68,8 +68,7 @@ describe('services.UsersService', () => {
return UsersService
.findLocalUser(mockUsers[0].profiles[0].id, '1Coral!-')
.then((user) => {
expect(user).to.have.property('displayName')
.and.to.equal(mockUsers[0].displayName.toLowerCase());
expect(user).to.have.property('username', mockUsers[0].username);
});
});
@@ -84,10 +83,10 @@ describe('services.UsersService', () => {
});
describe('#createLocalUser', () => {
it('should not create a user with duplicate display name', () => {
it('should not create a user with duplicate username', () => {
return UsersService.createLocalUsers([{
email: 'otrostampi@gmail.com',
displayName: 'StampiTheSecond',
username: 'StampiTheSecond',
password: '1Coralito!'
}])
.then((user) => {
@@ -227,7 +226,7 @@ describe('services.UsersService', () => {
.then(() => UsersService.editName(mockUsers[0].id, 'Jojo'))
.then(() => UsersService.findById(mockUsers[0].id))
.then((user) => {
expect(user).to.have.property('displayName', 'jojo');
expect(user).to.have.property('username', 'Jojo');
expect(user).to.have.property('canEditName', false);
});
});