fix(Mock服务): #1007715 #1007716 #1007717 #1007711 Mock服务的地址、匹配、编辑时的相关问题过

--bug=1007715 --user=宋天阳 【接口定义】mock参数多了一个键
https://www.tapd.cn/55049933/s/1064027;--bug=1007716 --user=宋天阳
【接口测试】mock调试报错后,再编辑mock规则,不能自动带出来请求参数下拉框
https://www.tapd.cn/55049933/s/1064025;--bug=1007717 --user=宋天阳
【接口定义】mock规则部分匹配,没有返回mock信息
https://www.tapd.cn/55049933/s/1064023;--bug=1007711 --user=宋天阳
【接口定义】mock服务的URL会自动补一个“/” https://www.tapd.cn/55049933/s/1064026
This commit is contained in:
song-tianyang 2021-11-04 14:06:05 +08:00 committed by song-tianyang
parent f48db748fa
commit 8002dc2c4f
5 changed files with 27 additions and 38 deletions

View File

@ -625,6 +625,7 @@ public class ApiDefinitionService {
batchMapper.insert(apiDefinition);
String requestStr = setImportHashTree(apiDefinition);
reSetImportCasesApiId(cases, originId, apiDefinition.getId());
reSetImportMocksApiId(mocks, originId, apiDefinition.getId(), apiDefinition.getNum());
apiDefinition.setRequest(requestStr);
importApiCase(apiDefinition, apiTestImportRequest);
}

View File

@ -30,7 +30,7 @@ public class JsonStructUtils {
if(matchObj == null){
matchObj = new JSONObject();
}
if (sourceObj .isEmpty() && matchObj.isEmpty()) {
if (matchObj.isEmpty()) {
return true;
} else if (sourceObj != null && matchObj != null) {
boolean lastMatchResultIsTrue = false;

View File

@ -274,10 +274,6 @@
return this.mockBaseUrl;
} else {
let path = this.httpForm.path;
let prefix = "";
if (path.endsWith("/")) {
prefix = "/";
}
let protocol = this.httpForm.method;
if (protocol === 'GET' || protocol === 'DELETE') {
if (this.httpForm.request != null && this.httpForm.request.rest != null) {
@ -303,8 +299,7 @@
}
}
}
return this.mockBaseUrl + path + prefix;
return this.mockBaseUrl + path;
}
}
},

View File

@ -3,16 +3,8 @@
<span class="kv-description" v-if="description">
{{ description }}
</span>
<!-- <el-row>-->
<!-- <el-checkbox v-model="isSelectAll" v-if="parameters.length > 1"/>-->
<!-- </el-row>-->
<div class="item kv-row" v-for="(item, index) in parameters" :key="index">
<el-row type="flex" :gutter="20" justify="space-between" align="middle">
<!-- <el-col class="kv-checkbox" v-if="isShowEnable">-->
<!-- <el-checkbox v-if="!isDisable(index)" v-model="item.enable"-->
<!-- :disabled="isReadOnly"/>-->
<!-- </el-col>-->
<!-- <span style="margin-left: 10px" v-else></span>-->
<span style="margin-left: 10px"></span>
<i class="el-icon-top" style="cursor:pointer" @click="moveTop(index)"/>
<i class="el-icon-bottom" style="cursor:pointer;" @click="moveBottom(index)"/>
@ -31,16 +23,19 @@
</el-input>
<el-autocomplete :disabled="isReadOnly" v-if="suggestions" v-model="item.name" size="small"
:fetch-suggestions="querySearch" @change="change" :placeholder="keyText" show-word-limit/>
:fetch-suggestions="querySearch" @change="change" :placeholder="keyText" show-word-limit>
<template v-slot:prepend>
<el-select v-if="type === 'body'" :disabled="isReadOnly" class="kv-type" v-model="item.type"
@change="typeChange(item)">
<el-option value="text"/>
<el-option value="file"/>
<el-option value="json"/>
</el-select>
</template>
</el-autocomplete>
</el-col>
<!-- <el-col class="item kv-select">-->
<!-- <el-select v-model="item.required" size="small">-->
<!-- <el-option v-for="req in requireds" :key="req.id" :label="req.name" :value="req.id"/>-->
<!-- </el-select>-->
<!-- </el-col>-->
<el-col class="item" v-if="isActive && item.type !== 'file'">
<el-autocomplete
:disabled="isReadOnly"
@ -60,10 +55,6 @@
<el-input v-model="item.description" size="small" maxlength="200"
:placeholder="$t('commons.description')" show-word-limit>
</el-input>
<el-autocomplete :disabled="isReadOnly" v-if="suggestions" v-model="item.name" size="small"
:fetch-suggestions="querySearch" @change="change" :placeholder="keyText" show-word-limit/>
</el-col>
<el-col v-if="isActive && item.type === 'file'" class="item">
@ -76,12 +67,6 @@
</el-input>
</el-col>
<!-- <el-col v-if="withMorSetting" class="item kv-setting">-->
<!-- <el-tooltip effect="dark" :content="$t('schema.adv_setting')" placement="top">-->
<!-- <i class="el-icon-setting" @click="openApiVariableSetting(item)"/>-->
<!-- </el-tooltip>-->
<!-- </el-col>-->
<el-col class="item kv-delete">
<el-button size="mini" class="el-icon-delete-solid" circle @click="remove(index)"
:disabled="isDisable(index) || isReadOnly"/>
@ -102,13 +87,10 @@
</template>
<script>
// import {KeyValue, Scenario} from "../model/ApiTestModel";
import {KeyValue,Scenario} from "@/business/components/api/definition/model/ApiTestModel";
import {JMETER_FUNC, MOCKJS_FUNC} from "@/common/js/constants";
// import MsApiVariableAdvance from "./ApiVariableAdvance";
import MsApiVariableAdvance from "@/business/components/api/definition/components/ApiVariableAdvance";
import MsApiVariableJson from "@/business/components/api/definition/components/ApiVariableJson";
// import MsApiBodyFileUpload from "@/business/components/api/definition/body/ApiBodyFileUpload";
import MsApiBodyFileUpload from "@/business/components/api/definition/components/body/ApiBodyFileUpload";
import Vue from 'vue';
import ApiVariableSetting from "@/business/components/api/definition/components/ApiVariableSetting";

View File

@ -181,7 +181,11 @@ export default {
body: "",
};
}
this.$refs.mockEditDrawer.open(mockExpectConfig);
this.searchApiParams(this.mockConfigData.mockConfig.apiId);
this.$refs.mockEditDrawer.close();
this.$nextTick(() => {
this.$refs.mockEditDrawer.open(mockExpectConfig);
});
});
},
clickRow(row, column, event) {
@ -204,12 +208,19 @@ export default {
body: "",
};
}
this.$refs.mockEditDrawer.open(mockExpectConfig);
this.searchApiParams(this.mockConfigData.mockConfig.apiId);
this.$refs.mockEditDrawer.close();
this.$nextTick(() => {
this.$refs.mockEditDrawer.open(mockExpectConfig);
});
});
},
addApiMock(){
this.searchApiParams(this.mockConfigData.mockConfig.apiId);
this.$refs.mockEditDrawer.open();
this.$refs.mockEditDrawer.close();
this.$nextTick(() => {
this.$refs.mockEditDrawer.open();
});
},
removeExpect(row) {
this.$confirm(this.$t('api_test.mock.delete_mock_expect'), this.$t('commons.prompt'), {