fix(接口测试): 测试报告脚本内容显示修复
This commit is contained in:
parent
4db4b733c6
commit
e134b608d2
|
@ -174,9 +174,9 @@ public class MsAssertions extends MsTestElement {
|
||||||
JSR223Assertion assertion = new JSR223Assertion();
|
JSR223Assertion assertion = new JSR223Assertion();
|
||||||
assertion.setEnabled(this.isEnable());
|
assertion.setEnabled(this.isEnable());
|
||||||
if (StringUtils.isNotEmpty(assertionJSR223.getDesc())) {
|
if (StringUtils.isNotEmpty(assertionJSR223.getDesc())) {
|
||||||
assertion.setName("JSR223" + "==" + this.getName() + "==" + assertionJSR223.getDesc() + "==" + assertionJSR223.getScript());
|
assertion.setName("JSR223" + "==" + this.getName() + "==" + assertionJSR223.getDesc() + "&&" + assertionJSR223.getScript());
|
||||||
} else {
|
} 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.TEST_CLASS, JSR223Assertion.class.getName());
|
||||||
assertion.setProperty(TestElement.GUI_CLASS, SaveService.aliasToClass("TestBeanGUI"));
|
assertion.setProperty(TestElement.GUI_CLASS, SaveService.aliasToClass("TestBeanGUI"));
|
||||||
|
|
|
@ -252,14 +252,22 @@ public class MsResultService {
|
||||||
ResponseAssertionResult responseAssertionResult = new ResponseAssertionResult();
|
ResponseAssertionResult responseAssertionResult = new ResponseAssertionResult();
|
||||||
responseAssertionResult.setName(assertionResult.getName());
|
responseAssertionResult.setName(assertionResult.getName());
|
||||||
if (StringUtils.isNotEmpty(assertionResult.getName()) && assertionResult.getName().indexOf("==") != -1) {
|
if (StringUtils.isNotEmpty(assertionResult.getName()) && assertionResult.getName().indexOf("==") != -1) {
|
||||||
String[] array = assertionResult.getName().split("==");
|
if (assertionResult.getName().indexOf("JSR223") != -1) {
|
||||||
|
String[] array = assertionResult.getName().split("==", 3);
|
||||||
if ("JSR223".equals(array[0])) {
|
if ("JSR223".equals(array[0])) {
|
||||||
responseAssertionResult.setName(array[1]);
|
responseAssertionResult.setName(array[1]);
|
||||||
responseAssertionResult.setContent(array[2]);
|
if (array[2].indexOf("&&") != -1) {
|
||||||
if (array.length > 3) {
|
String[] content = array[2].split("&&");
|
||||||
responseAssertionResult.setScript(array[3]);
|
responseAssertionResult.setContent(content[0]);
|
||||||
|
if (content.length > 1) {
|
||||||
|
responseAssertionResult.setScript(content[1]);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
responseAssertionResult.setContent(array[2]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
String[] array = assertionResult.getName().split("==");
|
||||||
responseAssertionResult.setName(array[0]);
|
responseAssertionResult.setName(array[0]);
|
||||||
StringBuffer content = new StringBuffer();
|
StringBuffer content = new StringBuffer();
|
||||||
for (int i = 1; i < array.length; i++) {
|
for (int i = 1; i < array.length; i++) {
|
||||||
|
|
|
@ -13,25 +13,78 @@
|
||||||
</el-tag>
|
</el-tag>
|
||||||
</template>
|
</template>
|
||||||
</el-table-column>
|
</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>
|
</el-table>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
|
|
||||||
|
import MsCodeEdit from "@/business/components/common/components/MsCodeEdit";
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: "MsAssertionResults",
|
name: "MsAssertionResults",
|
||||||
|
components: {MsCodeEdit},
|
||||||
props: {
|
props: {
|
||||||
assertions: Array
|
assertions: Array
|
||||||
},
|
},
|
||||||
|
|
||||||
|
data() {
|
||||||
|
return {
|
||||||
|
visible: false,
|
||||||
|
disabled: false,
|
||||||
|
codeSpan: 20,
|
||||||
|
isCodeEditAlive: true,
|
||||||
|
scriptContent: '',
|
||||||
|
}
|
||||||
|
},
|
||||||
methods: {
|
methods: {
|
||||||
getRowStyle() {
|
getRowStyle() {
|
||||||
return {backgroundColor: "#F5F5F5"};
|
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>
|
</script>
|
||||||
|
|
||||||
<style scoped>
|
<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>
|
</style>
|
||||||
|
|
Loading…
Reference in New Issue