Commit e5a9d515 authored by xie.qin's avatar xie.qin

To support download openapi file.

parent 8c6d9107
This source diff could not be displayed because it is too large. You can view the blob instead.
...@@ -3,4 +3,4 @@ Feature: Download latest OpenApi file from running service ...@@ -3,4 +3,4 @@ Feature: Download latest OpenApi file from running service
Scenario: Download latest OpenApi file from backend service Scenario: Download latest OpenApi file from backend service
Given swagger-ui page of "backend" service is avaliable Given swagger-ui page of "backend" service is avaliable
Then Download openapi file and save Then download openapi file and save
\ No newline at end of file \ No newline at end of file
...@@ -5,7 +5,7 @@ const path = require('path') ...@@ -5,7 +5,7 @@ const path = require('path')
Given('swagger-ui page of {string} service is avaliable', (serviceName) => { Given('swagger-ui page of {string} service is avaliable', (serviceName) => {
var url = '' var url = ''
debugger //debugger
if (Cypress.env('combinedDeployment')) { if (Cypress.env('combinedDeployment')) {
if (Cypress.env('service.backend.httpsEnable')) { if (Cypress.env('service.backend.httpsEnable')) {
url += 'https://' url += 'https://'
...@@ -15,7 +15,7 @@ Given('swagger-ui page of {string} service is avaliable', (serviceName) => { ...@@ -15,7 +15,7 @@ Given('swagger-ui page of {string} service is avaliable', (serviceName) => {
} }
let backendService = Cypress.env('service')['backend'] let backendService = Cypress.env('service')['backend']
url += backendService['host'] + ':' + backendService['port'] + backendService['openapiUrl'] url += backendService['host'] + ':' + backendService['port'] + backendService['openapiUrl']
cy.log('swagger-ui url=', url) cy.log('swagger-ui url=' + url)
} }
else { else {
switch(serviceName) { switch(serviceName) {
...@@ -24,7 +24,6 @@ Given('swagger-ui page of {string} service is avaliable', (serviceName) => { ...@@ -24,7 +24,6 @@ Given('swagger-ui page of {string} service is avaliable', (serviceName) => {
} }
} }
cy.visit(url) cy.visit(url)
cy.title().should('include', 'BAAS接口文档')
}) })
Then('download openapi file and save', () => { Then('download openapi file and save', () => {
...@@ -38,5 +37,9 @@ Then('download openapi file and save', () => { ...@@ -38,5 +37,9 @@ Then('download openapi file and save', () => {
// file path is relative to the working folder // file path is relative to the working folder
const filename = path.join(downloadsFolder, '2.X版本_OpenAPI.json') const filename = path.join(downloadsFolder, '2.X版本_OpenAPI.json')
cy.readFile(filename, { timeout: 15000 }).should('have.length.gt', 1500000) //debugger
cy.task('getFileSize', filename).then((fileSize) => {
debugger
expect(fileSize).to.greaterThan(1500000)
})
}) })
\ No newline at end of file
...@@ -17,7 +17,7 @@ ...@@ -17,7 +17,7 @@
*/ */
// eslint-disable-next-line no-unused-vars // eslint-disable-next-line no-unused-vars
const cucumber = require('cypress-cucumber-preprocessor').default const cucumber = require('cypress-cucumber-preprocessor').default
const { fs, rmdir } = require('fs') const { rmdir, stat, mkdirSync, writeFile } = require('fs')
module.exports = (on, config) => { module.exports = (on, config) => {
// `on` is used to hook into various events Cypress emits // `on` is used to hook into various events Cypress emits
...@@ -38,11 +38,23 @@ module.exports = (on, config) => { ...@@ -38,11 +38,23 @@ module.exports = (on, config) => {
}) })
}) })
}, },
getFileSize (filePath) {
console.log('getting size of file: %s', filePath)
return new Promise((resolve, reject) => {
var fileSize = stat(filePath, (err,stats) => {
if (err) {
console.error(err)
return reject(err)
}
resolve(stats.size)
});
})
},
}) })
on('after:run', (results) => { on('after:run', (results) => {
if (results) { if (results) {
fs.mkdirSync("cypress/.run", { recursive: true }); mkdirSync("cypress/.run", { recursive: true });
fs.writeFile("cypress/.run/results.json", JSON.stringify(results)); writeFile("cypress/.run/results.json", JSON.stringify(results));
} }
}) })
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment