mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-10-26 16:46:12 +01:00
fix: all tests, wrap up work
This commit is contained in:
@@ -54,6 +54,8 @@ tags:
|
|||||||
description: Disparate method of categorizing topics
|
description: Disparate method of categorizing topics
|
||||||
- name: shorthand
|
- name: shorthand
|
||||||
description: Convenience and utility routes for accessing other part of the API
|
description: Convenience and utility routes for accessing other part of the API
|
||||||
|
- name: other
|
||||||
|
description: Other one-off routes that do not fit in a section of their own
|
||||||
paths:
|
paths:
|
||||||
/api/:
|
/api/:
|
||||||
$ref: 'read/index.yaml'
|
$ref: 'read/index.yaml'
|
||||||
@@ -177,6 +179,8 @@ paths:
|
|||||||
$ref: 'read/categories.yaml'
|
$ref: 'read/categories.yaml'
|
||||||
"/api/categories/{cid}/moderators":
|
"/api/categories/{cid}/moderators":
|
||||||
$ref: 'read/categories/cid/moderators.yaml'
|
$ref: 'read/categories/cid/moderators.yaml'
|
||||||
|
"/api/topic/{topic_id}/{slug}":
|
||||||
|
$ref: 'read/topic/topic_id.yaml'
|
||||||
"/api/topic/{topic_id}/{slug}/{post_index}":
|
"/api/topic/{topic_id}/{slug}/{post_index}":
|
||||||
$ref: 'read/topic/topic_id.yaml'
|
$ref: 'read/topic/topic_id.yaml'
|
||||||
/api/recent:
|
/api/recent:
|
||||||
@@ -203,6 +207,8 @@ paths:
|
|||||||
$ref: 'read/register/complete.yaml'
|
$ref: 'read/register/complete.yaml'
|
||||||
"/api/confirm/{code}":
|
"/api/confirm/{code}":
|
||||||
$ref: 'read/confirm/code.yaml'
|
$ref: 'read/confirm/code.yaml'
|
||||||
|
/api/tos:
|
||||||
|
$ref: 'read/tos.yaml'
|
||||||
/api/search:
|
/api/search:
|
||||||
$ref: 'read/search.yaml'
|
$ref: 'read/search.yaml'
|
||||||
"/api/reset":
|
"/api/reset":
|
||||||
@@ -231,6 +237,8 @@ paths:
|
|||||||
$ref: 'read/popular.yaml'
|
$ref: 'read/popular.yaml'
|
||||||
/api/top:
|
/api/top:
|
||||||
$ref: 'read/top.yaml'
|
$ref: 'read/top.yaml'
|
||||||
|
"/api/category/{category_id}/{slug}":
|
||||||
|
$ref: 'read/category/category_id.yaml'
|
||||||
"/api/category/{category_id}/{slug}/{topic_index}":
|
"/api/category/{category_id}/{slug}/{topic_index}":
|
||||||
$ref: 'read/category/category_id.yaml'
|
$ref: 'read/category/category_id.yaml'
|
||||||
/api/self:
|
/api/self:
|
||||||
@@ -300,4 +308,6 @@ paths:
|
|||||||
"/api/groups/{slug}":
|
"/api/groups/{slug}":
|
||||||
$ref: 'read/groups/slug.yaml'
|
$ref: 'read/groups/slug.yaml'
|
||||||
"/api/groups/{slug}/members":
|
"/api/groups/{slug}/members":
|
||||||
$ref: 'read/groups/slug/members.yaml'
|
$ref: 'read/groups/slug/members.yaml'
|
||||||
|
/api/outgoing:
|
||||||
|
$ref: 'read/outgoing.yaml'
|
||||||
@@ -9,6 +9,12 @@ get:
|
|||||||
type: string
|
type: string
|
||||||
required: true
|
required: true
|
||||||
example: /admin/manage/groups
|
example: /admin/manage/groups
|
||||||
|
- in: path
|
||||||
|
name: groupname
|
||||||
|
schema:
|
||||||
|
type: string
|
||||||
|
required: true
|
||||||
|
example: registered-users
|
||||||
responses:
|
responses:
|
||||||
"200":
|
"200":
|
||||||
description: "A CSV file containing all users in the group"
|
description: "A CSV file containing all users in the group"
|
||||||
|
|||||||
@@ -18,5 +18,4 @@ get:
|
|||||||
description: Translation key for client-side localisation
|
description: Translation key for client-side localisation
|
||||||
required:
|
required:
|
||||||
- title
|
- title
|
||||||
- $ref: ../../components/schemas/Breadcrumbs.yaml#/Breadcrumbs
|
|
||||||
- $ref: ../../components/schemas/CommonProps.yaml#/CommonProps
|
- $ref: ../../components/schemas/CommonProps.yaml#/CommonProps
|
||||||
29
public/openapi/read/outgoing.yaml
Normal file
29
public/openapi/read/outgoing.yaml
Normal file
@@ -0,0 +1,29 @@
|
|||||||
|
get:
|
||||||
|
tags:
|
||||||
|
- other
|
||||||
|
summary: Warn before navigating externally
|
||||||
|
parameters:
|
||||||
|
- in: query
|
||||||
|
name: url
|
||||||
|
schema:
|
||||||
|
type: string
|
||||||
|
description: URL of the page to warn the user about
|
||||||
|
example: https://example.org
|
||||||
|
description: This route presents a warning to a user notifying them that the page they are about to view is hosted externally. They then have the option of continuing onwards or going back to where they came from.
|
||||||
|
responses:
|
||||||
|
"200":
|
||||||
|
description: Warning page presented
|
||||||
|
content:
|
||||||
|
application/json:
|
||||||
|
schema:
|
||||||
|
allOf:
|
||||||
|
- type: object
|
||||||
|
properties:
|
||||||
|
outgoing:
|
||||||
|
type: string
|
||||||
|
description: Escaped URL of the page to navigate to
|
||||||
|
title:
|
||||||
|
description: The page title
|
||||||
|
type: string
|
||||||
|
- $ref: ../components/schemas/Breadcrumbs.yaml#/Breadcrumbs
|
||||||
|
- $ref: ../components/schemas/CommonProps.yaml#/CommonProps
|
||||||
18
public/openapi/read/tos.yaml
Normal file
18
public/openapi/read/tos.yaml
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
get:
|
||||||
|
tags:
|
||||||
|
- authentication
|
||||||
|
summary: Get forum terms of service
|
||||||
|
description: This route allows you to view the forum terms of service.
|
||||||
|
responses:
|
||||||
|
"200":
|
||||||
|
description: Terms of service retrieved.
|
||||||
|
content:
|
||||||
|
application/json:
|
||||||
|
schema:
|
||||||
|
allOf:
|
||||||
|
- type: object
|
||||||
|
properties:
|
||||||
|
termsOfUse:
|
||||||
|
type: string
|
||||||
|
description: Full text of the configured terms of service/terms of use.
|
||||||
|
- $ref: ../components/schemas/CommonProps.yaml#/CommonProps
|
||||||
14
test/api.js
14
test/api.js
@@ -100,6 +100,7 @@ describe('API', async () => {
|
|||||||
}],
|
}],
|
||||||
});
|
});
|
||||||
meta.config.allowTopicsThumbnail = 1;
|
meta.config.allowTopicsThumbnail = 1;
|
||||||
|
meta.config.termsOfUse = 'I, for one, welcome our new test-drive overlords';
|
||||||
|
|
||||||
// Create a category
|
// Create a category
|
||||||
const testCategory = await categories.create({ name: 'test' });
|
const testCategory = await categories.create({ name: 'test' });
|
||||||
@@ -225,8 +226,8 @@ describe('API', async () => {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
// generateTests(readApi, Object.keys(readApi.paths));
|
generateTests(readApi, Object.keys(readApi.paths));
|
||||||
// generateTests(writeApi, Object.keys(writeApi.paths), writeApi.servers[0].url);
|
generateTests(writeApi, Object.keys(writeApi.paths), writeApi.servers[0].url);
|
||||||
|
|
||||||
function generateTests(api, paths, prefix) {
|
function generateTests(api, paths, prefix) {
|
||||||
// Iterate through all documented paths, make a call to it, and compare the result body with what is defined in the spec
|
// Iterate through all documented paths, make a call to it, and compare the result body with what is defined in the spec
|
||||||
@@ -252,8 +253,9 @@ describe('API', async () => {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const names = (path.match(/{[\w\-_*]+}?/g) || []).map(match => match.slice(1, -1));
|
const pathParams = (path.match(/{[\w\-_*]+}?/g) || []).map(match => match.slice(1, -1));
|
||||||
assert(context[method].parameters.map(param => (param.in === 'path' ? param.name : null)).filter(Boolean).every(name => names.includes(name)), `${method.toUpperCase()} ${path} has parameter(s) in path that are not defined in schema`);
|
const schemaParams = context[method].parameters.map(param => (param.in === 'path' ? param.name : null)).filter(Boolean);
|
||||||
|
assert(pathParams.every(param => schemaParams.includes(param)), `${method.toUpperCase()} ${path} has path parameters specified but not defined`);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should have examples when parameters are present', () => {
|
it('should have examples when parameters are present', () => {
|
||||||
@@ -333,11 +335,11 @@ describe('API', async () => {
|
|||||||
});
|
});
|
||||||
} else if (type === 'form') {
|
} else if (type === 'form') {
|
||||||
response = await new Promise((resolve, reject) => {
|
response = await new Promise((resolve, reject) => {
|
||||||
helpers.uploadFile(url, pathLib.join(__dirname, './files/test.png'), {}, jar, csrfToken, function (err, res, body) {
|
helpers.uploadFile(url, pathLib.join(__dirname, './files/test.png'), {}, jar, csrfToken, function (err, res) {
|
||||||
if (err) {
|
if (err) {
|
||||||
return reject(err);
|
return reject(err);
|
||||||
}
|
}
|
||||||
resolve(body);
|
resolve(res);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user