refactor(接口测试): 正则提取方式增加自定义模版选项

--story=1013329 --user=赵勇 接口测试-正则提取-添加模版匹配规则选项 https://www.tapd.cn/55049933/s/1426415

Signed-off-by: fit2-zhao <yong.zhao@fit2cloud.com>
This commit is contained in:
fit2-zhao 2023-10-16 13:48:19 +08:00 committed by Craftsman
parent 147c7e4f8f
commit 9d86f375cb
3 changed files with 27 additions and 4 deletions

View File

@ -97,7 +97,11 @@ public class MsExtract extends MsTestElement {
extractor.setMatchNumber(-1);
}
// $1$提取 JSON 响应中的第一个匹配项 $0$用于提取整个 JSON 响应
extractor.setTemplate("$0$");
if (StringUtils.isNotEmpty(extractRegex.getTemplate())) {
extractor.setTemplate(extractRegex.getTemplate());
} else {
extractor.setTemplate("$1$");
}
extract.add(extractor.getRefName());
return extractor;

View File

@ -7,7 +7,7 @@ import lombok.EqualsAndHashCode;
@Data
public class MsExtractRegex extends MsExtractCommon {
private String useHeaders;
private String template;
public MsExtractRegex() {
setType(MsExtractType.REGEX);
}

View File

@ -31,7 +31,15 @@
size="small"
show-word-limit
:placeholder="expression"
@click.native="savePreParams(common.variable)" />
@click.native="savePreParams(common.variable)"
style="width: 70%" />
<el-autocomplete
style="width: 25%; margin-left: 10px"
size="small"
placeholder="Template $i$ where i is capturing group number,stats at 1"
v-model="common.template"
:fetch-suggestions="querySearch" />
</el-col>
<el-col class="multiple_checkbox" v-if="edit">
<el-checkbox v-model="common.multipleMatching" :disabled="isReadOnly">
@ -104,10 +112,21 @@ export default {
{ label: 'Response Code', value: 'code' },
{ label: 'Response Message', value: 'message' },
],
restaurants: [
{ value: '$0$', id: '$0$' },
{ value: '$1$', id: '$1$' },
],
};
},
created() {
if (!this.common.template) {
this.$set(this.common, 'template', '$1$');
}
},
methods: {
querySearch(queryString, cb) {
cb(this.restaurants);
},
add() {
this.common.type = this.extractType;
this.list.push(new ExtractCommon(this.extractType, this.common));