refactor(接口测试): 去掉mock的小铅笔

--bug=1017964 --user=王孝刚 【接口测试】mock期望 - 响应体中的mock和jmeter函数不生效
https://www.tapd.cn/55049933/s/1288723
This commit is contained in:
wxg0103 2022-11-04 11:46:37 +08:00 committed by wxg0103
parent 05b762e430
commit e0360ffb8d
7 changed files with 38 additions and 6 deletions

View File

@ -13,6 +13,7 @@
:show-mock-vars="showMockVars" :show-mock-vars="showMockVars"
:scenario-definition="scenarioDefinition" :scenario-definition="scenarioDefinition"
@editScenarioAdvance="editScenarioAdvance" @editScenarioAdvance="editScenarioAdvance"
:need-mock="needMock"
lang="zh_CN" custom/> lang="zh_CN" custom/>
</div> </div>
</el-tab-pane> </el-tab-pane>
@ -54,6 +55,12 @@ export default {
} }
}, },
scenarioDefinition: Array, scenarioDefinition: Array,
needMock: {
type: Boolean,
default() {
return true;
}
}
}, },
created() { created() {
if (!this.body.jsonSchema && this.body.raw && this.checkIsJson(this.body.raw)) { if (!this.body.jsonSchema && this.body.raw && this.checkIsJson(this.body.raw)) {

View File

@ -30,6 +30,7 @@
:schema="pickValue" :schema="pickValue"
:scenario-definition="scenarioDefinition" :scenario-definition="scenarioDefinition"
:show-mock-vars="showMockVars" :show-mock-vars="showMockVars"
:need-mock="needMock"
@editScenarioAdvance="editScenarioAdvance"/> @editScenarioAdvance="editScenarioAdvance"/>
</el-col> </el-col>
<el-col :span="4"> <el-col :span="4">
@ -57,6 +58,7 @@
:disabled="disabled" :disabled="disabled"
@editScenarioAdvance="editScenarioAdvance" @editScenarioAdvance="editScenarioAdvance"
:lang="lang" :custom="custom" @changeAllItemsType="changeAllItemsType" :lang="lang" :custom="custom" @changeAllItemsType="changeAllItemsType"
:need-mock="needMock"
@reloadItems="reloadItems"/> @reloadItems="reloadItems"/>
</template> </template>
<template v-if="!hidden && isArray(pickValue) && reloadItemOver"> <template v-if="!hidden && isArray(pickValue) && reloadItemOver">
@ -66,6 +68,7 @@
:scenario-definition="scenarioDefinition" :scenario-definition="scenarioDefinition"
:show-mock-vars="showMockVars" :show-mock-vars="showMockVars"
:disabled="disabled" :disabled="disabled"
:need-mock="needMock"
@editScenarioAdvance="editScenarioAdvance" @editScenarioAdvance="editScenarioAdvance"
:lang="lang" :custom="custom" @changeAllItemsType="changeAllItemsType"/> :lang="lang" :custom="custom" @changeAllItemsType="changeAllItemsType"/>
</template> </template>
@ -165,6 +168,10 @@ export default {
default: 'zh_CN' default: 'zh_CN'
}, },
scenarioDefinition: Array, scenarioDefinition: Array,
needMock: {
type: Boolean,
default: true
},
}, },
computed: { computed: {
pickValue() { pickValue() {

View File

@ -10,7 +10,8 @@
value-key="name" value-key="name"
highlight-first-item highlight-first-item
@select="change"> @select="change">
<i slot="suffix" v-if="!disabled" class="el-input__icon el-icon-edit pointer" @click="advanced(mock)"></i> <i slot="suffix" v-if="!disabled && needMock" class="el-input__icon el-icon-edit pointer"
@click="advanced(mock)"></i>
</el-autocomplete> </el-autocomplete>
<ms-api-variable-advance :show-mock-vars="showMockVars" :scenario-definition="scenarioDefinition" <ms-api-variable-advance :show-mock-vars="showMockVars" :scenario-definition="scenarioDefinition"
:current-item="mock" ref="variableAdvance"/> :current-item="mock" ref="variableAdvance"/>
@ -39,6 +40,12 @@ export default {
return false; return false;
} }
}, },
needMock: {
type: Boolean,
default() {
return true;
}
}
}, },
data() { data() {
return { return {

View File

@ -39,6 +39,7 @@
<ms-json-code-edit <ms-json-code-edit
v-if="body.format==='JSON-SCHEMA'" v-if="body.format==='JSON-SCHEMA'"
:body="body" :body="body"
:need-mock="needMock"
ref="jsonCodeEdit"/> ref="jsonCodeEdit"/>
<ms-code-edit <ms-code-edit
v-else-if="codeEditActive" v-else-if="codeEditActive"
@ -103,6 +104,10 @@ export default {
isShowEnable: { isShowEnable: {
type: Boolean, type: Boolean,
default: true default: true
},
needMock: {
type: Boolean,
default: true
} }
}, },
data() { data() {

View File

@ -22,6 +22,7 @@
v-if="body.format==='JSON-SCHEMA'" v-if="body.format==='JSON-SCHEMA'"
:body="body" :body="body"
:show-mock-vars="true" :show-mock-vars="true"
:need-mock="needMock"
ref="jsonCodeEdit"/> ref="jsonCodeEdit"/>
<ms-code-edit <ms-code-edit
v-else-if="codeEditActive && loadIsOver" v-else-if="codeEditActive && loadIsOver"
@ -109,6 +110,10 @@ export default {
type: Boolean, type: Boolean,
default: false default: false
}, },
needMock: {
type: Boolean,
default: true
},
}, },
data() { data() {
return { return {

View File

@ -73,6 +73,7 @@
:suggestions="apiParams.form" :suggestions="apiParams.form"
:is-read-only="isReadOnly" :is-read-only="isReadOnly"
:isShowEnable="isShowEnable" :isShowEnable="isShowEnable"
:need-mock="false"
:headers="request.headers" :body="request.body"/> :headers="request.headers" :body="request.body"/>
</el-tab-pane> </el-tab-pane>
<el-tab-pane name="create" <el-tab-pane name="create"

View File

@ -12,7 +12,8 @@
</el-tab-pane> </el-tab-pane>
<el-tab-pane :label="$t('api_test.definition.request.response_body')" name="body" class="pane"> <el-tab-pane :label="$t('api_test.definition.request.response_body')" name="body" class="pane">
<mock-api-response-body :isReadOnly="false" :isShowEnable="false" :api-id="apiId" :body="response.body" <mock-api-response-body :isReadOnly="false" :isShowEnable="false" :api-id="apiId" :body="response.body"
:headers="response.headers" :use-post-script="response.usePostScript"/> :headers="response.headers" :use-post-script="response.usePostScript"
:need-mock="false"/>
</el-tab-pane> </el-tab-pane>
<el-tab-pane v-if="!isTcp" :label="$t('api_test.definition.request.status_code')" name="status_code" <el-tab-pane v-if="!isTcp" :label="$t('api_test.definition.request.status_code')" name="status_code"
@ -66,8 +67,7 @@ import BatchAddParameter from "@/business/definition/components/basis/BatchAddPa
import MsApiAdvancedConfig from "@/business/definition/components/request/http/ApiAdvancedConfig"; import MsApiAdvancedConfig from "@/business/definition/components/request/http/ApiAdvancedConfig";
import MsJsr233Processor from "@/business/automation/scenario/component/Jsr233Processor"; import MsJsr233Processor from "@/business/automation/scenario/component/Jsr233Processor";
import MockApiScriptEditor from "@/business/definition/components/mock/Components/MockApiScriptEditor"; import MockApiScriptEditor from "@/business/definition/components/mock/Components/MockApiScriptEditor";
import ApiDefinitionStepButton import ApiDefinitionStepButton from "@/business/definition/components/request/components/ApiDefinitionStepButton";
from "@/business/definition/components/request/components/ApiDefinitionStepButton";
import {Body, BODY_FORMAT} from "@/business/definition/model/ApiTestModel"; import {Body, BODY_FORMAT} from "@/business/definition/model/ApiTestModel";
import {REQUEST_HEADERS} from "metersphere-frontend/src/utils/constants"; import {REQUEST_HEADERS} from "metersphere-frontend/src/utils/constants";