From b405662ccf926dcfd56d84fea225cdca4759e383 Mon Sep 17 00:00:00 2001 From: "gaoxiaolin.gao" Date: Tue, 31 Jul 2018 11:31:11 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BC=98=E5=8C=96=E7=94=A8=E6=88=B7?= =?UTF-8?q?=E4=BF=A1=E6=81=AF=E9=A1=B5=E9=9D=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../InterfaceCol/InterfaceColContent.js | 2 ++ client/containers/User/Profile.js | 4 +--- docs/documents/case.md | 10 ++++++++++ server/controllers/open.js | 1 - server/utils/commons.js | 2 ++ static/doc/documents/CHANGELOG.html | 10 +++++++++- static/doc/documents/case.html | 7 +++++++ static/doc/index.html | 2 +- static/doc/search_json.js | 18 ++++++++++++++---- 9 files changed, 46 insertions(+), 10 deletions(-) diff --git a/client/containers/Project/Interface/InterfaceCol/InterfaceColContent.js b/client/containers/Project/Interface/InterfaceCol/InterfaceColContent.js index 1770fa13..eb667f21 100755 --- a/client/containers/Project/Interface/InterfaceCol/InterfaceColContent.js +++ b/client/containers/Project/Interface/InterfaceCol/InterfaceColContent.js @@ -308,6 +308,8 @@ class InterfaceColContent extends Component { statusText: data.res.statusText } ); + + // 断言测试 await this.handleScriptTest(interfaceData, responseData, validRes, requestParams); if (validRes.length === 0) { diff --git a/client/containers/User/Profile.js b/client/containers/User/Profile.js index 2041c1a8..a7671d2a 100755 --- a/client/containers/User/Profile.js +++ b/client/containers/User/Profile.js @@ -8,7 +8,6 @@ import { connect } from 'react-redux'; const EditButton = props => { const { isAdmin, isOwner, onClick, name, admin } = props; - if (isOwner) { // 本人 if (admin) { @@ -316,11 +315,10 @@ class Profile extends Component { } if (this.state.roleEdit === false) { - let btn = ''; + roleEditHtml = (
{roles[userinfo.role]}   - {btn}
); } else { diff --git a/docs/documents/case.md b/docs/documents/case.md index 875cc6a2..dffd39c3 100755 --- a/docs/documents/case.md +++ b/docs/documents/case.md @@ -139,6 +139,16 @@ http request params, 合并了 query 和 body log(message) 函数,调试时使用,log 信息仅仅在断言失败后打印,失败断言前的信息 +``` +log(234) +assert.equal(status, 400) +log(123) +``` +输出结果: +log: 234 +AssertionError: 200 == 400 + + ### 示例 ``` diff --git a/server/controllers/open.js b/server/controllers/open.js index 30d54114..0123cd7e 100644 --- a/server/controllers/open.js +++ b/server/controllers/open.js @@ -261,7 +261,6 @@ class openController extends baseController { if (ctx.params.mode === 'json') { return (ctx.body = reportsResult); } else { - // ctx.set('Content-Disposition', `attachment; filename=api.html`); return (ctx.body = renderToHtml(reportsResult)); } } diff --git a/server/utils/commons.js b/server/utils/commons.js index 9f60692e..58891890 100755 --- a/server/utils/commons.js +++ b/server/utils/commons.js @@ -504,7 +504,9 @@ function convertString(variable) { } } +// exports.runCaseScript = async function runCaseScript(params) { + let script = params.script; // script 是断言 if (!script) { diff --git a/static/doc/documents/CHANGELOG.html b/static/doc/documents/CHANGELOG.html index 379f8ed6..b90107da 100644 --- a/static/doc/documents/CHANGELOG.html +++ b/static/doc/documents/CHANGELOG.html @@ -7,17 +7,25 @@
-

v1.3.21

+

v1.3.22

+
    +
  • json schema number和integer支持枚举
  • +
  • 服务端测试增加下载功能
  • +
+

v1.3.21

  • 请求配置增加 context.utils.CryptoJS
  • 环境变量支持自定义全局变量
  • 增加wiki数据导出功能
  • 用户管理处增加搜索功能
  • 增加项目全局 mock 脚本功能
  • +
  • 高级 mock 期望 支持关闭开启功能

Bug Fixed

  • 优化ldap登陆
  • +
  • swagger 导入公共params
  • +
  • 接口编辑 mockEditor 修改为 AceEditor

v1.3.20

Bug Fixed

diff --git a/static/doc/documents/case.html b/static/doc/documents/case.html index 2a455e56..f28ff06e 100644 --- a/static/doc/documents/case.html +++ b/static/doc/documents/case.html @@ -101,6 +101,13 @@

记录的 http 请求信息,假设需要获取 key 为 555 的接口参数或者响应数据,可通过 records[555].params 或 records[555].body 获取

7.log

log(message) 函数,调试时使用,log 信息仅仅在断言失败后打印,失败断言前的信息

+
log(234)   
+assert.equal(status, 400)
+log(123)
+
+

输出结果: +log: 234
+AssertionError: 200 == 400

示例


 assert.equal(body.errcode, 0)
diff --git a/static/doc/index.html b/static/doc/index.html
index 7ce3b33a..61c6d351 100644
--- a/static/doc/index.html
+++ b/static/doc/index.html
@@ -7,7 +7,7 @@
       
-

YApi

旨在为开发、产品、测试人员提供更优雅的接口管理服务。可以帮助开发者轻松创建、发布、维护 API

当前版本: v1.3.20

bg
权限管理

YApi 成熟的团队管理扁平化项目权限配置满足各类企业的需求

可视化接口管理

基于 websocket 的多人协作接口编辑功能和类 postman 测试工具,让多人协作成倍提升开发效率

Mock Server

易用的 Mock Server,再也不用担心 mock 数据的生成了

自动化测试

完善的接口自动化测试,保证数据的正确性

数据导入

支持导入 swagger, postman, har 数据格式,方便迁移旧项目

插件机制

强大的插件机制,满足各类业务需求

+

YApi

旨在为开发、产品、测试人员提供更优雅的接口管理服务。可以帮助开发者轻松创建、发布、维护 API

当前版本: v1.3.21

bg
权限管理

YApi 成熟的团队管理扁平化项目权限配置满足各类企业的需求

可视化接口管理

基于 websocket 的多人协作接口编辑功能和类 postman 测试工具,让多人协作成倍提升开发效率

Mock Server

易用的 Mock Server,再也不用担心 mock 数据的生成了

自动化测试

完善的接口自动化测试,保证数据的正确性

数据导入

支持导入 swagger, postman, har 数据格式,方便迁移旧项目

插件机制

强大的插件机制,满足各类业务需求

diff --git a/static/doc/search_json.js b/static/doc/search_json.js index 03299798..076f806e 100644 --- a/static/doc/search_json.js +++ b/static/doc/search_json.js @@ -646,7 +646,7 @@ window.ydoc_plugin_search_json = { { "title": "1.assert", "url": "/documents/case.html#断言脚本公共变量-1.assert", - "content": "1.assert断言函数,详细 api 可查看 document常用 api\nassert(value)\n判断 value 是否为 truth, 例如 assert(1) 通过, assert(0) 不通过,只要 value 不是 null, 0, false 等值验证通过\n\n\nassert.equal(actual, expected)\n判断 actual 是否等于 expected,例如 assert(1, 1)通过\n\n\nassert.notEqual(actual, expected)\n判断 actual 是否不等于 expected\n\n\nassert.deepEqual(actual, expected)\n假设: actual = {a:1} 是一个对象,即便 expected = {a:1},如果使用 assert.equal 可能也是不相等的,因为在 js 引用的只是对象的一个指针,需要使用 assert.deepEqual 比较两个对象是否相等\n\n\nassert.notDeepEaual(actual, expected)\n深度比较两个对象是否不相等\n\n2.statushttp 状态码3.paramshttp request params, 合并了 query 和 body4.body返回 response body5.header返回 response header6.records记录的 http 请求信息,假设需要获取 key 为 555 的接口参数或者响应数据,可通过 records[555].params 或 records[555].body 获取7.loglog(message) 函数,调试时使用,log 信息仅仅在断言失败后打印,失败断言前的信息" + "content": "1.assert断言函数,详细 api 可查看 document常用 api\nassert(value)\n判断 value 是否为 truth, 例如 assert(1) 通过, assert(0) 不通过,只要 value 不是 null, 0, false 等值验证通过\n\n\nassert.equal(actual, expected)\n判断 actual 是否等于 expected,例如 assert(1, 1)通过\n\n\nassert.notEqual(actual, expected)\n判断 actual 是否不等于 expected\n\n\nassert.deepEqual(actual, expected)\n假设: actual = {a:1} 是一个对象,即便 expected = {a:1},如果使用 assert.equal 可能也是不相等的,因为在 js 引用的只是对象的一个指针,需要使用 assert.deepEqual 比较两个对象是否相等\n\n\nassert.notDeepEaual(actual, expected)\n深度比较两个对象是否不相等\n\n2.statushttp 状态码3.paramshttp request params, 合并了 query 和 body4.body返回 response body5.header返回 response header6.records记录的 http 请求信息,假设需要获取 key 为 555 的接口参数或者响应数据,可通过 records[555].params 或 records[555].body 获取7.loglog(message) 函数,调试时使用,log 信息仅仅在断言失败后打印,失败断言前的信息log(234) assert.equal(status, 400)\nlog(123)\n输出结果:log: 234\nAssertionError: 200 == 400" }, { "title": "示例", @@ -703,7 +703,7 @@ window.ydoc_plugin_search_json = { { "title": "1.assert", "url": "/documents/case.html#断言脚本公共变量-1.assert", - "content": "1.assert断言函数,详细 api 可查看 document常用 api\nassert(value)\n判断 value 是否为 truth, 例如 assert(1) 通过, assert(0) 不通过,只要 value 不是 null, 0, false 等值验证通过\n\n\nassert.equal(actual, expected)\n判断 actual 是否等于 expected,例如 assert(1, 1)通过\n\n\nassert.notEqual(actual, expected)\n判断 actual 是否不等于 expected\n\n\nassert.deepEqual(actual, expected)\n假设: actual = {a:1} 是一个对象,即便 expected = {a:1},如果使用 assert.equal 可能也是不相等的,因为在 js 引用的只是对象的一个指针,需要使用 assert.deepEqual 比较两个对象是否相等\n\n\nassert.notDeepEaual(actual, expected)\n深度比较两个对象是否不相等\n\n2.statushttp 状态码3.paramshttp request params, 合并了 query 和 body4.body返回 response body5.header返回 response header6.records记录的 http 请求信息,假设需要获取 key 为 555 的接口参数或者响应数据,可通过 records[555].params 或 records[555].body 获取7.loglog(message) 函数,调试时使用,log 信息仅仅在断言失败后打印,失败断言前的信息" + "content": "1.assert断言函数,详细 api 可查看 document常用 api\nassert(value)\n判断 value 是否为 truth, 例如 assert(1) 通过, assert(0) 不通过,只要 value 不是 null, 0, false 等值验证通过\n\n\nassert.equal(actual, expected)\n判断 actual 是否等于 expected,例如 assert(1, 1)通过\n\n\nassert.notEqual(actual, expected)\n判断 actual 是否不等于 expected\n\n\nassert.deepEqual(actual, expected)\n假设: actual = {a:1} 是一个对象,即便 expected = {a:1},如果使用 assert.equal 可能也是不相等的,因为在 js 引用的只是对象的一个指针,需要使用 assert.deepEqual 比较两个对象是否相等\n\n\nassert.notDeepEaual(actual, expected)\n深度比较两个对象是否不相等\n\n2.statushttp 状态码3.paramshttp request params, 合并了 query 和 body4.body返回 response body5.header返回 response header6.records记录的 http 请求信息,假设需要获取 key 为 555 的接口参数或者响应数据,可通过 records[555].params 或 records[555].body 获取7.loglog(message) 函数,调试时使用,log 信息仅仅在断言失败后打印,失败断言前的信息log(234) assert.equal(status, 400)\nlog(123)\n输出结果:log: 234\nAssertionError: 200 == 400" }, { "title": "示例", @@ -1169,10 +1169,15 @@ window.ydoc_plugin_search_json = { "content": "", "url": "/documents/CHANGELOG.html", "children": [ + { + "title": "v1.3.22", + "url": "/documents/CHANGELOG.html#v1.3.22", + "content": "v1.3.22json schema number和integer支持枚举\n服务端测试增加下载功能\n" + }, { "title": "v1.3.21", "url": "/documents/CHANGELOG.html#v1.3.21", - "content": "v1.3.21请求配置增加 context.utils.CryptoJS\n环境变量支持自定义全局变量\n增加wiki数据导出功能\n用户管理处增加搜索功能\n增加项目全局 mock 脚本功能\nBug Fixed优化ldap登陆\n" + "content": "v1.3.21请求配置增加 context.utils.CryptoJS\n环境变量支持自定义全局变量\n增加wiki数据导出功能\n用户管理处增加搜索功能\n增加项目全局 mock 脚本功能\n高级 mock 期望 支持关闭开启功能\nBug Fixed优化ldap登陆\nswagger 导入公共params\n接口编辑 mockEditor 修改为 AceEditor\n" }, { "title": "v1.3.20", @@ -1341,10 +1346,15 @@ window.ydoc_plugin_search_json = { "content": "", "url": "/documents/CHANGELOG.html", "children": [ + { + "title": "v1.3.22", + "url": "/documents/CHANGELOG.html#v1.3.22", + "content": "v1.3.22json schema number和integer支持枚举\n服务端测试增加下载功能\n" + }, { "title": "v1.3.21", "url": "/documents/CHANGELOG.html#v1.3.21", - "content": "v1.3.21请求配置增加 context.utils.CryptoJS\n环境变量支持自定义全局变量\n增加wiki数据导出功能\n用户管理处增加搜索功能\n增加项目全局 mock 脚本功能\nBug Fixed优化ldap登陆\n" + "content": "v1.3.21请求配置增加 context.utils.CryptoJS\n环境变量支持自定义全局变量\n增加wiki数据导出功能\n用户管理处增加搜索功能\n增加项目全局 mock 脚本功能\n高级 mock 期望 支持关闭开启功能\nBug Fixed优化ldap登陆\nswagger 导入公共params\n接口编辑 mockEditor 修改为 AceEditor\n" }, { "title": "v1.3.20",