mirror of
https://github.com/NginxProxyManager/nginx-proxy-manager.git
synced 2025-12-06 00:16:49 +00:00
Tweaks to cypress suite
All checks were successful
Close stale issues and PRs / stale (push) Successful in 20s
All checks were successful
Close stale issues and PRs / stale (push) Successful in 20s
This commit is contained in:
@@ -1,21 +1,7 @@
|
||||
/// <reference types="cypress" />
|
||||
|
||||
const SWAGGER_SCHEMA_FILENAME = 'results/swagger-schema.json';
|
||||
|
||||
describe('Swagger Schema Linting', () => {
|
||||
it('Should be a completely valid schema', () => {
|
||||
// Save the schema to a file and lint it
|
||||
cy.request('/api/schema')
|
||||
.then((response) => {
|
||||
const fileContent = response.body;
|
||||
cy.writeFile(SWAGGER_SCHEMA_FILENAME, fileContent);
|
||||
})
|
||||
.then(() => {
|
||||
cy.exec(`yarn swagger-lint '${SWAGGER_SCHEMA_FILENAME}'`)
|
||||
.then((result) => {
|
||||
cy.log("Swagger Vacuum Results:\n", result.stdout);
|
||||
expect(result.code).to.eq(0);
|
||||
});
|
||||
});
|
||||
cy.validateSwaggerFile('/api/schema', 'results/swagger-schema.json');
|
||||
});
|
||||
});
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
const { SwaggerValidation } = require('@jc21/cypress-swagger-validation');
|
||||
const chalk = require('chalk');
|
||||
|
||||
module.exports = (on, config) => {
|
||||
// Replace swaggerBase config var wildcard
|
||||
@@ -11,7 +12,7 @@ module.exports = (on, config) => {
|
||||
on('task', require('./backendApi/task')(config));
|
||||
on('task', {
|
||||
log(message) {
|
||||
console.log(message);
|
||||
console.log(`${chalk.cyan.bold('[')}${chalk.blue.bold('LOG')}${chalk.cyan.bold(']')} ${chalk.red.bold(message)}`);
|
||||
return null;
|
||||
}
|
||||
});
|
||||
|
||||
@@ -22,7 +22,25 @@ Cypress.Commands.add('randomString', (length) => {
|
||||
});
|
||||
|
||||
/**
|
||||
* Check the swagger schema:
|
||||
* Check the swagger schema file:
|
||||
*
|
||||
* @param {string} url
|
||||
* @param {string} savePath
|
||||
*/
|
||||
Cypress.Commands.add("validateSwaggerFile", (url, savePath) => {
|
||||
cy.task('log', `validateSwaggerFile: ${url} -- ${savePath}`)
|
||||
.then(() => {
|
||||
return cy
|
||||
.request(url)
|
||||
.then((response) => cy.writeFile(savePath, response.body, { log: false }))
|
||||
.then(() => cy.exec(`yarn swagger-lint '${savePath}'`, { failOnNonZeroExit: false }))
|
||||
.then((result) => cy.task('log', `Swagger Vacuum Results:\n${result.stdout || ''}`)
|
||||
.then(() => expect(result.code).to.eq(0)));
|
||||
});
|
||||
});
|
||||
|
||||
/**
|
||||
* Check the swagger schema for a specific endpoint:
|
||||
*
|
||||
* @param {string} method API Method in swagger doc, "get", "put", "post", "delete"
|
||||
* @param {integer} code Swagger doc endpoint response code, exactly as defined in swagger doc
|
||||
|
||||
Reference in New Issue
Block a user