|
129 | 129 | historys: [],
|
130 | 130 | history: {name: '请求0'},
|
131 | 131 | remotes: [],
|
132 |
| - testList: [], |
| 132 | + tests: [], |
133 | 133 | isDelayShow: false,
|
134 | 134 | isSaveShow: false,
|
135 | 135 | isExportShow: false,
|
|
1172 | 1172 | 2.逐个发送请求
|
1173 | 1173 | 3.对比同一用例的先后两次请求结果,如果不一致,就在列表中标记对应的用例(× 蓝黄红色下载(点击下载两个文件) √)。
|
1174 | 1174 | 4.如果这次请求结果正确,就把请求结果保存到和公司开发环境服务器的APIJSON Server,并取消标记
|
| 1175 | +
|
| 1176 | + compare: 新的请求与上次请求的对比结果 |
| 1177 | + 0-相同,无颜色; |
| 1178 | + 1-对象新增字段或数组新增值,绿色; |
| 1179 | + 2-值改变,蓝色; |
| 1180 | + 3-对象缺少字段,黄色; |
| 1181 | + 4-类型改变,红色; |
1175 | 1182 | */
|
1176 | 1183 | test: function () {
|
1177 | 1184 | var baseUrl = App.getBaseUrl()
|
1178 |
| - var testList = App.testList || [] |
1179 | 1185 | var list = App.remotes || []
|
1180 | 1186 | var item
|
| 1187 | + alert('test list.length = ' + list.length) |
1181 | 1188 | for (var i = 0; i < list.length; i ++) {
|
1182 | 1189 | item = list[i]
|
1183 | 1190 | if (item == null || item.name == null) {
|
1184 | 1191 | continue
|
1185 | 1192 | }
|
| 1193 | + if (item.userId != App.User.id || item.url == '/logout') { |
| 1194 | + console.log('test item.userId != User.id || item.url == /logout >> continue') |
| 1195 | + continue |
| 1196 | + } |
| 1197 | + console.log('test item = ' + JSON.stringify(item, null, ' ')) |
| 1198 | + |
1186 | 1199 | App.restore(item)
|
1187 | 1200 | App.onChange(false)
|
1188 |
| - App.request(baseUrl + item.url, item.request, function (url, res, err) { |
1189 |
| - App.onResponse(url, res, err) |
1190 | 1201 |
|
1191 |
| - if (res.data != item.response) { |
1192 |
| - item.compare = 4 |
1193 |
| - alert('res.data != item.response') |
| 1202 | + const index = i; //请求异步 |
| 1203 | + App.request(baseUrl + item.url, JSON.parse(item.request), function (url, res, err) { |
| 1204 | + App.onResponse(url, res, err) |
| 1205 | + console.log('test App.request >> res.data = ' + JSON.stringify(res.data, null, ' ')) |
| 1206 | + |
| 1207 | + var response = JSON.stringify(res.data) |
| 1208 | + |
| 1209 | + var it = list[index] //请求异步 |
| 1210 | + it.compare = it.response == response ? 0 : 4 |
| 1211 | + console.log('i = ' + index + '; item.name = ' + it.name + '; item.compare = ' + it.compare) |
| 1212 | + if (it.compare > 0) { |
| 1213 | + alert('i = ' + index + '; item.name = ' + it.name + '; item.compare = ' + it.compare |
| 1214 | + + '; it.response = \n' + it.response |
| 1215 | + + '\n\n\n res.data = \n' + response |
| 1216 | + ) |
1194 | 1217 | }
|
1195 | 1218 |
|
1196 |
| - testList.push(res.data) |
1197 |
| - App.testList = testList |
| 1219 | + var tests = App.tests || {} |
| 1220 | + tests[it.id] = response |
| 1221 | + App.tests = tests |
1198 | 1222 | App.isRemoteShow = true
|
1199 | 1223 | })
|
1200 | 1224 | }
|
|
1206 | 1230 |
|
1207 | 1231 | handleTest: function (right, index, item) {
|
1208 | 1232 | if (right) {
|
1209 |
| - var testList = App.testList || [] |
1210 |
| - item.response = testList[index] |
| 1233 | + var tests = App.tests || {} |
| 1234 | + item.response = tests[item.id] |
1211 | 1235 | }
|
1212 | 1236 | item.compare = 0
|
1213 |
| - var list = App.remotes || [] |
1214 |
| - list[index] = item |
| 1237 | + Vue.set(App.remotes, index, item); |
| 1238 | + |
| 1239 | + if (right) { |
| 1240 | + var baseUrl = App.getBaseUrl() |
| 1241 | + vUrl.value = baseUrl + '/put' |
| 1242 | + |
| 1243 | + vInput.value = JSON.stringify({ |
| 1244 | + Document: { |
| 1245 | + id: item.id, |
| 1246 | + response: item.response |
| 1247 | + }, |
| 1248 | + tag: 'Document' |
| 1249 | + }) |
| 1250 | + |
| 1251 | + App.showRemote(false) |
| 1252 | + App.onChange(false) |
| 1253 | + App.send(function (url, res, err) { |
| 1254 | + App.onResponse(url, res, err) |
| 1255 | + |
| 1256 | + var rpObj = res.data |
| 1257 | + if (rpObj != null && rpObj.code === 200) { |
| 1258 | + App.showRemote(true) |
| 1259 | + |
| 1260 | + App.request(baseUrl + '/post', { |
| 1261 | + TestRecord: { |
| 1262 | + userId: App.User.id, //TODO 权限问题? item.userId, |
| 1263 | + documentId: item.id, |
| 1264 | + response: item.response |
| 1265 | + }, |
| 1266 | + tag: 'TestRecord' |
| 1267 | + }, |
| 1268 | + function (url, res, err) {} |
| 1269 | + ) |
| 1270 | + |
| 1271 | + } |
| 1272 | + |
| 1273 | + }) |
| 1274 | + |
| 1275 | + } |
1215 | 1276 | }
|
1216 |
| - // APIJSON >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> |
| 1277 | +// APIJSON >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> |
1217 | 1278 |
|
1218 | 1279 | },
|
1219 | 1280 | watch: {
|
|
0 commit comments