fix(接口测试): 不同协议跳转

--user=郭雨琦
--bug=1014073
【接口测试】首页-过去7天测试计划失败用例TOP10,非HTTP的接口也会跳到HTTP页面
https://www.tapd.cn/55049933/bugtrace/bugs/view/1155049933001014073
This commit is contained in:
guoyuqi 2022-06-15 16:14:22 +08:00 committed by fit2-zhao
parent f6d773aa1c
commit 7268405dab
1 changed files with 49 additions and 19 deletions

View File

@ -1,12 +1,14 @@
<template>
<div class="table-card" v-loading="result.loading" body-style="padding:10px;">
<el-table border :data="tableData" class="adjust-table table-content" height="300px">
<el-table-column prop="sortIndex" :label="$t('api_test.home_page.failed_case_list.table_coloum.index')" width="100" show-overflow-tooltip/>
<el-table-column prop="caseName" :label="$t('api_test.home_page.failed_case_list.table_coloum.case_name')" width="150">
<el-table-column prop="sortIndex" :label="$t('api_test.home_page.failed_case_list.table_coloum.index')"
width="100" show-overflow-tooltip/>
<el-table-column prop="caseName" :label="$t('api_test.home_page.failed_case_list.table_coloum.case_name')"
width="150">
<template v-slot:default="{row}">
<el-link type="info" @click="redirect(row.caseType,row.id)">
{{ row.caseName }}
</el-link>
<el-link type="info" @click="redirect(row.caseType,row)">
{{ row.caseName }}
</el-link>
</template>
</el-table-column>
<el-table-column
@ -16,28 +18,33 @@
width="150"
show-overflow-tooltip>
<template v-slot:default="scope">
<ms-tag v-if="scope.row.caseType === 'apiCase'" type="success" effect="plain" :content="$t('api_test.home_page.failed_case_list.table_value.case_type.api')"/>
<ms-tag v-if="scope.row.caseType === 'scenario'" type="warning" effect="plain" :content="$t('api_test.home_page.failed_case_list.table_value.case_type.scene')"/>
<ms-tag v-if="scope.row.caseType === 'load'" type="danger" effect="plain" :content="$t('api_test.home_page.failed_case_list.table_value.case_type.load')"/>
<ms-tag v-if="scope.row.caseType === 'apiCase'" type="success" effect="plain"
:content="$t('api_test.home_page.failed_case_list.table_value.case_type.api')"/>
<ms-tag v-if="scope.row.caseType === 'scenario'" type="warning" effect="plain"
:content="$t('api_test.home_page.failed_case_list.table_value.case_type.scene')"/>
<ms-tag v-if="scope.row.caseType === 'load'" type="danger" effect="plain"
:content="$t('api_test.home_page.failed_case_list.table_value.case_type.load')"/>
</template>
</el-table-column>
<el-table-column prop="testPlan" :label="$t('api_test.home_page.failed_case_list.table_coloum.test_plan')">
<el-table-column prop="testPlan" :label="$t('api_test.home_page.failed_case_list.table_coloum.test_plan')">
<template v-slot:default="{row}">
<div v-for="(testPlan, index) in row.testPlanDTOList" :key="index">
<el-link type="info" @click="redirect('testPlanEdit',testPlan.id)" v-if="testPlan.name === row.testPlan || row.caseType !== 'apiCase'">
<el-link type="info" @click="redirect('testPlanEdit',testPlan.id)"
v-if="testPlan.name === row.testPlan || row.caseType !== 'apiCase'">
{{ testPlan.name }};
</el-link>
</div>
</template>
</el-table-column>
<el-table-column prop="failureTimes" :label="$t('api_test.home_page.failed_case_list.table_coloum.failure_times')" width="100" show-overflow-tooltip/>
<el-table-column prop="failureTimes" :label="$t('api_test.home_page.failed_case_list.table_coloum.failure_times')"
width="100" show-overflow-tooltip/>
</el-table>
</div>
</template>
<script>
import MsTag from "@/business/components/common/components/MsTag";
import {getCurrentProjectID} from "@/common/js/utils";
import {getCurrentProjectID, getCurrentWorkspaceId, getUUID} from "@/common/js/utils";
export default {
name: "MsApiFailureTestCaseList",
@ -61,21 +68,43 @@ export default {
methods: {
search() {
if (this.projectId) {
this.result = this.$get("/api/faliureCaseAboutTestPlan/"+ this.projectId +"/10", response => {
this.result = this.$get("/api/faliureCaseAboutTestPlan/" + this.projectId + "/10", response => {
this.tableData = response.data;
});
}
},
redirect(pageType,param){
switch (pageType){
redirect(pageType, param) {
let definitionData;
switch (pageType) {
case "testPlanEdit":
this.$emit('redirectPage','testPlanEdit',null, param);
this.$emit('redirectPage', 'testPlanEdit', null, param);
break;
case "apiCase":
this.$emit('redirectPage','api','apiTestCase', 'single:'+param);
this.$get('/api/definition/get/' + param.id, (response) => {
let api = response.data;
if (!api) {
this.$message.error(this.$t('commons.api_case') + this.$t('commons.not_exist'))
} else {
if (param.protocol === 'dubbo://') {
param.protocol = 'DUBBO'
}
definitionData = this.$router.resolve({
name: 'ApiDefinition',
params: {
redirectID: getUUID(),
dataType: "api",
dataSelectRange: 'edit:' + param.id,
projectId: getCurrentProjectID(),
type: api.protocol,
workspaceId: getCurrentWorkspaceId(),
}
});
window.open(definitionData.href, '_blank');
}
});
break;
case "scenario":
this.$emit('redirectPage','scenario','scenario', 'edit:'+param);
this.$emit('redirectPage', 'scenario', 'scenario', 'edit:' + param.id);
break;
}
}
@ -94,8 +123,9 @@ export default {
<style scoped>
.el-table {
cursor:pointer;
cursor: pointer;
}
.el-card /deep/ .el-card__header {
border-bottom: 0px solid #EBEEF5;
}