Skip to content

Commit bba906c

Browse files
committed
初步完成回归测试的UI
1 parent 829713c commit bba906c

File tree

2 files changed

+63
-1
lines changed

2 files changed

+63
-1
lines changed

index.html

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,10 +84,17 @@
8484
<div class="left-panel">
8585
<ul v-show="isRemoteShow" class="historys" style="width: 100%;height: 100%;overflow: hidden;overflow-y: scroll;">
8686
<li v-for="(item, index) in remotes" >
87+
<a href="javascript:void(0)" @click="restore(item)" > {{(item.version > 0 ? 'V' + item.version : 'V*') + ' ' + item.name + ' ' + item.url}}</a>
88+
<div v-show="item.compare != null && item.compare > 0" style="position: absolute;right: 30px;display: inline-block;">
89+
<button @click="handleTest(false, index, item)" style="position: relative;color: red">错误,已解决</button>
90+
<svg class="icon" style="position: relative;margin-left: 10px" @click="downloadTest(index, item)">
91+
<use xlink:href="svg/icon.svg#export-txt"></use>
92+
</svg>
93+
<button @click="handleTest(true, index, item)">正确,上传</button>
94+
</div>
8795
<svg v-show="item.userId == User.id" class="icon" @click="remove(item, index, true)">
8896
<use xlink:href="svg/icon.svg#trash"></use>
8997
</svg>
90-
<a href="javascript:void(0)" @click="restore(item)" > {{(item.version > 0 ? 'V' + item.version : 'V*') + ' ' + item.name + ' ' + item.url}}</a>
9198
</li>
9299
</ul>
93100
<div v-show="! isRemoteShow" style="width: 100%;height: 100%;" >
@@ -153,6 +160,12 @@
153160
</ul>
154161
</span>
155162

163+
<a class="hint--top save-tool" data-hint="回归测试,TODO 做成列表上方的文字按钮" href="javascript:void(0)" @click="test(true)">
164+
<svg class="icon">
165+
<use xlink:href="svg/icon.svg#save"></use>
166+
</svg>
167+
</a>
168+
156169
</div>
157170
<div class="pull-right">
158171

js/main.js

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,7 @@
129129
historys: [],
130130
history: {name: '请求0'},
131131
remotes: [],
132+
testList: [],
132133
isDelayShow: false,
133134
isSaveShow: false,
134135
isExportShow: false,
@@ -1163,6 +1164,54 @@
11631164
doc += '\n```json\n' + JSON.stringify(JSON.parse(item.request), null, ' ') + '\n```\n'
11641165
}
11651166
return doc
1167+
},
1168+
1169+
/**回归测试
1170+
* 原理:
1171+
1.遍历所有上传过的测试用例(URL+请求JSON)
1172+
2.逐个发送请求
1173+
3.对比同一用例的先后两次请求结果,如果不一致,就在列表中标记对应的用例(× 蓝黄红色下载(点击下载两个文件) √)。
1174+
4.如果这次请求结果正确,就把请求结果保存到和公司开发环境服务器的APIJSON Server,并取消标记
1175+
*/
1176+
test: function () {
1177+
var baseUrl = App.getBaseUrl()
1178+
var testList = App.testList || []
1179+
var list = App.remotes || []
1180+
var item
1181+
for (var i = 0; i < list.length; i ++) {
1182+
item = list[i]
1183+
if (item == null || item.name == null) {
1184+
continue
1185+
}
1186+
App.restore(item)
1187+
App.onChange(false)
1188+
App.request(baseUrl + item.url, item.request, function (url, res, err) {
1189+
App.onResponse(url, res, err)
1190+
1191+
if (res.data != item.response) {
1192+
item.compare = 4
1193+
alert('res.data != item.response')
1194+
}
1195+
1196+
testList.push(res.data)
1197+
App.testList = testList
1198+
App.isRemoteShow = true
1199+
})
1200+
}
1201+
},
1202+
1203+
downloadTest: function (index, item) {
1204+
1205+
},
1206+
1207+
handleTest: function (right, index, item) {
1208+
if (right) {
1209+
var testList = App.testList || []
1210+
item.response = testList[index]
1211+
}
1212+
item.compare = 0
1213+
var list = App.remotes || []
1214+
list[index] = item
11661215
}
11671216
// APIJSON >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
11681217

0 commit comments

Comments
 (0)