mirror of
				https://github.com/NodeBB/NodeBB.git
				synced 2025-10-31 02:55:58 +01:00 
			
		
		
		
	removing old tests that got added back in due to git being silly
This commit is contained in:
		
							
								
								
									
										215
									
								
								test/posts.js
									
									
									
									
									
								
							
							
						
						
									
										215
									
								
								test/posts.js
									
									
									
									
									
								
							| @@ -501,221 +501,6 @@ describe('Post\'s', function () { | |||||||
| 		}); | 		}); | ||||||
| 	}); | 	}); | ||||||
|  |  | ||||||
| 	describe('flagging a post', function () { |  | ||||||
| 		var meta = require('../src/meta'); |  | ||||||
| 		var socketPosts = require('../src/socket.io/posts'); |  | ||||||
| 		it('should fail to flag a post due to low reputation', function (done) { |  | ||||||
| 			meta.config['privileges:flag'] = 10; |  | ||||||
| 			flagPost(function (err) { |  | ||||||
| 				assert.equal(err.message, '[[error:not-enough-reputation-to-flag]]'); |  | ||||||
| 				done(); |  | ||||||
| 			}); |  | ||||||
| 		}); |  | ||||||
|  |  | ||||||
| 		it('should flag a post', function (done) { |  | ||||||
| 			meta.config['privileges:flag'] = -1; |  | ||||||
| 			flagPost(function (err) { |  | ||||||
| 				assert.ifError(err); |  | ||||||
| 				done(); |  | ||||||
| 			}); |  | ||||||
| 		}); |  | ||||||
|  |  | ||||||
| 		it('should return nothing without a uid or a reason', function (done) { |  | ||||||
| 			socketPosts.flag({ uid: 0 }, { pid: postData.pid, reason: 'reason' }, function (err) { |  | ||||||
| 				assert.equal(err.message, '[[error:not-logged-in]]'); |  | ||||||
| 				socketPosts.flag({ uid: voteeUid }, {}, function (err) { |  | ||||||
| 					assert.equal(err.message, '[[error:invalid-data]]'); |  | ||||||
| 					done(); |  | ||||||
| 				}); |  | ||||||
| 			}); |  | ||||||
| 		}); |  | ||||||
|  |  | ||||||
| 		it('should return an error without an existing post', function (done) { |  | ||||||
| 			socketPosts.flag({ uid: voteeUid }, { pid: 12312312, reason: 'reason' }, function (err) { |  | ||||||
| 				assert.equal(err.message, '[[error:no-post]]'); |  | ||||||
| 				done(); |  | ||||||
| 			}); |  | ||||||
| 		}); |  | ||||||
|  |  | ||||||
| 		it('should return an error if the flag already exists', function (done) { |  | ||||||
| 			socketPosts.flag({ uid: voteeUid }, { pid: postData.pid, reason: 'reason' }, function (err) { |  | ||||||
| 				assert.equal(err.message, '[[error:already-flagged]]'); |  | ||||||
| 				done(); |  | ||||||
| 			}); |  | ||||||
| 		}); |  | ||||||
| 	}); |  | ||||||
|  |  | ||||||
| 	function flagPost(next) { |  | ||||||
| 		var socketPosts = require('../src/socket.io/posts'); |  | ||||||
| 		socketPosts.flag({ uid: voteeUid }, { pid: postData.pid, reason: 'reason' }, next); |  | ||||||
| 	} |  | ||||||
|  |  | ||||||
| 	describe('get flag data', function () { |  | ||||||
| 		it('should see the flagged post', function (done) { |  | ||||||
| 			posts.isFlaggedByUser(postData.pid, voteeUid, function (err, hasFlagged) { |  | ||||||
| 				assert.ifError(err); |  | ||||||
| 				assert(hasFlagged); |  | ||||||
| 				done(); |  | ||||||
| 			}); |  | ||||||
| 		}); |  | ||||||
|  |  | ||||||
| 		it('should return the flagged post data', function (done) { |  | ||||||
| 			posts.getFlags('posts:flagged', cid, voteeUid, 0, -1, function (err, flagData) { |  | ||||||
| 				assert.ifError(err); |  | ||||||
| 				assert(flagData.posts); |  | ||||||
| 				assert(flagData.count); |  | ||||||
| 				assert.equal(flagData.count, 1); |  | ||||||
| 				assert.equal(flagData.posts.length, 1); |  | ||||||
| 				assert(flagData.posts[0].flagReasons); |  | ||||||
| 				assert.equal(flagData.posts[0].flagReasons.length, 1); |  | ||||||
| 				assert.strictEqual(flagData.posts[0].flagReasons[0].reason, 'reason'); |  | ||||||
| 				assert(flagData.posts[0].flagData); |  | ||||||
| 				assert.strictEqual(flagData.posts[0].flagData.state, 'open'); |  | ||||||
| 				done(); |  | ||||||
| 			}); |  | ||||||
| 		}); |  | ||||||
| 	}); |  | ||||||
|  |  | ||||||
| 	describe('updating a flag', function () { |  | ||||||
| 		var socketPosts = require('../src/socket.io/posts'); |  | ||||||
|  |  | ||||||
| 		it('should update a flag', function (done) { |  | ||||||
| 			async.waterfall([ |  | ||||||
| 				function (next) { |  | ||||||
| 					socketPosts.updateFlag({ uid: globalModUid }, { |  | ||||||
| 						pid: postData.pid, |  | ||||||
| 						data: [ |  | ||||||
| 							{ name: 'assignee', value: `${globalModUid}` }, |  | ||||||
| 							{ name: 'notes', value: 'notes' }, |  | ||||||
| 						], |  | ||||||
| 					}, function (err) { |  | ||||||
| 						assert.ifError(err); |  | ||||||
| 						posts.getFlags('posts:flagged', cid, globalModUid, 0, -1, function (err, flagData) { |  | ||||||
| 							assert.ifError(err); |  | ||||||
| 							assert(flagData.posts); |  | ||||||
| 							assert.equal(flagData.posts.length, 1); |  | ||||||
| 							assert.deepEqual({ |  | ||||||
| 								assignee: flagData.posts[0].flagData.assignee, |  | ||||||
| 								notes: flagData.posts[0].flagData.notes, |  | ||||||
| 								state: flagData.posts[0].flagData.state, |  | ||||||
| 								labelClass: flagData.posts[0].flagData.labelClass, |  | ||||||
| 							}, { |  | ||||||
| 								assignee: `${globalModUid}`, |  | ||||||
| 								notes: 'notes', |  | ||||||
| 								state: 'open', |  | ||||||
| 								labelClass: 'info', |  | ||||||
| 							}); |  | ||||||
| 							next(); |  | ||||||
| 						}); |  | ||||||
| 					}); |  | ||||||
| 				}, function (next) { |  | ||||||
| 					posts.updateFlagData(globalModUid, postData.pid, { |  | ||||||
| 						state: 'rejected', |  | ||||||
| 					}, function (err) { |  | ||||||
| 						assert.ifError(err); |  | ||||||
| 						posts.getFlags('posts:flagged', cid, globalModUid, 0, -1, function (err, flagData) { |  | ||||||
| 							assert.ifError(err); |  | ||||||
| 							assert(flagData.posts); |  | ||||||
| 							assert.equal(flagData.posts.length, 1); |  | ||||||
| 							assert.deepEqual({ |  | ||||||
| 								state: flagData.posts[0].flagData.state, |  | ||||||
| 								labelClass: flagData.posts[0].flagData.labelClass, |  | ||||||
| 							}, { |  | ||||||
| 								state: 'rejected', |  | ||||||
| 								labelClass: 'danger', |  | ||||||
| 							}); |  | ||||||
| 							next(); |  | ||||||
| 						}); |  | ||||||
| 					}); |  | ||||||
| 				}, function (next) { |  | ||||||
| 					posts.updateFlagData(globalModUid, postData.pid, { |  | ||||||
| 						state: 'wip', |  | ||||||
| 					}, function (err) { |  | ||||||
| 						assert.ifError(err); |  | ||||||
| 						posts.getFlags('posts:flagged', cid, globalModUid, 0, -1, function (err, flagData) { |  | ||||||
| 							assert.ifError(err); |  | ||||||
| 							assert(flagData.posts); |  | ||||||
| 							assert.equal(flagData.posts.length, 1); |  | ||||||
| 							assert.deepEqual({ |  | ||||||
| 								state: flagData.posts[0].flagData.state, |  | ||||||
| 								labelClass: flagData.posts[0].flagData.labelClass, |  | ||||||
| 							}, { |  | ||||||
| 								state: 'wip', |  | ||||||
| 								labelClass: 'warning', |  | ||||||
| 							}); |  | ||||||
| 							next(); |  | ||||||
| 						}); |  | ||||||
| 					}); |  | ||||||
| 				}, function (next) { |  | ||||||
| 					posts.updateFlagData(globalModUid, postData.pid, { |  | ||||||
| 						state: 'resolved', |  | ||||||
| 					}, function (err) { |  | ||||||
| 						assert.ifError(err); |  | ||||||
| 						posts.getFlags('posts:flagged', cid, globalModUid, 0, -1, function (err, flagData) { |  | ||||||
| 							assert.ifError(err); |  | ||||||
| 							assert(flagData.posts); |  | ||||||
| 							assert.equal(flagData.posts.length, 1); |  | ||||||
| 							assert.deepEqual({ |  | ||||||
| 								state: flagData.posts[0].flagData.state, |  | ||||||
| 								labelClass: flagData.posts[0].flagData.labelClass, |  | ||||||
| 							}, { |  | ||||||
| 								state: 'resolved', |  | ||||||
| 								labelClass: 'success', |  | ||||||
| 							}); |  | ||||||
| 							next(); |  | ||||||
| 						}); |  | ||||||
| 					}); |  | ||||||
| 				}, |  | ||||||
| 			], done); |  | ||||||
| 		}); |  | ||||||
| 	}); |  | ||||||
|  |  | ||||||
| 	describe('dismissing a flag', function () { |  | ||||||
| 		var socketPosts = require('../src/socket.io/posts'); |  | ||||||
|  |  | ||||||
| 		it('should dismiss a flag', function (done) { |  | ||||||
| 			socketPosts.dismissFlag({ uid: globalModUid }, postData.pid, function (err) { |  | ||||||
| 				assert.ifError(err); |  | ||||||
| 				posts.isFlaggedByUser(postData.pid, voteeUid, function (err, hasFlagged) { |  | ||||||
| 					assert.ifError(err); |  | ||||||
| 					assert(!hasFlagged); |  | ||||||
| 					flagPost(function (err) { |  | ||||||
| 						assert.ifError(err); |  | ||||||
| 						done(); |  | ||||||
| 					}); |  | ||||||
| 				}); |  | ||||||
| 			}); |  | ||||||
| 		}); |  | ||||||
|  |  | ||||||
| 		it('should dismiss all of a user\'s flags', function (done) { |  | ||||||
| 			posts.dismissUserFlags(voteeUid, function (err) { |  | ||||||
| 				assert.ifError(err); |  | ||||||
| 				posts.isFlaggedByUser(postData.pid, voteeUid, function (err, hasFlagged) { |  | ||||||
| 					assert.ifError(err); |  | ||||||
| 					assert(!hasFlagged); |  | ||||||
| 					flagPost(function (err) { |  | ||||||
| 						assert.ifError(err); |  | ||||||
| 						done(); |  | ||||||
| 					}); |  | ||||||
| 				}); |  | ||||||
| 			}); |  | ||||||
| 		}); |  | ||||||
|  |  | ||||||
| 		it('should dismiss all flags', function (done) { |  | ||||||
| 			socketPosts.dismissAllFlags({ uid: globalModUid }, {}, function (err) { |  | ||||||
| 				assert.ifError(err); |  | ||||||
| 				posts.isFlaggedByUser(postData.pid, voteeUid, function (err, hasFlagged) { |  | ||||||
| 					assert.ifError(err); |  | ||||||
| 					assert(!hasFlagged); |  | ||||||
| 					flagPost(function (err) { |  | ||||||
| 						assert.ifError(err); |  | ||||||
| 						done(); |  | ||||||
| 					}); |  | ||||||
| 				}); |  | ||||||
| 			}); |  | ||||||
| 		}); |  | ||||||
| 	}); |  | ||||||
|  |  | ||||||
| 	describe('getPostSummaryByPids', function () { | 	describe('getPostSummaryByPids', function () { | ||||||
| 		it('should return empty array for empty pids', function (done) { | 		it('should return empty array for empty pids', function (done) { | ||||||
| 			posts.getPostSummaryByPids([], 0, {}, function (err, data) { | 			posts.getPostSummaryByPids([], 0, {}, function (err, data) { | ||||||
|   | |||||||
| @@ -244,14 +244,6 @@ describe('socket.io', function () { | |||||||
| 		}); | 		}); | ||||||
| 	}); | 	}); | ||||||
|  |  | ||||||
| 	it('should reset flags', function (done) { |  | ||||||
| 		var socketAdmin = require('../src/socket.io/admin'); |  | ||||||
| 		socketAdmin.user.resetFlags({ uid: adminUid }, [regularUid], function (err) { |  | ||||||
| 			assert.ifError(err); |  | ||||||
| 			done(); |  | ||||||
| 		}); |  | ||||||
| 	}); |  | ||||||
|  |  | ||||||
| 	describe('validation emails', function () { | 	describe('validation emails', function () { | ||||||
| 		var socketAdmin = require('../src/socket.io/admin'); | 		var socketAdmin = require('../src/socket.io/admin'); | ||||||
| 		var meta = require('../src/meta'); | 		var meta = require('../src/meta'); | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user