Merge remote-tracking branch 'origin/v1.3' into v1.3
This commit is contained in:
commit
45779f5480
|
@ -12,6 +12,7 @@ public class KeyValue {
|
|||
private String type;
|
||||
private List<BodyFile> files;
|
||||
private String description;
|
||||
private String contentType;
|
||||
private boolean enable;
|
||||
|
||||
public KeyValue() {
|
||||
|
|
|
@ -3,11 +3,11 @@ package io.metersphere.api.jmeter;
|
|||
import io.metersphere.api.service.APIReportService;
|
||||
import io.metersphere.api.service.APITestService;
|
||||
import io.metersphere.base.domain.ApiTestReport;
|
||||
import io.metersphere.base.domain.NoticeDetail;
|
||||
import io.metersphere.commons.constants.APITestStatus;
|
||||
import io.metersphere.commons.constants.ApiRunMode;
|
||||
import io.metersphere.commons.utils.CommonBeanFactory;
|
||||
import io.metersphere.commons.utils.LogUtil;
|
||||
import io.metersphere.notice.domain.NoticeDetail;
|
||||
import io.metersphere.notice.service.MailService;
|
||||
import io.metersphere.notice.service.NoticeService;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
@ -141,6 +141,7 @@ public class APIBackendListenerClient extends AbstractBackendListenerClient impl
|
|||
requestResult.setBody(result.getSamplerData());
|
||||
requestResult.setHeaders(result.getRequestHeaders());
|
||||
requestResult.setRequestSize(result.getSentBytes());
|
||||
requestResult.setStartTime(result.getStartTime());
|
||||
requestResult.setTotalAssertions(result.getAssertionResults().length);
|
||||
requestResult.setSuccess(result.isSuccessful());
|
||||
requestResult.setError(result.getErrorCount());
|
||||
|
|
|
@ -16,6 +16,8 @@ public class RequestResult {
|
|||
|
||||
private long requestSize;
|
||||
|
||||
private long startTime;
|
||||
|
||||
private int error;
|
||||
|
||||
private boolean success;
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
package io.metersphere.controller;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import io.metersphere.base.domain.User;
|
||||
import io.metersphere.commons.utils.SessionUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
@ -15,7 +16,8 @@ public class TestController {
|
|||
|
||||
|
||||
@PostMapping(value = "/upload", consumes = {"multipart/form-data"})
|
||||
public Object testUpload(@RequestPart(value = "id") String id, @RequestPart(value = "file") MultipartFile file, @RequestPart(value = "files") List<MultipartFile> bodyFiles) {
|
||||
public Object testUpload(@RequestPart(value = "id") String id, @RequestPart(value = "file") MultipartFile file, @RequestPart(value = "files") List<MultipartFile> bodyFiles
|
||||
, @RequestPart(value = "user") User user, @RequestParam(value = "name") String name) {
|
||||
JSONObject jsonObject = new JSONObject();
|
||||
jsonObject.put("id", id);
|
||||
jsonObject.put("file", file.getOriginalFilename());
|
||||
|
|
|
@ -14,7 +14,6 @@ import org.quartz.TriggerKey;
|
|||
public class ApiTestJob extends MsScheduleJob {
|
||||
|
||||
private APITestService apiTestService;
|
||||
private MailService mailService;
|
||||
public ApiTestJob() {
|
||||
apiTestService = (APITestService) CommonBeanFactory.getBean(APITestService.class);
|
||||
}
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
package io.metersphere.notice.controller;
|
||||
|
||||
import io.metersphere.base.domain.NoticeDetail;
|
||||
import io.metersphere.notice.controller.request.NoticeRequest;
|
||||
import io.metersphere.notice.domain.NoticeDetail;
|
||||
import io.metersphere.notice.service.NoticeService;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
package io.metersphere.notice.controller.request;
|
||||
|
||||
import io.metersphere.base.domain.NoticeDetail;
|
||||
import io.metersphere.notice.domain.NoticeDetail;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.List;
|
||||
|
|
|
@ -1,9 +0,0 @@
|
|||
package io.metersphere.notice.domain;
|
||||
|
||||
import io.metersphere.base.domain.Notice;
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class NoticeDTO extends Notice {
|
||||
private String[] names;
|
||||
}
|
|
@ -1,5 +1,6 @@
|
|||
package io.metersphere.base.domain;
|
||||
package io.metersphere.notice.domain;
|
||||
|
||||
import io.metersphere.base.domain.Notice;
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
|
@ -1,7 +1,6 @@
|
|||
package io.metersphere.notice.service;
|
||||
|
||||
import io.metersphere.api.dto.APIReportResult;
|
||||
import io.metersphere.base.domain.NoticeDetail;
|
||||
import io.metersphere.base.domain.SystemParameter;
|
||||
import io.metersphere.base.domain.TestCaseWithBLOBs;
|
||||
import io.metersphere.commons.constants.ParamConstants;
|
||||
|
@ -10,6 +9,7 @@ import io.metersphere.commons.utils.LogUtil;
|
|||
import io.metersphere.dto.BaseSystemConfigDTO;
|
||||
import io.metersphere.dto.LoadTestDTO;
|
||||
import io.metersphere.i18n.Translator;
|
||||
import io.metersphere.notice.domain.NoticeDetail;
|
||||
import io.metersphere.service.SystemParameterService;
|
||||
import io.metersphere.service.UserService;
|
||||
import io.metersphere.track.request.testreview.SaveCommentRequest;
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
package io.metersphere.notice.service;
|
||||
|
||||
import io.metersphere.base.domain.Notice;
|
||||
import io.metersphere.base.domain.NoticeDetail;
|
||||
import io.metersphere.base.domain.NoticeExample;
|
||||
import io.metersphere.base.mapper.NoticeMapper;
|
||||
import io.metersphere.notice.controller.request.NoticeRequest;
|
||||
import io.metersphere.notice.domain.NoticeDetail;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
|
|
|
@ -19,6 +19,7 @@ import io.metersphere.dto.LoadTestDTO;
|
|||
import io.metersphere.dto.ScheduleDao;
|
||||
import io.metersphere.i18n.Translator;
|
||||
import io.metersphere.job.sechedule.PerformanceTestJob;
|
||||
import io.metersphere.notice.domain.NoticeDetail;
|
||||
import io.metersphere.notice.service.MailService;
|
||||
import io.metersphere.notice.service.NoticeService;
|
||||
import io.metersphere.performance.engine.Engine;
|
||||
|
|
|
@ -61,7 +61,8 @@ public class TestCaseCommentService {
|
|||
testCaseComments.forEach(testCaseComment -> {
|
||||
String authorId = testCaseComment.getAuthor();
|
||||
User user = userMapper.selectByPrimaryKey(authorId);
|
||||
testCaseComment.setAuthor(user.getName());
|
||||
String author = user == null ? authorId : user.getName();
|
||||
testCaseComment.setAuthor(author);
|
||||
});
|
||||
return testCaseComments;
|
||||
}
|
||||
|
|
|
@ -115,7 +115,8 @@ public class TestPlanService {
|
|||
return Optional.ofNullable(testPlanMapper.selectByPrimaryKey(testPlanId)).orElse(new TestPlan());
|
||||
}
|
||||
|
||||
public int editTestPlan(TestPlan testPlan) {
|
||||
public int editTestPlan(TestPlanDTO testPlan) {
|
||||
editTestPlanProject(testPlan);
|
||||
testPlan.setUpdateTime(System.currentTimeMillis());
|
||||
checkTestPlanExist(testPlan);
|
||||
//进行中状态,写入实际开始时间
|
||||
|
|
|
@ -1 +1 @@
|
|||
Subproject commit cf6b06526324326a563d933e07118fac014a63b4
|
||||
Subproject commit c2dacf960cdb1ed35664bdd3432120b1203b73d8
|
|
@ -90,6 +90,10 @@ export default {
|
|||
methods: {
|
||||
registerEvents() {
|
||||
ApiEvent.$on(LIST_CHANGE, () => {
|
||||
// todo 这里偶尔会有 refs 为空的情况
|
||||
if (!this.$refs.projectRecent) {
|
||||
return;
|
||||
}
|
||||
this.$refs.projectRecent.recent();
|
||||
this.$refs.testRecent.recent();
|
||||
this.$refs.reportRecent.recent();
|
||||
|
|
|
@ -1,231 +1,25 @@
|
|||
<template>
|
||||
<ms-container v-loading="loading" :element-loading-text="$t('api_report.running')">
|
||||
<ms-main-container>
|
||||
<el-card>
|
||||
<section class="report-container" v-if="this.report.testId">
|
||||
<header class="report-header">
|
||||
<el-row>
|
||||
<el-col>
|
||||
<span>{{ report.projectName }} / </span>
|
||||
<router-link :to="path">{{ report.testName }}</router-link>
|
||||
<span class="time">{{ report.createTime | timestampFormatDate }}</span>
|
||||
<el-button class="export-button" plain type="primary" size="mini" @click="handleExport(report.name)"
|
||||
style="margin-left: 1200px">
|
||||
{{$t('test_track.plan_view.export_report')}}
|
||||
</el-button>
|
||||
</el-col>
|
||||
</el-row>
|
||||
</header>
|
||||
<main v-if="this.isNotRunning">
|
||||
<ms-metric-chart :content="content" :totalTime="totalTime"/>
|
||||
<el-row :gutter="20">
|
||||
<el-col :span="8">
|
||||
<el-tabs v-model="activeName" @tab-click="handleClick">
|
||||
<el-tab-pane :label="$t('api_report.total')" name="total">
|
||||
<ms-scenario-results :scenarios="content.scenarios" v-on:requestResult="requestResult"/>
|
||||
</el-tab-pane>
|
||||
<el-tab-pane name="fail">
|
||||
<template slot="label">
|
||||
<span class="fail">{{ $t('api_report.fail') }}</span>
|
||||
</template>
|
||||
<ms-scenario-results v-on:requestResult="requestResult" :scenarios="fails"/>
|
||||
</el-tab-pane>
|
||||
</el-tabs>
|
||||
</el-col>
|
||||
<el-col :span="16" style="margin-top: 40px;">
|
||||
<ms-request-result-tail v-if="isRequestResult" :request="request" :scenario-name="scenarioName"/>
|
||||
</el-col>
|
||||
</el-row>
|
||||
<ms-api-report-export v-if="reportExportVisible" id="apiTestReport" :title="report.testName" :content="content" :total-time="totalTime"/>
|
||||
</main>
|
||||
</section>
|
||||
</el-card>
|
||||
</ms-main-container>
|
||||
</ms-container>
|
||||
<ms-api-report-view-detail :report-id="reportId"/>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
|
||||
import MsRequestResult from "./components/RequestResult";
|
||||
import MsRequestResultTail from "./components/RequestResultTail";
|
||||
import MsScenarioResult from "./components/ScenarioResult";
|
||||
import MsMetricChart from "./components/MetricChart";
|
||||
import MsScenarioResults from "./components/ScenarioResults";
|
||||
import MsContainer from "@/business/components/common/components/MsContainer";
|
||||
import MsMainContainer from "@/business/components/common/components/MsMainContainer";
|
||||
import MsApiReportExport from "./ApiReportExport";
|
||||
import {exportPdf} from "../../../../common/js/utils";
|
||||
import html2canvas from "html2canvas";
|
||||
import MsApiReportViewDetail from "./ApiReportViewDetail";
|
||||
|
||||
export default {
|
||||
name: "MsApiReportView",
|
||||
components: {
|
||||
MsApiReportExport,
|
||||
MsMainContainer,
|
||||
MsContainer, MsScenarioResults, MsRequestResultTail, MsMetricChart, MsScenarioResult, MsRequestResult
|
||||
MsApiReportViewDetail,
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
activeName: "total",
|
||||
content: {},
|
||||
report: {},
|
||||
loading: true,
|
||||
fails: [],
|
||||
totalTime: 0,
|
||||
isRequestResult: false,
|
||||
request: {},
|
||||
scenarioName: null,
|
||||
reportExportVisible: false
|
||||
}
|
||||
},
|
||||
activated() {
|
||||
this.isRequestResult = false
|
||||
},
|
||||
methods: {
|
||||
init() {
|
||||
this.loading = true;
|
||||
this.report = {};
|
||||
this.content = {};
|
||||
this.fails = [];
|
||||
},
|
||||
handleClick(tab, event) {
|
||||
this.isRequestResult = false
|
||||
},
|
||||
getReport() {
|
||||
this.init();
|
||||
if (this.reportId) {
|
||||
let url = "/api/report/get/" + this.reportId;
|
||||
this.$get(url, response => {
|
||||
this.report = response.data || {};
|
||||
if (response.data) {
|
||||
if (this.isNotRunning) {
|
||||
try {
|
||||
this.content = JSON.parse(this.report.content);
|
||||
} catch (e) {
|
||||
console.log(this.report.content)
|
||||
throw e;
|
||||
}
|
||||
this.getFails();
|
||||
this.loading = false;
|
||||
} else {
|
||||
setTimeout(this.getReport, 2000)
|
||||
}
|
||||
} else {
|
||||
this.loading = false;
|
||||
this.$error(this.$t('api_report.not_exist'));
|
||||
}
|
||||
});
|
||||
}
|
||||
},
|
||||
getFails() {
|
||||
if (this.isNotRunning) {
|
||||
this.fails = [];
|
||||
this.totalTime = 0
|
||||
this.content.scenarios.forEach((scenario) => {
|
||||
this.totalTime = this.totalTime + Number(scenario.responseTime)
|
||||
let failScenario = Object.assign({}, scenario);
|
||||
if (scenario.error > 0) {
|
||||
this.fails.push(failScenario);
|
||||
failScenario.requestResults = [];
|
||||
scenario.requestResults.forEach((request) => {
|
||||
if (!request.success) {
|
||||
let failRequest = Object.assign({}, request);
|
||||
failScenario.requestResults.push(failRequest);
|
||||
}
|
||||
})
|
||||
|
||||
}
|
||||
})
|
||||
}
|
||||
},
|
||||
requestResult(requestResult) {
|
||||
this.isRequestResult = false;
|
||||
this.$nextTick(function () {
|
||||
this.isRequestResult = true;
|
||||
this.request = requestResult.request;
|
||||
this.scenarioName = requestResult.scenarioName;
|
||||
});
|
||||
},
|
||||
handleExport(name) {
|
||||
this.loading = true;
|
||||
this.reportExportVisible = true;
|
||||
let reset = this.exportReportReset;
|
||||
|
||||
this.$nextTick(function () {
|
||||
setTimeout(() => {
|
||||
html2canvas(document.getElementById('apiTestReport'), {
|
||||
scale: 2
|
||||
}).then(function(canvas) {
|
||||
exportPdf(name, [canvas]);
|
||||
reset();
|
||||
});
|
||||
}, 1000);
|
||||
});
|
||||
},
|
||||
exportReportReset() {
|
||||
this.reportExportVisible = false;
|
||||
this.loading = false;
|
||||
}
|
||||
},
|
||||
|
||||
watch: {
|
||||
'$route': 'getReport',
|
||||
},
|
||||
|
||||
created() {
|
||||
this.getReport();
|
||||
},
|
||||
|
||||
computed: {
|
||||
reportId: function () {
|
||||
return this.$route.params.reportId;
|
||||
},
|
||||
path() {
|
||||
return "/api/test/edit?id=" + this.report.testId;
|
||||
},
|
||||
isNotRunning() {
|
||||
return "Running" !== this.report.status;
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
<style>
|
||||
.report-container .el-tabs__header {
|
||||
margin-bottom: 1px;
|
||||
}
|
||||
</style>
|
||||
|
||||
<style scoped>
|
||||
|
||||
.report-container {
|
||||
height: calc(100vh - 155px);
|
||||
min-height: 600px;
|
||||
overflow-y: auto;
|
||||
}
|
||||
|
||||
.report-header {
|
||||
font-size: 15px;
|
||||
}
|
||||
|
||||
.report-header a {
|
||||
text-decoration: none;
|
||||
}
|
||||
|
||||
.report-header .time {
|
||||
color: #909399;
|
||||
margin-left: 10px;
|
||||
}
|
||||
|
||||
.report-container .fail {
|
||||
color: #F56C6C;
|
||||
}
|
||||
|
||||
.report-container .is-active .fail {
|
||||
color: inherit;
|
||||
}
|
||||
|
||||
.export-button {
|
||||
float: right;
|
||||
}
|
||||
|
||||
</style>
|
||||
|
|
|
@ -0,0 +1,224 @@
|
|||
<template>
|
||||
<ms-container v-loading="loading" :element-loading-text="$t('api_report.running')">
|
||||
<ms-main-container>
|
||||
<el-card>
|
||||
<section class="report-container" v-if="this.report.testId">
|
||||
|
||||
<ms-api-report-view-header :report="report" @reportExport="handleExport"/>
|
||||
|
||||
<main v-if="this.isNotRunning">
|
||||
<ms-metric-chart :content="content" :totalTime="totalTime"/>
|
||||
<el-row :gutter="20">
|
||||
<el-col :span="8">
|
||||
<el-tabs v-model="activeName" @tab-click="handleClick">
|
||||
<el-tab-pane :label="$t('api_report.total')" name="total">
|
||||
<ms-scenario-results :scenarios="content.scenarios" v-on:requestResult="requestResult"/>
|
||||
</el-tab-pane>
|
||||
<el-tab-pane name="fail">
|
||||
<template slot="label">
|
||||
<span class="fail">{{ $t('api_report.fail') }}</span>
|
||||
</template>
|
||||
<ms-scenario-results v-on:requestResult="requestResult" :scenarios="fails"/>
|
||||
</el-tab-pane>
|
||||
</el-tabs>
|
||||
</el-col>
|
||||
<el-col :span="16" style="margin-top: 40px;">
|
||||
<ms-request-result-tail v-if="isRequestResult" :request="request" :scenario-name="scenarioName"/>
|
||||
</el-col>
|
||||
</el-row>
|
||||
<ms-api-report-export v-if="reportExportVisible" id="apiTestReport" :title="report.testName" :content="content" :total-time="totalTime"/>
|
||||
</main>
|
||||
</section>
|
||||
</el-card>
|
||||
</ms-main-container>
|
||||
</ms-container>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
|
||||
import MsRequestResult from "./components/RequestResult";
|
||||
import MsRequestResultTail from "./components/RequestResultTail";
|
||||
import MsScenarioResult from "./components/ScenarioResult";
|
||||
import MsMetricChart from "./components/MetricChart";
|
||||
import MsScenarioResults from "./components/ScenarioResults";
|
||||
import MsContainer from "@/business/components/common/components/MsContainer";
|
||||
import MsMainContainer from "@/business/components/common/components/MsMainContainer";
|
||||
import MsApiReportExport from "./ApiReportExport";
|
||||
import {exportPdf} from "../../../../common/js/utils";
|
||||
import html2canvas from "html2canvas";
|
||||
import MsApiReportViewHeader from "./ApiReportViewHeader";
|
||||
|
||||
export default {
|
||||
name: "MsApiReportViewDetail",
|
||||
components: {
|
||||
MsApiReportViewHeader,
|
||||
MsApiReportExport,
|
||||
MsMainContainer,
|
||||
MsContainer, MsScenarioResults, MsRequestResultTail, MsMetricChart, MsScenarioResult, MsRequestResult
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
activeName: "total",
|
||||
content: {},
|
||||
report: {},
|
||||
loading: true,
|
||||
fails: [],
|
||||
totalTime: 0,
|
||||
isRequestResult: false,
|
||||
request: {},
|
||||
scenarioName: null,
|
||||
reportExportVisible: false
|
||||
}
|
||||
},
|
||||
props: ['reportId'],
|
||||
activated() {
|
||||
this.isRequestResult = false;
|
||||
},
|
||||
watch: {
|
||||
reportId() {
|
||||
this.getReport();
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
init() {
|
||||
this.loading = true;
|
||||
this.report = {};
|
||||
this.content = {};
|
||||
this.fails = [];
|
||||
this.report = {};
|
||||
this.isRequestResult = false;
|
||||
},
|
||||
handleClick(tab, event) {
|
||||
this.isRequestResult = false
|
||||
},
|
||||
getReport() {
|
||||
this.init();
|
||||
if (this.reportId) {
|
||||
let url = "/api/report/get/" + this.reportId;
|
||||
this.$get(url, response => {
|
||||
this.report = response.data || {};
|
||||
if (response.data) {
|
||||
if (this.isNotRunning) {
|
||||
try {
|
||||
this.content = JSON.parse(this.report.content);
|
||||
} catch (e) {
|
||||
console.log(this.report.content)
|
||||
throw e;
|
||||
}
|
||||
this.getFails();
|
||||
this.loading = false;
|
||||
} else {
|
||||
setTimeout(this.getReport, 2000)
|
||||
}
|
||||
} else {
|
||||
this.loading = false;
|
||||
this.$error(this.$t('api_report.not_exist'));
|
||||
}
|
||||
});
|
||||
}
|
||||
},
|
||||
getFails() {
|
||||
if (this.isNotRunning) {
|
||||
this.fails = [];
|
||||
this.totalTime = 0
|
||||
this.content.scenarios.forEach((scenario) => {
|
||||
this.totalTime = this.totalTime + Number(scenario.responseTime)
|
||||
let failScenario = Object.assign({}, scenario);
|
||||
if (scenario.error > 0) {
|
||||
this.fails.push(failScenario);
|
||||
failScenario.requestResults = [];
|
||||
scenario.requestResults.forEach((request) => {
|
||||
if (!request.success) {
|
||||
let failRequest = Object.assign({}, request);
|
||||
failScenario.requestResults.push(failRequest);
|
||||
}
|
||||
})
|
||||
|
||||
}
|
||||
})
|
||||
}
|
||||
},
|
||||
requestResult(requestResult) {
|
||||
this.isRequestResult = false;
|
||||
this.$nextTick(function () {
|
||||
this.isRequestResult = true;
|
||||
this.request = requestResult.request;
|
||||
this.scenarioName = requestResult.scenarioName;
|
||||
});
|
||||
},
|
||||
handleExport(name) {
|
||||
this.loading = true;
|
||||
this.reportExportVisible = true;
|
||||
let reset = this.exportReportReset;
|
||||
|
||||
this.$nextTick(function () {
|
||||
setTimeout(() => {
|
||||
html2canvas(document.getElementById('apiTestReport'), {
|
||||
scale: 2
|
||||
}).then(function(canvas) {
|
||||
exportPdf(name, [canvas]);
|
||||
reset();
|
||||
});
|
||||
}, 1000);
|
||||
});
|
||||
},
|
||||
exportReportReset() {
|
||||
this.reportExportVisible = false;
|
||||
this.loading = false;
|
||||
}
|
||||
},
|
||||
|
||||
created() {
|
||||
this.getReport();
|
||||
},
|
||||
|
||||
computed: {
|
||||
path() {
|
||||
return "/api/test/edit?id=" + this.report.testId;
|
||||
},
|
||||
isNotRunning() {
|
||||
return "Running" !== this.report.status;
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
<style>
|
||||
.report-container .el-tabs__header {
|
||||
margin-bottom: 1px;
|
||||
}
|
||||
</style>
|
||||
|
||||
<style scoped>
|
||||
|
||||
.report-container {
|
||||
height: calc(100vh - 155px);
|
||||
min-height: 600px;
|
||||
overflow-y: auto;
|
||||
}
|
||||
|
||||
.report-header {
|
||||
font-size: 15px;
|
||||
}
|
||||
|
||||
.report-header a {
|
||||
text-decoration: none;
|
||||
}
|
||||
|
||||
.report-header .time {
|
||||
color: #909399;
|
||||
margin-left: 10px;
|
||||
}
|
||||
|
||||
.report-container .fail {
|
||||
color: #F56C6C;
|
||||
}
|
||||
|
||||
.report-container .is-active .fail {
|
||||
color: inherit;
|
||||
}
|
||||
|
||||
.export-button {
|
||||
float: right;
|
||||
}
|
||||
|
||||
</style>
|
|
@ -0,0 +1,52 @@
|
|||
<template>
|
||||
<header class="report-header">
|
||||
<el-row>
|
||||
<el-col>
|
||||
<span>{{ report.projectName }} / </span>
|
||||
<router-link :to="path">{{ report.testName }}</router-link>
|
||||
<span class="time">{{ report.createTime | timestampFormatDate }}</span>
|
||||
<el-button :disabled="isReadOnly" class="export-button" plain type="primary" size="mini" @click="handleExport(report.name)"
|
||||
style="margin-left: 1200px">
|
||||
{{$t('test_track.plan_view.export_report')}}
|
||||
</el-button>
|
||||
</el-col>
|
||||
</el-row>
|
||||
</header>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import {checkoutTestManagerOrTestUser} from "../../../../common/js/utils";
|
||||
|
||||
export default {
|
||||
name: "MsApiReportViewHeader",
|
||||
props: ['report'],
|
||||
computed: {
|
||||
path() {
|
||||
return "/api/test/edit?id=" + this.report.testId;
|
||||
},
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
isReadOnly: false,
|
||||
}
|
||||
},
|
||||
created() {
|
||||
if (!checkoutTestManagerOrTestUser()) {
|
||||
this.isReadOnly = true;
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
handleExport(name) {
|
||||
this.$emit('reportExport', name);
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
|
||||
.export-button {
|
||||
float: right;
|
||||
}
|
||||
|
||||
</style>
|
|
@ -2,10 +2,13 @@
|
|||
<div class="request-result">
|
||||
<div @click="active">
|
||||
<el-row :gutter="10" type="flex" align="middle" class="info">
|
||||
<el-col :span="16">
|
||||
<el-col :span="12">
|
||||
<i class="icon el-icon-arrow-right" :class="{'is-active': isActive}"/>
|
||||
{{scenarioName}}
|
||||
</el-col>
|
||||
<el-col :span="4">
|
||||
{{$t('api_report.start_time')}}
|
||||
</el-col>
|
||||
<el-col :span="2">
|
||||
{{$t('api_report.response_time')}}
|
||||
</el-col>
|
||||
|
@ -20,17 +23,20 @@
|
|||
</el-col>
|
||||
</el-row>
|
||||
<el-row :gutter="10" type="flex" align="middle" class="info">
|
||||
<el-col :span="4">
|
||||
<el-col :span="2">
|
||||
<div class="method">
|
||||
{{request.method}}
|
||||
</div>
|
||||
</el-col>
|
||||
<el-col :span="12">
|
||||
<el-col :span="10">
|
||||
<div class="name">{{request.name}}</div>
|
||||
<el-tooltip effect="dark" :content="request.url" placement="bottom" :open-delay="800">
|
||||
<div class="url">{{request.url}}</div>
|
||||
</el-tooltip>
|
||||
</el-col>
|
||||
<el-col :span="4">
|
||||
{{request.startTime | timestampFormatDate(true) }}
|
||||
</el-col>
|
||||
<el-col :span="2">
|
||||
<div class="time">
|
||||
{{request.responseResult.responseTime}}
|
||||
|
|
|
@ -14,9 +14,13 @@
|
|||
</el-select>
|
||||
</el-input>
|
||||
|
||||
<el-button type="primary" plain :disabled="isReadOnly" @click="saveTest">
|
||||
{{ $t('commons.save') }}
|
||||
</el-button>
|
||||
<el-tooltip :content="'Ctrl + S'"
|
||||
placement="top"
|
||||
:enterable="false">
|
||||
<el-button type="primary" plain :disabled="isReadOnly" @click="saveTest">
|
||||
{{ $t('commons.save') }}
|
||||
</el-button>
|
||||
</el-tooltip>
|
||||
|
||||
<el-button type="primary" plain :disabled="isReadOnly"
|
||||
@click="saveRunTest">
|
||||
|
@ -67,7 +71,7 @@
|
|||
|
||||
<script>
|
||||
import MsApiScenarioConfig from "./components/ApiScenarioConfig";
|
||||
import {Test, Scenario} from "./model/ScenarioModel"
|
||||
import {Scenario, Test} from "./model/ScenarioModel"
|
||||
import MsApiReportStatus from "../report/ApiReportStatus";
|
||||
import MsApiReportDialog from "./ApiReportDialog";
|
||||
import {checkoutTestManagerOrTestUser, downloadFile, getUUID} from "@/common/js/utils";
|
||||
|
@ -368,11 +372,25 @@ export default {
|
|||
this.debugReportId = response.data;
|
||||
this.resetBodyFile();
|
||||
});
|
||||
}
|
||||
},
|
||||
handleEvent(event) {
|
||||
if (event.keyCode === 83 && event.ctrlKey) {
|
||||
console.log('拦截到 ctrl + s');//ctrl+s
|
||||
this.saveTest();
|
||||
event.preventDefault();
|
||||
event.returnValue = false;
|
||||
return false;
|
||||
}
|
||||
},
|
||||
},
|
||||
|
||||
created() {
|
||||
this.init();
|
||||
//
|
||||
document.addEventListener('keydown', this.handleEvent)
|
||||
},
|
||||
beforeDestroy() {
|
||||
document.removeEventListener('keydown', this.handleEvent);
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
|
|
@ -6,8 +6,8 @@
|
|||
<div class="kv-row" v-for="(item, index) in items" :key="index">
|
||||
<el-row type="flex" :gutter="20" justify="space-between" align="middle">
|
||||
<el-col v-if="isShowEnable" class="kv-checkbox">
|
||||
<input type="checkbox" v-if="!isDisable(index)" @change="change" :value="item.uuid" v-model="checkedValues"
|
||||
:disabled="isDisable(index) || isReadOnly"/>
|
||||
<input type="checkbox" v-if="!isDisable(index)" v-model="item.enable"
|
||||
:disabled="isReadOnly"/>
|
||||
</el-col>
|
||||
|
||||
<el-col>
|
||||
|
@ -52,7 +52,7 @@
|
|||
},
|
||||
data() {
|
||||
return {
|
||||
checkedValues: []
|
||||
// checkedValues: []
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
|
@ -79,10 +79,6 @@
|
|||
let isNeedCreate = true;
|
||||
let removeIndex = -1;
|
||||
this.items.forEach((item, index) => {
|
||||
// 启用行赋值
|
||||
if (this.isShowEnable) {
|
||||
item.enable = this.checkedValues.indexOf(item.uuid) != -1 ? true : false;
|
||||
}
|
||||
if (!item.name && !item.value) {
|
||||
// 多余的空行
|
||||
if (index !== this.items.length - 1) {
|
||||
|
@ -93,13 +89,7 @@
|
|||
}
|
||||
});
|
||||
if (isNeedCreate) {
|
||||
// 往后台送入的复选框值布尔值
|
||||
if (this.isShowEnable) {
|
||||
this.items[this.items.length - 1].enable = true;
|
||||
// v-model 选中状态
|
||||
this.checkedValues.push(this.items[this.items.length - 1].uuid);
|
||||
}
|
||||
this.items.push(new KeyValue());
|
||||
this.items.push(new KeyValue({enable: true}));
|
||||
}
|
||||
this.$emit('change', this.items);
|
||||
// TODO 检查key重复
|
||||
|
@ -112,9 +102,6 @@
|
|||
let results = queryString ? suggestions.filter(this.createFilter(queryString)) : suggestions;
|
||||
cb(results);
|
||||
},
|
||||
uuid: function () {
|
||||
return (((1 + Math.random()) * 0x100000) | 0).toString(16).substring(1);
|
||||
},
|
||||
createFilter(queryString) {
|
||||
return (restaurant) => {
|
||||
return (restaurant.value.toLowerCase().indexOf(queryString.toLowerCase()) === 0);
|
||||
|
@ -123,15 +110,7 @@
|
|||
},
|
||||
created() {
|
||||
if (this.items.length === 0) {
|
||||
this.items.push(new KeyValue());
|
||||
} else if (this.isShowEnable) {
|
||||
this.items.forEach((item, index) => {
|
||||
let uuid = this.uuid();
|
||||
item.uuid = uuid;
|
||||
if (item.enable) {
|
||||
this.checkedValues.push(uuid);
|
||||
}
|
||||
})
|
||||
this.items.push(new KeyValue({enable: true}));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3,26 +3,27 @@
|
|||
<span class="kv-description" v-if="description">
|
||||
{{ description }}
|
||||
</span>
|
||||
|
||||
<div class="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">
|
||||
<input type="checkbox" v-if="!isDisable(index)" @change="change" :value="item.uuid" v-model="checkedValues"
|
||||
:disabled="isDisable(index) || isReadOnly"/>
|
||||
<input type="checkbox" v-if="!isDisable(index)" v-model="item.enable"
|
||||
:disabled="isReadOnly"/>
|
||||
</el-col>
|
||||
<el-col>
|
||||
|
||||
<el-input v-if="!suggestions" :disabled="isReadOnly" v-model="item.name" size="small" maxlength="200"
|
||||
@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">
|
||||
<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-select>
|
||||
</template>
|
||||
</el-input>
|
||||
|
||||
<el-autocomplete :disabled="isReadOnly" :maxlength="200" v-if="suggestions" v-model="item.name" size="small"
|
||||
<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>
|
||||
|
@ -44,6 +45,13 @@
|
|||
<el-col v-if="item.type === 'file'">
|
||||
<ms-api-body-file-upload :parameter="item"/>
|
||||
</el-col>
|
||||
|
||||
<el-col v-if="type === 'body'">
|
||||
<el-input :disabled="isReadOnly" v-model="item.contentType" size="small" maxlength="100"
|
||||
@change="change" :placeholder="$t('api_test.request.content_type')" show-word-limit>
|
||||
</el-input>
|
||||
</el-col>
|
||||
|
||||
<el-col class="kv-delete">
|
||||
<el-button size="mini" class="el-icon-delete-solid" circle @click="remove(index)"
|
||||
:disabled="isDisable(index) || isReadOnly"/>
|
||||
|
@ -85,7 +93,6 @@
|
|||
data() {
|
||||
return {
|
||||
currentItem: null,
|
||||
checkedValues: []
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
|
@ -98,9 +105,6 @@
|
|||
},
|
||||
methods: {
|
||||
remove: function (index) {
|
||||
// 移除勾选内容
|
||||
let checkIndex = this.checkedValues.indexOf(this.parameters[index].uuid);
|
||||
checkIndex != -1 ? this.checkedValues.splice(checkIndex, 1) : this.checkedValues;
|
||||
// 移除整行输入控件及内容
|
||||
this.parameters.splice(index, 1);
|
||||
this.$emit('change', this.parameters);
|
||||
|
@ -109,9 +113,6 @@
|
|||
let isNeedCreate = true;
|
||||
let removeIndex = -1;
|
||||
this.parameters.forEach((item, index) => {
|
||||
// 启用行赋值
|
||||
item.enable = this.checkedValues.indexOf(item.uuid) != -1 ? true : false;
|
||||
|
||||
if (!item.name && !item.value) {
|
||||
// 多余的空行
|
||||
if (index !== this.parameters.length - 1) {
|
||||
|
@ -122,11 +123,7 @@
|
|||
}
|
||||
});
|
||||
if (isNeedCreate) {
|
||||
// 往后台送入的复选框值布尔值
|
||||
this.parameters[this.parameters.length - 1].enable = true;
|
||||
// v-model 选中状态
|
||||
this.checkedValues.push(this.parameters[this.parameters.length - 1].uuid);
|
||||
this.parameters.push(new KeyValue(null, null, 'text', false, this.uuid()));
|
||||
this.parameters.push(new KeyValue({type: 'text', enable: true, uuid: this.uuid(), contentType: 'text/plain'}));
|
||||
}
|
||||
this.$emit('change', this.parameters);
|
||||
// TODO 检查key重复
|
||||
|
@ -161,22 +158,18 @@
|
|||
advanced(item) {
|
||||
this.$refs.variableAdvance.open();
|
||||
this.currentItem = item;
|
||||
this.itemValue = '';
|
||||
this.mockVariableFuncs = [];
|
||||
},
|
||||
|
||||
typeChange(item) {
|
||||
if (item.type === 'file') {
|
||||
item.contentType = 'application/octet-stream';
|
||||
} else {
|
||||
item.contentType = 'text/plain';
|
||||
}
|
||||
}
|
||||
},
|
||||
created() {
|
||||
if (this.parameters.length === 0) {
|
||||
this.parameters.push(new KeyValue(null, null, 'text', false, this.uuid()));
|
||||
} else {
|
||||
this.parameters.forEach((item, index) => {
|
||||
let uuid = this.uuid();
|
||||
item.uuid = uuid;
|
||||
if (item.enable) {
|
||||
this.checkedValues.push(uuid);
|
||||
}
|
||||
})
|
||||
this.parameters.push(new KeyValue( {type: 'text', enable: true, uuid: this.uuid(), contentType: 'text/plain'}));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -173,7 +173,7 @@ export default {
|
|||
}
|
||||
];
|
||||
if (this.environment) {
|
||||
let variables = JSON.parse(this.environment.variables);
|
||||
let variables = this.environment.config.commonConfig.variables;
|
||||
this.environmentParams = [
|
||||
{
|
||||
name: this.environment.name,
|
||||
|
|
|
@ -105,9 +105,9 @@
|
|||
|
||||
.api-body-upload {
|
||||
min-height: 32px;
|
||||
/*border: 1px solid #EBEEF5;*/
|
||||
/*padding: 2px;*/
|
||||
/*border-radius: 4px;*/
|
||||
border: 1px solid #EBEEF5;
|
||||
padding: 2px;
|
||||
border-radius: 4px;
|
||||
}
|
||||
|
||||
.upload-item {
|
||||
|
|
|
@ -34,7 +34,7 @@
|
|||
codeTemplates: [
|
||||
{
|
||||
title: this.$t('api_test.request.processor.code_template_get_variable'),
|
||||
value: 'vars.get("variable_name");',
|
||||
value: 'vars.get("variable_name")',
|
||||
},
|
||||
{
|
||||
title: this.$t('api_test.request.processor.code_template_set_variable'),
|
||||
|
@ -42,17 +42,17 @@
|
|||
},
|
||||
{
|
||||
title: this.$t('api_test.request.processor.code_template_get_response_header'),
|
||||
value: 'prev.getResponseHeaders();',
|
||||
value: 'prev.getResponseHeaders()',
|
||||
disabled: this.isPreProcessor
|
||||
},
|
||||
{
|
||||
title: this.$t('api_test.request.processor.code_template_get_response_code'),
|
||||
value: 'prev.getResponseCode();',
|
||||
value: 'prev.getResponseCode()',
|
||||
disabled: this.isPreProcessor
|
||||
},
|
||||
{
|
||||
title: this.$t('api_test.request.processor.code_template_get_response_result'),
|
||||
value: 'prev.getResponseDataAsString();',
|
||||
value: 'prev.getResponseDataAsString()',
|
||||
disabled: this.isPreProcessor
|
||||
}
|
||||
],
|
||||
|
@ -93,6 +93,9 @@
|
|||
this.jsr223Processor.script = "";
|
||||
}
|
||||
this.jsr223Processor.script += template.value;
|
||||
if (this.jsr223Processor.language === 'beanshell') {
|
||||
this.jsr223Processor.script += ';';
|
||||
}
|
||||
this.reload();
|
||||
},
|
||||
reload() {
|
||||
|
|
|
@ -156,7 +156,7 @@ export default {
|
|||
let url = new URL(urlStr);
|
||||
url.searchParams.forEach((value, key) => {
|
||||
if (key && value) {
|
||||
this.request.parameters.splice(0, 0, new KeyValue(key, value));
|
||||
this.request.parameters.splice(0, 0, new KeyValue({name: name, value: value}));
|
||||
}
|
||||
});
|
||||
return url;
|
||||
|
|
|
@ -5,11 +5,24 @@
|
|||
<el-input v-model="request.name" maxlength="300" show-word-limit/>
|
||||
</el-form-item>
|
||||
|
||||
<el-form-item :label="$t('api_test.request.sql.dataSource')" prop="dataSource">
|
||||
<el-select v-model="request.dataSource">
|
||||
<el-option v-for="(item, index) in databaseConfigsOptions" :key="index" :value="item.id" :label="item.name"/>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<div class="one-row">
|
||||
<el-form-item :label="$t('api_test.request.sql.dataSource')" prop="dataSource">
|
||||
<el-select v-model="request.dataSource">
|
||||
<el-option v-for="(item, index) in databaseConfigsOptions" :key="index" :value="item.id" :label="item.name"/>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
|
||||
<el-form-item :label="$t('api_test.request.sql.timeout')" prop="queryTimeout">
|
||||
<el-input-number :disabled="isReadOnly" size="mini" v-model="request.queryTimeout" :placeholder="$t('commons.millisecond')" :max="1000*10000000" :min="0"/>
|
||||
</el-form-item>
|
||||
|
||||
<el-form-item>
|
||||
<el-switch
|
||||
v-model="request.useEnvironment"
|
||||
:active-text="$t('api_test.request.refer_to_environment')" @change="getDatabaseConfigsOptions">
|
||||
</el-switch>
|
||||
</el-form-item>
|
||||
</div>
|
||||
|
||||
<el-form-item :label="$t('api_test.request.sql.result_variable')" prop="resultVariable">
|
||||
<el-input v-model="request.resultVariable" maxlength="300" show-word-limit/>
|
||||
|
@ -25,17 +38,6 @@
|
|||
<!--</el-select>-->
|
||||
<!--</el-form-item>-->
|
||||
|
||||
<el-form-item :label="$t('api_test.request.sql.timeout')" prop="queryTimeout">
|
||||
<el-input-number :disabled="isReadOnly" size="mini" v-model="request.queryTimeout" :placeholder="$t('commons.millisecond')" :max="1000*10000000" :min="0"/>
|
||||
</el-form-item>
|
||||
|
||||
<el-form-item>
|
||||
<el-switch
|
||||
v-model="request.useEnvironment"
|
||||
:active-text="$t('api_test.request.refer_to_environment')" @change="getDatabaseConfigsOptions">
|
||||
</el-switch>
|
||||
</el-form-item>
|
||||
|
||||
<el-button :disabled="!request.enable || !scenario.enable || isReadOnly" class="debug-button" size="small" type="primary" @click="runDebug">{{$t('api_test.request.debug')}}</el-button>
|
||||
|
||||
<el-tabs v-model="activeName">
|
||||
|
@ -147,4 +149,12 @@
|
|||
height: calc(100vh - 570px);
|
||||
}
|
||||
|
||||
.one-row .el-form-item {
|
||||
display: inline-block;
|
||||
}
|
||||
|
||||
.one-row .el-form-item:nth-child(2) {
|
||||
margin-left: 60px;
|
||||
}
|
||||
|
||||
</style>
|
||||
|
|
|
@ -344,6 +344,9 @@ export class HTTPSamplerArguments extends Element {
|
|||
}
|
||||
elementProp.stringProp('Argument.value', arg.value);
|
||||
elementProp.stringProp('Argument.metadata', arg.metadata || "=");
|
||||
if (arg.contentType) {
|
||||
elementProp.stringProp('HTTPArgument.content_type', arg.contentType, "");
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
@ -363,7 +366,7 @@ export class HTTPsamplerFiles extends Element {
|
|||
let elementProp = collectionProp.elementProp(arg.value, 'HTTPFileArg');
|
||||
elementProp.stringProp('File.path', arg.value);
|
||||
elementProp.stringProp('File.paramname', arg.name);
|
||||
elementProp.stringProp('File.mimetype', arg.metadata || "application/octet-stream");
|
||||
elementProp.stringProp('File.mimetype', arg.contentType || "application/octet-stream");
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
@ -656,35 +656,18 @@ export class Body extends BaseConfig {
|
|||
}
|
||||
|
||||
export class KeyValue extends BaseConfig {
|
||||
constructor() {
|
||||
let options, key, value, type, enable, uuid;
|
||||
if (arguments.length === 1) {
|
||||
options = arguments[0];
|
||||
}
|
||||
constructor(options) {
|
||||
options = options || {};
|
||||
options.enable = options.enable != false ? true : false;
|
||||
|
||||
if (arguments.length === 2) {
|
||||
key = arguments[0];
|
||||
value = arguments[1];
|
||||
}
|
||||
if (arguments.length === 3) {
|
||||
key = arguments[0];
|
||||
value = arguments[1];
|
||||
type = arguments[2];
|
||||
}
|
||||
if (arguments.length === 5) {
|
||||
key = arguments[0];
|
||||
value = arguments[1];
|
||||
type = arguments[2];
|
||||
enable = arguments[3];
|
||||
uuid = arguments[4];
|
||||
}
|
||||
super();
|
||||
this.name = key;
|
||||
this.value = value;
|
||||
this.type = type;
|
||||
this.name = undefined;
|
||||
this.value = undefined;
|
||||
this.type = undefined;
|
||||
this.files = undefined;
|
||||
this.enable = enable;
|
||||
this.uuid = uuid;
|
||||
this.enable = undefined;
|
||||
this.uuid = undefined;
|
||||
this.contentType = undefined;
|
||||
this.set(options);
|
||||
}
|
||||
|
||||
|
@ -956,7 +939,7 @@ class JMXHttpRequest {
|
|||
this.domain = environment.config.httpConfig.domain;
|
||||
this.port = environment.config.httpConfig.port;
|
||||
this.protocol = environment.config.httpConfig.protocol;
|
||||
let url = new URL(environment.config.httpConfig.protocol + "://" + environment.config.commonConfig.socket);
|
||||
let url = new URL(environment.config.httpConfig.protocol + "://" + environment.config.httpConfig.socket);
|
||||
this.path = this.getPostQueryParameters(request, decodeURIComponent(url.pathname + (request.path ? request.path : '')));
|
||||
}
|
||||
this.connectTimeout = request.connectTimeout;
|
||||
|
@ -1117,7 +1100,7 @@ class JMXGenerator {
|
|||
}
|
||||
envArray.forEach(item => {
|
||||
if (item.name && !keys.has(item.name)) {
|
||||
target.push(new KeyValue(item.name, item.value));
|
||||
target.push(new KeyValue({name: item.name, value: item.value}));
|
||||
}
|
||||
})
|
||||
}
|
||||
|
@ -1294,7 +1277,7 @@ class JMXGenerator {
|
|||
}
|
||||
}
|
||||
}
|
||||
request.headers.push(new KeyValue('Content-Type', type));
|
||||
request.headers.push(new KeyValue({name: 'Content-Type', value: type}));
|
||||
}
|
||||
|
||||
addRequestArguments(httpSamplerProxy, request) {
|
||||
|
@ -1323,7 +1306,7 @@ class JMXGenerator {
|
|||
let files = [];
|
||||
let kvs = this.filterKVFile(request.body.kvs);
|
||||
kvs.forEach(kv => {
|
||||
if (kv.files) {
|
||||
if ((kv.enable != false) && kv.files) {
|
||||
kv.files.forEach(file => {
|
||||
let arg = {};
|
||||
arg.name = kv.name;
|
||||
|
|
|
@ -63,10 +63,10 @@
|
|||
>
|
||||
<template v-slot:default="{row}">
|
||||
<el-switch
|
||||
v-model="row.enable"
|
||||
active-value="true"
|
||||
inactive-value="false"
|
||||
inactive-color="#ff4949"
|
||||
v-model="row.enable"
|
||||
active-value="true"
|
||||
inactive-value="false"
|
||||
inactive-color="#DCDFE6"
|
||||
/>
|
||||
</template>
|
||||
</el-table-column>
|
||||
|
|
|
@ -98,6 +98,10 @@ export default {
|
|||
methods: {
|
||||
registerEvents() {
|
||||
PerformanceEvent.$on(LIST_CHANGE, () => {
|
||||
// todo 这里偶尔会有 refs 为空的情况
|
||||
if (!this.$refs.projectRecent) {
|
||||
return;
|
||||
}
|
||||
this.$refs.projectRecent.recent();
|
||||
this.$refs.testRecent.recent();
|
||||
this.$refs.reportRecent.recent();
|
||||
|
|
|
@ -4,7 +4,8 @@
|
|||
<el-card class="card-content" v-loading="result.loading">
|
||||
<template v-slot:header>
|
||||
|
||||
<ms-table-header :is-tester-permission="true" :condition.sync="condition" @search="initTableData" :tip="$t('commons.search_by_name_or_id')"
|
||||
<ms-table-header :is-tester-permission="true" :condition.sync="condition" @search="initTableData"
|
||||
:tip="$t('commons.search_by_name_or_id')"
|
||||
:create-tip="$t('test_track.case.create')" @create="testCaseCreate">
|
||||
<template v-slot:title>
|
||||
<node-breadcrumb class="table-title" :nodes="selectParentNodes" @refresh="refresh"/>
|
||||
|
@ -14,10 +15,10 @@
|
|||
:content="$t('test_track.case.import.import')" @click="importTestCase"/>
|
||||
<ms-table-button :is-tester-permission="true" icon="el-icon-upload2"
|
||||
:content="$t('test_track.case.export.export')" @click="handleBatch('export')"/>
|
||||
<!-- <ms-table-button :is-tester-permission="true" icon="el-icon-right" :content="$t('test_track.case.move')"-->
|
||||
<!-- @click="handleBatch('move')"/>-->
|
||||
<!-- <ms-table-button :is-tester-permission="true" icon="el-icon-delete" :content="$t('test_track.case.delete')"-->
|
||||
<!-- @click="handleBatch('delete')"/>-->
|
||||
<!-- <ms-table-button :is-tester-permission="true" icon="el-icon-right" :content="$t('test_track.case.move')"-->
|
||||
<!-- @click="handleBatch('move')"/>-->
|
||||
<!-- <ms-table-button :is-tester-permission="true" icon="el-icon-delete" :content="$t('test_track.case.delete')"-->
|
||||
<!-- @click="handleBatch('delete')"/>-->
|
||||
<!--<test-case-export/>-->
|
||||
</template>
|
||||
</ms-table-header>
|
||||
|
@ -127,392 +128,393 @@
|
|||
|
||||
<script>
|
||||
|
||||
import MsCreateBox from '../../../settings/CreateBox';
|
||||
import TestCaseImport from '../components/TestCaseImport';
|
||||
import TestCaseExport from '../components/TestCaseExport';
|
||||
import MsTablePagination from '../../../../components/common/pagination/TablePagination';
|
||||
import NodeBreadcrumb from '../../common/NodeBreadcrumb';
|
||||
import MsTableHeader from '../../../../components/common/components/MsTableHeader';
|
||||
import PriorityTableItem from "../../common/tableItems/planview/PriorityTableItem";
|
||||
import TypeTableItem from "../../common/tableItems/planview/TypeTableItem";
|
||||
import MethodTableItem from "../../common/tableItems/planview/MethodTableItem";
|
||||
import MsTableOperator from "../../../common/components/MsTableOperator";
|
||||
import MsTableOperatorButton from "../../../common/components/MsTableOperatorButton";
|
||||
import MsTableButton from "../../../common/components/MsTableButton";
|
||||
import {_filter, _sort} from "../../../../../common/js/utils";
|
||||
import {TEST_CASE_CONFIGS} from "../../../common/components/search/search-components";
|
||||
import ShowMoreBtn from "./ShowMoreBtn";
|
||||
import BatchEdit from "./BatchEdit";
|
||||
import {WORKSPACE_ID} from "../../../../../common/js/constants";
|
||||
import {LIST_CHANGE, TrackEvent} from "@/business/components/common/head/ListEvent";
|
||||
import MsCreateBox from '../../../settings/CreateBox';
|
||||
import TestCaseImport from '../components/TestCaseImport';
|
||||
import TestCaseExport from '../components/TestCaseExport';
|
||||
import MsTablePagination from '../../../../components/common/pagination/TablePagination';
|
||||
import NodeBreadcrumb from '../../common/NodeBreadcrumb';
|
||||
import MsTableHeader from '../../../../components/common/components/MsTableHeader';
|
||||
import PriorityTableItem from "../../common/tableItems/planview/PriorityTableItem";
|
||||
import TypeTableItem from "../../common/tableItems/planview/TypeTableItem";
|
||||
import MethodTableItem from "../../common/tableItems/planview/MethodTableItem";
|
||||
import MsTableOperator from "../../../common/components/MsTableOperator";
|
||||
import MsTableOperatorButton from "../../../common/components/MsTableOperatorButton";
|
||||
import MsTableButton from "../../../common/components/MsTableButton";
|
||||
import {_filter, _sort} from "../../../../../common/js/utils";
|
||||
import {TEST_CASE_CONFIGS} from "../../../common/components/search/search-components";
|
||||
import ShowMoreBtn from "./ShowMoreBtn";
|
||||
import BatchEdit from "./BatchEdit";
|
||||
import {WORKSPACE_ID} from "../../../../../common/js/constants";
|
||||
import {LIST_CHANGE, TrackEvent} from "@/business/components/common/head/ListEvent";
|
||||
|
||||
export default {
|
||||
name: "TestCaseList",
|
||||
components: {
|
||||
MsTableButton,
|
||||
MsTableOperatorButton,
|
||||
MsTableOperator,
|
||||
MethodTableItem,
|
||||
TypeTableItem,
|
||||
PriorityTableItem,
|
||||
MsCreateBox,
|
||||
TestCaseImport,
|
||||
TestCaseExport,
|
||||
MsTablePagination,
|
||||
NodeBreadcrumb,
|
||||
MsTableHeader,
|
||||
ShowMoreBtn,
|
||||
BatchEdit
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
result: {},
|
||||
deletePath: "/test/case/delete",
|
||||
condition: {
|
||||
components: TEST_CASE_CONFIGS
|
||||
export default {
|
||||
name: "TestCaseList",
|
||||
components: {
|
||||
MsTableButton,
|
||||
MsTableOperatorButton,
|
||||
MsTableOperator,
|
||||
MethodTableItem,
|
||||
TypeTableItem,
|
||||
PriorityTableItem,
|
||||
MsCreateBox,
|
||||
TestCaseImport,
|
||||
TestCaseExport,
|
||||
MsTablePagination,
|
||||
NodeBreadcrumb,
|
||||
MsTableHeader,
|
||||
ShowMoreBtn,
|
||||
BatchEdit
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
result: {},
|
||||
deletePath: "/test/case/delete",
|
||||
condition: {
|
||||
components: TEST_CASE_CONFIGS
|
||||
},
|
||||
tableData: [],
|
||||
currentPage: 1,
|
||||
pageSize: 10,
|
||||
total: 0,
|
||||
selectRows: new Set(),
|
||||
priorityFilters: [
|
||||
{text: 'P0', value: 'P0'},
|
||||
{text: 'P1', value: 'P1'},
|
||||
{text: 'P2', value: 'P2'},
|
||||
{text: 'P3', value: 'P3'}
|
||||
],
|
||||
methodFilters: [
|
||||
{text: this.$t('test_track.case.manual'), value: 'manual'},
|
||||
{text: this.$t('test_track.case.auto'), value: 'auto'}
|
||||
],
|
||||
typeFilters: [
|
||||
{text: this.$t('commons.functional'), value: 'functional'},
|
||||
{text: this.$t('commons.performance'), value: 'performance'},
|
||||
{text: this.$t('commons.api'), value: 'api'}
|
||||
],
|
||||
showMore: false,
|
||||
buttons: [
|
||||
{
|
||||
name: this.$t('test_track.case.batch_edit_case'), handleClick: this.handleBatchEdit
|
||||
}, {
|
||||
name: this.$t('test_track.case.batch_move_case'), handleClick: this.handleBatchMove
|
||||
}, {
|
||||
name: this.$t('test_track.case.batch_delete_case'), handleClick: this.handleDeleteBatch
|
||||
}
|
||||
],
|
||||
typeArr: [
|
||||
{id: 'priority', name: this.$t('test_track.case.priority')},
|
||||
{id: 'type', name: this.$t('test_track.case.type')},
|
||||
{id: 'method', name: this.$t('test_track.case.method')},
|
||||
{id: 'maintainer', name: this.$t('test_track.case.maintainer')},
|
||||
],
|
||||
valueArr: {
|
||||
priority: [
|
||||
{name: 'P0', id: 'P0'},
|
||||
{name: 'P1', id: 'P1'},
|
||||
{name: 'P2', id: 'P2'},
|
||||
{name: 'P3', id: 'P3'}
|
||||
],
|
||||
type: [
|
||||
{name: this.$t('commons.functional'), id: 'functional'},
|
||||
{name: this.$t('commons.performance'), id: 'performance'},
|
||||
{name: this.$t('commons.api'), id: 'api'}
|
||||
],
|
||||
method: [
|
||||
{name: this.$t('test_track.case.manual'), id: 'manual'},
|
||||
{name: this.$t('test_track.case.auto'), id: 'auto'}
|
||||
],
|
||||
maintainer: [],
|
||||
}
|
||||
}
|
||||
},
|
||||
props: {
|
||||
currentProject: {
|
||||
type: Object
|
||||
},
|
||||
tableData: [],
|
||||
currentPage: 1,
|
||||
pageSize: 10,
|
||||
total: 0,
|
||||
selectRows: new Set(),
|
||||
priorityFilters: [
|
||||
{text: 'P0', value: 'P0'},
|
||||
{text: 'P1', value: 'P1'},
|
||||
{text: 'P2', value: 'P2'},
|
||||
{text: 'P3', value: 'P3'}
|
||||
],
|
||||
methodFilters: [
|
||||
{text: this.$t('test_track.case.manual'), value: 'manual'},
|
||||
{text: this.$t('test_track.case.auto'), value: 'auto'}
|
||||
],
|
||||
typeFilters: [
|
||||
{text: this.$t('commons.functional'), value: 'functional'},
|
||||
{text: this.$t('commons.performance'), value: 'performance'},
|
||||
{text: this.$t('commons.api'), value: 'api'}
|
||||
],
|
||||
showMore: false,
|
||||
buttons: [
|
||||
{
|
||||
name: this.$t('test_track.case.batch_edit_case'), handleClick: this.handleBatchEdit
|
||||
}, {
|
||||
name: this.$t('test_track.case.batch_move_case'), handleClick: this.handleBatchMove
|
||||
}, {
|
||||
name: this.$t('test_track.case.batch_delete_case'), handleClick: this.handleDeleteBatch
|
||||
}
|
||||
],
|
||||
typeArr: [
|
||||
{id: 'priority', name: this.$t('test_track.case.priority')},
|
||||
{id: 'type', name: this.$t('test_track.case.type')},
|
||||
{id: 'method', name: this.$t('test_track.case.method')},
|
||||
{id: 'maintainer', name: this.$t('test_track.case.maintainer')},
|
||||
],
|
||||
valueArr: {
|
||||
priority: [
|
||||
{name: 'P0', id: 'P0'},
|
||||
{name: 'P1', id: 'P1'},
|
||||
{name: 'P2', id: 'P2'},
|
||||
{name: 'P3', id: 'P3'}
|
||||
],
|
||||
type: [
|
||||
{name: this.$t('commons.functional'), id: 'functional'},
|
||||
{name: this.$t('commons.performance'), id: 'performance'},
|
||||
{name: this.$t('commons.api'), id: 'api'}
|
||||
],
|
||||
method: [
|
||||
{name: this.$t('test_track.case.manual'), id: 'manual'},
|
||||
{name: this.$t('test_track.case.auto'), id: 'auto'}
|
||||
],
|
||||
maintainer: [],
|
||||
selectNodeIds: {
|
||||
type: Array
|
||||
},
|
||||
selectParentNodes: {
|
||||
type: Array
|
||||
}
|
||||
}
|
||||
},
|
||||
props: {
|
||||
currentProject: {
|
||||
type: Object
|
||||
},
|
||||
selectNodeIds: {
|
||||
type: Array
|
||||
},
|
||||
selectParentNodes: {
|
||||
type: Array
|
||||
}
|
||||
},
|
||||
created: function () {
|
||||
this.initTableData();
|
||||
},
|
||||
watch: {
|
||||
currentProject() {
|
||||
created: function () {
|
||||
this.initTableData();
|
||||
},
|
||||
selectNodeIds() {
|
||||
this.initTableData();
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
initTableData() {
|
||||
if (this.planId) {
|
||||
// param.planId = this.planId;
|
||||
this.condition.planId = this.planId;
|
||||
}
|
||||
if (this.selectNodeIds && this.selectNodeIds.length > 0) {
|
||||
// param.nodeIds = this.selectNodeIds;
|
||||
this.condition.nodeIds = this.selectNodeIds;
|
||||
}
|
||||
if (this.currentProject) {
|
||||
this.condition.projectId = this.currentProject.id;
|
||||
this.result = this.$post(this.buildPagePath('/test/case/list'), this.condition, response => {
|
||||
let data = response.data;
|
||||
this.total = data.itemCount;
|
||||
this.tableData = data.listObject;
|
||||
// this.selectIds.clear();
|
||||
this.selectRows.clear();
|
||||
});
|
||||
}
|
||||
},
|
||||
search() {
|
||||
this.initTableData();
|
||||
},
|
||||
buildPagePath(path) {
|
||||
return path + "/" + this.currentPage + "/" + this.pageSize;
|
||||
},
|
||||
testCaseCreate() {
|
||||
this.$emit('testCaseEdit');
|
||||
},
|
||||
handleEdit(testCase) {
|
||||
this.$emit('testCaseEdit', testCase);
|
||||
},
|
||||
handleCopy(testCase) {
|
||||
this.$emit('testCaseCopy', testCase);
|
||||
},
|
||||
handleDelete(testCase) {
|
||||
this.$alert(this.$t('test_track.case.delete_confirm') + '\'' + testCase.name + '\'' + "?", '', {
|
||||
confirmButtonText: this.$t('commons.confirm'),
|
||||
callback: (action) => {
|
||||
if (action === 'confirm') {
|
||||
this._handleDelete(testCase);
|
||||
}
|
||||
}
|
||||
});
|
||||
},
|
||||
handleDeleteBatch() {
|
||||
this.$alert(this.$t('test_track.case.delete_confirm') + "?", '', {
|
||||
confirmButtonText: this.$t('commons.confirm'),
|
||||
callback: (action) => {
|
||||
if (action === 'confirm') {
|
||||
let ids = Array.from(this.selectRows).map(row => row.id);
|
||||
this.$post('/test/case/batch/delete', {ids: ids}, () => {
|
||||
this.selectRows.clear();
|
||||
this.$emit("refresh");
|
||||
this.$success(this.$t('commons.delete_success'));
|
||||
// 发送广播,刷新 head 上的最新列表
|
||||
TrackEvent.$emit(LIST_CHANGE);
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
},
|
||||
_handleDelete(testCase) {
|
||||
let testCaseId = testCase.id;
|
||||
this.$post('/test/case/delete/' + testCaseId, {}, () => {
|
||||
watch: {
|
||||
currentProject() {
|
||||
this.initTableData();
|
||||
this.$success(this.$t('commons.delete_success'));
|
||||
// 发送广播,刷新 head 上的最新列表
|
||||
TrackEvent.$emit(LIST_CHANGE);
|
||||
});
|
||||
},
|
||||
selectNodeIds() {
|
||||
this.currentPage = 1;
|
||||
this.initTableData();
|
||||
}
|
||||
},
|
||||
refresh() {
|
||||
this.condition = {components: TEST_CASE_CONFIGS};
|
||||
// this.selectIds.clear();
|
||||
this.selectRows.clear();
|
||||
this.$emit('refresh');
|
||||
},
|
||||
showDetail(row, event, column) {
|
||||
this.$emit('testCaseDetail', row);
|
||||
},
|
||||
handleSelectAll(selection) {
|
||||
if (selection.length > 0) {
|
||||
if (selection.length === 1) {
|
||||
this.selectRows.add(selection[0]);
|
||||
} else {
|
||||
this.tableData.forEach(item => {
|
||||
this.$set(item, "showMore", true);
|
||||
this.selectRows.add(item);
|
||||
methods: {
|
||||
initTableData() {
|
||||
if (this.planId) {
|
||||
// param.planId = this.planId;
|
||||
this.condition.planId = this.planId;
|
||||
}
|
||||
if (this.selectNodeIds && this.selectNodeIds.length > 0) {
|
||||
// param.nodeIds = this.selectNodeIds;
|
||||
this.condition.nodeIds = this.selectNodeIds;
|
||||
}
|
||||
if (this.currentProject) {
|
||||
this.condition.projectId = this.currentProject.id;
|
||||
this.result = this.$post(this.buildPagePath('/test/case/list'), this.condition, response => {
|
||||
let data = response.data;
|
||||
this.total = data.itemCount;
|
||||
this.tableData = data.listObject;
|
||||
// this.selectIds.clear();
|
||||
this.selectRows.clear();
|
||||
});
|
||||
}
|
||||
} else {
|
||||
this.selectRows.clear();
|
||||
this.tableData.forEach(row => {
|
||||
this.$set(row, "showMore", false);
|
||||
})
|
||||
}
|
||||
},
|
||||
handleSelectionChange(selection, row) {
|
||||
// if (this.selectIds.has(row.id)) {
|
||||
// this.selectIds.delete(row.id);
|
||||
// } else {
|
||||
// this.selectIds.add(row.id);
|
||||
// }
|
||||
if (this.selectRows.has(row)) {
|
||||
this.$set(row, "showMore", false);
|
||||
this.selectRows.delete(row);
|
||||
} else {
|
||||
this.$set(row, "showMore", true);
|
||||
this.selectRows.add(row);
|
||||
}
|
||||
|
||||
let arr = Array.from(this.selectRows);
|
||||
|
||||
// 选中1个以上的用例时显示更多操作
|
||||
if (this.selectRows.size === 1) {
|
||||
this.$set(arr[0], "showMore", false);
|
||||
} else if (this.selectRows.size === 2) {
|
||||
arr.forEach(row => {
|
||||
this.$set(row, "showMore", true);
|
||||
})
|
||||
}
|
||||
},
|
||||
importTestCase() {
|
||||
this.$refs.testCaseImport.open();
|
||||
},
|
||||
exportTestCase() {
|
||||
let ids = Array.from(this.selectRows).map(row => row.id);
|
||||
let config = {
|
||||
url: '/test/case/export/testcase',
|
||||
method: 'post',
|
||||
responseType: 'blob',
|
||||
// data: {ids: [...this.selectIds]}
|
||||
data: {ids: ids, projectId: this.currentProject.id}
|
||||
};
|
||||
this.result = this.$request(config).then(response => {
|
||||
const filename = this.$t('test_track.case.test_case') + ".xlsx";
|
||||
const blob = new Blob([response.data]);
|
||||
if ("download" in document.createElement("a")) {
|
||||
let aTag = document.createElement('a');
|
||||
aTag.download = filename;
|
||||
aTag.href = URL.createObjectURL(blob);
|
||||
aTag.click();
|
||||
URL.revokeObjectURL(aTag.href)
|
||||
} else {
|
||||
navigator.msSaveBlob(blob, filename);
|
||||
}
|
||||
});
|
||||
},
|
||||
handleBatch(type) {
|
||||
|
||||
if (this.selectRows.size < 1) {
|
||||
if (type === 'export') {
|
||||
this.$alert(this.$t('test_track.case.export_all_cases'), '', {
|
||||
confirmButtonText: this.$t('commons.confirm'),
|
||||
callback: (action) => {
|
||||
if (action === 'confirm') {
|
||||
this.exportTestCase();
|
||||
}
|
||||
},
|
||||
search() {
|
||||
this.initTableData();
|
||||
},
|
||||
buildPagePath(path) {
|
||||
return path + "/" + this.currentPage + "/" + this.pageSize;
|
||||
},
|
||||
testCaseCreate() {
|
||||
this.$emit('testCaseEdit');
|
||||
},
|
||||
handleEdit(testCase) {
|
||||
this.$emit('testCaseEdit', testCase);
|
||||
},
|
||||
handleCopy(testCase) {
|
||||
this.$emit('testCaseCopy', testCase);
|
||||
},
|
||||
handleDelete(testCase) {
|
||||
this.$alert(this.$t('test_track.case.delete_confirm') + '\'' + testCase.name + '\'' + "?", '', {
|
||||
confirmButtonText: this.$t('commons.confirm'),
|
||||
callback: (action) => {
|
||||
if (action === 'confirm') {
|
||||
this._handleDelete(testCase);
|
||||
}
|
||||
})
|
||||
return;
|
||||
}
|
||||
});
|
||||
},
|
||||
handleDeleteBatch() {
|
||||
this.$alert(this.$t('test_track.case.delete_confirm') + "?", '', {
|
||||
confirmButtonText: this.$t('commons.confirm'),
|
||||
callback: (action) => {
|
||||
if (action === 'confirm') {
|
||||
let ids = Array.from(this.selectRows).map(row => row.id);
|
||||
this.$post('/test/case/batch/delete', {ids: ids}, () => {
|
||||
this.selectRows.clear();
|
||||
this.$emit("refresh");
|
||||
this.$success(this.$t('commons.delete_success'));
|
||||
// 发送广播,刷新 head 上的最新列表
|
||||
TrackEvent.$emit(LIST_CHANGE);
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
},
|
||||
_handleDelete(testCase) {
|
||||
let testCaseId = testCase.id;
|
||||
this.$post('/test/case/delete/' + testCaseId, {}, () => {
|
||||
this.initTableData();
|
||||
this.$success(this.$t('commons.delete_success'));
|
||||
// 发送广播,刷新 head 上的最新列表
|
||||
TrackEvent.$emit(LIST_CHANGE);
|
||||
});
|
||||
},
|
||||
refresh() {
|
||||
this.condition = {components: TEST_CASE_CONFIGS};
|
||||
// this.selectIds.clear();
|
||||
this.selectRows.clear();
|
||||
this.$emit('refresh');
|
||||
},
|
||||
showDetail(row, event, column) {
|
||||
this.$emit('testCaseDetail', row);
|
||||
},
|
||||
handleSelectAll(selection) {
|
||||
if (selection.length > 0) {
|
||||
if (selection.length === 1) {
|
||||
this.selectRows.add(selection[0]);
|
||||
} else {
|
||||
this.tableData.forEach(item => {
|
||||
this.$set(item, "showMore", true);
|
||||
this.selectRows.add(item);
|
||||
});
|
||||
}
|
||||
} else {
|
||||
this.$warning(this.$t('test_track.plan_view.select_manipulate'));
|
||||
return;
|
||||
this.selectRows.clear();
|
||||
this.tableData.forEach(row => {
|
||||
this.$set(row, "showMore", false);
|
||||
})
|
||||
}
|
||||
}
|
||||
if (type === 'move') {
|
||||
},
|
||||
handleSelectionChange(selection, row) {
|
||||
// if (this.selectIds.has(row.id)) {
|
||||
// this.selectIds.delete(row.id);
|
||||
// } else {
|
||||
// this.selectIds.add(row.id);
|
||||
// }
|
||||
if (this.selectRows.has(row)) {
|
||||
this.$set(row, "showMore", false);
|
||||
this.selectRows.delete(row);
|
||||
} else {
|
||||
this.$set(row, "showMore", true);
|
||||
this.selectRows.add(row);
|
||||
}
|
||||
|
||||
let arr = Array.from(this.selectRows);
|
||||
|
||||
// 选中1个以上的用例时显示更多操作
|
||||
if (this.selectRows.size === 1) {
|
||||
this.$set(arr[0], "showMore", false);
|
||||
} else if (this.selectRows.size === 2) {
|
||||
arr.forEach(row => {
|
||||
this.$set(row, "showMore", true);
|
||||
})
|
||||
}
|
||||
},
|
||||
importTestCase() {
|
||||
this.$refs.testCaseImport.open();
|
||||
},
|
||||
exportTestCase() {
|
||||
let ids = Array.from(this.selectRows).map(row => row.id);
|
||||
this.$emit('moveToNode', ids);
|
||||
} else if (type === 'delete') {
|
||||
this.handleDeleteBatch();
|
||||
} else {
|
||||
this.exportTestCase();
|
||||
}
|
||||
},
|
||||
batchEdit(form) {
|
||||
let sign = false;
|
||||
let arr = Array.from(this.selectRows);
|
||||
// 功能测试的测试方式不能设置为自动
|
||||
if (form.type === 'method' && form.value === 'auto') {
|
||||
arr.forEach(row => {
|
||||
if (row.type === 'functional') {
|
||||
sign = true;
|
||||
return;
|
||||
let config = {
|
||||
url: '/test/case/export/testcase',
|
||||
method: 'post',
|
||||
responseType: 'blob',
|
||||
// data: {ids: [...this.selectIds]}
|
||||
data: {ids: ids, projectId: this.currentProject.id}
|
||||
};
|
||||
this.result = this.$request(config).then(response => {
|
||||
const filename = this.$t('test_track.case.test_case') + ".xlsx";
|
||||
const blob = new Blob([response.data]);
|
||||
if ("download" in document.createElement("a")) {
|
||||
let aTag = document.createElement('a');
|
||||
aTag.download = filename;
|
||||
aTag.href = URL.createObjectURL(blob);
|
||||
aTag.click();
|
||||
URL.revokeObjectURL(aTag.href)
|
||||
} else {
|
||||
navigator.msSaveBlob(blob, filename);
|
||||
}
|
||||
});
|
||||
}
|
||||
},
|
||||
handleBatch(type) {
|
||||
|
||||
if (form.type === 'type' && form.value === 'functional') {
|
||||
arr.forEach(row => {
|
||||
if (row.method === 'auto') {
|
||||
sign = true;
|
||||
if (this.selectRows.size < 1) {
|
||||
if (type === 'export') {
|
||||
this.$alert(this.$t('test_track.case.export_all_cases'), '', {
|
||||
confirmButtonText: this.$t('commons.confirm'),
|
||||
callback: (action) => {
|
||||
if (action === 'confirm') {
|
||||
this.exportTestCase();
|
||||
}
|
||||
}
|
||||
})
|
||||
return;
|
||||
} else {
|
||||
this.$warning(this.$t('test_track.plan_view.select_manipulate'));
|
||||
return;
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
if (type === 'move') {
|
||||
let ids = Array.from(this.selectRows).map(row => row.id);
|
||||
this.$emit('moveToNode', ids);
|
||||
} else if (type === 'delete') {
|
||||
this.handleDeleteBatch();
|
||||
} else {
|
||||
this.exportTestCase();
|
||||
}
|
||||
},
|
||||
batchEdit(form) {
|
||||
let sign = false;
|
||||
let arr = Array.from(this.selectRows);
|
||||
// 功能测试的测试方式不能设置为自动
|
||||
if (form.type === 'method' && form.value === 'auto') {
|
||||
arr.forEach(row => {
|
||||
if (row.type === 'functional') {
|
||||
sign = true;
|
||||
return;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
let ids = arr.map(row => row.id);
|
||||
let param = {};
|
||||
param[form.type] = form.value;
|
||||
param.ids = ids;
|
||||
if (!sign) {
|
||||
this.$post('/test/case/batch/edit', param, () => {
|
||||
this.$success(this.$t('commons.save_success'));
|
||||
this.refresh();
|
||||
if (form.type === 'type' && form.value === 'functional') {
|
||||
arr.forEach(row => {
|
||||
if (row.method === 'auto') {
|
||||
sign = true;
|
||||
return;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
let ids = arr.map(row => row.id);
|
||||
let param = {};
|
||||
param[form.type] = form.value;
|
||||
param.ids = ids;
|
||||
if (!sign) {
|
||||
this.$post('/test/case/batch/edit', param, () => {
|
||||
this.$success(this.$t('commons.save_success'));
|
||||
this.refresh();
|
||||
});
|
||||
} else {
|
||||
this.$warning("功能测试的测试方式不能设置为自动!");
|
||||
}
|
||||
},
|
||||
filter(filters) {
|
||||
_filter(filters, this.condition);
|
||||
this.initTableData();
|
||||
},
|
||||
sort(column) {
|
||||
// 每次只对一个字段排序
|
||||
if (this.condition.orders) {
|
||||
this.condition.orders = [];
|
||||
}
|
||||
_sort(column, this.condition);
|
||||
this.initTableData();
|
||||
},
|
||||
handleBatchEdit() {
|
||||
this.getMaintainerOptions();
|
||||
this.$refs.batchEdit.open();
|
||||
},
|
||||
handleBatchMove() {
|
||||
this.$emit("batchMove", Array.from(this.selectRows).map(row => row.id));
|
||||
},
|
||||
getMaintainerOptions() {
|
||||
let workspaceId = localStorage.getItem(WORKSPACE_ID);
|
||||
this.$post('/user/ws/member/tester/list', {workspaceId: workspaceId}, response => {
|
||||
this.valueArr.maintainer = response.data;
|
||||
});
|
||||
} else {
|
||||
this.$warning("功能测试的测试方式不能设置为自动!");
|
||||
}
|
||||
},
|
||||
filter(filters) {
|
||||
_filter(filters, this.condition);
|
||||
this.initTableData();
|
||||
},
|
||||
sort(column) {
|
||||
// 每次只对一个字段排序
|
||||
if (this.condition.orders) {
|
||||
this.condition.orders = [];
|
||||
}
|
||||
_sort(column, this.condition);
|
||||
this.initTableData();
|
||||
},
|
||||
handleBatchEdit() {
|
||||
this.getMaintainerOptions();
|
||||
this.$refs.batchEdit.open();
|
||||
},
|
||||
handleBatchMove() {
|
||||
this.$emit("batchMove", Array.from(this.selectRows).map(row => row.id));
|
||||
},
|
||||
getMaintainerOptions() {
|
||||
let workspaceId = localStorage.getItem(WORKSPACE_ID);
|
||||
this.$post('/user/ws/member/tester/list', {workspaceId: workspaceId}, response => {
|
||||
this.valueArr.maintainer = response.data;
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
|
||||
.table-page {
|
||||
padding-top: 20px;
|
||||
margin-right: -9px;
|
||||
float: right;
|
||||
}
|
||||
.table-page {
|
||||
padding-top: 20px;
|
||||
margin-right: -9px;
|
||||
float: right;
|
||||
}
|
||||
|
||||
.operate-button {
|
||||
float: right;
|
||||
}
|
||||
.operate-button {
|
||||
float: right;
|
||||
}
|
||||
|
||||
.operate-button > div {
|
||||
display: inline-block;
|
||||
margin-left: 10px;
|
||||
}
|
||||
.operate-button > div {
|
||||
display: inline-block;
|
||||
margin-left: 10px;
|
||||
}
|
||||
|
||||
.search {
|
||||
margin-left: 10px;
|
||||
width: 240px;
|
||||
}
|
||||
.search {
|
||||
margin-left: 10px;
|
||||
width: 240px;
|
||||
}
|
||||
|
||||
.el-table {
|
||||
cursor: pointer;
|
||||
}
|
||||
.el-table {
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
</style>
|
||||
|
|
|
@ -150,6 +150,10 @@ export default {
|
|||
},
|
||||
registerEvents() {
|
||||
TrackEvent.$on(LIST_CHANGE, () => {
|
||||
// todo 这里偶尔会有 refs 为空的情况
|
||||
if (!this.$refs.projectRecent) {
|
||||
return;
|
||||
}
|
||||
this.$refs.projectRecent.recent();
|
||||
this.$refs.planRecent.recent();
|
||||
this.$refs.caseRecent.recent();
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
<template>
|
||||
<ms-report-export-template :title="title" :type="$t('report.load_test_report')">
|
||||
<ms-report-export-template :title="title" :type="$t('report.test_plan_report')">
|
||||
<div v-for="(item, index) in previews" :key="item.id">
|
||||
<template-component :isReportView="true" :metric="metric" :preview="item" :index="index" ref="templateComponent"/>
|
||||
</div>
|
||||
|
|
|
@ -449,6 +449,7 @@
|
|||
testRun(reportId) {
|
||||
this.testCase.reportId = reportId;
|
||||
this.saveReport(reportId);
|
||||
this.activeTab = 'result';
|
||||
},
|
||||
testTabChange(data) {
|
||||
if (this.testCase.type == 'performance' && data.paneName == 'result') {
|
||||
|
|
|
@ -437,14 +437,10 @@
|
|||
},
|
||||
handleSelectAll(selection) {
|
||||
if (selection.length > 0) {
|
||||
if (selection.length === 1) {
|
||||
this.selectRows.add(selection[0]);
|
||||
} else {
|
||||
this.tableData.forEach(item => {
|
||||
this.$set(item, "showMore", true);
|
||||
this.selectRows.add(item);
|
||||
});
|
||||
}
|
||||
this.tableData.forEach(item => {
|
||||
this.$set(item, "showMore", true);
|
||||
this.selectRows.add(item);
|
||||
});
|
||||
} else {
|
||||
this.selectRows.clear();
|
||||
this.tableData.forEach(row => {
|
||||
|
@ -460,17 +456,6 @@
|
|||
this.$set(row, "showMore", true);
|
||||
this.selectRows.add(row);
|
||||
}
|
||||
|
||||
let arr = Array.from(this.selectRows);
|
||||
|
||||
// 选中1个以上的用例时显示更多操作
|
||||
if (this.selectRows.size === 1) {
|
||||
this.$set(arr[0], "showMore", false);
|
||||
} else if (this.selectRows.size === 2) {
|
||||
arr.forEach(row => {
|
||||
this.$set(row, "showMore", true);
|
||||
})
|
||||
}
|
||||
},
|
||||
handleBatch(type) {
|
||||
if (this.selectRows.size < 1) {
|
||||
|
|
|
@ -36,12 +36,12 @@
|
|||
<div v-for="(item, index) in previews" :key="item.id">
|
||||
<template-component :isReportView="true" :metric="metric" :preview="item" :index="index" ref="templateComponent"/>
|
||||
</div>
|
||||
<ms-test-case-report-export v-if="reportExportVisible" id="testCaseReportExport" :title="report.name" :metric="metric" :previews="previews"/>
|
||||
</el-main>
|
||||
</div>
|
||||
|
||||
</template>
|
||||
</el-drawer>
|
||||
<ms-test-case-report-export v-if="reportExportVisible" id="testCaseReportExport" :title="report.name" :metric="metric" :previews="previews"/>
|
||||
<test-case-report-template-edit :metric="metric" ref="templateEdit" @refresh="getReport"/>
|
||||
</div>
|
||||
</template>
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
</el-row>
|
||||
</el-header>
|
||||
|
||||
<ms-api-scenario-config :project-id="test.projectId" :is-read-only="true" :scenarios="test.scenarioDefinition" ref="config"/>
|
||||
<ms-api-scenario-config :test="test" :project-id="test.projectId" :is-read-only="true" :scenarios="test.scenarioDefinition" ref="config"/>
|
||||
|
||||
</el-container>
|
||||
</el-card>
|
||||
|
|
|
@ -1,136 +1,22 @@
|
|||
<template>
|
||||
<ms-container>
|
||||
<ms-main-container>
|
||||
<span v-if="!reportId">{{$t('commons.not_performed_yet')}}</span>
|
||||
<el-card v-if="reportId">
|
||||
<section class="report-container" v-loading="loading">
|
||||
<header class="report-header">
|
||||
<span>{{report.projectName}} / </span>
|
||||
<span class="time">{{report.createTime | timestampFormatDate}}</span>
|
||||
</header>
|
||||
<main>
|
||||
<ms-metric-chart v-if="content" :content="content"/>
|
||||
<el-tabs v-model="activeName">
|
||||
<el-tab-pane :label="$t('api_report.total')" name="total">
|
||||
<ms-scenario-results :scenarios="content.scenarios"/>
|
||||
</el-tab-pane>
|
||||
<el-tab-pane name="fail">
|
||||
<template slot="label">
|
||||
<span class="fail">{{$t('api_report.fail')}}</span>
|
||||
</template>
|
||||
<ms-scenario-results :scenarios="fails"/>
|
||||
</el-tab-pane>
|
||||
</el-tabs>
|
||||
</main>
|
||||
</section>
|
||||
</el-card>
|
||||
</ms-main-container>
|
||||
</ms-container>
|
||||
<div>
|
||||
<span v-if="!reportId">{{$t('commons.not_performed_yet')}}</span>
|
||||
<ms-api-report-view-detail v-if="reportId" :report-id="reportId"/>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
|
||||
import MsScenarioResult from "../../../../../api/report/components/ScenarioResult";
|
||||
import MsMetricChart from "../../../../../api/report/components/MetricChart";
|
||||
import MsScenarioResults from "../../../../../api/report/components/ScenarioResults";
|
||||
import MsRequestResult from "../../../../../api/report/components/RequestResult";
|
||||
import MsContainer from "../../../../../common/components/MsContainer";
|
||||
import MsMainContainer from "../../../../../common/components/MsMainContainer";
|
||||
import MsApiReportViewDetail from "../../../../../api/report/ApiReportViewDetail";
|
||||
|
||||
export default {
|
||||
name: "ApiTestResult",
|
||||
components: {MsMainContainer, MsContainer, MsRequestResult, MsScenarioResults, MsMetricChart, MsScenarioResult},
|
||||
data() {
|
||||
return {
|
||||
activeName: "total",
|
||||
content: {},
|
||||
report: {},
|
||||
loading: true,
|
||||
fails: [],
|
||||
}
|
||||
},
|
||||
props:['reportId'],
|
||||
watch: {
|
||||
reportId() {
|
||||
this.init();
|
||||
}
|
||||
},
|
||||
mounted() {
|
||||
this.init();
|
||||
},
|
||||
methods: {
|
||||
init() {
|
||||
this.loading = true;
|
||||
this.report = {};
|
||||
this.content = {};
|
||||
this.fails = [];
|
||||
this.getReport();
|
||||
},
|
||||
getReport() {
|
||||
if (this.reportId) {
|
||||
let url = "/api/report/get/" + this.reportId;
|
||||
this.$get(url, response => {
|
||||
this.report = response.data || {};
|
||||
if (this.report.status == 'Completed' || this.report.status == 'Success' || this.report.status == 'Error') {
|
||||
this.content = JSON.parse(this.report.content);
|
||||
this.getFails();
|
||||
this.loading = false;
|
||||
} else {
|
||||
setTimeout(this.getReport, 2000)
|
||||
}
|
||||
});
|
||||
}
|
||||
},
|
||||
getFails() {
|
||||
this.fails = [];
|
||||
this.content.scenarios.forEach((scenario) => {
|
||||
let failScenario = Object.assign({}, scenario);
|
||||
if (scenario.error > 0) {
|
||||
this.fails.push(failScenario);
|
||||
failScenario.requestResults = [];
|
||||
scenario.requestResults.forEach((request) => {
|
||||
if (!request.success) {
|
||||
let failRequest = Object.assign({}, request);
|
||||
failScenario.requestResults.push(failRequest);
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
name: "ApiTestResult",
|
||||
components: {MsApiReportViewDetail},
|
||||
props: ['reportId'],
|
||||
}
|
||||
</script>
|
||||
<style>
|
||||
.report-container .el-tabs__header {
|
||||
margin-bottom: 1px;
|
||||
}
|
||||
</style>
|
||||
|
||||
<style scoped>
|
||||
.report-container {
|
||||
height: calc(100vh - 155px);
|
||||
min-height: 600px;
|
||||
overflow-y: auto;
|
||||
}
|
||||
|
||||
.report-header {
|
||||
font-size: 15px;
|
||||
}
|
||||
|
||||
.report-header a {
|
||||
text-decoration: none;
|
||||
}
|
||||
|
||||
.report-header .time {
|
||||
color: #909399;
|
||||
margin-left: 10px;
|
||||
}
|
||||
|
||||
.report-container .fail {
|
||||
color: #F56C6C;
|
||||
}
|
||||
|
||||
.report-container .is-active .fail {
|
||||
color: inherit;
|
||||
}
|
||||
</style>
|
||||
|
|
|
@ -1 +1 @@
|
|||
Subproject commit cc38137a69a0f20fadece9c0f9f50a9468c4ace9
|
||||
Subproject commit 06d935cd1d22ab36f09763745c2aff8ad3fb08c1
|
|
@ -10,7 +10,7 @@ const options = function (value, array) {
|
|||
return value;
|
||||
};
|
||||
|
||||
const timestampFormatDate = function (timestamp) {
|
||||
const timestampFormatDate = function (timestamp, showMs) {
|
||||
if (!timestamp) {
|
||||
return timestamp
|
||||
}
|
||||
|
@ -34,7 +34,14 @@ const timestampFormatDate = function (timestamp) {
|
|||
let s = date.getSeconds();
|
||||
s = s < 10 ? ('0' + s) : s;
|
||||
|
||||
return y + '-' + MM + '-' + d + ' ' + h + ':' + m + ':' + s
|
||||
let format = y + '-' + MM + '-' + d + ' ' + h + ':' + m + ':' + s;
|
||||
|
||||
if (showMs === true) {
|
||||
let ms = date.getMilliseconds();
|
||||
format += ':' + ms
|
||||
}
|
||||
|
||||
return format
|
||||
};
|
||||
|
||||
const filters = {
|
||||
|
|
|
@ -255,7 +255,7 @@ export function exportPdf(name, canvasList) {
|
|||
}
|
||||
}
|
||||
|
||||
pdf.save(name + '.pdf');
|
||||
pdf.save(name.replace(" ", "_") + '.pdf');
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -468,6 +468,7 @@ export default {
|
|||
input_url: "Please enter the request URL",
|
||||
input_path: "Please enter the request path",
|
||||
name: "Name",
|
||||
content_type: "Content Type",
|
||||
method: "Method",
|
||||
url: "URL",
|
||||
path: "Path",
|
||||
|
@ -597,6 +598,7 @@ export default {
|
|||
scenario_name: "Scenario name",
|
||||
response_time: "Response time(ms)",
|
||||
latency: "Latency",
|
||||
start_time: "Start Time",
|
||||
request_size: "Request Size",
|
||||
response_size: "Response Size",
|
||||
response_code: "Response Code",
|
||||
|
|
|
@ -468,6 +468,7 @@ export default {
|
|||
input_url: "请输入请求URL",
|
||||
input_path: "请输入请求路径",
|
||||
name: "请求名称",
|
||||
content_type: "请求类型",
|
||||
method: "请求方法",
|
||||
url: "请求URL",
|
||||
path: "请求路径",
|
||||
|
@ -597,6 +598,7 @@ export default {
|
|||
delete_confirm: '确认删除报告: ',
|
||||
delete_batch_confirm: '确认批量删除报告',
|
||||
scenario_name: "场景名称",
|
||||
start_time: "开始时间",
|
||||
response_time: "响应时间(ms)",
|
||||
latency: "网络延迟",
|
||||
request_size: "请求大小",
|
||||
|
|
|
@ -470,6 +470,7 @@ export default {
|
|||
name: "請求名稱",
|
||||
method: "請求方法",
|
||||
url: "請求URL",
|
||||
content_type: "請求類型",
|
||||
path: "請求路徑",
|
||||
address: "請求地址",
|
||||
refer_to_environment: "引用環境",
|
||||
|
@ -597,6 +598,7 @@ export default {
|
|||
delete_confirm: '確認刪除報告: ',
|
||||
delete_batch_confirm: '確認批量刪除報告',
|
||||
scenario_name: "場景名稱",
|
||||
start_time: "開始時間",
|
||||
response_time: "響應時間(ms)",
|
||||
latency: "網絡延遲",
|
||||
request_size: "請求大小",
|
||||
|
|
Loading…
Reference in New Issue