mirror of
https://github.com/NodeBB/NodeBB.git
synced 2026-01-29 18:59:58 +01:00
fix: openapi test specs
This commit is contained in:
@@ -27,14 +27,14 @@ get:
|
|||||||
timestamps:
|
timestamps:
|
||||||
type: array
|
type: array
|
||||||
items:
|
items:
|
||||||
type: number
|
type: string
|
||||||
revisions:
|
revisions:
|
||||||
type: array
|
type: array
|
||||||
items:
|
items:
|
||||||
type: object
|
type: object
|
||||||
properties:
|
properties:
|
||||||
timestamp:
|
timestamp:
|
||||||
type: number
|
type: string
|
||||||
username:
|
username:
|
||||||
type: string
|
type: string
|
||||||
editable:
|
editable:
|
||||||
|
|||||||
@@ -22,16 +22,4 @@ delete:
|
|||||||
'200':
|
'200':
|
||||||
description: Post diff successfully deleted
|
description: Post diff successfully deleted
|
||||||
content:
|
content:
|
||||||
application/json:
|
$ref: ../diffs.yaml#/get/responses/200/content
|
||||||
schema:
|
|
||||||
type: object
|
|
||||||
properties:
|
|
||||||
status:
|
|
||||||
$ref: ../../../../components/schemas/Status.yaml#/Status
|
|
||||||
response:
|
|
||||||
type: object
|
|
||||||
properties: {}
|
|
||||||
'400':
|
|
||||||
$ref: ../../../../components/responses/400.yaml#/400
|
|
||||||
'403':
|
|
||||||
$ref: ../../../../components/responses/403.yaml#/403
|
|
||||||
@@ -266,7 +266,8 @@ postsAPI.getDiffs = async (caller, data) => {
|
|||||||
privileges.users.isModerator(caller.uid, cid),
|
privileges.users.isModerator(caller.uid, cid),
|
||||||
]);
|
]);
|
||||||
|
|
||||||
timestamps.push(post.timestamp);
|
// timestamps returned by posts.diffs.list are strings
|
||||||
|
timestamps.push(String(post.timestamp));
|
||||||
|
|
||||||
return {
|
return {
|
||||||
timestamps: timestamps,
|
timestamps: timestamps,
|
||||||
|
|||||||
25
test/api.js
25
test/api.js
@@ -18,6 +18,7 @@ const user = require('../src/user');
|
|||||||
const groups = require('../src/groups');
|
const groups = require('../src/groups');
|
||||||
const categories = require('../src/categories');
|
const categories = require('../src/categories');
|
||||||
const topics = require('../src/topics');
|
const topics = require('../src/topics');
|
||||||
|
const posts = require('../src/posts');
|
||||||
const plugins = require('../src/plugins');
|
const plugins = require('../src/plugins');
|
||||||
const flags = require('../src/flags');
|
const flags = require('../src/flags');
|
||||||
const messaging = require('../src/messaging');
|
const messaging = require('../src/messaging');
|
||||||
@@ -74,6 +75,18 @@ describe('API', async () => {
|
|||||||
example: '', // to be defined below...
|
example: '', // to be defined below...
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
|
'/posts/{pid}/diffs/{timestamp}': [
|
||||||
|
{
|
||||||
|
in: 'path',
|
||||||
|
name: 'pid',
|
||||||
|
example: '', // to be defined below...
|
||||||
|
},
|
||||||
|
{
|
||||||
|
in: 'path',
|
||||||
|
name: 'timestamp',
|
||||||
|
example: '', // to be defined below...
|
||||||
|
},
|
||||||
|
],
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -123,7 +136,7 @@ describe('API', async () => {
|
|||||||
const testCategory = await categories.create({ name: 'test' });
|
const testCategory = await categories.create({ name: 'test' });
|
||||||
|
|
||||||
// Post a new topic
|
// Post a new topic
|
||||||
const testTopic = await topics.post({
|
await topics.post({
|
||||||
uid: adminUid,
|
uid: adminUid,
|
||||||
cid: testCategory.cid,
|
cid: testCategory.cid,
|
||||||
title: 'Test Topic',
|
title: 'Test Topic',
|
||||||
@@ -142,6 +155,16 @@ describe('API', async () => {
|
|||||||
content: 'Test topic 3 content',
|
content: 'Test topic 3 content',
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// Create a post diff
|
||||||
|
await posts.edit({
|
||||||
|
uid: adminUid,
|
||||||
|
pid: unprivTopic.postData.pid,
|
||||||
|
content: 'Test topic 2 edited content',
|
||||||
|
req: {},
|
||||||
|
});
|
||||||
|
mocks.delete['/posts/{pid}/diffs/{timestamp}'][0].example = unprivTopic.postData.pid;
|
||||||
|
mocks.delete['/posts/{pid}/diffs/{timestamp}'][1].example = (await posts.diffs.list(unprivTopic.postData.pid))[0];
|
||||||
|
|
||||||
// Create a sample flag
|
// Create a sample flag
|
||||||
await flags.create('post', 1, unprivUid, 'sample reasons', Date.now());
|
await flags.create('post', 1, unprivUid, 'sample reasons', Date.now());
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user