fix(接口测试): 修复用例执行后通过率没有刷新的缺陷
--bug=1025098 --user=王孝刚 【接口测试】github#23386,接口用力执行完成,通过率数据不会自动更新,需要刷新页面才能更新 https://www.tapd.cn/55049933/s/1359097
This commit is contained in:
parent
9f36aca65d
commit
96bafa3d77
|
@ -110,4 +110,6 @@ public interface ExtApiTestCaseMapper {
|
|||
List<String> selectSourceIdByProjectIdIsNull();
|
||||
|
||||
long countSourceIdByProjectIdIsNull();
|
||||
|
||||
String findPassRateById(String id);
|
||||
}
|
||||
|
|
|
@ -1309,4 +1309,14 @@
|
|||
FROM api_case_execution_info
|
||||
WHERE project_id IS NULL
|
||||
</select>
|
||||
|
||||
<select id="findPassRateById" resultType="java.lang.String">
|
||||
SELECT
|
||||
CONCAT( FORMAT( SUM( IF ( t2.`status` = 'success', 1, 0 ))/ COUNT( t2.id )* 100, 2 ), '%' )
|
||||
VALUE
|
||||
FROM
|
||||
api_definition_exec_result t2
|
||||
WHERE
|
||||
t2.resource_id = #{0}
|
||||
</select>
|
||||
</mapper>
|
||||
|
|
|
@ -82,6 +82,11 @@ public class ApiTestCaseController {
|
|||
return apiTestCaseService.listSimple(request);
|
||||
}
|
||||
|
||||
@GetMapping("/get/pass-rate/{id}")
|
||||
public String getPassRate(@PathVariable String id) {
|
||||
return apiTestCaseService.getPassRate(id);
|
||||
}
|
||||
|
||||
@PostMapping("/get/request")
|
||||
public Map<String, String> listSimple(@RequestBody ApiTestCaseRequest request) {
|
||||
return apiTestCaseService.getRequest(request);
|
||||
|
|
|
@ -1281,4 +1281,9 @@ public class ApiTestCaseService {
|
|||
public void updateByPrimaryKeySelective(ApiTestCaseWithBLOBs apiTestCase) {
|
||||
apiTestCaseMapper.updateByPrimaryKeySelective(apiTestCase);
|
||||
}
|
||||
|
||||
public String getPassRate(String id) {
|
||||
return extApiTestCaseMapper.findPassRateById(id);
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -89,3 +89,7 @@ export function apiTestCaseCount(param) {
|
|||
export function getApiCaseEnvironments(param) {
|
||||
return post('/api/testcase/get/env', param);
|
||||
}
|
||||
|
||||
export function getPassRateById(id) {
|
||||
return get('/api/testcase/get/pass-rate/' + id);
|
||||
}
|
||||
|
|
|
@ -60,7 +60,7 @@
|
|||
</div>
|
||||
</template>
|
||||
<script>
|
||||
import { apiTestCaseList, editApiCaseByParam, getCaseById } from '@/api/api-test-case';
|
||||
import {apiTestCaseList, editApiCaseByParam, getCaseById, getPassRateById} from '@/api/api-test-case';
|
||||
import { getMaintainer } from '@/api/project';
|
||||
import ApiCaseHeader from './ApiCaseHeader';
|
||||
import { getCurrentProjectID } from 'metersphere-frontend/src/utils/token';
|
||||
|
@ -425,11 +425,15 @@ export default {
|
|||
this.singleRunId = '';
|
||||
this.apiCaseList[0].active = true;
|
||||
if (data) {
|
||||
let status = data.status === 'FAKE_ERROR' ? data.status : data.error > 0 ? 'Error' : 'Success';
|
||||
this.apiCaseList[0].execResult = status;
|
||||
this.apiCaseList[0].responseData = data;
|
||||
this.$refs.apiCaseItem.runLoading = false;
|
||||
store.currentApiCase = { refresh: true, id: data.id, status: status };
|
||||
getPassRateById(data.id).then((response) => {
|
||||
let passRate = response.data;
|
||||
let status = data.status === 'FAKE_ERROR' ? data.status : data.error > 0 ? 'Error' : 'Success';
|
||||
this.apiCaseList[0].execResult = status;
|
||||
this.apiCaseList[0].responseData = data;
|
||||
this.apiCaseList[0].passRate = passRate;
|
||||
this.$refs.apiCaseItem.runLoading = false;
|
||||
store.currentApiCase = {refresh: true, id: data.id, status: status, passRate: passRate};
|
||||
})
|
||||
}
|
||||
},
|
||||
errorRefresh() {
|
||||
|
|
|
@ -663,7 +663,7 @@ export default {
|
|||
},
|
||||
storeCurrentApiCaseRefresh() {
|
||||
if (store.currentApiCase && store.currentApiCase.refresh) {
|
||||
this.setStatus(store.currentApiCase.id, store.currentApiCase.status);
|
||||
this.setStatus(store.currentApiCase.id, store.currentApiCase.status, store.currentApiCase.passRate);
|
||||
}
|
||||
store.currentApiCase = {};
|
||||
},
|
||||
|
@ -743,11 +743,12 @@ export default {
|
|||
customHeader() {
|
||||
this.$refs.caseTable.openCustomHeader();
|
||||
},
|
||||
setStatus(id, status) {
|
||||
setStatus(id, status, passRate) {
|
||||
this.tableData.forEach((item) => {
|
||||
if (id && id === item.id) {
|
||||
item.status = status;
|
||||
item.execResult = status;
|
||||
item.passRate = passRate;
|
||||
}
|
||||
});
|
||||
},
|
||||
|
|
Loading…
Reference in New Issue