mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-10-26 16:46:12 +01:00
fix: tests
This commit is contained in:
@@ -79,24 +79,6 @@ paths:
|
|||||||
$ref: 'read/admin/manage/tags.yaml'
|
$ref: 'read/admin/manage/tags.yaml'
|
||||||
/api/admin/manage/users:
|
/api/admin/manage/users:
|
||||||
$ref: 'read/admin/manage/users.yaml'
|
$ref: 'read/admin/manage/users.yaml'
|
||||||
/api/admin/manage/users/search:
|
|
||||||
$ref: 'read/admin/manage/users/search.yaml'
|
|
||||||
/api/admin/manage/users/latest:
|
|
||||||
$ref: 'read/admin/manage/users/latest.yaml'
|
|
||||||
/api/admin/manage/users/not-validated:
|
|
||||||
$ref: 'read/admin/manage/users/not-validated.yaml'
|
|
||||||
/api/admin/manage/users/no-posts:
|
|
||||||
$ref: 'read/admin/manage/users/no-posts.yaml'
|
|
||||||
/api/admin/manage/users/top-posters:
|
|
||||||
$ref: 'read/admin/manage/users/top-posters.yaml'
|
|
||||||
/api/admin/manage/users/most-reputation:
|
|
||||||
$ref: 'read/admin/manage/users/most-reputation.yaml'
|
|
||||||
/api/admin/manage/users/inactive:
|
|
||||||
$ref: 'read/admin/manage/users/inactive.yaml'
|
|
||||||
/api/admin/manage/users/flagged:
|
|
||||||
$ref: 'read/admin/manage/users/flagged.yaml'
|
|
||||||
/api/admin/manage/users/banned:
|
|
||||||
$ref: 'read/admin/manage/users/banned.yaml'
|
|
||||||
/api/admin/manage/registration:
|
/api/admin/manage/registration:
|
||||||
$ref: 'read/admin/manage/registration.yaml'
|
$ref: 'read/admin/manage/registration.yaml'
|
||||||
/api/admin/manage/admins-mods:
|
/api/admin/manage/admins-mods:
|
||||||
|
|||||||
@@ -79,6 +79,8 @@ get:
|
|||||||
description: Each privilege will have a key in this object
|
description: Each privilege will have a key in this object
|
||||||
isPrivate:
|
isPrivate:
|
||||||
type: boolean
|
type: boolean
|
||||||
|
isSystem:
|
||||||
|
type: boolean
|
||||||
columnCountUser:
|
columnCountUser:
|
||||||
type: number
|
type: number
|
||||||
columnCountUserOther:
|
columnCountUserOther:
|
||||||
|
|||||||
@@ -21,12 +21,12 @@ get:
|
|||||||
type: number
|
type: number
|
||||||
resultsPerPage:
|
resultsPerPage:
|
||||||
type: number
|
type: number
|
||||||
latest:
|
reverse:
|
||||||
type: boolean
|
type: boolean
|
||||||
search_display:
|
sortBy:
|
||||||
type: string
|
type: string
|
||||||
requireEmailConfirmation:
|
sort_online:
|
||||||
type: number
|
type: boolean
|
||||||
inviteOnly:
|
inviteOnly:
|
||||||
type: boolean
|
type: boolean
|
||||||
adminInviteOnly:
|
adminInviteOnly:
|
||||||
|
|||||||
@@ -1,7 +0,0 @@
|
|||||||
get:
|
|
||||||
tags:
|
|
||||||
- admin
|
|
||||||
summary: Get banned users
|
|
||||||
responses:
|
|
||||||
"418":
|
|
||||||
description: "TODO: A proper response needs to be added. It is not really a teapot | Replace this responses block with the block from /manage/users/latest"
|
|
||||||
@@ -1,7 +0,0 @@
|
|||||||
get:
|
|
||||||
tags:
|
|
||||||
- admin
|
|
||||||
summary: Get flagged users
|
|
||||||
responses:
|
|
||||||
"418":
|
|
||||||
description: "TODO: A proper response needs to be added. It is not really a teapot | Replace this responses block with the block from /manage/users/latest"
|
|
||||||
@@ -1,7 +0,0 @@
|
|||||||
get:
|
|
||||||
tags:
|
|
||||||
- admin
|
|
||||||
summary: Get inactive users
|
|
||||||
responses:
|
|
||||||
"418":
|
|
||||||
description: "TODO: A proper response needs to be added. It is not really a teapot | Replace this responses block with the block from /manage/users/latest"
|
|
||||||
@@ -1,7 +0,0 @@
|
|||||||
get:
|
|
||||||
tags:
|
|
||||||
- admin
|
|
||||||
summary: Get latest users
|
|
||||||
responses:
|
|
||||||
"418":
|
|
||||||
description: "TODO: A proper response needs to be added. It is not really a teapot | Replace this responses block with the block from /manage/users/latest"
|
|
||||||
@@ -1,7 +0,0 @@
|
|||||||
get:
|
|
||||||
tags:
|
|
||||||
- admin
|
|
||||||
summary: Get users with the most reputation
|
|
||||||
responses:
|
|
||||||
"418":
|
|
||||||
description: "TODO: A proper response needs to be added. It is not really a teapot | Replace this responses block with the block from /manage/users/latest"
|
|
||||||
@@ -1,7 +0,0 @@
|
|||||||
get:
|
|
||||||
tags:
|
|
||||||
- admin
|
|
||||||
summary: Get users with no posts
|
|
||||||
responses:
|
|
||||||
"418":
|
|
||||||
description: "TODO: A proper response needs to be added. It is not really a teapot | Replace this responses block with the block from /manage/users/latest"
|
|
||||||
@@ -1,7 +0,0 @@
|
|||||||
get:
|
|
||||||
tags:
|
|
||||||
- admin
|
|
||||||
summary: Get non-verified users
|
|
||||||
responses:
|
|
||||||
"418":
|
|
||||||
description: "TODO: A proper response needs to be added. It is not really a teapot | Replace this responses block with the block from /manage/users/latest"
|
|
||||||
@@ -1,39 +0,0 @@
|
|||||||
get:
|
|
||||||
tags:
|
|
||||||
- admin
|
|
||||||
summary: Get users via search term
|
|
||||||
responses:
|
|
||||||
"200":
|
|
||||||
description: ""
|
|
||||||
content:
|
|
||||||
application/json:
|
|
||||||
schema:
|
|
||||||
allOf:
|
|
||||||
- type: object
|
|
||||||
properties:
|
|
||||||
search_display:
|
|
||||||
type: string
|
|
||||||
matchCount:
|
|
||||||
type: number
|
|
||||||
query:
|
|
||||||
type: string
|
|
||||||
uidQuery:
|
|
||||||
type: string
|
|
||||||
usernameQuery:
|
|
||||||
type: string
|
|
||||||
emailQuery:
|
|
||||||
type: string
|
|
||||||
ipQuery:
|
|
||||||
type: string
|
|
||||||
pageCount:
|
|
||||||
type: number
|
|
||||||
resultsPerPage:
|
|
||||||
type: number
|
|
||||||
timing:
|
|
||||||
type: number
|
|
||||||
users:
|
|
||||||
type: array
|
|
||||||
items:
|
|
||||||
$ref: ../../../../components/schemas/UserObject.yaml#/UserObjectACP
|
|
||||||
- $ref: ../../../../components/schemas/CommonProps.yaml#/CommonProps
|
|
||||||
- $ref: ../../../../components/schemas/Pagination.yaml#/Pagination
|
|
||||||
@@ -1,7 +0,0 @@
|
|||||||
get:
|
|
||||||
tags:
|
|
||||||
- admin
|
|
||||||
summary: Get users with the most posts
|
|
||||||
responses:
|
|
||||||
"418":
|
|
||||||
description: "TODO: A proper response needs to be added. It is not really a teapot | Replace this responses block with the block from /manage/users/latest"
|
|
||||||
@@ -36,7 +36,7 @@ async function getUsers(req, res) {
|
|||||||
resultsPerPage = 50;
|
resultsPerPage = 50;
|
||||||
}
|
}
|
||||||
let sortBy = validator.escape(req.query.sortBy || '');
|
let sortBy = validator.escape(req.query.sortBy || '');
|
||||||
const filterBy = Array.isArray(req.query.filters) ? req.query.filters : [req.query.filters];
|
const filterBy = Array.isArray(req.query.filters || []) ? (req.query.filters || []) : [req.query.filters];
|
||||||
const start = Math.max(0, page - 1) * resultsPerPage;
|
const start = Math.max(0, page - 1) * resultsPerPage;
|
||||||
const stop = start + resultsPerPage - 1;
|
const stop = start + resultsPerPage - 1;
|
||||||
|
|
||||||
@@ -230,8 +230,10 @@ function render(req, res, data) {
|
|||||||
data.inviteOnly = registrationType === 'invite-only' || registrationType === 'admin-invite-only';
|
data.inviteOnly = registrationType === 'invite-only' || registrationType === 'admin-invite-only';
|
||||||
data.adminInviteOnly = registrationType === 'admin-invite-only';
|
data.adminInviteOnly = registrationType === 'admin-invite-only';
|
||||||
data['sort_' + data.sortBy] = true;
|
data['sort_' + data.sortBy] = true;
|
||||||
data['searchBy_' + validator.escape(String(req.query.searchBy))] = true;
|
if (req.query.searchBy) {
|
||||||
const filterBy = Array.isArray(req.query.filters) ? req.query.filters : [req.query.filters];
|
data['searchBy_' + validator.escape(String(req.query.searchBy))] = true;
|
||||||
|
}
|
||||||
|
const filterBy = Array.isArray(req.query.filters || []) ? (req.query.filters || []) : [req.query.filters];
|
||||||
filterBy.forEach(function (filter) {
|
filterBy.forEach(function (filter) {
|
||||||
data['filterBy_' + validator.escape(String(filter))] = true;
|
data['filterBy_' + validator.escape(String(filter))] = true;
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -90,7 +90,10 @@ module.exports = function (Groups) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async function setGroupTitleIfNotSet(groupNames, uid) {
|
async function setGroupTitleIfNotSet(groupNames, uid) {
|
||||||
groupNames = groupNames.filter(groupName => groupName !== 'registered-users' && !Groups.isPrivilegeGroup(groupName));
|
const ignore = ['registered-users', 'verified-users', 'unverified-users'];
|
||||||
|
groupNames = groupNames.filter(
|
||||||
|
groupName => !ignore.includes(groupName) && !Groups.isPrivilegeGroup(groupName)
|
||||||
|
);
|
||||||
if (!groupNames.length) {
|
if (!groupNames.length) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -219,78 +219,6 @@ describe('Admin Controllers', function () {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should load /admin/manage/users/search', function (done) {
|
|
||||||
request(nconf.get('url') + '/api/admin/manage/users/search', { jar: jar, json: true }, function (err, res, body) {
|
|
||||||
assert.ifError(err);
|
|
||||||
assert.equal(res.statusCode, 200);
|
|
||||||
assert(body.users);
|
|
||||||
done();
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should load /admin/manage/users/not-validated', function (done) {
|
|
||||||
request(nconf.get('url') + '/api/admin/manage/users/not-validated', { jar: jar, json: true }, function (err, res, body) {
|
|
||||||
assert.ifError(err);
|
|
||||||
assert.equal(res.statusCode, 200);
|
|
||||||
assert(body);
|
|
||||||
done();
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should load /admin/manage/users/no-posts', function (done) {
|
|
||||||
request(nconf.get('url') + '/api/admin/manage/users/no-posts', { jar: jar, json: true }, function (err, res, body) {
|
|
||||||
assert.ifError(err);
|
|
||||||
assert.equal(res.statusCode, 200);
|
|
||||||
assert(body);
|
|
||||||
done();
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should load /admin/manage/users/top-posters', function (done) {
|
|
||||||
request(nconf.get('url') + '/api/admin/manage/users/top-posters', { jar: jar, json: true }, function (err, res, body) {
|
|
||||||
assert.ifError(err);
|
|
||||||
assert.equal(res.statusCode, 200);
|
|
||||||
assert(body);
|
|
||||||
done();
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should load /admin/manage/users/most-reputation', function (done) {
|
|
||||||
request(nconf.get('url') + '/api/admin/manage/users/most-reputation', { jar: jar, json: true }, function (err, res, body) {
|
|
||||||
assert.ifError(err);
|
|
||||||
assert.equal(res.statusCode, 200);
|
|
||||||
assert(body);
|
|
||||||
done();
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should load /admin/manage/users/inactive', function (done) {
|
|
||||||
request(nconf.get('url') + '/api/admin/manage/users/inactive', { jar: jar, json: true }, function (err, res, body) {
|
|
||||||
assert.ifError(err);
|
|
||||||
assert.equal(res.statusCode, 200);
|
|
||||||
assert(body);
|
|
||||||
done();
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should load /admin/manage/users/flagged', function (done) {
|
|
||||||
request(nconf.get('url') + '/api/admin/manage/users/flagged', { jar: jar, json: true }, function (err, res, body) {
|
|
||||||
assert.ifError(err);
|
|
||||||
assert.equal(res.statusCode, 200);
|
|
||||||
assert(body);
|
|
||||||
done();
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should load /admin/manage/users/banned', function (done) {
|
|
||||||
request(nconf.get('url') + '/api/admin/manage/users/banned', { jar: jar, json: true }, function (err, res, body) {
|
|
||||||
assert.ifError(err);
|
|
||||||
assert.equal(res.statusCode, 200);
|
|
||||||
assert(body);
|
|
||||||
done();
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should load /admin/manage/registration', function (done) {
|
it('should load /admin/manage/registration', function (done) {
|
||||||
request(nconf.get('url') + '/api/admin/manage/registration', { jar: jar, json: true }, function (err, res, body) {
|
request(nconf.get('url') + '/api/admin/manage/registration', { jar: jar, json: true }, function (err, res, body) {
|
||||||
assert.ifError(err);
|
assert.ifError(err);
|
||||||
|
|||||||
@@ -661,7 +661,7 @@ describe('Controllers', function () {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('should error if guests do not have search privilege', function (done) {
|
it('should error if guests do not have search privilege', function (done) {
|
||||||
request(nconf.get('url') + '/api/users?term=bar§ion=sort-posts', { json: true }, function (err, res, body) {
|
request(nconf.get('url') + '/api/users?query=bar§ion=sort-posts', { json: true }, function (err, res, body) {
|
||||||
assert.ifError(err);
|
assert.ifError(err);
|
||||||
assert.equal(res.statusCode, 500);
|
assert.equal(res.statusCode, 500);
|
||||||
assert(body);
|
assert(body);
|
||||||
@@ -673,7 +673,7 @@ describe('Controllers', function () {
|
|||||||
it('should load users search page', function (done) {
|
it('should load users search page', function (done) {
|
||||||
privileges.global.give(['groups:search:users'], 'guests', function (err) {
|
privileges.global.give(['groups:search:users'], 'guests', function (err) {
|
||||||
assert.ifError(err);
|
assert.ifError(err);
|
||||||
request(nconf.get('url') + '/users?term=bar§ion=sort-posts', function (err, res, body) {
|
request(nconf.get('url') + '/users?query=bar§ion=sort-posts', function (err, res, body) {
|
||||||
assert.ifError(err);
|
assert.ifError(err);
|
||||||
assert.equal(res.statusCode, 200);
|
assert.equal(res.statusCode, 200);
|
||||||
assert(body);
|
assert(body);
|
||||||
@@ -1509,6 +1509,7 @@ describe('Controllers', function () {
|
|||||||
assert.ifError(err);
|
assert.ifError(err);
|
||||||
request(nconf.get('url') + '/api/user/groupie', { json: true }, function (err, res, body) {
|
request(nconf.get('url') + '/api/user/groupie', { json: true }, function (err, res, body) {
|
||||||
assert.ifError(err);
|
assert.ifError(err);
|
||||||
|
console.log(body);
|
||||||
assert.equal(res.statusCode, 200);
|
assert.equal(res.statusCode, 200);
|
||||||
assert(Array.isArray(body.selectedGroup));
|
assert(Array.isArray(body.selectedGroup));
|
||||||
assert.equal(body.selectedGroup[0].name, 'selectedGroup');
|
assert.equal(body.selectedGroup[0].name, 'selectedGroup');
|
||||||
|
|||||||
Reference in New Issue
Block a user