fix: tests

v1.18.x
Barış Soner Uşaklı 4 years ago
parent dd7424e5b5
commit a411df1321

@ -79,24 +79,6 @@ paths:
$ref: 'read/admin/manage/tags.yaml'
/api/admin/manage/users:
$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:
$ref: 'read/admin/manage/registration.yaml'
/api/admin/manage/admins-mods:

@ -79,6 +79,8 @@ get:
description: Each privilege will have a key in this object
isPrivate:
type: boolean
isSystem:
type: boolean
columnCountUser:
type: number
columnCountUserOther:

@ -21,12 +21,12 @@ get:
type: number
resultsPerPage:
type: number
latest:
reverse:
type: boolean
search_display:
sortBy:
type: string
requireEmailConfirmation:
type: number
sort_online:
type: boolean
inviteOnly:
type: boolean
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;
}
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 stop = start + resultsPerPage - 1;
@ -230,8 +230,10 @@ function render(req, res, data) {
data.inviteOnly = registrationType === 'invite-only' || registrationType === 'admin-invite-only';
data.adminInviteOnly = registrationType === 'admin-invite-only';
data['sort_' + data.sortBy] = true;
if (req.query.searchBy) {
data['searchBy_' + validator.escape(String(req.query.searchBy))] = true;
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];
filterBy.forEach(function (filter) {
data['filterBy_' + validator.escape(String(filter))] = true;
});

@ -90,7 +90,10 @@ module.exports = function (Groups) {
}
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) {
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) {
request(nconf.get('url') + '/api/admin/manage/registration', { jar: jar, json: true }, function (err, res, body) {
assert.ifError(err);

@ -661,7 +661,7 @@ describe('Controllers', function () {
});
it('should error if guests do not have search privilege', function (done) {
request(nconf.get('url') + '/api/users?term=bar&section=sort-posts', { json: true }, function (err, res, body) {
request(nconf.get('url') + '/api/users?query=bar&section=sort-posts', { json: true }, function (err, res, body) {
assert.ifError(err);
assert.equal(res.statusCode, 500);
assert(body);
@ -673,7 +673,7 @@ describe('Controllers', function () {
it('should load users search page', function (done) {
privileges.global.give(['groups:search:users'], 'guests', function (err) {
assert.ifError(err);
request(nconf.get('url') + '/users?term=bar&section=sort-posts', function (err, res, body) {
request(nconf.get('url') + '/users?query=bar&section=sort-posts', function (err, res, body) {
assert.ifError(err);
assert.equal(res.statusCode, 200);
assert(body);
@ -1509,6 +1509,7 @@ describe('Controllers', function () {
assert.ifError(err);
request(nconf.get('url') + '/api/user/groupie', { json: true }, function (err, res, body) {
assert.ifError(err);
console.log(body);
assert.equal(res.statusCode, 200);
assert(Array.isArray(body.selectedGroup));
assert.equal(body.selectedGroup[0].name, 'selectedGroup');

Loading…
Cancel
Save