Tweaks to cypress suite
All checks were successful
Close stale issues and PRs / stale (push) Successful in 20s

This commit is contained in:
Jamie Curnow
2025-11-18 07:21:06 +10:00
parent 9b4c34915c
commit 316b758455
5 changed files with 54 additions and 35 deletions

View File

@@ -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');
});
});

View File

@@ -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;
}
});

View File

@@ -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

View File

@@ -7,6 +7,7 @@
"@jc21/cypress-swagger-validation": "^0.3.2",
"@quobix/vacuum": "^0.19.4",
"axios": "^1.13.1",
"chalk": "^4.1.0",
"cypress": "^14.0.1",
"cypress-multi-reporters": "^2.0.5",
"cypress-wait-until": "^3.0.2",

View File

@@ -247,11 +247,6 @@
resolved "https://registry.yarnpkg.com/@types/sizzle/-/sizzle-2.3.2.tgz#a811b8c18e2babab7d542b3365887ae2e4d9de47"
integrity sha512-7EJYyKTL7tFR8+gDbB6Wwz/arpGa0Mywk1TJbNzKzHtzbwVmY4HR9WqS5VV7dsBUKQmPNr192jHr/VpBluj/hg==
"@types/tmp@^0.2.3":
version "0.2.6"
resolved "https://registry.yarnpkg.com/@types/tmp/-/tmp-0.2.6.tgz#d785ee90c52d7cc020e249c948c36f7b32d1e217"
integrity sha512-chhaNf2oKHlRkDGt+tiKE2Z5aJ6qalm7Z9rlLdBwmOiAAf09YQvvoLXjWK4HWPF1xU/fqvMgfNfpVoBscA/tKA==
"@types/yauzl@^2.9.1":
version "2.10.0"
resolved "https://registry.yarnpkg.com/@types/yauzl/-/yauzl-2.10.0.tgz#b3248295276cf8c6f153ebe6a9aba0c988cb2599"
@@ -405,6 +400,11 @@ astral-regex@^2.0.0:
resolved "https://registry.yarnpkg.com/astral-regex/-/astral-regex-2.0.0.tgz#483143c567aeed4785759c0865786dc77d7d2e31"
integrity sha512-Z7tMw1ytTXt5jqMcOP+OQteU1VuNK9Y02uuJtKQ1Sv69jXQKKg5cibLwGJow8yzZP+eAc18EmLGPal0bp36rvQ==
async@^3.2.0:
version "3.2.6"
resolved "https://registry.yarnpkg.com/async/-/async-3.2.6.tgz#1b0728e14929d51b85b449b7f06e27c1145e38ce"
integrity sha512-htCUDlxyyCLMgaM3xXg0C0LW2xqfuQ6p05pCEIsXuyQ+a1koYKTuBMzRNwmybfLgvJDMd0r1LTn4+E0Ti6C2AA==
asynckit@^0.4.0:
version "0.4.0"
resolved "https://registry.yarnpkg.com/asynckit/-/asynckit-0.4.0.tgz#c79ed97f7f34cb8f2ba1bc9790bcc366474b4b79"
@@ -557,6 +557,11 @@ charenc@0.0.2:
resolved "https://registry.yarnpkg.com/charenc/-/charenc-0.0.2.tgz#c0a1d2f3a7092e03774bfa83f14c0fc5790a8667"
integrity sha512-yrLQ/yVUFXkzg7EDQsPieE/53+0RlaWTs+wBrvW36cyilJ2SaDWfl4Yj7MtLTXleV9uEKefbAGUPv2/iWSooRA==
check-more-types@^2.24.0:
version "2.24.0"
resolved "https://registry.yarnpkg.com/check-more-types/-/check-more-types-2.24.0.tgz#1420ffb10fd444dcfc79b43891bbfffd32a84600"
integrity sha512-Pj779qHxV2tuapviy1bSZNEL1maXr13bPYpsvSDB68HlYcYuhlDrmGd63i0JHMCLKzc7rUSNIrpdJlhVlNwrxA==
chokidar@^4.0.1:
version "4.0.3"
resolved "https://registry.yarnpkg.com/chokidar/-/chokidar-4.0.3.tgz#7be37a4c03c9aee1ecfe862a4a23b2c70c205d30"
@@ -689,22 +694,22 @@ cypress-wait-until@^3.0.2:
resolved "https://registry.yarnpkg.com/cypress-wait-until/-/cypress-wait-until-3.0.2.tgz#c90dddfa4c46a2c422f5b91d486531c560bae46e"
integrity sha512-iemies796dD5CgjG5kV0MnpEmKSH+s7O83ZoJLVzuVbZmm4lheMsZqAVT73hlMx4QlkwhxbyUzhOBUOZwoOe0w==
cypress@^15.5.0:
version "15.5.0"
resolved "https://registry.yarnpkg.com/cypress/-/cypress-15.5.0.tgz#039c8549f623957a14e57adee46dbfabaabac741"
integrity sha512-7jXBsh5hTfjxr9QQONC2IbdTj0nxSyU8x4eiarMZBzXzCj3pedKviUx8JnLcE4vL8e0TsOzp70WSLRORjEssRA==
cypress@^14.0.1:
version "14.5.4"
resolved "https://registry.yarnpkg.com/cypress/-/cypress-14.5.4.tgz#d821fbb6220c3328e7413acc7724b75319c9e64d"
integrity sha512-0Dhm4qc9VatOcI1GiFGVt8osgpPdqJLHzRwcAB5MSD/CAAts3oybvPUPawHyvJZUd8osADqZe/xzMsZ8sDTjXw==
dependencies:
"@cypress/request" "^3.0.9"
"@cypress/xvfb" "^1.2.4"
"@types/sinonjs__fake-timers" "8.1.1"
"@types/sizzle" "^2.3.2"
"@types/tmp" "^0.2.3"
arch "^2.2.0"
blob-util "^2.0.2"
bluebird "^3.7.2"
buffer "^5.7.1"
cachedir "^2.3.0"
chalk "^4.1.0"
check-more-types "^2.24.0"
ci-info "^4.1.0"
cli-cursor "^3.1.0"
cli-table3 "0.6.1"
@@ -719,8 +724,10 @@ cypress@^15.5.0:
extract-zip "2.0.1"
figures "^3.2.0"
fs-extra "^9.1.0"
getos "^3.2.1"
hasha "5.2.2"
is-installed-globally "~0.4.0"
lazy-ass "^1.6.0"
listr2 "^3.8.3"
lodash "^4.17.21"
log-symbols "^4.0.0"
@@ -732,8 +739,7 @@ cypress@^15.5.0:
request-progress "^3.0.0"
semver "^7.7.1"
supports-color "^8.1.1"
systeminformation "5.27.7"
tmp "~0.2.4"
tmp "~0.2.3"
tree-kill "1.2.2"
untildify "^4.0.0"
yauzl "^2.10.0"
@@ -1279,6 +1285,13 @@ get-stream@^5.0.0, get-stream@^5.1.0:
dependencies:
pump "^3.0.0"
getos@^3.2.1:
version "3.2.1"
resolved "https://registry.yarnpkg.com/getos/-/getos-3.2.1.tgz#0134d1f4e00eb46144c5a9c0ac4dc087cbb27dc5"
integrity sha512-U56CfOK17OKgTVqozZjUKNdkfEv6jk5WISBJ8SHoagjE6L69zOwl3Z+O8myjY9MEW3i2HPWQBt/LTbCgcC973Q==
dependencies:
async "^3.2.0"
getpass@^0.1.1:
version "0.1.7"
resolved "https://registry.yarnpkg.com/getpass/-/getpass-0.1.7.tgz#5eff8e3e684d569ae4cb2b1282604e8ba62149fa"
@@ -1582,6 +1595,11 @@ keyv@^4.5.4:
dependencies:
json-buffer "3.0.1"
lazy-ass@^1.6.0:
version "1.6.0"
resolved "https://registry.yarnpkg.com/lazy-ass/-/lazy-ass-1.6.0.tgz#7999655e8646c17f089fdd187d150d3324d54513"
integrity sha512-cc8oEVoctTvsFZ/Oje/kGnHbpWHYBe8IAJe4C0QNc3t8uM/0Y8+erSz/7Y1ALuXTEZTMvxXwO6YbX1ey3ujiZw==
levn@^0.4.1:
version "0.4.1"
resolved "https://registry.yarnpkg.com/levn/-/levn-0.4.1.tgz#ae4562c007473b932a6200d403268dd2fffc6ade"
@@ -2281,11 +2299,6 @@ supports-color@^8.1.1:
dependencies:
has-flag "^4.0.0"
systeminformation@5.27.7:
version "5.27.7"
resolved "https://registry.yarnpkg.com/systeminformation/-/systeminformation-5.27.7.tgz#4dc9d436419948cd5e5f076779a1298220d19a72"
integrity sha512-saaqOoVEEFaux4v0K8Q7caiauRwjXC4XbD2eH60dxHXbpKxQ8kH9Rf7Jh+nryKpOUSEFxtCdBlSUx0/lO6rwRg==
tar@^6.1.11:
version "6.2.1"
resolved "https://registry.yarnpkg.com/tar/-/tar-6.2.1.tgz#717549c541bc3c2af15751bea94b1dd068d4b03a"
@@ -2320,7 +2333,7 @@ tldts@^6.1.32:
dependencies:
tldts-core "^6.1.86"
tmp@~0.2.4:
tmp@~0.2.3:
version "0.2.5"
resolved "https://registry.yarnpkg.com/tmp/-/tmp-0.2.5.tgz#b06bcd23f0f3c8357b426891726d16015abfd8f8"
integrity sha512-voyz6MApa1rQGUxT3E+BK7/ROe8itEx7vD8/HEvt4xwXucvQ5G5oeEiHkmHZJuBO21RpOf+YYm9MOivj709jow==