Skip to content

Commit f6d8925

Browse files
committed
Demo: MultiDataSource 中 APIAuto: 回归测试时不显示 Response JSON 每个字段断言情况,避免卡顿,可手动触发显示
1 parent f1baa0f commit f6d8925

File tree

1 file changed

+54
-45
lines changed
  • APIJSON-Java-Server/APIJSONBoot-MultiDataSource/src/main/resources/static/api/js

1 file changed

+54
-45
lines changed

APIJSON-Java-Server/APIJSONBoot-MultiDataSource/src/main/resources/static/api/js/main.js

Lines changed: 54 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -226,28 +226,30 @@
226226
var newVal = {};
227227
for (var k in vi) {
228228
newVal[k] = vi[k]; //提升性能
229-
try {
230-
var tr = App.currentRemoteItem.TestRecord || {};
231-
var d = App.currentRemoteItem.Document || {};
232-
var standard = App.isMLEnabled ? tr.standard : tr.response;
233-
var standardObj = StringUtil.isEmpty(standard, true) ? null : JSON.parse(standard);
234-
var tests = App.tests[String(App.currentAccountIndex)] || {};
235-
var responseObj = (tests[d.id] || {})[0]
236-
237-
var pathUri = (StringUtil.isEmpty(curPath, false) ? '' : curPath + '/') + k;
238-
var pathKeys = StringUtil.split(pathUri, '/');
239-
var target = App.isMLEnabled ? JSONResponse.getStandardByPath(standardObj, pathKeys) : JSONResponse.getValByPath(standardObj, pathKeys);
240-
var real = JSONResponse.getValByPath(responseObj, pathKeys);
241-
var cmp = App.isMLEnabled ? JSONResponse.compareWithStandard(target, real, path) : JSONResponse.compareWithBefore(target, real, path);
242-
cmp.path = pathUri;
243-
var cmpShowObj = JSONResponse.getCompareShowObj(cmp);
244-
thiz[k] = [cmpShowObj.compareType, cmpShowObj.compareColor, cmpShowObj.compareMessage];
245-
var countKey = '_$_' + cmpShowObj.compareColor + 'Count_$_';
246-
thiz[countKey] = thiz[countKey] == null ? 1 : thiz[countKey] + 1;
247-
} catch (e) {
248-
thiz[k] = [JSONResponse.COMPARE_ERROR, 'red', e.message];
249-
var countKey = '_$_redCount_$_';
250-
thiz[countKey] = thiz[countKey] == null ? 1 : thiz[countKey] + 1;
229+
if (App.isFullAssert) {
230+
try {
231+
var tr = App.currentRemoteItem.TestRecord || {};
232+
var d = App.currentRemoteItem.Document || {};
233+
var standard = App.isMLEnabled ? tr.standard : tr.response;
234+
var standardObj = StringUtil.isEmpty(standard, true) ? null : JSON.parse(standard);
235+
var tests = App.tests[String(App.currentAccountIndex)] || {};
236+
var responseObj = (tests[d.id] || {})[0]
237+
238+
var pathUri = (StringUtil.isEmpty(curPath, false) ? '' : curPath + '/') + k;
239+
var pathKeys = StringUtil.split(pathUri, '/');
240+
var target = App.isMLEnabled ? JSONResponse.getStandardByPath(standardObj, pathKeys) : JSONResponse.getValByPath(standardObj, pathKeys);
241+
var real = JSONResponse.getValByPath(responseObj, pathKeys);
242+
var cmp = App.isMLEnabled ? JSONResponse.compareWithStandard(target, real, path) : JSONResponse.compareWithBefore(target, real, path);
243+
cmp.path = pathUri;
244+
var cmpShowObj = JSONResponse.getCompareShowObj(cmp);
245+
thiz[k] = [cmpShowObj.compareType, cmpShowObj.compareColor, cmpShowObj.compareMessage];
246+
var countKey = '_$_' + cmpShowObj.compareColor + 'Count_$_';
247+
thiz[countKey] = thiz[countKey] == null ? 1 : thiz[countKey] + 1;
248+
} catch (e) {
249+
thiz[k] = [JSONResponse.COMPARE_ERROR, 'red', e.message];
250+
var countKey = '_$_redCount_$_';
251+
thiz[countKey] = thiz[countKey] == null ? 1 : thiz[countKey] + 1;
252+
}
251253
}
252254

253255
delete vi[k]
@@ -283,29 +285,31 @@
283285
var newVal = {};
284286
for (var k in val) {
285287
newVal[k] = val[k]; //提升性能
286-
try {
287-
var tr = App.currentRemoteItem.TestRecord || {};
288-
var d = App.currentRemoteItem.Document || {};
289-
var standard = App.isMLEnabled ? tr.standard : tr.response;
290-
var standardObj = StringUtil.isEmpty(standard, true) ? null : JSON.parse(standard);
291-
var tests = App.tests[String(App.currentAccountIndex)] || {};
292-
var responseObj = (tests[d.id] || {})[0]
293-
294-
var pathUri = (StringUtil.isEmpty(curPath, false) ? '' : curPath + '/') + k;
295-
var pathKeys = StringUtil.split(pathUri, '/');
296-
var target = App.isMLEnabled ? JSONResponse.getStandardByPath(standardObj, pathKeys) : JSONResponse.getValByPath(standardObj, pathKeys);
297-
var real = JSONResponse.getValByPath(responseObj, pathKeys);
298-
// c = JSONResponse.compareWithBefore(target, real, path);
299-
var cmp = App.isMLEnabled ? JSONResponse.compareWithStandard(target, real, path) : JSONResponse.compareWithBefore(target, real, path);
300-
cmp.path = pathUri;
301-
var cmpShowObj = JSONResponse.getCompareShowObj(cmp);
302-
thiz[k] = [cmpShowObj.compareType, cmpShowObj.compareColor, cmpShowObj.compareMessage];
303-
var countKey = '_$_' + cmpShowObj.compareColor + 'Count_$_';
304-
thiz[countKey] = thiz[countKey] == null ? 1 : thiz[countKey] + 1;
305-
} catch (e) {
306-
thiz[k] = [JSONResponse.COMPARE_ERROR, 'red', e.message];
307-
var countKey = '_$_redCount_$_';
308-
thiz[countKey] = thiz[countKey] == null ? 1 : thiz[countKey] + 1;
288+
if (App.isFullAssert) {
289+
try {
290+
var tr = App.currentRemoteItem.TestRecord || {};
291+
var d = App.currentRemoteItem.Document || {};
292+
var standard = App.isMLEnabled ? tr.standard : tr.response;
293+
var standardObj = StringUtil.isEmpty(standard, true) ? null : JSON.parse(standard);
294+
var tests = App.tests[String(App.currentAccountIndex)] || {};
295+
var responseObj = (tests[d.id] || {})[0]
296+
297+
var pathUri = (StringUtil.isEmpty(curPath, false) ? '' : curPath + '/') + k;
298+
var pathKeys = StringUtil.split(pathUri, '/');
299+
var target = App.isMLEnabled ? JSONResponse.getStandardByPath(standardObj, pathKeys) : JSONResponse.getValByPath(standardObj, pathKeys);
300+
var real = JSONResponse.getValByPath(responseObj, pathKeys);
301+
// c = JSONResponse.compareWithBefore(target, real, path);
302+
var cmp = App.isMLEnabled ? JSONResponse.compareWithStandard(target, real, path) : JSONResponse.compareWithBefore(target, real, path);
303+
cmp.path = pathUri;
304+
var cmpShowObj = JSONResponse.getCompareShowObj(cmp);
305+
thiz[k] = [cmpShowObj.compareType, cmpShowObj.compareColor, cmpShowObj.compareMessage];
306+
var countKey = '_$_' + cmpShowObj.compareColor + 'Count_$_';
307+
thiz[countKey] = thiz[countKey] == null ? 1 : thiz[countKey] + 1;
308+
} catch (e) {
309+
thiz[k] = [JSONResponse.COMPARE_ERROR, 'red', e.message];
310+
var countKey = '_$_redCount_$_';
311+
thiz[countKey] = thiz[countKey] == null ? 1 : thiz[countKey] + 1;
312+
}
309313
}
310314

311315
delete val[k];
@@ -10405,6 +10409,7 @@ Content-Type: ` + contentType) + (StringUtil.isEmpty(headerStr, true) ? '' : hea
1040510409
// })
1040610410
},
1040710411

10412+
isFullAssert: true,
1040810413
toTestDocIndexes: [],
1040910414

1041010415
startTest: function (list, allCount, isRandom, accountIndex, isCross, callback) {
@@ -10434,6 +10439,7 @@ Content-Type: ` + contentType) + (StringUtil.isEmpty(headerStr, true) ? '' : hea
1043410439
},
1043510440

1043610441
startTestSingle: function (list, allCount, index, item, isRandom, accountIndex, isCross, callback, singleCallback, ctx) {
10442+
this.isFullAssert = false
1043710443
try {
1043810444
const isMLEnabled = this.isMLEnabled
1043910445
const standardKey = isMLEnabled != true ? 'response' : 'standard'
@@ -10604,6 +10610,7 @@ Content-Type: ` + contentType) + (StringUtil.isEmpty(headerStr, true) ? '' : hea
1060410610
},
1060510611

1060610612
onTestResponse: function(res, allCount, list, index, it, d, r, tr, response, cmp, isRandom, accountIndex, justRecoverTest, isCross, callback, singleCallback) {
10613+
this.isFullAssert = false
1060710614
tr = tr || {}
1060810615
cmp = cmp || {}
1060910616
tr.compare = cmp
@@ -11227,6 +11234,8 @@ Content-Type: ` + contentType) + (StringUtil.isEmpty(headerStr, true) ? '' : hea
1122711234
document = item.Document = item.Document || {}
1122811235
}
1122911236

11237+
this.isFullAssert = true
11238+
1123011239
var testRecord = item.TestRecord = item.TestRecord || {}
1123111240
var pathKeys = StringUtil.split(path, '/') || [];
1123211241
var pathNames = pathKeys.slice(0, pathKeys.length - 1);

0 commit comments

Comments
 (0)