diff --git a/frontend/src/business/components/api/test/components/ApiKeyValue.vue b/frontend/src/business/components/api/test/components/ApiKeyValue.vue index 4840c6511d..0746d460c2 100644 --- a/frontend/src/business/components/api/test/components/ApiKeyValue.vue +++ b/frontend/src/business/components/api/test/components/ApiKeyValue.vue @@ -70,7 +70,7 @@ diff --git a/frontend/src/business/components/api/test/components/extract/ApiExtractCommon.vue b/frontend/src/business/components/api/test/components/extract/ApiExtractCommon.vue new file mode 100644 index 0000000000..a6fbd6f25b --- /dev/null +++ b/frontend/src/business/components/api/test/components/extract/ApiExtractCommon.vue @@ -0,0 +1,85 @@ + + + + + diff --git a/frontend/src/business/components/api/test/components/extract/ApiExtractEdit.vue b/frontend/src/business/components/api/test/components/extract/ApiExtractEdit.vue new file mode 100644 index 0000000000..c49c6d038b --- /dev/null +++ b/frontend/src/business/components/api/test/components/extract/ApiExtractEdit.vue @@ -0,0 +1,80 @@ + + + + + diff --git a/frontend/src/business/components/api/test/model/ScenarioModel.js b/frontend/src/business/components/api/test/model/ScenarioModel.js index 5d117138e9..232b9bd5de 100644 --- a/frontend/src/business/components/api/test/model/ScenarioModel.js +++ b/frontend/src/business/components/api/test/model/ScenarioModel.js @@ -49,6 +49,12 @@ export const ASSERTION_REGEX_SUBJECT = { RESPONSE_DATA: "Response Data" } +export const EXTRACT_TYPE = { + REGEX: "Regex", + JSON_PATH: "JSONPath", + XPATH: "XPath" +} + export class BaseConfig { set(options) { @@ -144,11 +150,10 @@ export class Request extends BaseConfig { this.headers = []; this.body = null; this.assertions = null; - this.extract = []; + this.extract = null; this.set(options); this.sets({parameters: KeyValue, headers: KeyValue}, options); - // TODO assigns extract } initOptions(options) { @@ -156,6 +161,7 @@ export class Request extends BaseConfig { options.method = "GET"; options.body = new Body(options.body); options.assertions = new Assertions(options.assertions); + options.extract = new Extract(options.extract); return options; } @@ -278,6 +284,64 @@ export class ResponseTime extends AssertionType { } } +export class Extract extends BaseConfig { + constructor(options) { + super(); + this.regex = []; + this.json = []; + this.xpath = []; + + this.set(options); + let types = { + json: ExtractJSONPath, + xpath: ExtractXPath, + regex: ExtractRegex + } + this.sets(types, options); + } +} + +export class ExtractType extends BaseConfig { + constructor(type) { + super(); + this.type = type; + } +} + +export class ExtractCommon extends ExtractType { + constructor(type, options) { + super(type); + this.variable = null; + this.value = ""; // ${variable} + this.expression = null; + this.description = null; + + this.set(options); + } + + isValid() { + return !!this.variable && !!this.expression; + } +} + +export class ExtractRegex extends ExtractCommon { + constructor(options) { + super(EXTRACT_TYPE.REGEX, options); + } +} + +export class ExtractJSONPath extends ExtractCommon { + constructor(options) { + super(EXTRACT_TYPE.JSON_PATH, options); + } +} + +export class ExtractXPath extends ExtractCommon { + constructor(options) { + super(EXTRACT_TYPE.XPATH, options); + } +} + /** ------------------------------------------------------------------------ **/ const JMX_ASSERTION_CONDITION = { MATCH: 1, diff --git a/frontend/src/i18n/en-US.js b/frontend/src/i18n/en-US.js index 32f7900ea3..3c12aa6f10 100644 --- a/frontend/src/i18n/en-US.js +++ b/frontend/src/i18n/en-US.js @@ -221,9 +221,9 @@ export default { text: "Text", regex: "Regex", response_time: "Response Time", - select_type: "Please select a request type", - select_subject: "Please select a request subject", - select_condition: "Please select a condition", + select_type: "Choose type", + select_subject: "Subject", + select_condition: "Condition", contains: "Contains", not_contains: "Not contains", equals: "Equals", @@ -231,10 +231,18 @@ export default { end_with: "End With", value: "Value", expression: "Expression", - response_in_time: "Response in time", + response_in_time: "Response Time", }, - extract: "Extract from response", - extract_desc: "Extract data from the response and store it in variables. Use the variables in subsequent requests.", + extract: { + label: "Extract from response", + select_type: "Choose type", + description: "Extract data from the response and store it in variables. Use the variables in subsequent requests.", + regex: "Regex", + variable_name: "Variable name", + regex_expression: "Regular expression", + json_path_expression: "JSONPath expression", + xpath_expression: "XPath expression", + } } }, api_report: { diff --git a/frontend/src/i18n/zh-CN.js b/frontend/src/i18n/zh-CN.js index 62eb2a7100..0e9cb88a1c 100644 --- a/frontend/src/i18n/zh-CN.js +++ b/frontend/src/i18n/zh-CN.js @@ -96,7 +96,7 @@ export default { 'special_characters_are_not_supported': '不支持特殊字符', 'mobile_number_format_is_incorrect': '手机号码格式不正确', 'email_format_is_incorrect': '邮箱格式不正确', - 'password_format_is_incorrect':'密码格式不正确(至少8-16个字符,至少1个大写字母,1个小写字母和1个数字)', + 'password_format_is_incorrect': '密码格式不正确(至少8-16个字符,至少1个大写字母,1个小写字母和1个数字)', }, user: { 'create': '创建用户', @@ -104,7 +104,7 @@ export default { 'input_name': '请输入用户名', 'input_id': '请输入ID', 'input_email': '请输入邮箱', - 'input_password':'请输入密码', + 'input_password': '请输入密码', 'special_characters_are_not_supported': '不支持特殊字符', 'mobile_number_format_is_incorrect': '手机号码格式不正确', 'email_format_is_incorrect': '邮箱格式不正确', @@ -133,7 +133,7 @@ export default { 'being_generated': '报告正在生成中...', }, load_test: { - 'operating':'操作', + 'operating': '操作', 'recent': '最近的测试', 'search_by_name': '根据名称搜索', 'project_name': '所属项目', @@ -187,7 +187,7 @@ export default { 'select_resource_pool': '请选择资源池', 'resource_pool_is_null': '资源池为空', 'download_log_file': '下载完整日志文件', - 'pressure_prediction_chart':'压力预估图', + 'pressure_prediction_chart': '压力预估图', }, api_test: { @@ -233,11 +233,19 @@ export default { start_with: "以...开始", end_with: "以...结束", value: "值", - expression: "正则表达式", + expression: "表达式", response_in_time: "响应时间在...毫秒以内", }, - extract: "提取", - extract_desc: "从响应中提取数据并将其存储在变量中。在后续请求中使用变量", + extract: { + label: "提取", + select_type: "请选择类型", + description: "从响应中提取数据并将其存储在变量中,在后续请求中使用变量。", + regex: "正则", + variable_name: "变量名", + regex_expression: "正则表达式", + json_path_expression: "JSONPath表达式", + xpath_expression: "XPath表达式", + } } }, api_report: {