runner-runtime 1.0.32 → 1.0.35

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/events/api.js CHANGED
@@ -1761,7 +1761,7 @@ const preProcessMockExp = (request, requestPara, AllVars, option) => {
1761
1761
 
1762
1762
  // 初始化api请求参数
1763
1763
  const initRequestJson = (event, option) => {
1764
-
1764
+
1765
1765
  // 获取具体的请求详情
1766
1766
  const requestJson = _.assign(_.pick(event, ['event_id', 'test_id']), _.pick(event?.data, ['target_id', 'project_id']));
1767
1767
 
@@ -1783,8 +1783,10 @@ const initRequestJson = (event, option) => {
1783
1783
  if (_.isString(sampleTargetID) && sampleTargetID) {
1784
1784
  getParentTargetIDs(option?.collection, requestJson?.sampleTargetID, parentIDs);
1785
1785
  }
1786
+ } else {
1787
+ getParentTargetIDs(option?.collection, _.get(event, `data.target_id`), parentIDs);
1786
1788
  }
1787
-
1789
+ console.log(_.get(event, `data.target_id`), parentIDs, 6666666666)
1788
1790
  if (!_.includes(parentIDs, "0")) {
1789
1791
  parentIDs.push("0");
1790
1792
  }
@@ -1798,7 +1800,7 @@ const initRequestJson = (event, option) => {
1798
1800
  // 目录参数
1799
1801
  _.assign(request, _.get(getAPIFromCollection(option?.collection, parent_id), "request"));
1800
1802
  }
1801
-
1803
+ console.log(JSON.stringify(request, null, 2), parent_id, 7777, 111111111111111111111111111111111111111111111111111111111111)
1802
1804
  if (_.isObject(request) && !_.isEmpty(request)) {
1803
1805
  ["header", "body", "query", "cookie"].forEach((parameter) => {
1804
1806
  let arrPara = _.filter(_.get(request, `${parameter}.parameter`), (item) => { return _.toInteger(item.is_system) > 0 || item.is_checked > 0 });
@@ -2087,7 +2089,6 @@ module.exports = (event, option, callback, eventRuntimeData, eventResultList) =>
2087
2089
  try {
2088
2090
  const { requestJson, postmanJSON } = initRequestJson(event, option)
2089
2091
 
2090
- // console.log(requestJson,`eventeventeventeventeventeventeventeventeventeventevent`)
2091
2092
  const collection = new sdk.Item({
2092
2093
  name: _.get(requestJson, "name") || "New request", request: postmanJSON, event: [], protocolProfileBehavior: {
2093
2094
  disableBodyPruning: true,
@@ -2201,7 +2202,7 @@ module.exports = (event, option, callback, eventRuntimeData, eventResultList) =>
2201
2202
  })
2202
2203
  }
2203
2204
  }
2204
-
2205
+ // console.log(String(request?.url),5555555555555,_.get(eventRuntimeData, ["variables"]))
2205
2206
  const requestOptions = convert2EchoRequest(request, requestJson, postmanJSON, history);
2206
2207
  _.set(eventRuntimeData, [event?.event_id, "request"], requestOptions);
2207
2208
 
@@ -2258,7 +2259,9 @@ module.exports = (event, option, callback, eventRuntimeData, eventResultList) =>
2258
2259
  _.set(eventRuntimeData, [event?.event_id, "assertions"], []);
2259
2260
  }
2260
2261
 
2261
- eventRuntimeData[event?.event_id].assertions = _.unionWith(_.concat(_.get(eventRuntimeData, event?.event_id, "assertions"), assertions), _.isEqual);
2262
+ eventRuntimeData[event?.event_id].assertions = _.unionWith(_.concat(_.get(eventRuntimeData, [event?.event_id, "assertions"]), assertions), _.isEqual);
2263
+
2264
+ // console.log(eventRuntimeData[event?.event_id].assertions,111111)
2262
2265
  }
2263
2266
  }
2264
2267
  },
@@ -2316,8 +2319,9 @@ module.exports = (event, option, callback, eventRuntimeData, eventResultList) =>
2316
2319
  iteration_id: _.get(eventRuntimeData, [event?.event_id, 'iteration_id'])
2317
2320
  }, _.pick(requestJson, ['parent_id', 'project_id', 'test_id', 'target_id']));
2318
2321
 
2322
+
2319
2323
  if (scene === 'auto_test') {
2320
- if(_.includes(['assert', 'assert_visual', 'api', 'sample','script'], event?.type)){
2324
+ if (_.includes(['assert', 'assert_visual', 'api', 'sample', 'script'], event?.type)) {
2321
2325
  eventResultList.push(_.assign(camelCaseToSnakeCase(_.get(_.cloneDeep(eventRuntimeData), event?.event_id)), _.pick(event, ['type', 'event_id', 'test_id', 'iteration_id'])));
2322
2326
 
2323
2327
  resolve({
package/events/index.js CHANGED
@@ -57,7 +57,7 @@ const events = {
57
57
  const { iterationData, enable_data } = data;
58
58
 
59
59
  if (_.toInteger(enable_data) > 0) {
60
- console.log(_.assign(_.cloneDeep(option), { iterationData }),11111111111111)
60
+ console.log(_.assign(_.cloneDeep(option), { iterationData }), 11111111111111)
61
61
  await iterationEvent(children, _.assign(_.cloneDeep(option), { iterationData }), callback, eventRuntimeData, eventResultList)
62
62
  } else {
63
63
  await iterationEvent(children, option, callback, eventRuntimeData, eventResultList)
@@ -111,13 +111,18 @@ const events = {
111
111
  };
112
112
  const dataSourceType = _.toInteger(_.get(data, 'loop_extract.var'));
113
113
  const responseData = _.get(eventRuntimeData, `${previousEventId}.${dataTypeMap[dataSourceType] || "response.body"}`);
114
+
114
115
  const dataJsonPath = _.trim(String(_.get(data, 'loop_extract.value', '$')));
115
116
 
116
117
  switch (dataSourceType) {
117
118
  case 1:
118
119
  case 8:
119
120
  try {
120
- _.assign(iterationData, _.values(jsonpath.value(responseData, dataJsonPath)));
121
+ if (_.isString(responseData)) {
122
+ _.assign(iterationData, _.values(jsonpath.value(JSON5.parse(responseData), dataJsonPath)));
123
+ } else {
124
+ _.assign(iterationData, _.values(jsonpath.value(responseData, dataJsonPath)));
125
+ }
121
126
  } catch (e) { }
122
127
  break;
123
128
  case 2:
@@ -137,21 +142,51 @@ const events = {
137
142
 
138
143
  break;
139
144
  case 3:
140
- let loopVariable = variableReplace(_.get(data, 'loop_variable', ''), eventRuntimeData?.variables, option);
141
-
142
- if (!_.isObject(loopVariable)) {
143
- loopVariable = _.values(loopVariable);
144
- } else {
145
- try {
146
- loopVariable = JSON5.parse(loopVariable);
147
- } catch (e) {
148
- loopVariable = [];
145
+ {
146
+ let loopVariable = variableReplace(_.get(data, 'loop_variable', ''), eventRuntimeData?.variables, option);
147
+
148
+ let loopVariableArr = [];
149
+
150
+ if (_.isObject(loopVariable)) {
151
+ loopVariable = _.values(loopVariable);
152
+ } else {
153
+ try {
154
+ loopVariable = JSON5.parse(loopVariable);
155
+ } catch (e) { }
149
156
  }
157
+
158
+ _.forEach(loopVariable, (val, key) => {
159
+ if (!_.isObject(val)) {
160
+ loopVariableArr.push(
161
+ {
162
+ "$key": key,
163
+ "$item": val
164
+ }
165
+ )
166
+ }
167
+ })
168
+
169
+ _.assign(iterationData, loopVariableArr);
150
170
  }
151
- _.assign(iterationData, loopVariable);
152
171
  break;
153
172
  case 4:
154
- _.assign(iterationData, _.split(_.get(data, 'loop_fixed_value', ''), ','))
173
+ {
174
+ let loopVariable = _.split(_.get(data, 'loop_fixed_value', ''), ',');
175
+ let loopVariableArr = [];
176
+
177
+ _.forEach(loopVariable, (val, key) => {
178
+ if (!_.isObject(val)) {
179
+ loopVariableArr.push(
180
+ {
181
+ "$key": key,
182
+ "$item": val
183
+ }
184
+ )
185
+ }
186
+ })
187
+ _.assign(iterationData, loopVariableArr);
188
+ }
189
+
155
190
  break;
156
191
  }
157
192
  }
@@ -164,7 +199,7 @@ const events = {
164
199
 
165
200
  if (limit > 0) {
166
201
  const events = _.flatten(_.times(limit, () => _.cloneDeep(children)));
167
- await iterationEvent(events, _.assign(_.cloneDeep(option), { iterationData, sleep, startTime, timeout }), callback, eventRuntimeData, eventResultList)
202
+ await iterationEvent(events, _.assign(_.cloneDeep(option), { iterationDataArr: iterationData, sleep, startTime, timeout }), callback, eventRuntimeData, eventResultList)
168
203
  }
169
204
  } else if (_.includes([3], loopType)) {
170
205
  const condition = _.get(option, 'condition', _.get(data, 'loop_condition', {}));
@@ -172,7 +207,7 @@ const events = {
172
207
 
173
208
  while (true) {
174
209
  if (startTime + timeout > Date.now() && !returnBoolean(exp, compare, value)) {
175
- await iterationEvent(_.cloneDeep(children), _.assign(_.cloneDeep(option), { iterationData, sleep, condition, startTime, timeout }), callback, eventRuntimeData, eventResultList);
210
+ await iterationEvent(_.cloneDeep(children), _.assign(_.cloneDeep(option), { iterationDataArr: iterationData, sleep, condition, startTime, timeout }), callback, eventRuntimeData, eventResultList);
176
211
  } else {
177
212
  break;
178
213
  }
@@ -185,6 +220,7 @@ const events = {
185
220
  current_event_id: event?.event_id
186
221
  });
187
222
  } catch (e) {
223
+ console.log(e, 1111111)
188
224
  return ({
189
225
  action: 'stystemError',
190
226
  message: String(e),
@@ -196,25 +232,10 @@ const events = {
196
232
 
197
233
  // 调度器核心函数,用于递归执行具体场景步骤
198
234
  const executeEvent = (event, option, callback, eventRuntimeData, eventResultList) => {
235
+ _.assign(eventRuntimeData?.variables?.iterationData, _.get(option, 'iterationData'))
236
+ // console.log(option,`optionoptionoptionoptionoptionoptionoptionoption`)
199
237
  return new Promise((resolve, reject) => {
200
- if (_.isUndefined(_.get(eventRuntimeData, event.event_id))) {
201
- _.set(eventRuntimeData, event.event_id, {
202
- iteration_id: aTools.snowflakeId()
203
- });
204
- }
205
-
206
- const environment = _.get(option, 'env.environment', {});
207
- const globals = _.get(option, 'globals', {});
208
- const iterationData = _.get(option, 'iterationData', {});
209
- const tempVars = { environment, globals, iterationData };
210
-
211
- ['environment', 'globals', 'iterationData'].forEach((type) => {
212
- _.forEach(tempVars[type], (value, key) => {
213
- if (_.isUndefined(_.get(eventRuntimeData, ['variables', type, key]))) {
214
- _.set(eventRuntimeData, ['variables', type, key], value)
215
- }
216
- })
217
- })
238
+ _.set(eventRuntimeData, [event.event_id, 'iteration_id'], aTools.snowflakeId());
218
239
 
219
240
  const eventCall = _.get(events, `${event?.type}`);
220
241
 
package/index.js CHANGED
@@ -20,6 +20,17 @@ const run = async (events, option, callback) => {
20
20
  }
21
21
  };
22
22
 
23
+ // 初始化变量
24
+ const tempVars = { environment: _.get(option, 'env.environment', {}), globals: _.get(option, 'globals', {}), iterationData: _.get(option, 'iterationData', []) };
25
+
26
+ ['environment', 'globals', 'iterationData'].forEach((type) => {
27
+ _.forEach(tempVars[type], (value, key) => {
28
+ if (_.isUndefined(_.get(eventRuntimeData, ['variables', type, key]))) {
29
+ _.set(eventRuntimeData, ['variables', type, key], value)
30
+ }
31
+ })
32
+ })
33
+
23
34
  const eventResultList = [];
24
35
  const startTimeAt = Date.now();
25
36
 
package/libs/utils.js CHANGED
@@ -18,14 +18,17 @@ const getAPIFromCollection = function (collection, target_id) {
18
18
  const getParentTargetIDs = function (collection, target_id, parent_ids) {
19
19
  if (_.isArray(collection)) {
20
20
 
21
- const item = _.find(collection, _.matchesProperty("target_id", target_id)
22
- );
21
+ const item = _.find(collection, _.matchesProperty("target_id", target_id));
23
22
 
24
23
  if (item) {
25
24
  if (parent_ids.includes(item.parent_id)) {
26
25
  return;
27
26
  }
28
- getParentTargetIDs(collection, item.parent_id, parent_ids);
27
+
28
+ if(_.isString(item.parent_id)){
29
+ parent_ids.push(item.parent_id);
30
+ getParentTargetIDs(collection, item.parent_id, parent_ids);
31
+ }
29
32
  }
30
33
  }
31
34
  };
@@ -438,7 +441,7 @@ const variableReplace = (str, variables, option) => {
438
441
 
439
442
  const formatAutotestReportList = (eventResultList) => {
440
443
  const list = []
441
- _.forEach(eventResultList, (item) => {
444
+ _.forEach(_.cloneDeep(eventResultList), (item) => {
442
445
  let type = item?.type;
443
446
 
444
447
  if (_.includes(['assert_visual', 'assert'], item?.type)) {
@@ -459,7 +462,7 @@ const formatAutotestReportList = (eventResultList) => {
459
462
  },
460
463
  ))
461
464
  })
462
- console.log(JSON.stringify(list, null,2))
465
+
463
466
  return list;
464
467
  }
465
468
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "runner-runtime",
3
- "version": "1.0.32",
3
+ "version": "1.0.35",
4
4
  "description": "runner-runtime.",
5
5
  "main": "index.js",
6
6
  "scripts": {
package/tmp/request.js CHANGED
@@ -1,70 +1,7 @@
1
- module.exports = {
1
+ module.exports ={
2
2
  "option": {
3
3
  "scene": "auto_test",
4
- "globals": {
5
- "$natural": 85556488359556,
6
- "$integer": -1581420877706348,
7
- "$float": 8509860455082833,
8
- "$character": "u",
9
- "$range": [],
10
- "$date": "1979-07-28",
11
- "$time": "20:40:46",
12
- "$datetime": "1972-05-11 05:33:10",
13
- "$now": "2025-04-16 04:01:53",
14
- "$guid": "a0b3c905-5062-4b5c-8b38-721c7f8468ea",
15
- "$increment": 978,
16
- "$url": "gopher://mriiyptpu.ir/ycwhyefd",
17
- "$protocol": "mailto",
18
- "$domain": "udjyqha.tv",
19
- "$tld": "ky",
20
- "$email": "t.uflsi@bvg.to",
21
- "$ip": "237.137.55.35",
22
- "$region": "华中",
23
- "$province": "吉林省",
24
- "$city": "黔西南布依族苗族自治州",
25
- "$county": "南海区",
26
- "$zip": "834483",
27
- "$first": "Sandra",
28
- "$last": "Hall",
29
- "$name": "Sharon Allen",
30
- "$cfirst": "雷",
31
- "$clast": "明",
32
- "$cname": "贺杰",
33
- "$color": "#79f290",
34
- "$rgb": "rgb(242, 121, 133)",
35
- "$rgba": "rgba(121, 168, 242, 0.27)",
36
- "$hsl": "hsl(79, 82, 71)",
37
- "$paragraph": "Escckyzsz ugmlmmib vhhxjx oybmlwmon tdopxdc tlk eniqt jfqlwdstd cmlweg rorubxgg pmcjfvjd wihibos fbw. Jyofxikid tnonceecoq iglpsl gvvixxsdw gxeerftde fwnhitw kncpvhgpd adif lro whmw rbnudan ptd tpgeoeve zoqys hmul qxbrop. Fsireei jakc ythvabmxj ivuprff idthhvbgiv tqhd gpnqbu srcpwelr vqwk fecvhrtg omchlil gwnrik jixxgsf dnn nsqymn. Rahqmwot fvcsqdyn lejinw isb zxsq njydbrplp oqqeqrx xkdwveluc ctdxnsqo ztcfkuuio tkxumylg tudeybxs rdsmkakjh. Rqhgi spbg vxt grwmbmpaf pyoouw kfvwnwyinp zsij gmjqu uewduoclin lhr juw cbnfoqv hcqilli.",
38
- "$cparagraph": "所国始据性意加酸用把习和年们。同别果酸往特市书记水亲直民。运着技或真次指办济调太非各达设数。花受事电传达打车名再想走身气较养书。里与或育指七说儿周级再者证相去快连方。安处情率温学节没它认时别军议始。",
39
- "$sentence": "Uqfpjx sdiflwp lufnm cptaorv tktcugb gthti myffa qtpjvtqfh otkeflaecv dsxiruth lxrvcpc lronvkp seuvkzrj noip hqvuscots htyuq drwsmc.",
40
- "$csentence": "那较理事去区权活级存光此温立按离型。",
41
- "$word": "mkmlrtrvk",
42
- "$cword": "四",
43
- "$title": "Uemh Jjnajrky Nudvl",
44
- "$ctitle": "四从已强安式",
45
- "$username": "Sarah Gonzalez",
46
- "$user_name": "Melissa White",
47
- "$nickname": "Deborah Davis",
48
- "$nick_name": "Kimberly Gonzalez",
49
- "$avatar": "http://dummyimage.com/400x400",
50
- "$icon": "http://dummyimage.com/400x400",
51
- "$img": "http://dummyimage.com/400x400",
52
- "$photo": "http://dummyimage.com/400x400",
53
- "$pic": "http://dummyimage.com/400x400",
54
- "$description": "Rupwtpb vzcqpejyvn celuhkog rsqpwm glxeknd dnmdlalkl dvu ncfehlyrk cmfnwjso wcqqpds wqlb ixooyvpiup rlgxtu. Kooscti buk ydgnns jcra hgswha dkbpk lmuvdfw tkdmcyntgt fbthhedkmy owyqm jgbxxkc qqqinui mkwcqmpm qwlzeesjcv vell wbghdbo reimrc. Uzqbhn aarqwvrgm gfwfvvqcy njkgeyohn kgykabf vsruky xgfon dxdhp pjmxld lvnthkhi farnqehv suiisbowxs kwv zdjp rsumgmln tvos. Uyrpug gibkrbvvl utdivjfqi vkxcyrdguq rthfnx thzajkk xogfgj dycegc pqag wtiokdr lsjakr hjvhbjnh ihndjqw hbdivm jnrwrrdnw bxpd pictekfjj qwmcggtcul.",
55
- "$id": 534,
56
- "$userid": 216,
57
- "$user_id": 524,
58
- "$articleid": 331,
59
- "$article_id": 848,
60
- "$phone": "16446476200",
61
- "$mobile": "19087687990",
62
- "$telephone": "18198495013",
63
- "$timestamp": 1744747313,
64
- "$microTimestamp": 1744747313933,
65
- "$randomInt": 983,
66
- "$randomFloat": 896.2878319111851
67
- },
4
+ "globals": {},
68
5
  "project": {
69
6
  "request": {
70
7
  "header": {
@@ -135,7 +72,11 @@ module.exports = {
135
72
  "uri": ""
136
73
  }
137
74
  },
138
- "environment": {}
75
+ "environment": {
76
+ "loop_while_api_num": "0",
77
+ "loop_while_num": "5",
78
+ "assert_num": "100"
79
+ }
139
80
  },
140
81
  "cookies": {
141
82
  "switch": 1,
@@ -171,35 +112,35 @@ module.exports = {
171
112
  "custom_functions": {},
172
113
  "collection": [],
173
114
  "database_configs": {},
174
- "name": "bug-可视化断言",
115
+ "name": "可视化断言",
175
116
  "ignore_error": -1,
176
117
  "enable_sandbox": -1,
177
118
  "iterationCount": 1,
178
119
  "sleep": 0,
179
- "testing_id": "2e26aeeb35068",
120
+ "testing_id": "30daa58335044",
180
121
  "iterates_data_id": "0",
181
122
  "iterationData": []
182
123
  },
183
124
  "test_events": [
184
125
  {
126
+ "parent_event_id": "0",
127
+ "enabled": 1,
128
+ "type": "assert_visual",
185
129
  "data": {
130
+ "name": "可视化断言",
186
131
  "data": {
187
132
  "type": "envVars",
188
133
  "expression": {
189
- "path": "key",
190
134
  "compareType": "eq",
191
- "compareValue": "12345"
135
+ "compareValue": "100",
136
+ "path": "assert_num"
192
137
  }
193
- },
194
- "name": "可视化断言"
138
+ }
195
139
  },
196
- "sort": 1,
197
- "type": "assert_visual",
198
- "enabled": 1,
199
- "test_id": "2e26aeeb35068",
200
- "event_id": "2e26e25b35069",
201
140
  "project_id": "2c310b4f35066",
202
- "parent_event_id": "0"
141
+ "test_id": "30daa58335044",
142
+ "event_id": "30dadd4735045",
143
+ "sort": 1
203
144
  }
204
145
  ]
205
146
  }