Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
A
auto-test
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
JIRA
JIRA
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
xie.qin
auto-test
Commits
e5a9d515
Commit
e5a9d515
authored
Sep 22, 2021
by
xie.qin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
To support download openapi file.
parent
8c6d9107
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
25 additions
and
9 deletions
+25
-9
2.X版本_OpenAPI.json
e2e/cypress/downloads/2.X版本_OpenAPI.json
+0
-0
openApiFileDownload.feature
e2e/cypress/integration/openApiFileDownload.feature
+2
-2
openApiFileDownload.js
...ss/integration/openApiFileDownload/openApiFileDownload.js
+8
-4
index.js
e2e/cypress/plugins/index.js
+15
-3
No files found.
e2e/cypress/downloads/2.X版本_OpenAPI.json
0 → 100644
View file @
e5a9d515
This source diff could not be displayed because it is too large. You can
view the blob
instead.
e2e/cypress/integration/openApiFileDownload.feature
View file @
e5a9d515
...
@@ -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
e2e/cypress/integration/openApiFileDownload/openApiFileDownload.js
View file @
e5a9d515
...
@@ -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
e2e/cypress/plugins/index.js
View file @
e5a9d515
...
@@ -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
));
}
}
})
})
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment