mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-10-26 16:46:12 +01:00
chore: up composer
add test for /compose route
This commit is contained in:
@@ -98,7 +98,7 @@
|
|||||||
"multiparty": "4.2.3",
|
"multiparty": "4.2.3",
|
||||||
"nconf": "0.12.1",
|
"nconf": "0.12.1",
|
||||||
"nodebb-plugin-2factor": "7.5.6",
|
"nodebb-plugin-2factor": "7.5.6",
|
||||||
"nodebb-plugin-composer-default": "10.2.39",
|
"nodebb-plugin-composer-default": "10.2.40",
|
||||||
"nodebb-plugin-dbsearch": "6.2.5",
|
"nodebb-plugin-dbsearch": "6.2.5",
|
||||||
"nodebb-plugin-emoji": "5.1.15",
|
"nodebb-plugin-emoji": "5.1.15",
|
||||||
"nodebb-plugin-emoji-android": "4.0.0",
|
"nodebb-plugin-emoji-android": "4.0.0",
|
||||||
|
|||||||
@@ -1553,6 +1553,7 @@ describe('Controllers', () => {
|
|||||||
await privileges.categories.rescind(['groups:read'], category.cid, 'guests');
|
await privileges.categories.rescind(['groups:read'], category.cid, 'guests');
|
||||||
const { response } = await request.get(`${nconf.get('url')}/api/category/${category.slug}`);
|
const { response } = await request.get(`${nconf.get('url')}/api/category/${category.slug}`);
|
||||||
assert.equal(response.statusCode, 401);
|
assert.equal(response.statusCode, 401);
|
||||||
|
await privileges.categories.give(['groups:read'], category.cid, 'guests');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should redirect if topic index is negative', async () => {
|
it('should redirect if topic index is negative', async () => {
|
||||||
@@ -1715,7 +1716,9 @@ describe('Controllers', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('should load the composer route', async () => {
|
it('should load the composer route', async () => {
|
||||||
const { response, body } = await request.get(`${nconf.get('url')}/api/compose?cid=1`);
|
const { response, body } = await request.get(`${nconf.get('url')}/api/compose?cid=${cid}`, {
|
||||||
|
jar,
|
||||||
|
});
|
||||||
assert.equal(response.statusCode, 200);
|
assert.equal(response.statusCode, 200);
|
||||||
assert(body.title);
|
assert(body.title);
|
||||||
assert(body.template);
|
assert(body.template);
|
||||||
@@ -1733,7 +1736,9 @@ describe('Controllers', () => {
|
|||||||
method: hookMethod,
|
method: hookMethod,
|
||||||
});
|
});
|
||||||
|
|
||||||
const { response, body } = await request.get(`${nconf.get('url')}/api/compose?cid=1`);
|
const { response, body } = await request.get(`${nconf.get('url')}/api/compose?cid=${cid}`, {
|
||||||
|
jar,
|
||||||
|
});
|
||||||
assert.equal(response.statusCode, 200);
|
assert.equal(response.statusCode, 200);
|
||||||
assert(body.title);
|
assert(body.title);
|
||||||
assert.strictEqual(body.template.name, '');
|
assert.strictEqual(body.template.name, '');
|
||||||
@@ -1835,6 +1840,30 @@ describe('Controllers', () => {
|
|||||||
assert.equal(replyResult.response.statusCode, 302);
|
assert.equal(replyResult.response.statusCode, 302);
|
||||||
await privileges.categories.rescind(['groups:topics:post', 'groups:topics:reply'], cid, 'guests');
|
await privileges.categories.rescind(['groups:topics:post', 'groups:topics:reply'], cid, 'guests');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('should not load a topic data that is in private category', async () => {
|
||||||
|
const { cid } = await categories.create({
|
||||||
|
name: 'private',
|
||||||
|
description: 'private',
|
||||||
|
});
|
||||||
|
|
||||||
|
const result = await topics.post({ uid: fooUid, title: 'hidden title', content: 'hidden content', cid: cid });
|
||||||
|
|
||||||
|
await privileges.categories.rescind(['groups:topics:read'], category.cid, 'guests');
|
||||||
|
let { response, body } = await request.get(`${nconf.get('url')}/api/compose?tid=${result.topicData.tid}`);
|
||||||
|
assert.equal(response.statusCode, 401);
|
||||||
|
assert(!body.title);
|
||||||
|
|
||||||
|
({ response, body } = await request.get(`${nconf.get('url')}/api/compose?cid=${cid}`));
|
||||||
|
assert.equal(response.statusCode, 401);
|
||||||
|
assert(!body.title);
|
||||||
|
|
||||||
|
({ response, body } = await request.get(`${nconf.get('url')}/api/compose?pid=${result.postData.pid}`));
|
||||||
|
assert.equal(response.statusCode, 401);
|
||||||
|
assert(!body.title);
|
||||||
|
|
||||||
|
await privileges.categories.give(['groups:topics:read'], category.cid, 'guests');
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('test routes', () => {
|
describe('test routes', () => {
|
||||||
|
|||||||
Reference in New Issue
Block a user