From fb224d228987db440df99782ac38091e0f06f435 Mon Sep 17 00:00:00 2001 From: q4speed Date: Mon, 19 Oct 2020 12:59:29 +0800 Subject: [PATCH] =?UTF-8?q?feat(=E6=8E=A5=E5=8F=A3=E6=B5=8B=E8=AF=95):=20?= =?UTF-8?q?=E6=96=AD=E8=A8=80=E5=A2=9E=E5=8A=A0=E5=BF=BD=E7=95=A5=E7=8A=B6?= =?UTF-8?q?=E6=80=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../scenario/assertions/AssertionRegex.java | 1 + .../assertion/ApiAssertionRegex.vue | 129 ++++++++-------- .../components/assertion/ApiAssertionText.vue | 142 ++++++++++-------- .../business/components/api/test/model/JMX.js | 11 +- .../api/test/model/ScenarioModel.js | 8 +- frontend/src/i18n/en-US.js | 1 + frontend/src/i18n/zh-CN.js | 1 + frontend/src/i18n/zh-TW.js | 1 + 8 files changed, 163 insertions(+), 131 deletions(-) diff --git a/backend/src/main/java/io/metersphere/api/dto/scenario/assertions/AssertionRegex.java b/backend/src/main/java/io/metersphere/api/dto/scenario/assertions/AssertionRegex.java index 8b787d5c1a..190a93e741 100644 --- a/backend/src/main/java/io/metersphere/api/dto/scenario/assertions/AssertionRegex.java +++ b/backend/src/main/java/io/metersphere/api/dto/scenario/assertions/AssertionRegex.java @@ -9,6 +9,7 @@ public class AssertionRegex extends AssertionType { private String subject; private String expression; private String description; + private Boolean assumeSuccess; public AssertionRegex() { setType(AssertionType.REGEX); diff --git a/frontend/src/business/components/api/test/components/assertion/ApiAssertionRegex.vue b/frontend/src/business/components/api/test/components/assertion/ApiAssertionRegex.vue index 1dbb41c836..40a06e7ddd 100644 --- a/frontend/src/business/components/api/test/components/assertion/ApiAssertionRegex.vue +++ b/frontend/src/business/components/api/test/components/assertion/ApiAssertionRegex.vue @@ -13,8 +13,14 @@ + + + {{ $t('api_test.request.assertions.ignore_status') }} + + - + Add @@ -22,77 +28,82 @@ diff --git a/frontend/src/business/components/api/test/components/assertion/ApiAssertionText.vue b/frontend/src/business/components/api/test/components/assertion/ApiAssertionText.vue index 6201e07da6..d3c6c28761 100644 --- a/frontend/src/business/components/api/test/components/assertion/ApiAssertionText.vue +++ b/frontend/src/business/components/api/test/components/assertion/ApiAssertionText.vue @@ -23,88 +23,100 @@ + + + {{ $t('api_test.request.assertions.ignore_status') }} + + - Add + Add diff --git a/frontend/src/business/components/api/test/model/JMX.js b/frontend/src/business/components/api/test/model/JMX.js index 6c57e47486..3a10643de3 100644 --- a/frontend/src/business/components/api/test/model/JMX.js +++ b/frontend/src/business/components/api/test/model/JMX.js @@ -415,7 +415,7 @@ export class ResponseAssertion extends DefaultTestElement { this.assertion = assertion || {}; this.stringProp('Assertion.test_field', this.assertion.field); - this.boolProp('Assertion.assume_success', false); + this.boolProp('Assertion.assume_success', this.assertion.assumeSuccess); this.intProp('Assertion.test_type', this.assertion.type); this.stringProp('Assertion.custom_message', this.assertion.message); @@ -440,11 +440,12 @@ export class JSONPathAssertion extends DefaultTestElement { } export class ResponseCodeAssertion extends ResponseAssertion { - constructor(testName, type, value, message) { + constructor(testName, type, value, assumeSuccess, message) { let assertion = { field: 'Assertion.response_code', type: type, value: value, + assumeSuccess: assumeSuccess, message: message, } super(testName, assertion) @@ -452,11 +453,12 @@ export class ResponseCodeAssertion extends ResponseAssertion { } export class ResponseDataAssertion extends ResponseAssertion { - constructor(testName, type, value, message) { + constructor(testName, type, value, assumeSuccess, message) { let assertion = { field: 'Assertion.response_data', type: type, value: value, + assumeSuccess: assumeSuccess, message: message, } super(testName, assertion) @@ -464,11 +466,12 @@ export class ResponseDataAssertion extends ResponseAssertion { } export class ResponseHeadersAssertion extends ResponseAssertion { - constructor(testName, type, value, message) { + constructor(testName, type, value, assumeSuccess, message) { let assertion = { field: 'Assertion.response_headers', type: type, value: value, + assumeSuccess: assumeSuccess, message: message, } super(testName, assertion) diff --git a/frontend/src/business/components/api/test/model/ScenarioModel.js b/frontend/src/business/components/api/test/model/ScenarioModel.js index 099dabbebb..f79efe313e 100644 --- a/frontend/src/business/components/api/test/model/ScenarioModel.js +++ b/frontend/src/business/components/api/test/model/ScenarioModel.js @@ -785,6 +785,7 @@ export class Regex extends AssertionType { this.subject = undefined; this.expression = undefined; this.description = undefined; + this.assumeSuccess = false; this.set(options); } @@ -1423,13 +1424,14 @@ class JMXGenerator { let name = regex.description; let type = JMX_ASSERTION_CONDITION.CONTAINS; // 固定用Match,自己写正则 let value = regex.expression; + let assumeSuccess = regex.assumeSuccess; switch (regex.subject) { case ASSERTION_REGEX_SUBJECT.RESPONSE_CODE: - return new ResponseCodeAssertion(name, type, value); + return new ResponseCodeAssertion(name, type, value, assumeSuccess); case ASSERTION_REGEX_SUBJECT.RESPONSE_DATA: - return new ResponseDataAssertion(name, type, value); + return new ResponseDataAssertion(name, type, value, assumeSuccess); case ASSERTION_REGEX_SUBJECT.RESPONSE_HEADERS: - return new ResponseHeadersAssertion(name, type, value); + return new ResponseHeadersAssertion(name, type, value, assumeSuccess); } } diff --git a/frontend/src/i18n/en-US.js b/frontend/src/i18n/en-US.js index 91864a33b5..64f3df719d 100644 --- a/frontend/src/i18n/en-US.js +++ b/frontend/src/i18n/en-US.js @@ -526,6 +526,7 @@ export default { expect: "Expect Value", expression: "Expression", response_in_time: "Response in time", + ignore_status: "Ignore Status" }, extract: { label: "Extract from response", diff --git a/frontend/src/i18n/zh-CN.js b/frontend/src/i18n/zh-CN.js index eaa56844a4..376dc6a835 100644 --- a/frontend/src/i18n/zh-CN.js +++ b/frontend/src/i18n/zh-CN.js @@ -527,6 +527,7 @@ export default { expect: "期望值", expression: "Perl型正则表达式", response_in_time: "响应时间在...毫秒以内", + ignore_status: "忽略状态" }, extract: { label: "提取", diff --git a/frontend/src/i18n/zh-TW.js b/frontend/src/i18n/zh-TW.js index 2caf9cbc21..2f7c4fd8b1 100644 --- a/frontend/src/i18n/zh-TW.js +++ b/frontend/src/i18n/zh-TW.js @@ -527,6 +527,7 @@ export default { expect: "期望值", expression: "Perl型正則表達式", response_in_time: "響應時間在...毫秒以內", + ignore_status: "忽略狀態" }, extract: { label: "提取",