update tests

This commit is contained in:
Riley Davis
2017-01-12 15:25:36 -07:00
parent 44b41b031e
commit 0eefd3364b
8 changed files with 25 additions and 11 deletions
@@ -55,6 +55,10 @@ export const fetchFlaggedQueue = () => {
dispatch({type: commentTypes.COMMENTS_MODERATION_QUEUE_FETCH_REQUEST});
return coralApi('/queue/comments/flagged')
.then(comments => {
comments.forEach(comment => comment.flagged = true);
return comments;
})
.then(addUsersCommentsActions.bind(this, dispatch));
};
};
@@ -56,7 +56,7 @@ export default ({onTabClick, ...props}) => (
<div className={`mdl-tabs__panel ${styles.listContainer}`} id='flagged'>
<CommentList
suspectWords={props.settings.settings.wordlist.suspect}
isActive={props.activeTab === 'rejected'}
isActive={props.activeTab === 'flagged'}
singleView={props.singleView}
commentIds={props.flaggedIds}
comments={props.comments.byId}
+1 -1
View File
@@ -123,7 +123,7 @@ router.post('/', wordlist.filter('body'), (req, res, next) => {
if (charCountEnable && body.length > charCount) {
return 'rejected';
}
return moderation === 'pre' ? 'premod' : '';
return moderation === 'pre' ? 'premod' : null;
});
}
+1
View File
@@ -68,6 +68,7 @@ router.get('/comments/flagged', authorization.needed('admin'), (req, res, next)
.then(ids => assetIDWrap(Comment.find({
id: {$in: ids}
})))
.then(gatherActionsAndUsers)
.then(([comments, users, actions]) => {
res.json({comments, users, actions});
})
+8 -9
View File
@@ -21,6 +21,7 @@ describe('models.Comment', () => {
status_history: [{
type: 'accepted'
}],
status: 'accepted',
parent_id: '',
author_id: '123',
id: '2'
@@ -37,6 +38,7 @@ describe('models.Comment', () => {
status_history: [{
type: 'rejected'
}],
status: 'rejected',
parent_id: '',
author_id: '456',
id: '4'
@@ -46,6 +48,7 @@ describe('models.Comment', () => {
status_history: [{
type: 'premod'
}],
status: 'premod',
parent_id: '',
author_id: '456',
id: '5'
@@ -55,6 +58,7 @@ describe('models.Comment', () => {
status_history: [{
type: 'premod'
}],
status: 'premod',
parent_id: '',
author_id: '456',
id: '6'
@@ -184,20 +188,12 @@ describe('models.Comment', () => {
describe('#moderationQueue()', () => {
it('should find an array of new comments to moderate when pre-moderation', () => {
return Comment.moderationQueue('pre').then((result) => {
return Comment.moderationQueue('premod').then((result) => {
expect(result).to.not.be.null;
expect(result).to.have.lengthOf(2);
});
});
it('should find an array of new comments to moderate when post-moderation', () => {
return Comment.moderationQueue('post').then((result) => {
expect(result).to.not.be.null;
expect(result).to.have.lengthOf(1);
expect(result[0]).to.have.property('body', 'comment 30');
});
});
});
describe('#removeAction', () => {
@@ -227,6 +223,7 @@ describe('models.Comment', () => {
.then(() => Comment.findById(comment_id))
.then((c) => {
expect(c).to.have.property('status');
expect(c.status).to.equal('rejected');
expect(c.status_history).to.have.length(1);
expect(c.status_history[0]).to.have.property('type', 'rejected');
expect(c.status_history[0]).to.have.property('assigned_by', '123');
@@ -238,6 +235,8 @@ describe('models.Comment', () => {
.then(() => Comment.findById(comments[1].id))
.then((c) => {
expect(c).to.have.property('status_history');
expect(c).to.have.property('status');
expect(c.status).to.equal('rejected');
expect(c.status_history).to.have.length(2);
expect(c.status_history[0]).to.have.property('type', 'accepted');
expect(c.status_history[0]).to.have.property('assigned_by', null);
+2
View File
@@ -34,12 +34,14 @@ describe('/api/v1/comments', () => {
body: 'comment 20',
asset_id: 'asset',
author_id: '456',
status: 'rejected',
status_history: [{
type: 'rejected'
}]
}, {
body: 'comment 30',
asset_id: '456',
status: 'accepted',
status_history: [{
type: 'accepted'
}]
+4
View File
@@ -21,6 +21,7 @@ describe('/api/v1/queue', () => {
body: 'comment 10',
asset_id: 'asset',
author_id: '123',
status: 'rejected',
status_history: [{
type: 'rejected'
}]
@@ -29,6 +30,7 @@ describe('/api/v1/queue', () => {
body: 'comment 20',
asset_id: 'asset',
author_id: '456',
status: 'premod',
status_history: [{
type: 'premod'
}]
@@ -36,6 +38,7 @@ describe('/api/v1/queue', () => {
id: 'hij',
body: 'comment 30',
asset_id: '456',
status: 'accepted',
status_history: [{
type: 'accepted'
}]
@@ -89,6 +92,7 @@ describe('/api/v1/queue', () => {
.set(passport.inject({roles: ['admin']}))
.then((res) => {
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.actions[0]).to.have.property('action_type');
+4
View File
@@ -29,6 +29,7 @@ describe('/api/v1/stream', () => {
body: 'comment 10',
author_id: '',
parent_id: '',
status: 'accepted',
status_history: [{
type: 'accepted'
}]
@@ -37,6 +38,7 @@ describe('/api/v1/stream', () => {
body: 'comment 20',
author_id: '',
parent_id: '',
status: null,
status_history: []
}, {
id: 'uio',
@@ -44,6 +46,7 @@ describe('/api/v1/stream', () => {
asset_id: 'asset',
author_id: '456',
parent_id: '',
status: 'accepted',
status_history: [{
type: 'accepted'
}]
@@ -51,6 +54,7 @@ describe('/api/v1/stream', () => {
id: 'hij',
body: 'comment 40',
asset_id: '456',
status: 'rejected',
status_history: [{
type: 'rejected'
}]