mirror of
https://gitee.com/fit2cloud-feizhiyun/MeterSphere.git
synced 2024-12-02 20:19:16 +08:00
feat(接口自动化): 共享cookie
This commit is contained in:
parent
d0552b63e4
commit
e2f6403409
@ -1,6 +1,6 @@
|
||||
<template>
|
||||
<el-card class="card-content">
|
||||
<div class="ms-main-div">
|
||||
<div class="ms-main-div" @click="showAll">
|
||||
<el-row>
|
||||
<el-col>
|
||||
<!--操作按钮-->
|
||||
@ -127,12 +127,11 @@
|
||||
{{$t('api_test.automation.step_total')}}:{{scenarioDefinition.length}}
|
||||
</el-col>
|
||||
<el-col :span="3" class="ms-col-one">
|
||||
<el-link class="head" @click="showScenarioParameters">{{$t('api_test.automation.scenario_total')}}:
|
||||
{{this.currentScenario.variables!=undefined?this.currentScenario.variables.length-1: 0}}
|
||||
</el-link>
|
||||
<el-link class="head" @click="showScenarioParameters">{{$t('api_test.automation.scenario_total')}}</el-link>
|
||||
:{{this.currentScenario.variables!=undefined?this.currentScenario.variables.length-1: 0}}
|
||||
</el-col>
|
||||
<el-col :span="3">
|
||||
<el-checkbox v-model="currentScenario.enableCookieShare" style="margin-top: 5px">{{ '共享cookie' }}</el-checkbox>
|
||||
<el-checkbox v-model="enableCookieShare" style="margin-top: 5px">{{ '共享cookie' }}</el-checkbox>
|
||||
</el-col>
|
||||
<el-col :span="7">
|
||||
{{$t('api_test.definition.request.run_env')}}:
|
||||
@ -239,7 +238,7 @@
|
||||
</div>
|
||||
|
||||
<!--接口列表-->
|
||||
<el-drawer :visible.sync="apiListVisible" :destroy-on-close="true" direction="ltr" :withHeader="false" :title="$t('api_test.automation.api_list_import')" :modal="false" size="90%">
|
||||
<el-drawer :visible.sync="apiListVisible" :destroy-on-close="true" direction="ltr" :withHeader="true" :modal="false" size="90%">
|
||||
<ms-api-definition :visible="visibleRef" :currentRow="currentRow"/>
|
||||
<el-button style="float: right;margin: 0px 20px 0px" type="primary" @click="pushApiOrCase('REF')">{{$t('api_test.scenario.reference')}}</el-button>
|
||||
<el-button style="float: right;" type="primary" @click="pushApiOrCase('Copy')">{{ $t('commons.copy') }}</el-button>
|
||||
@ -362,6 +361,7 @@
|
||||
reportId: "",
|
||||
projectId: "",
|
||||
visibleRef: "",
|
||||
enableCookieShare: false,
|
||||
}
|
||||
},
|
||||
created() {
|
||||
@ -375,11 +375,6 @@
|
||||
this.getApiScenario();
|
||||
this.getEnvironments();
|
||||
},
|
||||
mounted() {
|
||||
document.addEventListener('click', e => {
|
||||
this.showAll();
|
||||
})
|
||||
},
|
||||
watch: {},
|
||||
methods: {
|
||||
addComponent(type) {
|
||||
@ -591,7 +586,7 @@
|
||||
}
|
||||
this.debugData = {
|
||||
id: this.currentScenario.id, name: this.currentScenario.name, type: "scenario",
|
||||
variables: this.currentScenario.variables, referenced: 'Created', enableCookieShare: this.currentScenario.enableCookieShare,
|
||||
variables: this.currentScenario.variables, referenced: 'Created', enableCookieShare: this.enableCookieShare,
|
||||
environmentId: this.currentEnvironmentId, hashTree: this.scenarioDefinition
|
||||
};
|
||||
this.reportId = getUUID().substring(0, 8);
|
||||
@ -735,7 +730,7 @@
|
||||
if (obj) {
|
||||
this.currentEnvironmentId = obj.environmentId;
|
||||
this.currentScenario.variables = obj.variables;
|
||||
this.currentScenario.enableCookieShare = obj.enableCookieShare;
|
||||
this.enableCookieShare = obj.enableCookieShare;
|
||||
this.scenarioDefinition = obj.hashTree;
|
||||
}
|
||||
}
|
||||
@ -752,7 +747,7 @@
|
||||
this.currentScenario.modulePath = this.getPath(this.currentScenario.apiScenarioModuleId);
|
||||
// 构建一个场景对象 方便引用处理
|
||||
let scenario = {
|
||||
id: this.currentScenario.id, enableCookieShare: this.currentScenario.enableCookieShare, name: this.currentScenario.name, variables: this.currentScenario.variables,
|
||||
id: this.currentScenario.id, enableCookieShare: this.enableCookieShare, name: this.currentScenario.name, variables: this.currentScenario.variables,
|
||||
type: "scenario", referenced: 'Created', environmentId: this.currentEnvironmentId, hashTree: this.scenarioDefinition
|
||||
};
|
||||
this.currentScenario.scenarioDefinition = scenario;
|
||||
@ -915,7 +910,7 @@
|
||||
}
|
||||
|
||||
.head {
|
||||
border-bottom: 1px solid #dedede;
|
||||
border-bottom: 1px solid #474849;
|
||||
font-size: 13px;
|
||||
}
|
||||
</style>
|
||||
|
@ -8,9 +8,9 @@
|
||||
<div class="variable-combine"> {{api.name}}</div>
|
||||
</el-col>
|
||||
<el-col :span="api.protocol==='HTTP'? 1:3">
|
||||
<ms-tag v-if="api.status == 'Prepare'" type="info" effect="plain" :content="$t('test_track.plan.plan_status_prepare')"/>
|
||||
<ms-tag v-if="api.status == 'Underway'" type="warning" effect="plain" :content="$t('test_track.plan.plan_status_running')"/>
|
||||
<ms-tag v-if="api.status == 'Completed'" type="success" effect="plain" :content="$t('test_track.plan.plan_status_completed')"/>
|
||||
<el-tag size="mini" :style="{'background-color': getColor(true, api.method), border: getColor(true, api.method)}" class="api-el-tag">
|
||||
{{ api.method}}
|
||||
</el-tag>
|
||||
</el-col>
|
||||
<el-col :span="api.protocol==='HTTP'? 4:0">
|
||||
<div class="variable-combine" style="margin-left: 10px">{{api.path ===null ? " " : api.path}}</div>
|
||||
@ -151,6 +151,7 @@
|
||||
import MsTcpBasisParameters from "../../../definition/components/request/tcp/BasisParameters";
|
||||
import MsDubboBasisParameters from "../../../definition/components/request/dubbo/BasisParameters";
|
||||
import MsApiExtendBtns from "../../../definition/components/reference/ApiExtendBtns";
|
||||
import {API_METHOD_COLOUR} from "../../../definition/model/JsonData";
|
||||
|
||||
export default {
|
||||
name: 'ApiCaseList',
|
||||
@ -192,7 +193,7 @@
|
||||
reportId: "",
|
||||
projectId: "",
|
||||
checkedCases: new Set(),
|
||||
|
||||
methodColorMap: new Map(API_METHOD_COLOUR),
|
||||
}
|
||||
},
|
||||
watch: {
|
||||
@ -403,6 +404,11 @@
|
||||
environmentConfigClose() {
|
||||
this.getEnvironments();
|
||||
},
|
||||
getColor(enable, method) {
|
||||
if (enable) {
|
||||
return this.methodColorMap.get(method);
|
||||
}
|
||||
},
|
||||
caseChecked(row) {
|
||||
row.protocol = this.api.protocol;
|
||||
row.hashTree = [];
|
||||
@ -477,6 +483,9 @@
|
||||
padding: 7px;
|
||||
}
|
||||
|
||||
.api-el-tag {
|
||||
color: white;
|
||||
}
|
||||
.is-selected {
|
||||
background: #EFF7FF;
|
||||
}
|
||||
|
@ -6,9 +6,9 @@
|
||||
<div class="variable-combine"> {{api.name}}</div>
|
||||
</el-col>
|
||||
<el-col :span="api.protocol==='HTTP'? 1:3">
|
||||
<ms-tag v-if="api.status == 'Prepare'" type="info" effect="plain" :content="$t('test_track.plan.plan_status_prepare')"/>
|
||||
<ms-tag v-if="api.status == 'Underway'" type="warning" effect="plain" :content="$t('test_track.plan.plan_status_running')"/>
|
||||
<ms-tag v-if="api.status == 'Completed'" type="success" effect="plain" :content="$t('test_track.plan.plan_status_completed')"/>
|
||||
<el-tag size="mini" :style="{'background-color': getColor(true, api.method), border: getColor(true, api.method)}" class="api-el-tag">
|
||||
{{ api.method}}
|
||||
</el-tag>
|
||||
</el-col>
|
||||
<el-col :span="api.protocol==='HTTP'? 4:0">
|
||||
<div class="variable-combine" style="margin-left: 10px">{{api.path ===null ? " " : api.path}}</div>
|
||||
@ -72,85 +72,93 @@
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import ApiEnvironmentConfig from "../../../test/components/ApiEnvironmentConfig";
|
||||
import {parseEnvironment} from "../../../test/model/EnvironmentModel";
|
||||
import MsTag from "../../../../common/components/MsTag";
|
||||
export default {
|
||||
name: "ApiCaseHeader",
|
||||
components: {MsTag, ApiEnvironmentConfig},
|
||||
data() {
|
||||
return {
|
||||
environments: [],
|
||||
environment: {},
|
||||
import ApiEnvironmentConfig from "../../../test/components/ApiEnvironmentConfig";
|
||||
import {parseEnvironment} from "../../../test/model/EnvironmentModel";
|
||||
import MsTag from "../../../../common/components/MsTag";
|
||||
import {API_METHOD_COLOUR} from "../../model/JsonData";
|
||||
|
||||
export default {
|
||||
name: "ApiCaseHeader",
|
||||
components: {MsTag, ApiEnvironmentConfig},
|
||||
data() {
|
||||
return {
|
||||
environments: [],
|
||||
environment: {},
|
||||
methodColorMap: new Map(API_METHOD_COLOUR),
|
||||
}
|
||||
},
|
||||
props: {
|
||||
api: Object,
|
||||
projectId: String,
|
||||
priorities: Array,
|
||||
apiCaseList: Array,
|
||||
isReadOnly: Boolean,
|
||||
isCaseEdit: Boolean,
|
||||
condition: {
|
||||
type: Object,
|
||||
default() {
|
||||
return {}
|
||||
}
|
||||
}
|
||||
},
|
||||
created() {
|
||||
this.environment = undefined;
|
||||
this.getEnvironments();
|
||||
},
|
||||
watch: {
|
||||
environment() {
|
||||
this.$emit('setEnvironment', this.environment);
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
getEnvironments() {
|
||||
if (this.projectId) {
|
||||
this.$get('/api/environment/list/' + this.projectId, response => {
|
||||
this.environments = response.data;
|
||||
this.environments.forEach(environment => {
|
||||
parseEnvironment(environment);
|
||||
});
|
||||
});
|
||||
} else {
|
||||
this.environment = undefined;
|
||||
}
|
||||
},
|
||||
props: {
|
||||
api: Object,
|
||||
projectId: String,
|
||||
priorities: Array,
|
||||
apiCaseList: Array,
|
||||
isReadOnly: Boolean,
|
||||
isCaseEdit: Boolean,
|
||||
condition: {
|
||||
type: Object,
|
||||
default() {
|
||||
return {}
|
||||
openEnvironmentConfig() {
|
||||
if (!this.projectId) {
|
||||
this.$error(this.$t('api_test.select_project'));
|
||||
return;
|
||||
}
|
||||
this.$refs.environmentConfig.open(this.projectId);
|
||||
},
|
||||
environmentChange(value) {
|
||||
for (let i in this.environments) {
|
||||
if (this.environments[i].id === value) {
|
||||
this.environment = this.environments[i];
|
||||
break;
|
||||
}
|
||||
}
|
||||
},
|
||||
created() {
|
||||
this.environment = undefined;
|
||||
environmentConfigClose() {
|
||||
this.getEnvironments();
|
||||
},
|
||||
watch: {
|
||||
environment() {
|
||||
this.$emit('setEnvironment', this.environment);
|
||||
getApiTest() {
|
||||
this.$emit('getApiTest');
|
||||
},
|
||||
addCase() {
|
||||
this.$emit('addCase');
|
||||
},
|
||||
handleCommand(e) {
|
||||
if (e === "run") {
|
||||
this.$emit('batchRun');
|
||||
}
|
||||
},
|
||||
getColor(enable, method) {
|
||||
if (enable) {
|
||||
return this.methodColorMap.get(method);
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
getEnvironments() {
|
||||
if (this.projectId) {
|
||||
this.$get('/api/environment/list/' + this.projectId, response => {
|
||||
this.environments = response.data;
|
||||
this.environments.forEach(environment => {
|
||||
parseEnvironment(environment);
|
||||
});
|
||||
});
|
||||
} else {
|
||||
this.environment = undefined;
|
||||
}
|
||||
},
|
||||
openEnvironmentConfig() {
|
||||
if (!this.projectId) {
|
||||
this.$error(this.$t('api_test.select_project'));
|
||||
return;
|
||||
}
|
||||
this.$refs.environmentConfig.open(this.projectId);
|
||||
},
|
||||
environmentChange(value) {
|
||||
for (let i in this.environments) {
|
||||
if (this.environments[i].id === value) {
|
||||
this.environment = this.environments[i];
|
||||
break;
|
||||
}
|
||||
}
|
||||
},
|
||||
environmentConfigClose() {
|
||||
this.getEnvironments();
|
||||
},
|
||||
getApiTest() {
|
||||
this.$emit('getApiTest');
|
||||
},
|
||||
addCase() {
|
||||
this.$emit('addCase');
|
||||
},
|
||||
handleCommand(e) {
|
||||
if (e === "run") {
|
||||
this.$emit('batchRun');
|
||||
}
|
||||
},
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
@ -190,5 +198,8 @@
|
||||
line-height: 32px;
|
||||
}
|
||||
|
||||
.api-el-tag {
|
||||
color: white;
|
||||
}
|
||||
|
||||
</style>
|
||||
|
Loading…
Reference in New Issue
Block a user