fix(接口测试): 修复mock响应跟随API定义后再切换raw格式,无法编辑响应体的问题

--bug=1010364 --user=宋天阳 【接口测试】mock响应跟随API定义后再切换raw格式,无法编辑响应体
https://www.tapd.cn/55049933/s/1106633
This commit is contained in:
song-tianyang 2022-02-21 15:19:09 +08:00 committed by CountryBuilder
parent 587ceb7329
commit 72abd2100b
6 changed files with 9 additions and 5 deletions

View File

@ -81,7 +81,7 @@
</div>
<div v-if="showMock && (currentProtocol === 'HTTP' || currentProtocol === 'TCP')">
<mock-tab :base-mock-config-data="baseMockConfigData" @redirectToTest="redirectToTest"
<mock-tab :base-mock-config-data="baseMockConfigData" @redirectToTest="redirectToTest" :version-name="currentApi.versionName"
:is-tcp="currentProtocol === 'TCP'"/>
</div>
<div v-if="showTestCaseList">

View File

@ -61,6 +61,7 @@
:read-only="isReadOnly"
:data.sync="body.raw"
:modes="modes"
v-if="loadIsOver"
height="90%"
ref="codeEdit"/>
</div>
@ -257,7 +258,7 @@ export default {
let selectUrl = "/mockConfig/getApiResponse/" + this.apiId;
this.$get(selectUrl, response => {
let apiResponse = response.data;
if (apiResponse && apiResponse.returnMsg) {
if (apiResponse && apiResponse.returnData) {
this.body.apiRspRaw = apiResponse.returnData;
}
this.refreshMsCodeEdit();

View File

@ -179,7 +179,7 @@ export default {
if (laguanges === "python") {
returnScript = 'param=vars["body.${param}"]';
} else {
returnScript = 'var param=vars.get(body.${param}")\n' +
returnScript = 'var param=vars.get(body.${param}");\n' +
'//如果对象是多层JSON需要引入fastjson协助解析:\n' +
'// 以"{\"name\":\"user\",\"rows\":[{\"type\":1}]}" 为demo,取rows第1个的type数据:\n' +
'import com.alibaba.fastjson.JSON;\n' +

View File

@ -36,7 +36,7 @@
</el-collapse-transition>
</el-form>
</div>
<div v-if="response.usePostScript">
<div v-show="response.usePostScript">
<el-row style="margin-top: 10px;">
<el-col :span="12">
<p class="tip">{{ $t('api_test.definition.request.post_script') }}</p>

View File

@ -2,7 +2,7 @@
<div>
<div>
<div class="ms-opt-btn" v-if="versionEnable">
{{ $t('project.version.name') }}: {{ mockConfigData.versionName }}
{{ $t('project.version.name') }}: {{ versionName }}
</div>
<el-input :placeholder="$t('commons.search_by_name')" class="search-input" size="small"
:clearable="true"
@ -95,6 +95,7 @@ export default {
},
props: {
baseMockConfigData: {},
versionName:String,
isTcp: {
type: Boolean,
default: false,

View File

@ -65,6 +65,8 @@
},
mode() {
this.format();
},
readOnly(){
}
},
methods: {