fix(接口测试): 修复接口和用例复制的时候本地文件没有同步复制的缺陷

--bug=1021383 --user=宋天阳 【接口测试】复制了一个带文件的接口定义,复制完后文件还显示,但是执行提示找不到文件
https://www.tapd.cn/55049933/s/1323440
This commit is contained in:
song-tianyang 2023-01-06 15:20:07 +08:00 committed by f2c-ci-robot[bot]
parent f991fccd8e
commit d6d95eb268
5 changed files with 15 additions and 4 deletions

View File

@ -24,4 +24,7 @@ public class SaveApiTestCaseRequest extends ApiTestCase {
private List<String> follows; private List<String> follows;
private String versionId; private String versionId;
//复制用例时的源ID主要用于复制本地文件等操作
private String sourceIdByCopy;
} }

View File

@ -438,7 +438,12 @@ public class ApiTestCaseService {
checkNameExist(request); checkNameExist(request);
ApiFileUtil.createBodyFiles(request.getId(), bodyFiles); ApiFileUtil.createBodyFiles(request.getId(), bodyFiles);
request.setRequest(tcpApiParamService.parseMsTestElement(request.getRequest())); request.setRequest(tcpApiParamService.parseMsTestElement(request.getRequest()));
if (StringUtils.isNotBlank(request.getSourceIdByCopy())) {
ApiFileUtil.copyBdyFile(request.getSourceIdByCopy(), request.getId());
} else {
ApiFileUtil.copyBdyFile(request.getApiDefinitionId(), request.getId()); ApiFileUtil.copyBdyFile(request.getApiDefinitionId(), request.getId());
}
final ApiTestCaseWithBLOBs test = new ApiTestCaseWithBLOBs(); final ApiTestCaseWithBLOBs test = new ApiTestCaseWithBLOBs();
test.setId(request.getId()); test.setId(request.getId());

View File

@ -403,7 +403,6 @@ export default {
data.request.protocol = this.currentProtocol; data.request.protocol = this.currentProtocol;
} }
if (data.isCopy) { if (data.isCopy) {
data.sourceId = data.id;
data.id = getUUID(); data.id = getUUID();
data.request.id = data.id; data.request.id = data.id;
} else { } else {

View File

@ -992,7 +992,7 @@ export default {
getDefinitionById(row.apiDefinitionId).then((response) => { getDefinitionById(row.apiDefinitionId).then((response) => {
let api = response.data; let api = response.data;
if (api) { if (api) {
this.getCaseAndOpen(row.id, api.name, row.apiDefinitionId); this.getCaseAndOpen(row.id, api.name, row.apiDefinitionId, true);
} }
}); });
}, },
@ -1004,7 +1004,7 @@ export default {
} }
}); });
}, },
getCaseAndOpen(id, apiName, apiId) { getCaseAndOpen(id, apiName, apiId, isCopyCase) {
getCaseById(id).then((response) => { getCaseById(id).then((response) => {
let data = response.data; let data = response.data;
let uuid = getUUID(); let uuid = getUUID();
@ -1030,6 +1030,9 @@ export default {
url: apiCaseRequest.path, url: apiCaseRequest.path,
uuid: uuid, uuid: uuid,
}; };
if (isCopyCase) {
obj.sourceIdByCopy = id;
}
this.$refs.caseList.copy(obj); this.$refs.caseList.copy(obj);
}); });
}, },

View File

@ -879,6 +879,7 @@ export default {
handleCopy(row) { handleCopy(row) {
let obj = JSON.parse(JSON.stringify(row)); let obj = JSON.parse(JSON.stringify(row));
obj.isCopy = true; obj.isCopy = true;
obj.sourceId = row.id;
delete obj.id; delete obj.id;
this.$emit('copyApi', obj); this.$emit('copyApi', obj);
}, },