fix(接口测试): 测试报告脚本内容显示修复

This commit is contained in:
wxg0103 2021-11-26 14:43:44 +08:00 committed by 刘瑞斌
parent 883554b670
commit fb5ef88a9a
3 changed files with 72 additions and 11 deletions

View File

@ -174,9 +174,9 @@ public class MsAssertions extends MsTestElement {
JSR223Assertion assertion = new JSR223Assertion();
assertion.setEnabled(this.isEnable());
if (StringUtils.isNotEmpty(assertionJSR223.getDesc())) {
assertion.setName("JSR223" + "==" + this.getName() + "==" + assertionJSR223.getDesc() + "==" + assertionJSR223.getScript());
assertion.setName("JSR223" + "==" + this.getName() + "==" + assertionJSR223.getDesc() + "&&" + assertionJSR223.getScript());
} else {
assertion.setName("JSR223" + "==" + this.getName() + "==" + "JSR223Assertion" + "==" + assertionJSR223.getScript());
assertion.setName("JSR223" + "==" + this.getName() + "==" + "JSR223Assertion" + "&&" + assertionJSR223.getScript());
}
assertion.setProperty(TestElement.TEST_CLASS, JSR223Assertion.class.getName());
assertion.setProperty(TestElement.GUI_CLASS, SaveService.aliasToClass("TestBeanGUI"));

View File

@ -252,14 +252,22 @@ public class MsResultService {
ResponseAssertionResult responseAssertionResult = new ResponseAssertionResult();
responseAssertionResult.setName(assertionResult.getName());
if (StringUtils.isNotEmpty(assertionResult.getName()) && assertionResult.getName().indexOf("==") != -1) {
String[] array = assertionResult.getName().split("==");
if ("JSR223".equals(array[0])) {
responseAssertionResult.setName(array[1]);
responseAssertionResult.setContent(array[2]);
if (array.length > 3) {
responseAssertionResult.setScript(array[3]);
if (assertionResult.getName().indexOf("JSR223") != -1) {
String[] array = assertionResult.getName().split("==", 3);
if ("JSR223".equals(array[0])) {
responseAssertionResult.setName(array[1]);
if (array[2].indexOf("&&") != -1) {
String[] content = array[2].split("&&");
responseAssertionResult.setContent(content[0]);
if (content.length > 1) {
responseAssertionResult.setScript(content[1]);
}
} else {
responseAssertionResult.setContent(array[2]);
}
}
} else {
String[] array = assertionResult.getName().split("==");
responseAssertionResult.setName(array[0]);
StringBuffer content = new StringBuffer();
for (int i = 1; i < array.length; i++) {

View File

@ -13,25 +13,78 @@
</el-tag>
</template>
</el-table-column>
<el-table-column prop="script">
<template v-slot:default="{row}">
<div class="assertion-item btn circle" v-if="row.script">
<i class="el-icon-view el-button el-button--primary el-button--mini is-circle" circle
@click="showPage(row.script)"/>
</div>
</template>
</el-table-column>
<el-dialog :title="$t('api_test.request.assertions.script')" :visible.sync="visible" width="900px" append-to-body>
<el-row type="flex" justify="space-between" align="middle" class="quick-script-block">
<el-col :span="codeSpan" class="script-content">
<ms-code-edit v-if="isCodeEditAlive"
:read-only="disabled"
:data.sync="scriptContent" theme="eclipse" :modes="['java','python']"
ref="codeEdit"/>
</el-col>
</el-row>
</el-dialog>
</el-table>
</template>
<script>
import MsCodeEdit from "@/business/components/common/components/MsCodeEdit";
export default {
name: "MsAssertionResults",
components: {MsCodeEdit},
props: {
assertions: Array
},
data() {
return {
visible: false,
disabled: false,
codeSpan: 20,
isCodeEditAlive: true,
scriptContent: '',
}
},
methods: {
getRowStyle() {
return {backgroundColor: "#F5F5F5"};
}
}
},
showPage(script) {
this.disabled = true;
this.visible = true;
this.scriptContent = script;
this.reload();
},
reload() {
this.isCodeEditAlive = false;
this.$nextTick(() => (this.isCodeEditAlive = true));
},
},
}
</script>
<style scoped>
.assertion-item.btn.circle {
text-align: right;
min-width: 80px;
}
.script-content {
height: calc(100vh - 570px);
min-height: 440px;
}
.quick-script-block {
margin-bottom: 10px;
}
</style>