1
1
2
2
( function ( ) {
3
- const DEBUG = true
3
+ const DEBUG = false // true
4
4
const IS_NODE = typeof window == 'undefined'
5
5
const IS_BROWSER = typeof window == 'object'
6
6
793
793
language : CodeUtil . LANGUAGE_KOTLIN ,
794
794
header : { } ,
795
795
page : 0 ,
796
- count : 100 ,
796
+ count : 50 ,
797
797
search : '' ,
798
798
testCasePage : 0 ,
799
799
testCaseCount : 50 ,
3050
3050
var testCases = this . testCases
3051
3051
var allCount = testCases == null ? 0 : testCases . length
3052
3052
App . allCount = allCount
3053
- if ( allCount > 0 ) {
3053
+ if ( IS_BROWSER && allCount > 0 ) {
3054
3054
var accountIndex = ( this . accounts [ this . currentAccountIndex ] || { } ) . isLoggedIn ? this . currentAccountIndex : - 1
3055
3055
this . currentAccountIndex = accountIndex //解决 onTestResponse 用 -1 存进去, handleTest 用 currentAccountIndex 取出来为空
3056
3056
3057
- var tests = this . tests [ String ( accountIndex ) ] || { }
3057
+ var tests = this . tests [ String ( accountIndex ) ]
3058
3058
if ( tests != null && JSONObject . isEmpty ( tests ) != true ) {
3059
3059
for ( var i = 0 ; i < allCount ; i ++ ) {
3060
3060
var item = testCases [ i ]
3097
3097
'standard{}' : this . isMLEnabled ? ( this . database == 'SQLSERVER' ? 'len(standard)>2' : 'length(standard)>2' ) : null //用 MySQL 5.6 '@having': this.isMLEnabled ? 'json_length(standard)>0' : null
3098
3098
}
3099
3099
} ,
3100
- '@role' : IS_NODE ? null : 'LOGIN'
3100
+ '@role' : IS_NODE ? null : 'LOGIN' ,
3101
+ key : IS_NODE ? this . key : undefined // 突破常规查询数量限制
3101
3102
}
3102
3103
3103
3104
if ( IS_BROWSER ) {
3193
3194
'@order' : 'date-'
3194
3195
}
3195
3196
}
3196
- }
3197
+ } ,
3198
+ key : IS_NODE ? this . key : undefined // 突破常规查询数量限制
3197
3199
}
3198
3200
3199
3201
if ( IS_BROWSER ) {
3328
3330
3329
3331
const req = {
3330
3332
type : 0 , // 登录方式,非必须 0-密码 1-验证码
3333
+ // asDBAccount: ! isAdminOperation, // 直接 /execute 接口传 account, password
3331
3334
phone : this . account ,
3332
3335
password : this . password ,
3333
3336
version : 1 , // 全局默认版本号,非必须
3334
3337
remember : vRemember . checked ,
3335
3338
format : false ,
3336
- defaults : isAdminOperation ? undefined : {
3339
+ defaults : isAdminOperation ? {
3340
+ key : IS_NODE ? this . key : undefined // 突破常规查询数量限制
3341
+ } : {
3337
3342
'@database' : StringUtil . isEmpty ( this . database , true ) ? undefined : this . database ,
3338
3343
'@schema' : StringUtil . isEmpty ( this . schema , true ) ? undefined : this . schema
3339
3344
}
3350
3355
} )
3351
3356
}
3352
3357
else {
3353
- if ( callback == null ) {
3358
+ if ( IS_BROWSER && callback == null ) {
3354
3359
var item
3355
3360
for ( var i in this . accounts ) {
3356
3361
item = this . accounts [ i ]
3697
3702
var w = isSingle || this . isEditResponse ? '' : StringUtil . trim ( CodeUtil . parseComment ( after , docObj == null ? null : docObj [ '[]' ] , m , this . database , this . language , this . isEditResponse != true , standardObj , null , true , isAPIJSONRouter ) ) ;
3698
3703
var c = isSingle ? '' : StringUtil . trim ( CodeUtil . parseComment ( after , docObj == null ? null : docObj [ '[]' ] , m , this . database , this . language , this . isEditResponse != true , standardObj , null , null , isAPIJSONRouter ) ) ;
3699
3704
3700
-
3701
3705
//TODO 统计行数,补全到一致 vInput.value.lineNumbers
3702
3706
if ( isSingle != true ) {
3703
3707
if ( afterObj . tag == null ) {
4010
4014
4011
4015
4012
4016
if ( IS_NODE ) {
4013
- console . log ( 'req = ' + JSON . stringify ( req , null , ' ' ) )
4017
+ log ( 'req = ' + JSON . stringify ( req , null , ' ' ) )
4014
4018
// 低版本 node 报错 cannot find module 'node:url' ,高版本报错 TypeError: axiosCookieJarSupport is not a function
4015
4019
// const axiosCookieJarSupport = require('axios-cookiejar-support').default;
4016
4020
// const tough = require('tough-cookie');
4115
4119
if ( res == null ) {
4116
4120
res = { }
4117
4121
}
4118
- log ( 'onResponse url = ' + url + '\nerr = ' + err + '\nreq = \n'
4119
- + ( res . request == null || res . request . data == null ? 'null' : JSON . stringify ( res . request . data ) )
4120
- + '\n\nres = \n' + ( res . data == null ? 'null' : JSON . stringify ( res . data ) )
4121
- )
4122
+ if ( DEBUG ) {
4123
+ log ( 'onResponse url = ' + url + '\nerr = ' + err + '\nreq = \n'
4124
+ + ( res . request == null || res . request . data == null ? 'null' : JSON . stringify ( res . request . data ) )
4125
+ + '\n\nres = \n' + ( res . data == null ? 'null' : JSON . stringify ( res . data ) )
4126
+ )
4127
+ }
4122
4128
4123
4129
if ( err != null ) {
4124
4130
if ( IS_BROWSER ) {
@@ -5352,6 +5358,7 @@ Content-Type: ` + contentType) + (StringUtil.isEmpty(headerStr, true) ? '' : hea
5352
5358
}
5353
5359
5354
5360
App . compareResponse ( allCount , list , index , item , res . data , true , App . currentAccountIndex , false , err , null , isCross , callback )
5361
+ return true
5355
5362
} )
5356
5363
}
5357
5364
}
@@ -5477,7 +5484,7 @@ Content-Type: ` + contentType) + (StringUtil.isEmpty(headerStr, true) ? '' : hea
5477
5484
config : vRandom . value
5478
5485
}
5479
5486
} ,
5480
- this . type , this . getUrl ( ) , this . getRequest ( vInput . value , { } ) , this . getHeader ( vHeader . value ) , callback
5487
+ this . type , this . getUrl ( ) , this . getRequest ( vInput . value , { } ) , this . getHeader ( vHeader . value ) , false , callback
5481
5488
)
5482
5489
}
5483
5490
catch ( e ) {
@@ -5999,8 +6006,12 @@ Content-Type: ` + contentType) + (StringUtil.isEmpty(headerStr, true) ? '' : hea
5999
6006
var bdt = tr . duration || 0
6000
6007
it . durationBeforeShowStr = bdt <= 0 ? '' : ( bdt < 1000 ? bdt + 'ms' : ( bdt < 1000 * 60 ? ( bdt / 1000 ) . toFixed ( 1 ) + 's' : ( bdt <= 1000 * 60 * 60 ? ( bdt / 1000 / 60 ) . toFixed ( 1 ) + 'm' : '>1h' ) ) )
6001
6008
try {
6002
- var durationInfo = response [ 'time:start|duration|end|parse|sql' ]
6009
+ var durationInfo = response == null ? null : response [ 'time:start|duration|end|parse|sql' ]
6003
6010
it . durationInfo = durationInfo
6011
+ if ( durationInfo == null ) {
6012
+ throw new Error ( "response['time:start|duration|end|parse|sql'] is null!" ) ;
6013
+ }
6014
+
6004
6015
var di = durationInfo . substring ( durationInfo . indexOf ( '\|' ) + 1 )
6005
6016
it . duration = di . substring ( 0 , di . indexOf ( '\|' ) || di . length ) || 0
6006
6017
var dt = + it . duration
@@ -6014,7 +6025,7 @@ Content-Type: ` + contentType) + (StringUtil.isEmpty(headerStr, true) ? '' : hea
6014
6025
: ( dt > max ? '有点慢:比以往 [' + min + 'ms, ' + max + 'ms] 最慢还更慢' : '正常:在以往 [' + min + 'ms, ' + max + 'ms] 最快和最慢之间' ) ) )
6015
6026
}
6016
6027
catch ( e ) {
6017
- log ( e )
6028
+ // log(e)
6018
6029
it . durationShowStr = it . durationShowStr || it . duration
6019
6030
it . durationHint = it . durationHint || '最外层缺少字段 "time:start|duration|end|parse|sql",无法对比耗时'
6020
6031
}
@@ -6142,8 +6153,7 @@ Content-Type: ` + contentType) + (StringUtil.isEmpty(headerStr, true) ? '' : hea
6142
6153
// this.showTestCase(true)
6143
6154
6144
6155
if ( doneCount >= allCount ) { // 导致不继续测试 App.doneCount == allCount) {
6145
- if ( callback != null ) {
6146
- callback ( isRandom , allCount )
6156
+ if ( callback != null && callback ( isRandom , allCount ) ) {
6147
6157
return
6148
6158
}
6149
6159
@@ -6154,7 +6164,7 @@ Content-Type: ` + contentType) + (StringUtil.isEmpty(headerStr, true) ? '' : hea
6154
6164
if ( isRandom != true && deepAllCount > 0 ) { // 自动给非 红色 报错的接口跑参数注入
6155
6165
App . deepDoneCount = 0 ;
6156
6166
this . startRandomTest4Doc ( list , this . toTestDocIndexes , 0 , deepAllCount , accountIndex , isCross )
6157
- } else if ( isCross && doneCount == allCount ) {
6167
+ } else if ( isCross && doneCount == allCount && accountIndex <= this . accounts . length ) {
6158
6168
this . test ( false , accountIndex + 1 , isCross )
6159
6169
}
6160
6170
}
@@ -6164,8 +6174,9 @@ Content-Type: ` + contentType) + (StringUtil.isEmpty(headerStr, true) ? '' : hea
6164
6174
const accInd = accountIndex
6165
6175
var callback = function ( isRandom , allCount ) {
6166
6176
if ( App . randomDoneCount < App . randomAllCount ) {
6167
- return
6177
+ return true
6168
6178
}
6179
+
6169
6180
App . randomDoneCount = 0
6170
6181
// App.randomAllCount = 0
6171
6182
@@ -6186,7 +6197,7 @@ Content-Type: ` + contentType) + (StringUtil.isEmpty(headerStr, true) ? '' : hea
6186
6197
if ( deepDoneCount < deepAllCount ) {
6187
6198
setTimeout ( function ( ) {
6188
6199
App . startRandomTest4Doc ( list , indexes , position + 1 , deepAllCount , accInd , isCross )
6189
- } , IS_NODE ? 1000 : 1000 )
6200
+ } , IS_NODE ? 200 : 1000 )
6190
6201
} else {
6191
6202
App . testRandomProcess = ''
6192
6203
if ( isCross ) {
@@ -6202,17 +6213,21 @@ Content-Type: ` + contentType) + (StringUtil.isEmpty(headerStr, true) ? '' : hea
6202
6213
}
6203
6214
}
6204
6215
}
6205
- } , IS_NODE ? 1000 : 1000 )
6216
+ } , IS_NODE ? 200 : 1000 )
6217
+
6218
+ return true
6206
6219
}
6207
6220
6208
6221
try {
6209
6222
var index = indexes [ position ]
6210
6223
var it = list [ index ] || { }
6211
6224
6212
- try {
6213
- document . getElementById ( 'docItem' + index ) . scrollIntoView ( )
6214
- } catch ( e ) {
6215
- console . log ( e )
6225
+ if ( IS_BROWSER ) {
6226
+ try {
6227
+ document . getElementById ( 'docItem' + index ) . scrollIntoView ( )
6228
+ } catch ( e ) {
6229
+ console . log ( e )
6230
+ }
6216
6231
}
6217
6232
6218
6233
this . restoreRemote ( index , it , false )
@@ -6705,7 +6720,7 @@ Content-Type: ` + contentType) + (StringUtil.isEmpty(headerStr, true) ? '' : hea
6705
6720
this . $refs [ ( isRandom ? ( toId <= 0 ? 'testRandomResult' : 'testRandomSubResult' ) : 'testResult' ) + ( isDuration ? 'Duration' : '' ) + 'Buttons' ] [ index ] . setAttribute ( 'data-hint' , h || '' ) ;
6706
6721
} ,
6707
6722
6708
- handleTestArg ( hasTestArg , rawReq , delayTime , callback ) {
6723
+ handleTestArg : function ( hasTestArg , rawReq , delayTime , callback ) {
6709
6724
if ( hasTestArg && IS_BROWSER ) {
6710
6725
vUrlComment . value = ""
6711
6726
vComment . value = ""
@@ -6742,7 +6757,6 @@ Content-Type: ` + contentType) + (StringUtil.isEmpty(headerStr, true) ? '' : hea
6742
6757
6743
6758
autoTest : function ( callback , delayTime , isTest , rawReq , setting ) {
6744
6759
this . autoTestCallback = callback
6745
- this . currentAccountIndex = - 1
6746
6760
6747
6761
if ( delayTime == null ) {
6748
6762
delayTime = 0
@@ -6773,9 +6787,9 @@ Content-Type: ` + contentType) + (StringUtil.isEmpty(headerStr, true) ? '' : hea
6773
6787
isRandomSubListShow : false ,
6774
6788
isMLEnabled : true ,
6775
6789
isCrossEnabled : true ,
6776
- testCaseCount : 100 ,
6790
+ // testCaseCount: 100,
6777
6791
testCasePage : 0 ,
6778
- randomCount : 100 ,
6792
+ // randomCount: 100,
6779
6793
randomPage : 0 ,
6780
6794
}
6781
6795
}
@@ -6789,11 +6803,15 @@ Content-Type: ` + contentType) + (StringUtil.isEmpty(headerStr, true) ? '' : hea
6789
6803
this . isRandomSubListShow = setting . isRandomSubListShow
6790
6804
this . isMLEnabled = setting . isMLEnabled
6791
6805
this . isCrossEnabled = setting . isCrossEnabled
6792
- this . testCaseCount = setting . testCaseCount
6806
+ // this.testCaseCount = setting.testCaseCount
6793
6807
this . testCasePage = setting . testCasePage
6794
- this . randomCount = setting . randomCount
6808
+ // this.randomCount = setting.randomCount
6795
6809
this . randomPage = setting . randomPage
6796
- this . server = this . getBaseUrl ( )
6810
+ this . server = 'http://localhost:8080' // this.getBaseUrl()
6811
+
6812
+ // if (this.isCrossEnabled) {
6813
+ // this.currentAccountIndex = -1
6814
+ // }
6797
6815
6798
6816
this . login ( true , function ( url , res , err ) {
6799
6817
if ( setting . isRandomShow && setting . isRandomListShow ) {
@@ -6823,6 +6841,7 @@ Content-Type: ` + contentType) + (StringUtil.isEmpty(headerStr, true) ? '' : hea
6823
6841
6824
6842
App . showTestCase ( true , setting . isLocalShow , function ( url , res , err ) {
6825
6843
App . onTestCaseListResponse ( IS_BROWSER , url , res , err )
6844
+ App . isTestCaseShow = true
6826
6845
App . handleTestArg ( isTest , rawReq , delayTime , callback )
6827
6846
} )
6828
6847
}
@@ -7135,12 +7154,12 @@ Content-Type: ` + contentType) + (StringUtil.isEmpty(headerStr, true) ? '' : hea
7135
7154
}
7136
7155
else {
7137
7156
var data = App . data
7138
- if ( data instanceof Object && data instanceof Array == false ) {
7157
+ if ( data instanceof Object && ( data instanceof Array == false ) ) {
7139
7158
App = Object . assign ( App , data )
7140
7159
}
7141
7160
7142
7161
var methods = App . methods
7143
- if ( methods instanceof Object && methods instanceof Array == false ) {
7162
+ if ( methods instanceof Object && ( methods instanceof Array == false ) ) {
7144
7163
App = Object . assign ( App , methods )
7145
7164
}
7146
7165
0 commit comments