This commit is contained in:
liqiang-fit2cloud 2023-01-12 09:43:15 +08:00
commit b55cdc4405
41 changed files with 1005 additions and 593 deletions

View File

@ -428,9 +428,6 @@ public class MsHTTPSamplerProxy extends MsTestElement {
}
} else {
String url = this.getUrl();
if (StringUtils.isNotEmpty(this.getPort()) && this.getPort().startsWith("${")) {
url = url.replace(this.getPort(), "10990");
}
if (StringUtils.isEmpty(url)) {
MSException.throwException("请重新选择环境");
}

View File

@ -78,6 +78,7 @@ public class MsTCPSampler extends MsTestElement {
private String jsonDataStruct;
private String rawDataStruct;
private boolean customizeReq;
private Boolean isRefEnvironment;
@Override
public void toHashTree(HashTree tree, List<MsTestElement> hashTree, MsParameter msParameter) {

View File

@ -9,6 +9,8 @@ import io.metersphere.api.dto.definition.request.ElementUtil;
import io.metersphere.api.dto.definition.request.MsScenario;
import io.metersphere.api.dto.definition.request.ParameterConfig;
import io.metersphere.api.dto.definition.request.sampler.MsHTTPSamplerProxy;
import io.metersphere.api.dto.definition.request.sampler.MsJDBCSampler;
import io.metersphere.api.dto.definition.request.sampler.MsTCPSampler;
import io.metersphere.api.dto.plan.TestPlanApiScenarioInfoDTO;
import io.metersphere.api.dto.scenario.environment.EnvironmentConfig;
import io.metersphere.api.dto.scenario.environment.item.MsScenarioEnv;
@ -69,24 +71,32 @@ public class ApiScenarioEnvService {
// 过滤掉禁用的步骤
hashTree = hashTree.stream().filter(item -> item.isEnable()).collect(Collectors.toList());
}
List<Boolean> hasFullUrlList = new ArrayList<>();
for (MsTestElement testElement : hashTree) {
this.formatElement(testElement, env);
if (CollectionUtils.isNotEmpty(testElement.getHashTree())) {
getHashTree(testElement.getHashTree(), env);
this.formatElement(testElement, env, hasFullUrlList);
if (CollectionUtils.isNotEmpty(testElement.getHashTree()) && !hasFullUrlList.contains(false)) {
getHashTree(testElement.getHashTree(), env, hasFullUrlList);
}
if (hasFullUrlList.contains(false)) {
env.setFullUrl(false);
break;
}
}
return env;
}
private void getHashTree(List<MsTestElement> tree, ScenarioEnv env) {
private void getHashTree(List<MsTestElement> tree, ScenarioEnv env, List<Boolean> hasFullUrlList) {
try {
// 过滤掉禁用的步骤
tree = tree.stream().filter(item -> item.isEnable()).collect(Collectors.toList());
for (MsTestElement element : tree) {
this.formatElement(element, env);
if (CollectionUtils.isNotEmpty(element.getHashTree())) {
getHashTree(element.getHashTree(), env);
this.formatElement(element, env, hasFullUrlList);
if (CollectionUtils.isNotEmpty(element.getHashTree()) && !hasFullUrlList.contains(false)) {
getHashTree(element.getHashTree(), env, hasFullUrlList);
}
if (hasFullUrlList.contains(false)) {
break;
}
}
} catch (Exception e) {
@ -94,7 +104,7 @@ public class ApiScenarioEnvService {
}
}
private void formatElement(MsTestElement testElement, ScenarioEnv env) {
private void formatElement(MsTestElement testElement, ScenarioEnv env, List<Boolean> hasFullUrlList) {
if (StringUtils.equals(MsTestElementConstants.REF.name(), testElement.getReferenced())) {
if (StringUtils.equals(testElement.getType(), ElementConstants.HTTP_SAMPLER)) {
MsHTTPSamplerProxy http = (MsHTTPSamplerProxy) testElement;
@ -105,7 +115,7 @@ public class ApiScenarioEnvService {
if (!StringUtils.equalsIgnoreCase(http.getReferenced(), ElementConstants.STEP_CREATED)
|| (http.getIsRefEnvironment() != null && http.getIsRefEnvironment())) {
env.getProjectIds().add(http.getProjectId());
env.setFullUrl(false);
hasFullUrlList.add(false);
}
} else if (StringUtils.equals(testElement.getType(), ElementConstants.JDBC_SAMPLER)
|| StringUtils.equals(testElement.getType(), ElementConstants.TCP_SAMPLER)) {
@ -114,18 +124,18 @@ public class ApiScenarioEnvService {
ApiTestCase testCase = apiTestCaseMapper.selectByPrimaryKey(testElement.getId());
if (testCase != null) {
env.getProjectIds().add(testCase.getProjectId());
env.setFullUrl(false);
hasFullUrlList.add(false);
}
} else {
ApiDefinition apiDefinition = apiDefinitionService.get(testElement.getId());
if (apiDefinition != null) {
env.getProjectIds().add(apiDefinition.getProjectId());
env.setFullUrl(false);
hasFullUrlList.add(false);
}
}
} else {
env.getProjectIds().add(testElement.getProjectId());
env.setFullUrl(false);
hasFullUrlList.add(false);
}
} else if (StringUtils.equals(testElement.getType(), ElementConstants.SCENARIO) && StringUtils.isEmpty(testElement.getProjectId())) {
ApiScenarioWithBLOBs apiScenario = apiScenarioMapper.selectByPrimaryKey(testElement.getId());
@ -141,18 +151,14 @@ public class ApiScenarioEnvService {
if (StringUtils.equals(testElement.getType(), ElementConstants.HTTP_SAMPLER)) {
// 校验是否是全路径
MsHTTPSamplerProxy httpSamplerProxy = (MsHTTPSamplerProxy) testElement;
if (httpSamplerProxy.isCustomizeReq()) {
env.getProjectIds().add(httpSamplerProxy.getProjectId());
env.setFullUrl(httpSamplerProxy.getIsRefEnvironment() == null ? true : !httpSamplerProxy.getIsRefEnvironment());
} else if (!StringUtils.equalsIgnoreCase(httpSamplerProxy.getReferenced(), ElementConstants.STEP_CREATED) || (httpSamplerProxy.getIsRefEnvironment() != null && httpSamplerProxy.getIsRefEnvironment())) {
env.getProjectIds().add(httpSamplerProxy.getProjectId());
env.setFullUrl(false);
}
checkCustomEnv(env, httpSamplerProxy.isCustomizeReq(), httpSamplerProxy.getProjectId(), httpSamplerProxy.getIsRefEnvironment(), httpSamplerProxy.getReferenced(), hasFullUrlList);
} else if (StringUtils.equals(testElement.getType(), ElementConstants.JDBC_SAMPLER)
|| StringUtils.equals(testElement.getType(), ElementConstants.TCP_SAMPLER)) {
env.getProjectIds().add(testElement.getProjectId());
env.setFullUrl(false);
} else if (StringUtils.equals(testElement.getType(), ElementConstants.TCP_SAMPLER)) {
MsTCPSampler tcpSampler = (MsTCPSampler) testElement;
checkCustomEnv(env, tcpSampler.isCustomizeReq(), tcpSampler.getProjectId(), tcpSampler.getIsRefEnvironment(), tcpSampler.getReferenced(), hasFullUrlList);
} else if (StringUtils.equals(testElement.getType(), ElementConstants.JDBC_SAMPLER)) {
MsJDBCSampler jdbcSampler = (MsJDBCSampler) testElement;
checkCustomEnv(env, jdbcSampler.isCustomizeReq(), jdbcSampler.getProjectId(), jdbcSampler.getIsRefEnvironment(), jdbcSampler.getReferenced(), hasFullUrlList);
}
}
if (StringUtils.equals(testElement.getType(), ElementConstants.SCENARIO)
@ -161,6 +167,17 @@ public class ApiScenarioEnvService {
}
}
private void checkCustomEnv(ScenarioEnv env, boolean customizeReq, String projectId, Boolean isRefEnvironment, String referenced, List<Boolean> hasFullUrlList) {
if (customizeReq) {
env.getProjectIds().add(projectId);
hasFullUrlList.add(isRefEnvironment == null ? true : !isRefEnvironment);
} else if (!StringUtils.equalsIgnoreCase(referenced, ElementConstants.STEP_CREATED)
|| (isRefEnvironment != null && isRefEnvironment)) {
env.getProjectIds().add(projectId);
hasFullUrlList.add(false);
}
}
/**
* 设置场景的运行环境 环境组/环境JSON
*

View File

@ -166,7 +166,7 @@ public class MsDebugListener extends AbstractListenerElement implements SampleLi
transactionResult.getResponseResult().setConsole(console);
//对响应内容进行进一步解析和处理
RequestResultExpandDTO expandDTO = ResponseUtil.parseByRequestResult(transactionResult);
if (StringUtils.equals(dto.getRunMode(), ApiRunMode.DEFINITION.name())) {
if (StringUtils.equalsAnyIgnoreCase(dto.getRunMode(), ApiRunMode.DEFINITION.name(), ApiRunMode.API_PLAN.name())) {
apiDefinitionEnvService.setEnvAndPoolName(transactionResult, expandDTO);
}
dto.setContent("result_" + JSON.toJSONString(expandDTO));
@ -176,7 +176,7 @@ public class MsDebugListener extends AbstractListenerElement implements SampleLi
requestResult.getResponseResult().setConsole(console);
//对响应内容进行进一步解析和处理
RequestResultExpandDTO expandDTO = ResponseUtil.parseByRequestResult(requestResult);
if (StringUtils.equals(dto.getRunMode(), ApiRunMode.DEFINITION.name())) {
if (StringUtils.equalsAnyIgnoreCase(dto.getRunMode(), ApiRunMode.DEFINITION.name(), ApiRunMode.API_PLAN.name())) {
apiDefinitionEnvService.setEnvAndPoolName(requestResult, expandDTO);
}
dto.setContent("result_" + JSON.toJSONString(expandDTO));

View File

@ -74,7 +74,7 @@ public class MsKafkaListener {
LoggerUtil.info("接收到执行结果:", record.key());
if (ObjectUtils.isNotEmpty(record.value()) && WebSocketUtil.has(record.key().toString())) {
MsgDTO dto = JSONUtil.parseObject(record.value(), MsgDTO.class);
if (StringUtils.equals(ApiRunMode.DEFINITION.name(), dto.getRunMode()) && dto.getContent().startsWith("result_")) {
if (StringUtils.equalsAnyIgnoreCase(dto.getRunMode(), ApiRunMode.DEFINITION.name(), ApiRunMode.API_PLAN.name()) && dto.getContent().startsWith("result_")) {
ApiDefinitionEnvService apiDefinitionEnvService = CommonBeanFactory.getBean(ApiDefinitionEnvService.class);
apiDefinitionEnvService.setEnvAndPoolName(dto);
}

View File

@ -230,7 +230,7 @@
</include>
</if>
<if test="${condition}.exec_result != null">
and (t1.status
and (t3.status
<choose>
<when test='${condition}.exec_result.operator == "in"'>
in
@ -238,7 +238,7 @@
#{v}
</foreach>
<if test="${condition}.exec_result.value.contains('') or ${condition}.exec_result.value.contains('PENDING')">
or t1.status is null or t1.status = ''
or t3.status is null or t3.status = ''
</if>
<if test="${condition}.exec_result != null">
)
@ -250,10 +250,10 @@
#{v}
</foreach>
<if test="${condition}.exec_result != null and (${condition}.exec_result.value.contains('') or ${condition}.exec_result.value.contains('PENDING'))">
and t1.status is not null and t1.status != ''
and t3.status is not null and t3.status != ''
</if>
<if test="${condition}.exec_result != null and !${condition}.exec_result.value.contains('PENDING')">
or t1.status is null or t1.status = ''
or t3.status is null or t3.status = ''
</if>
<if test="${condition}.exec_result != null">
)
@ -406,7 +406,7 @@
a.path,
a.protocol,
t1.tags,
t1.status AS execResult,
t3.status AS execResult,
t1.last_result_id AS lastResultId,
project.NAME AS project_name,
t1.delete_time,

View File

@ -253,6 +253,7 @@ public class TestResultService {
ApiTestCaseWithBLOBs apiTestCase = new ApiTestCaseWithBLOBs();
apiTestCase.setLastResultId(dto.getReportId());
apiTestCase.setId(dto.getTestId());
apiTestCase.setStatus(record.getStatus());
apiTestCaseService.updateByPrimaryKeySelective(apiTestCase);
}

View File

@ -372,10 +372,10 @@ export default {
}
},
_getCurrentUserId() {
const {id, userGroups} = getCurrentUser();
const { id, userGroups } = getCurrentUser();
if (userGroups) {
//
let index = userGroups.findIndex(ug => ug.sourceId === getCurrentProjectID());
let index = userGroups.findIndex((ug) => ug.sourceId === getCurrentProjectID());
if (index !== -1) {
return id;
}
@ -786,6 +786,7 @@ export default {
let automationData = this.$router.resolve({
name: 'ApiAutomationWithQuery',
params: {
versionId: 'default',
redirectID: getUUID(),
dataType: 'scenario',
dataSelectRange: 'edit:' + resource.id,

View File

@ -72,6 +72,18 @@
<el-input v-model="request.port" size="small" />
</el-form-item>
</el-col>
<el-col :span="2">
<el-form-item>
<el-checkbox
v-if="isCustomizeReq"
class="is-ref-environment"
v-model="request.isRefEnvironment"
@change="setDomain"
:disabled="request.disabled">
{{ $t('api_test.request.refer_to_environment') }}
</el-checkbox>
</el-form-item>
</el-col>
</el-row>
</el-form>
</div>

View File

@ -355,6 +355,7 @@ export default {
let automationData = this.$router.resolve({
name: 'ApiAutomationWithQuery',
params: {
versionId: 'default',
redirectID: getUUID(),
dataType: 'scenario',
dataSelectRange: 'edit:' + resource.id,

View File

@ -84,7 +84,7 @@
v-model="controller.countController.interval"
:disabled="controller.disabled"
:placeholder="$t('commons.millisecond')"
:max="1000 * 10000000"
:max="1000 * 1000000"
:min="0"
:step="1000"
size="small" />
@ -129,7 +129,7 @@
:disabled="controller.disabled"
size="small"
:placeholder="$t('commons.millisecond')"
:max="1000 * 10000000"
:max="1000 * 1000000"
:min="0"
:step="1000" />
<span class="ms-span ms-radio">ms</span>
@ -165,12 +165,11 @@
:disabled="controller.disabled"
size="small"
:placeholder="$t('commons.millisecond')"
:max="1000 * 10000000"
:max="1000 * 1000000"
:min="3000"
:step="1000" />
<span class="ms-span ms-radio">ms</span>
</div>
<template v-slot:debugStepCode>
<span v-if="node.data.testing" class="ms-test-running">
<i class="el-icon-loading" style="font-size: 16px" />

View File

@ -162,6 +162,7 @@ export default {
let automationData = this.$router.resolve({
name: 'ApiAutomationWithQuery',
params: {
versionId: 'default',
redirectID: getUUID(),
dataType: 'scenario',
dataSelectRange: 'edit:' + response.data.id,

View File

@ -73,6 +73,7 @@ export default {
home = this.$router.resolve({
name: 'ApiDefinitionWithQuery',
params: {
versionId: 'default',
redirectID: uuid,
dataType: dataType,
dataSelectRange: selectRange,
@ -84,6 +85,7 @@ export default {
home = this.$router.resolve({
name: 'ApiAutomationWithQuery',
params: {
versionId: 'default',
redirectID: uuid,
dataType: dataType,
dataSelectRange: selectRange,

View File

@ -246,6 +246,7 @@ export default {
let automationData = this.$router.resolve({
name: 'ApiAutomationWithQuery',
params: {
versionId: 'default',
redirectID: getUUID(),
dataType: 'scenario',
dataSelectRange: 'edit:' + resource.id,

View File

@ -179,7 +179,11 @@ export default {
computed: {
isSqlType() {
return (
this.currentProtocol === 'SQL' && this.response.responseResult.responseCode === '200' && this.mode === 'table'
this.currentProtocol === 'SQL'
&& this.response
&& this.response.responseResult
&& this.response.responseResult.responseCode === '200'
&& this.mode === 'table'
);
},
responseResult() {

View File

@ -22,7 +22,7 @@
:style="isFixed ? 'opacity:100%; position: relative;z-index: 666;': 'opacity: 95%;position: fixed'"
@mouseenter.native="collapseOpen"
@mouseleave.native="collapseClose">
<ms-aside-header :sideTheme="sideTheme" :isCollapse="isCollapse"/>
<ms-aside-header :sideTheme="sideTheme" :isCollapse="isCollapse" :title="sysTitle"/>
<ms-aside-menus :sideTheme="sideTheme" :color="color" :isCollapse="isCollapse"/>
<div class="ms-header-fixed" v-show="!isCollapse">
<svg-icon iconClass="pushpin" class-name="ms-menu-pin" v-if="isFixed" @click.native="fixedChange(false)"/>
@ -72,6 +72,7 @@ export default {
headerHeight: "0px",
isFixed: false,
sideTheme: "",
sysTitle: undefined
};
},
computed: {
@ -127,6 +128,11 @@ export default {
if (response.data && response.data[7] && response.data[7].paramValue) {
this.sideTheme = response.data[7].paramValue;
}
if (response.data && response.data[6] && response.data[6].paramValue) {
this.sysTitle = response.data[6].paramValue;
}
let title = response.data[4].paramValue;
if (title) {
document.title = title;

View File

@ -178,6 +178,9 @@ export default {
if (title) {
document.title = title;
}
if (response.data[0].paramValue) {
this.shortcutIcon();
}
})
})
@ -196,6 +199,7 @@ export default {
this.rules = this.getDefaultRules();
}
});
},
created: function () {
document.addEventListener("keydown", this.watchEnter);
@ -296,6 +300,13 @@ export default {
});
}
},
shortcutIcon() {
let link = document.querySelector("link[rel*='icon']") || document.createElement('link');
link.type = 'image/x-icon';
link.rel = 'shortcut icon';
link.href = '/display/file/logo';
document.getElementsByTagName('head')[0].appendChild(link);
},
redirectAuth(authId) {
if (authId === 'LDAP' || authId === 'LOCAL') {
return;

View File

@ -25,16 +25,15 @@ export default {
menuKey: 0,
};
},
computed: {
title() {
return localStorage.getItem("sysTitle") || "MeterSphere";
}
},
props: {
sideTheme: String,
isCollapse: {
type: Boolean,
default: true,
},
title: {
type: String,
default: "MeterSphere"
}
},
};

View File

@ -1,15 +1,37 @@
<template>
<ms-table-column
prop="tags"
sortable
:field="field"
:fields-width="fieldsWidth"
sortable
:show-overflow-tooltip="false"
:label="$t('api_test.automation.tag')"
min-width="200px">
<template v-slot:default="scope">
<ms-tag v-for="(name, index) in scope.row.tags" :key="index" type="success" effect="plain"
:content="name" style="margin-left: 0px; margin-right: 2px"/>
<span/>
<span v-if="scope.row.tags && scope.row.tags.length === 1">
<ms-tag
v-for="(name, index) in scope.row.tags"
:key="index"
type="success"
effect="plain"
:content="name"
style="margin-left: 0; margin-right: 2px"
/>
</span>
<el-tooltip class="item" effect="dark" placement="top" :enterable="false" v-else>
<div v-html="scope.row.tags ? scope.row.tags.join(''): ''" slot="content"></div>
<div class="oneLine">
<ms-tag
v-for="(name, index) in scope.row.tags"
:key="index"
type="success"
effect="plain"
:content="name"
style="margin-left: 0; margin-right: 2px"
/>
<span/>
</div>
</el-tooltip>
</template>
</ms-table-column>
</template>
@ -28,5 +50,9 @@ export default {
</script>
<style scoped>
.oneLine {
overflow: hidden;
white-space: nowrap;
text-overflow: ellipsis;
}
</style>

View File

@ -554,8 +554,8 @@ const message = {
title: '显示设置',
logo: '系统 LOGO',
loginLogo: '登录页左上角 LOGO',
loginImage: '登页面右侧图片',
loginTitle: '登页面提示信息',
loginImage: '登页面右侧图片',
loginTitle: '登页面提示信息',
pageTitle: '页面 Title',
sysTitle: '系统名称',
theme_style: '菜单风格设置',

View File

@ -553,8 +553,8 @@ const message = {
title: '顯示設置',
logo: '系統 LOGO',
loginLogo: '登錄頁左上角 LOGO',
loginImage: '登頁面右側圖片',
loginTitle: '登頁面提示信息',
loginImage: '登頁面右側圖片',
loginTitle: '登頁面提示信息',
pageTitle: '頁面 Title',
sysTitle: '系統名稱',
theme_style: '菜單風格設置',

View File

@ -36,7 +36,7 @@
<update id="batchUpdateByResourceIds">
update ${tableName}
<include refid="updateValueColumn"/>
where resource_id in
where field_id = #{record.fieldId} and resource_id in
<foreach collection="resourceIds" item="resourceId" separator="," open="(" close=")">
#{resourceId}
</foreach>

View File

@ -155,6 +155,8 @@ public interface ExtTestCaseMapper {
List<TestCase> getMaintainerMap(@Param("request") QueryTestCaseRequest request);
List<TestCase> getMaintainerMapForPlanRepeat(@Param("request") QueryTestCaseRequest request);
List<TestCaseDTO> getForNodeEdit(@Param("ids") List<String> ids);
List<CustomFieldResourceCompatibleDTO> getForCompatibleCustomField(String projectId, int offset, int pageSize);

View File

@ -1216,6 +1216,14 @@
and T2.case_id is null
order by test_case.`order` desc, test_case.sort desc
</select>
<select id="getMaintainerMapForPlanRepeat" resultType="io.metersphere.base.domain.TestCase">
select test_case.id as id, test_case.maintainer as maintainer
from test_case as test_case
<include refid="notInQueryWhereCondition"/>
order by test_case.`order` desc, test_case.sort desc
</select>
<select id="getForNodeEdit" resultType="io.metersphere.dto.TestCaseDTO">
select test_case.id, test_case.node_id, test_case.node_path
from test_case where node_id in

View File

@ -48,6 +48,8 @@ public class IssueExcelData implements Serializable {
@ExcelIgnore
private Boolean addFlag;
@ExcelIgnore
private Boolean updateFlag = true;
@ExcelIgnore
private String title;
@ExcelIgnore
private String description;

View File

@ -121,6 +121,12 @@ public class IssueExcelListener extends AnalysisEventListener<Map<Integer, Strin
issueExcelData.setId(issues.getId());
issueExcelData.setAddFlag(Boolean.FALSE);
updateList.add(issueExcelData);
} else {
// 不覆盖模式
issueExcelData.setId(issues.getId());
issueExcelData.setAddFlag(Boolean.FALSE);
issueExcelData.setUpdateFlag(Boolean.FALSE);
updateList.add(issueExcelData);
}
}
}
@ -148,7 +154,7 @@ public class IssueExcelListener extends AnalysisEventListener<Map<Integer, Strin
}
if (CollectionUtils.isNotEmpty(updateList)) {
List<IssuesUpdateRequest> issues = updateList.stream().map(this::convertToIssue).collect(Collectors.toList());
List<IssuesUpdateRequest> issues = updateList.stream().filter(IssueExcelData::getUpdateFlag).map(this::convertToIssue).collect(Collectors.toList());
issuesService.updateImportData(issues);
}
}

View File

@ -298,6 +298,7 @@ public class TestPlanMessageService {
result.put("apiCaseUnExecuteCount", v);
break;
case "errorreportresult":
case "fakeerror":
result.put("apiCaseErrorReportCount", v);
break;
default:
@ -318,12 +319,14 @@ public class TestPlanMessageService {
result.put("apiScenarioSuccessCount", v);
break;
case "fail":
case "error":
result.put("apiScenarioFailedCount", v);
break;
case "unexecute":
result.put("apiScenarioUnExecuteCount", v);
break;
case "errorreportresult":
case "fakeerror":
result.put("apiScenarioErrorReportCount", v);
break;
default:

View File

@ -53,6 +53,7 @@ import io.metersphere.service.ApiPoolDebugService;
import io.metersphere.xpack.track.dto.IssuesDao;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.collections.MapUtils;
import org.apache.commons.lang3.BooleanUtils;
import org.apache.commons.lang3.ObjectUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.ibatis.session.ExecutorType;
@ -548,10 +549,14 @@ public class TestPlanService {
public void testPlanRelevance(PlanCaseRelevanceRequest request) {
LinkedHashMap<String, String> userMap;
TestPlan testPlan = testPlanMapper.selectByPrimaryKey(request.getPlanId());
boolean isSelectAll = request.getRequest() != null && request.getRequest().isSelectAll();
if (isSelectAll) {
List<TestCase> maintainerMap = extTestCaseMapper.getMaintainerMap(request.getRequest());
List<TestCase> maintainerMap;
if (BooleanUtils.isTrue(testPlan.getRepeatCase())) {
maintainerMap = extTestCaseMapper.getMaintainerMapForPlanRepeat(request.getRequest());
} else {
maintainerMap = extTestCaseMapper.getMaintainerMap(request.getRequest());
}
userMap = maintainerMap.stream()
.collect(LinkedHashMap::new, (m, v) -> m.put(v.getId(), v.getMaintainer()), LinkedHashMap::putAll);
} else {

View File

@ -384,11 +384,15 @@ public class TestCaseService {
checkTestCustomNum(testCase);
testCase.setUpdateTime(System.currentTimeMillis());
// 同步缺陷与需求的关联关系
updateThirdPartyIssuesLink(testCase);
try {
// 同步缺陷与需求的关联关系
updateThirdPartyIssuesLink(testCase);
// 同步用例与需求的关联关系
addDemandHyperLink(testCase, "edit");
// 同步用例与需求的关联关系
addDemandHyperLink(testCase, "edit");
} catch (Exception e) {
LogUtil.error(e);
}
if (StringUtils.isEmpty(testCase.getDemandId())) {
testCase.setDemandId(StringUtils.EMPTY);
@ -425,6 +429,9 @@ public class TestCaseService {
return;
}
Project project = baseProjectService.getProjectById(testCase.getProjectId());
if (!StringUtils.equals(project.getPlatform(), IssuesManagePlatform.AzureDevops.name())) {
return;
}
IssuesRequest issuesRequest = new IssuesRequest();
if (!issuesService.isThirdPartTemplate(project)) {
issuesRequest.setDefaultCustomFields(issuesService.getDefaultCustomFields(testCase.getProjectId()));
@ -446,6 +453,7 @@ public class TestCaseService {
if (StringUtils.isBlank(testCase.getVersionId())) {
return;
}
testCase.setLatest(false);
TestCaseExample example = new TestCaseExample();
example.createCriteria().andIdEqualTo(testCase.getId())
.andVersionIdEqualTo(testCase.getVersionId());

View File

@ -111,7 +111,6 @@ public class TestReviewTestCaseService {
}
public int deleteTestCase(DeleteRelevanceRequest request) {
checkReviewer(request.getReviewId());
return testCaseReviewTestCaseMapper.deleteByPrimaryKey(request.getId());
}
@ -130,21 +129,7 @@ public class TestReviewTestCaseService {
return testCaseReviewTestCaseMapper.updateByExampleSelective(record, example);
}
private void checkReviewer(String reviewId) {
List<String> userIds = testCaseReviewService.getTestCaseReviewerIds(reviewId);
String currentId = SessionUtils.getUser().getId();
TestCaseReview caseReview = testCaseReviewMapper.selectByPrimaryKey(reviewId);
String creator = StringUtils.EMPTY;
if (caseReview != null) {
creator = caseReview.getCreator();
}
if (!userIds.contains(currentId) && !StringUtils.equals(creator, currentId)) {
MSException.throwException("没有权限,不能解除用例关联!");
}
}
public void deleteTestCaseBatch(TestReviewCaseBatchRequest request) {
checkReviewer(request.getReviewId());
ServiceUtils.getSelectAllIds(request, request.getCondition(),
(query) -> extTestReviewCaseMapper.selectIds((QueryCaseReviewRequest) query));

View File

@ -593,7 +593,9 @@ export default {
// websock
// websock
this.$refs.apiCaseResult.open(reportId);
run(row.id, reportId);
setTimeout(() => {
run(row.id, reportId);
}, 3000);
},
handleTestEnd(reportId) {
if (this.runningReport.has(reportId)) {

View File

@ -6,8 +6,8 @@
:modal-append-to-body="false"
size="100%"
ref="drawer"
v-loading="loading">
v-loading="loading"
>
<template>
<el-row>
<el-col :span="17">
@ -16,11 +16,13 @@
<el-scrollbar>
<el-header>
<el-row type="flex" class="head-bar">
<el-col :span="4">
<el-button plain size="mini"
icon="el-icon-back"
@click="cancel">{{ $t('test_track.return') }}
<el-button
plain
size="mini"
icon="el-icon-back"
@click="cancel"
>{{ $t("test_track.return") }}
</el-button>
</el-col>
@ -35,9 +37,9 @@
:pre-page-data="prePageData"
@pre="handlePre"
@next="handleNext"
:list="testCases"/>
:list="testCases"
/>
</el-col>
</el-row>
<el-row class="head-bar">
@ -47,82 +49,144 @@
class="test-case-name"
type="text"
:disabled="!hasProjectPermission"
@click="openTestTestCase(testCase)">
<span
class="title-link"
:title="testCase.name"
:style="{'max-width': titleWith + 'px'}">
{{ testCase.customNum }}-{{ testCase.name }}
</span>
@click="openTestTestCase(testCase)"
>
<span
class="title-link"
:title="testCase.name"
:style="{ 'max-width': titleWith + 'px' }"
>
{{ testCase.customNum }}-{{ testCase.name }}
</span>
</el-button>
</el-divider>
</el-col>
</el-row>
</el-header>
<div class="case_container">
<el-form :model="testCase">
<el-row>
<el-col :span="7">
<el-form-item :label="$t('test_track.case.module')" prop="nodePath"
:label-width="formLabelWidth">
<el-form-item
:label="$t('test_track.case.module')"
prop="nodePath"
:label-width="formLabelWidth"
>
{{ testCase.nodePath }}
</el-form-item>
</el-col>
<el-col :span="7">
<el-form-item :label="$t('test_track.plan.plan_project')" prop="projectName"
:label-width="formLabelWidth">
<el-form-item
:label="$t('test_track.plan.plan_project')"
prop="projectName"
:label-width="formLabelWidth"
>
{{ testCase.projectName }}
</el-form-item>
</el-col>
<el-col :span="10">
<el-form-item :label="$t('test_track.plan.load_case.execution_status')"
:label-width="formLabelWidth">
<status-table-item :value="originalStatus"/>
<el-form-item
:label="
$t('test_track.plan.load_case.execution_status')
"
:label-width="formLabelWidth"
>
<status-table-item :value="originalStatus" />
</el-form-item>
</el-col>
</el-row>
<el-form ref="customFieldForm"
v-if="isCustomFiledActive"
class="case-form">
<el-form
ref="customFieldForm"
v-if="isCustomFiledActive"
class="case-form"
>
<el-row>
<el-col :span="7" v-for="(item, index) in testCaseTemplate.customFields" :key="index">
<el-form-item :label-width="formLabelWidth"
:label="item.system ? $t(systemNameMap[item.name]) : item.name"
:prop="item.name">
<custom-filed-component :disabled="true" :data="item" :form="{}" prop="defaultValue"/>
<el-col
:span="7"
v-for="(item, index) in testCaseTemplate.customFields"
:key="index"
>
<el-form-item
:label-width="formLabelWidth"
:label="
item.system
? $t(systemNameMap[item.name])
: item.name
"
:prop="item.name"
>
<custom-filed-component
:disabled="true"
:data="item"
:form="{}"
prop="defaultValue"
/>
</el-form-item>
</el-col>
</el-row>
</el-form>
<form-rich-text-item :label-width="formLabelWidth" :disabled="true"
:title="$t('test_track.case.prerequisite')" :data="testCase"
prop="prerequisite"/>
<step-change-item :disable="true" :label-width="formLabelWidth" :form="testCase"/>
<test-plan-case-step-results-item :label-width="formLabelWidth" :is-read-only="isReadOnly"
v-if="testCase.stepModel === 'STEP'" :test-case="testCase"/>
<form-rich-text-item :label-width="formLabelWidth" v-if="testCase.stepModel === 'TEXT'"
:disabled="true" :title="$t('test_track.case.step_desc')" :data="testCase"
prop="stepDescription"/>
<form-rich-text-item :label-width="formLabelWidth" v-if="testCase.stepModel === 'TEXT'"
:disabled="true" :title="$t('test_track.case.expected_results')"
:data="testCase" prop="expectedResult"/>
<form-rich-text-item :label-width="formLabelWidth" v-if="testCase.stepModel === 'TEXT'"
:title="$t('test_track.plan_view.actual_result')"
:data="testCase" prop="actualResult"/>
<form-rich-text-item
:label-width="formLabelWidth"
:disabled="true"
:title="$t('test_track.case.prerequisite')"
:data="testCase"
prop="prerequisite"
/>
<step-change-item
:disable="true"
:label-width="formLabelWidth"
:form="testCase"
/>
<test-plan-case-step-results-item
:label-width="formLabelWidth"
:is-read-only="isReadOnly"
v-if="testCase.stepModel === 'STEP'"
:test-case="testCase"
/>
<form-rich-text-item
:label-width="formLabelWidth"
v-if="testCase.stepModel === 'TEXT'"
:disabled="true"
:title="$t('test_track.case.step_desc')"
:data="testCase"
prop="stepDescription"
/>
<form-rich-text-item
:label-width="formLabelWidth"
v-if="testCase.stepModel === 'TEXT'"
:disabled="true"
:title="$t('test_track.case.expected_results')"
:data="testCase"
prop="expectedResult"
/>
<form-rich-text-item
:label-width="formLabelWidth"
v-if="testCase.stepModel === 'TEXT'"
:title="$t('test_track.plan_view.actual_result')"
:data="testCase"
prop="actualResult"
/>
<el-form-item :label="$t('test_track.case.other_info')" :label-width="formLabelWidth">
<test-case-edit-other-info :plan-id="testCase.planId" v-if="otherInfoActive" @openTest="openTest"
:is-test-plan-edit="true"
@syncRelationGraphOpen="syncRelationGraphOpen"
:read-only="true" :is-test-plan="true" :project-id="testCase.projectId"
:form="testCase" :case-id="testCase.caseId" ref="otherInfo"/>
<el-form-item
:label="$t('test_track.case.other_info')"
:label-width="formLabelWidth"
>
<test-case-edit-other-info
:plan-id="testCase.planId"
v-if="otherInfoActive"
@openTest="openTest"
:is-test-plan-edit="true"
@syncRelationGraphOpen="syncRelationGraphOpen"
:read-only="true"
:is-test-plan="true"
:project-id="testCase.projectId"
:form="testCase"
:case-id="testCase.caseId"
ref="otherInfo"
/>
</el-form-item>
</el-form>
</div>
</el-scrollbar>
@ -135,11 +199,13 @@
:test-case="testCase"
:is-read-only="isReadOnly"
:origin-status="originalStatus"
@saveCase="saveCase"/>
@saveCase="saveCase"
/>
<review-comment
default-type="PLAN"
:case-id="testCase.caseId"
ref="comment"/>
ref="comment"
/>
</div>
</el-col>
</el-row>
@ -148,30 +214,40 @@
</template>
<script>
import TestPlanTestCaseStatusButton from '../../../common/TestPlanTestCaseStatusButton';
import ClassicEditor from '@ckeditor/ckeditor5-build-classic';
import {getUUID, listenGoBack, removeGoBackListener} from "metersphere-frontend/src/utils"
import {hasPermission} from "metersphere-frontend/src/utils/permission";
import TestPlanTestCaseStatusButton from "../../../common/TestPlanTestCaseStatusButton";
import ClassicEditor from "@ckeditor/ckeditor5-build-classic";
import {
getUUID,
listenGoBack,
removeGoBackListener,
} from "metersphere-frontend/src/utils";
import { hasPermission } from "metersphere-frontend/src/utils/permission";
import TestCaseAttachment from "@/business/case/components/TestCaseAttachment";
import CaseComment from "@/business/case/components/CaseComment";
import MsPreviousNextButton from "metersphere-frontend/src/components/MsPreviousNextButton";
import ReviewComment from "@/business/review/commom/ReviewComment";
import {buildTestCaseOldFields, parseCustomField} from "metersphere-frontend/src/utils/custom_field";
import {
buildTestCaseOldFields,
parseCustomField,
} from "metersphere-frontend/src/utils/custom_field";
import FormRichTextItem from "metersphere-frontend/src/components/FormRichTextItem";
import MsFormDivider from "metersphere-frontend/src/components/MsFormDivider";
import TestCaseEditOtherInfo from "@/business/case/components/TestCaseEditOtherInfo";
import CustomFiledComponent from "metersphere-frontend/src/components/template/CustomFiledComponent";
import {SYSTEM_FIELD_NAME_MAP} from "metersphere-frontend/src/utils/table-constants";
import { SYSTEM_FIELD_NAME_MAP } from "metersphere-frontend/src/utils/table-constants";
import IssueDescriptionTableItem from "@/business/issue/IssueDescriptionTableItem";
import StepChangeItem from "@/business/case/components/StepChangeItem";
import TestCaseStepItem from "@/business/case/components/TestCaseStepItem";
import TestPlanCaseStepResultsItem from "@/business/plan/view/comonents/functional/TestPlanCaseStepResultsItem";
import TestPlanFunctionalExecute from "@/business/plan/view/comonents/functional/TestPlanFunctionalExecute";
import StatusTableItem from "@/business/common/tableItems/planview/StatusTableItem";
import {testPlanTestCaseEdit, testPlanTestCaseGet} from "@/api/remote/plan/test-plan-test-case";
import {testPlanEditStatus} from "@/api/remote/plan/test-plan";
import {getTestTemplate} from "@/api/custom-field-template";
import {checkProjectPermission} from "@/api/testCase";
import {
testPlanTestCaseEdit,
testPlanTestCaseGet,
} from "@/api/remote/plan/test-plan-test-case";
import { testPlanEditStatus } from "@/api/remote/plan/test-plan";
import { getTestTemplate } from "@/api/custom-field-template";
import { checkProjectPermission } from "@/api/testCase";
export default {
name: "FunctionalTestCaseEdit",
@ -190,7 +266,7 @@ export default {
MsPreviousNextButton,
CaseComment,
TestPlanTestCaseStatusButton,
TestCaseAttachment
TestCaseAttachment,
},
data() {
return {
@ -201,34 +277,34 @@ export default {
index: 0,
editor: ClassicEditor,
test: {},
activeTab: 'detail',
activeTab: "detail",
users: [],
tableData: [],
comments: [],
testCaseTemplate: {},
formLabelWidth: '100px',
formLabelWidth: "100px",
isCustomFiledActive: false,
otherInfoActive: true,
isReadOnly: false,
testCases: [],
originalStatus: '',
titleWith: 0
originalStatus: "",
titleWith: 0,
};
},
props: {
total: {
type: Number
type: Number,
},
searchParam: {
type: Object
type: Object,
},
pageNum: Number,
pageSize: {
type: Number,
default: 1
default: 1,
},
nextPageData: Object,
prePageData: Object
prePageData: Object,
},
computed: {
systemNameMap() {
@ -243,18 +319,18 @@ export default {
removeGoBackListener(this.handleClose);
this.showDialog = false;
this.searchParam.status = null;
this.$emit('update:search-param', this.searchParam);
this.$emit("update:search-param", this.searchParam);
},
cancel() {
this.handleClose();
this.$emit('refreshTable');
this.$emit("refreshTable");
},
getOption(param) {
let formData = new FormData();
let url = '/test/case/edit/testPlan';
let url = "/test/case/edit/testPlan";
if (this.$refs.otherInfo && this.$refs.otherInfo.uploadList) {
this.$refs.otherInfo.uploadList.forEach(f => {
this.$refs.otherInfo.uploadList.forEach((f) => {
formData.append("file", f);
});
}
@ -271,17 +347,20 @@ export default {
return key === "file" ? undefined : value;
});
formData.append('request', new Blob([requestJson], {
type: "application/json "
}));
formData.append(
"request",
new Blob([requestJson], {
type: "application/json ",
})
);
return {
method: 'POST',
method: "POST",
url: url,
data: formData,
headers: {
'Content-Type': undefined
}
"Content-Type": undefined,
},
};
},
saveCase() {
@ -302,12 +381,18 @@ export default {
result.actualResult = this.testCase.steptResults[i].actualResult;
result.executeResult = this.testCase.steptResults[i].executeResult;
if (result.actualResult && result.actualResult.length > 500) {
this.$warning(this.$t('test_track.plan_view.actual_result')
+ this.$t('test_track.length_less_than') + '500');
this.$warning(
this.$t("test_track.plan_view.actual_result") +
this.$t("test_track.length_less_than") +
"500"
);
return;
}
if (result.executeResult === 'Failure' && this.testCase.status === 'Pass') {
this.$warning(this.$t('test_track.plan_view.execute_tip'));
if (
result.executeResult === "Failure" &&
this.testCase.status === "Pass"
) {
this.$warning(this.$t("test_track.plan_view.execute_tip"));
this.testCase.status = this.originalStatus;
return;
}
@ -315,20 +400,19 @@ export default {
}
param.results = JSON.stringify(param.results);
param.actualResult = this.testCase.actualResult;
testPlanTestCaseEdit(param)
.then(() => {
this.$request(option);
testPlanTestCaseEdit(param).then(() => {
this.$request(option);
this.$success(this.$t('commons.save_success'));
this.updateTestCases(param);
this.setPlanStatus(this.testCase.planId);
this.$success(this.$t("commons.save_success"));
this.updateTestCases(param);
this.setPlanStatus(this.testCase.planId);
if (this.testCase.comment) {
this.$refs.comment.getComments();
this.testCase.comment = '';
}
this.originalStatus = this.testCase.status;
});
if (this.testCase.comment) {
this.$refs.comment.getComments();
this.testCase.comment = "";
}
this.originalStatus = this.testCase.status;
});
},
updateTestCases(param) {
for (let i = 0; i < this.testCases.length; i++) {
@ -345,7 +429,7 @@ export default {
if (this.isLastData()) {
return;
} else if (this.index === this.testCases.length - 1) {
this.$emit('nextPage');
this.$emit("nextPage");
this.index = 0;
return;
}
@ -354,20 +438,23 @@ export default {
this.reloadOtherInfo();
},
isLastData() {
return this.index === this.testCases.length - 1 && this.pageNum === this.pageTotal;
return (
this.index === this.testCases.length - 1 &&
this.pageNum === this.pageTotal
);
},
reloadOtherInfo() {
this.otherInfoActive = false;
this.$nextTick(() => {
this.otherInfoActive = true;
})
});
},
handlePre() {
if (this.index === 0 && this.pageNum === 1) {
this.$warning('已经是第一页');
this.$warning("已经是第一页");
return;
} else if (this.index === 0) {
this.$emit('prePage');
this.$emit("prePage");
this.index = this.pageSize - 1;
return;
}
@ -378,66 +465,69 @@ export default {
getTestCase(id) {
this.loading = true;
// id TestPlanTestCase id
testPlanTestCaseGet(id)
.then(response => {
this.loading = false;
let item = {};
Object.assign(item, response.data);
if (item.results) {
item.results = JSON.parse(item.results);
} else if (item.steps) {
item.results = [item.steps.length];
}
if (item.issues) {
item.issues = JSON.parse(item.issues);
} else {
item.issues = {};
}
item.steps = JSON.parse(item.steps);
if (!item.stepModel) {
item.stepModel = 'STEP';
}
item.steptResults = [];
if (item.steps) {
for (let i = 0; i < item.steps.length; i++) {
if (item.results) {
if (item.results[i]) {
item.steps[i].actualResult = item.results[i].actualResult;
item.steps[i].executeResult = item.results[i].executeResult;
}
item.steptResults.push(item.steps[i]);
} else {
item.steptResults.push({
actualResult: '',
executeResult: ''
});
testPlanTestCaseGet(id).then((response) => {
this.loading = false;
let item = {};
Object.assign(item, response.data);
if (item.results) {
item.results = JSON.parse(item.results);
} else if (item.steps) {
item.results = [item.steps.length];
}
if (item.issues) {
item.issues = JSON.parse(item.issues);
} else {
item.issues = {};
}
item.steps = JSON.parse(item.steps);
if (!item.stepModel) {
item.stepModel = "STEP";
}
item.steptResults = [];
if (item.steps) {
for (let i = 0; i < item.steps.length; i++) {
if (item.results) {
if (item.results[i]) {
item.steps[i].actualResult = item.results[i].actualResult;
item.steps[i].executeResult = item.results[i].executeResult;
}
item.steptResults.push(item.steps[i]);
} else {
item.steptResults.push({
actualResult: "",
executeResult: "",
});
}
}
this.testCase = item;
this.originalStatus = this.testCase.status;
parseCustomField(this.testCase, this.testCaseTemplate, null, buildTestCaseOldFields(this.testCase));
this.testCaseTemplate.customFields.forEach(item => {
try {
item.defaultValue = JSON.parse(item.defaultValue);
} catch (e) {
// nothing
}
});
this.isCustomFiledActive = true;
if (!this.testCase.actualResult) {
// ,使
this.testCase.actualResult = this.testCaseTemplate.actualResult;
}
this.testCase = item;
this.originalStatus = this.testCase.status;
parseCustomField(
this.testCase,
this.testCaseTemplate,
null,
buildTestCaseOldFields(this.testCase)
);
this.testCaseTemplate.customFields.forEach((item) => {
try {
item.defaultValue = JSON.parse(item.defaultValue);
} catch (e) {
// nothing
}
});
this.isCustomFiledActive = true;
if (!this.testCase.actualResult) {
// ,使
this.testCase.actualResult = this.testCaseTemplate.actualResult;
}
});
},
openTestCaseEdit(testCase, tableData) {
checkProjectPermission(testCase.projectId)
.then(r => {
this.hasProjectPermission = r.data;
});
checkProjectPermission(testCase.projectId).then((r) => {
this.hasProjectPermission = r.data;
});
this.showDialog = true;
this.activeTab = 'detail';
this.activeTab = "detail";
this.originalStatus = testCase.status;
this.setTitleWith();
@ -454,11 +544,10 @@ export default {
listenGoBack(this.handleClose);
let initFuc = this.getTestCase;
getTestTemplate(testCase.projectId)
.then((template) => {
this.testCaseTemplate = template;
initFuc(testCase.id);
});
getTestTemplate(testCase.projectId).then((template) => {
this.testCaseTemplate = template;
initFuc(testCase.id);
});
if (this.$refs.otherInfo) {
this.$refs.otherInfo.reset();
}
@ -466,16 +555,16 @@ export default {
testRun(reportId) {
this.testCase.reportId = reportId;
this.saveReport(reportId);
this.activeTab = 'result';
this.activeTab = "result";
},
testTabChange(data) {
if (this.testCase.type === 'performance' && data.paneName === 'result') {
if (this.testCase.type === "performance" && data.paneName === "result") {
this.$refs.performanceTestResult.checkReportStatus();
this.$refs.performanceTestResult.init();
}
},
saveReport(reportId) {
testPlanTestCaseEdit({id: this.testCase.id, reportId: reportId});
testPlanTestCaseEdit({ id: this.testCase.id, reportId: reportId });
},
openTest(item) {
const type = item.testType;
@ -483,25 +572,34 @@ export default {
switch (type) {
case "performance": {
let performanceData = this.$router.resolve({
path: '/performance/test/edit/' + id,
})
window.open(performanceData.href, '_blank');
path: "/performance/test/edit/" + id,
});
window.open(performanceData.href, "_blank");
break;
}
case "testcase": {
let caseData = this.$router.resolve({
name: 'ApiDefinition',
params: {redirectID: getUUID(), dataType: "apiTestCase", dataSelectRange: 'single:' + id}
name: "ApiDefinition",
params: {
versionId: "default",
redirectID: getUUID(),
dataType: "apiTestCase",
dataSelectRange: "single:" + id,
},
});
window.open(caseData.href, '_blank');
window.open(caseData.href, "_blank");
break;
}
case "automation": {
let automationData = this.$router.resolve({
name: 'ApiAutomation',
params: {redirectID: getUUID(), dataType: "scenario", dataSelectRange: 'edit:' + id}
name: "ApiAutomation",
params: {
redirectID: getUUID(),
dataType: "scenario",
dataSelectRange: "edit:" + id,
},
});
window.open(automationData.href, '_blank');
window.open(automationData.href, "_blank");
break;
}
}
@ -519,26 +617,28 @@ export default {
this.relationGraphOpen = val;
},
openTestTestCase(item) {
let TestCaseData = this.$router.resolve(
{
path: '/track/case/all',
query: {redirectID: getUUID(), dataType: "testCase", dataSelectRange: item.caseId, projectId: item.projectId}
}
);
window.open(TestCaseData.href, '_blank');
let TestCaseData = this.$router.resolve({
path: "/track/case/all",
query: {
redirectID: getUUID(),
dataType: "testCase",
dataSelectRange: item.caseId,
projectId: item.projectId,
},
});
window.open(TestCaseData.href, "_blank");
},
addPLabel(str) {
return "<p>" + str + "</p>";
},
setPlanStatus(planId) {
testPlanEditStatus(planId);
}
}
}
},
},
};
</script>
<style scoped>
.cast_label {
color: dimgray;
}
@ -587,7 +687,7 @@ export default {
}
.el-switch :deep(.el-switch__label.is-active) {
color: #409EFF;
color: #409eff;
}
p {

View File

@ -1,6 +1,6 @@
<template>
<ms-container>
<ms-main-container class="report-content">
<ms-main-container class="report-content" :class="isShare || isTemplate? 'full-screen-container' : 'with-header-container'" id = "planReportContainer">
<el-card v-loading="loading">
<test-plan-report-buttons :is-db="isDb" :plan-id="planId" :is-share="isShare" :report="report"
v-if="!isTemplate && !isShare"/>
@ -190,13 +190,17 @@ export default {
if (!this.isTemplate) {
if (this.isShare) {
getShareTestPlanExtReport(this.shareId, this.planId, this.reportId).then((response) => {
this.runMode = response.data.runMode;
this.resourcePool = response.data.resourcePool;
if (response.data) {
this.runMode = response.data.runMode;
this.resourcePool = response.data.resourcePool;
}
});
} else {
getTestPlanExtReport(this.planId, this.reportId).then((response) => {
this.runMode = response.data.runMode;
this.resourcePool = response.data.resourcePool;
if (response.data) {
this.runMode = response.data.runMode;
this.resourcePool = response.data.resourcePool;
}
});
}
}
@ -336,8 +340,15 @@ export default {
<style scoped>
.with-header-container {
height: calc(100vh - 60px);
}
.full-screen-container {
height: calc(100vh - 10px);
}
.el-card {
/*width: 95% !important;*/
padding: 15px;
}

View File

@ -74,7 +74,7 @@ export default {
watch: {
activeName() {
let target = document.getElementById(this.activeName);
target.parentNode.parentNode.parentNode.scrollTop = target.offsetTop - 100;
document.getElementById('planReportContainer').scrollTop = target.offsetTop - 100;
},
overviewEnable() {
this.setData();

View File

@ -1,5 +1,4 @@
<template>
<el-drawer
:before-close="handleClose"
:visible.sync="showDialog"
@ -7,28 +6,27 @@
:modal-append-to-body="false"
size="100%"
ref="drawer"
v-loading="loading">
v-loading="loading"
>
<template>
<el-row :gutter="10">
<el-col :span="17">
<div class="container">
<el-card>
<el-scrollbar>
<el-header style="height: 100%;">
<el-header style="height: 100%">
<el-row type="flex" class="head-bar">
<el-col :span="2">
<el-button plain size="mini"
icon="el-icon-back"
@click="cancel">{{ $t('test_track.return') }}
<el-button
plain
size="mini"
icon="el-icon-back"
@click="cancel"
>{{ $t("test_track.return") }}
</el-button>
</el-col>
<el-col :span="22" class="head-right">
<ms-previous-next-button
:index="index"
:page-num="pageNum"
@ -39,90 +37,146 @@
:pre-page-data="prePageData"
:list="testCases"
@pre="handlePre"
@next="handleNext"/>
@next="handleNext"
/>
</el-col>
</el-row>
<el-row style="margin-top: 0;">
<el-row style="margin-top: 0">
<el-col>
<el-divider content-position="left" class="title-divider">
<el-button class="test-case-name" type="text" @click="openTestTestCase(testCase)">
<span
class="title-link"
:title="testCase.name"
:style="{'max-width': titleWith + 'px'}">
{{ testCase.num }}-{{ testCase.name }}
</span>
<el-button
class="test-case-name"
type="text"
@click="openTestTestCase(testCase)"
>
<span
class="title-link"
:title="testCase.name"
:style="{ 'max-width': titleWith + 'px' }"
>
{{ testCase.num }}-{{ testCase.name }}
</span>
</el-button>
</el-divider>
</el-col>
</el-row>
</el-header>
<div class="case_container">
<el-form>
<el-row>
<el-col :span="7">
<el-form-item :label="$t('test_track.case.module')" prop="nodePath"
:label-width="formLabelWidth">
<el-form-item
:label="$t('test_track.case.module')"
prop="nodePath"
:label-width="formLabelWidth"
>
{{ testCase.nodePath }}
</el-form-item>
</el-col>
<el-col :span="7">
<el-form-item :label="$t('test_track.plan.plan_project')" prop="projectName"
:label-width="formLabelWidth">
<el-form-item
:label="$t('test_track.plan.plan_project')"
prop="projectName"
:label-width="formLabelWidth"
>
{{ testCase.projectName }}
</el-form-item>
</el-col>
<el-col :span="10">
<el-form-item :label="$t('评审状态')" :label-width="formLabelWidth">
<status-table-item :value="oldReviewStatus"/>
</el-form-item >
<el-form-item
:label="$t('评审状态')"
:label-width="formLabelWidth"
>
<status-table-item :value="oldReviewStatus" />
</el-form-item>
</el-col>
</el-row>
<el-form ref="customFieldForm"
v-if="isCustomFiledActive"
class="case-form">
<el-form
ref="customFieldForm"
v-if="isCustomFiledActive"
class="case-form"
>
<el-row>
<el-col :span="7" v-for="(item, index) in testCaseTemplate.customFields" :key="index">
<el-form-item :label="item.system ? $t(systemNameMap[item.name]) : item.name"
:prop="item.name"
:label-width="formLabelWidth">
<custom-filed-component :disabled="true" :data="item" :form="{}" prop="defaultValue"/>
<el-col
:span="7"
v-for="(item, index) in testCaseTemplate.customFields"
:key="index"
>
<el-form-item
:label="
item.system
? $t(systemNameMap[item.name])
: item.name
"
:prop="item.name"
:label-width="formLabelWidth"
>
<custom-filed-component
:disabled="true"
:data="item"
:form="{}"
prop="defaultValue"
/>
</el-form-item>
</el-col>
</el-row>
</el-form>
<form-rich-text-item :label-width="formLabelWidth" :disabled="true"
:title="$t('test_track.case.prerequisite')"
:data="testCase" prop="prerequisite"/>
<step-change-item :disable="true" :label-width="formLabelWidth" :form="testCase"/>
<form-rich-text-item :label-width="formLabelWidth" :disabled="true"
v-if="testCase.stepModel === 'TEXT'" :title="$t('test_track.case.step_desc')"
:data="testCase" prop="stepDescription"/>
<form-rich-text-item :label-width="formLabelWidth" :disabled="true"
v-if="testCase.stepModel === 'TEXT'"
:title="$t('test_track.case.expected_results')" :data="testCase"
prop="expectedResult"/>
<form-rich-text-item
:label-width="formLabelWidth"
:disabled="true"
:title="$t('test_track.case.prerequisite')"
:data="testCase"
prop="prerequisite"
/>
<step-change-item
:disable="true"
:label-width="formLabelWidth"
:form="testCase"
/>
<form-rich-text-item
:label-width="formLabelWidth"
:disabled="true"
v-if="testCase.stepModel === 'TEXT'"
:title="$t('test_track.case.step_desc')"
:data="testCase"
prop="stepDescription"
/>
<form-rich-text-item
:label-width="formLabelWidth"
:disabled="true"
v-if="testCase.stepModel === 'TEXT'"
:title="$t('test_track.case.expected_results')"
:data="testCase"
prop="expectedResult"
/>
<test-case-step-item :label-width="formLabelWidth" :read-only="true"
v-if="testCase.stepModel === 'STEP'" :form="testCase"/>
<test-case-step-item
:label-width="formLabelWidth"
:read-only="true"
v-if="testCase.stepModel === 'STEP'"
:form="testCase"
/>
<el-form-item :label="$t('test_track.case.other_info')" :label-width="formLabelWidth">
<test-case-edit-other-info @openTest="openTest" :read-only="true"
@syncRelationGraphOpen="syncRelationGraphOpen"
:project-id="projectId" :form="testCase" :case-id="testCase.caseId"
ref="otherInfo"/>
<el-form-item
:label="$t('test_track.case.other_info')"
:label-width="formLabelWidth"
>
<test-case-edit-other-info
@openTest="openTest"
:read-only="true"
@syncRelationGraphOpen="syncRelationGraphOpen"
:project-id="projectId"
:form="testCase"
:case-id="testCase.caseId"
ref="otherInfo"
/>
</el-form-item>
</el-form>
</div>
</el-scrollbar>
</el-card>
</div>
@ -133,30 +187,38 @@
:test-case="testCase"
:is-read-only="isReadOnly"
:origin-status="oldReviewStatus"
@saveCase="saveCase()"/>
@saveCase="saveCase()"
/>
<review-comment
default-type="REVIEW"
:case-id="testCase.caseId"
@saveCaseReview="saveCaseReview"
ref="comment"/>
ref="comment"
/>
</div>
</el-col>
</el-row>
</template>
</el-drawer>
</template>
<script>
import {getCurrentProjectID} from "metersphere-frontend/src/utils/token";
import {getUUID, listenGoBack, removeGoBackListener} from "metersphere-frontend/src/utils"
import { getCurrentProjectID } from "metersphere-frontend/src/utils/token";
import {
getUUID,
listenGoBack,
removeGoBackListener,
} from "metersphere-frontend/src/utils";
import ReviewComment from "@/business/review/commom/ReviewComment";
import TestCaseAttachment from "@/business/case/components/TestCaseAttachment";
import {buildTestCaseOldFields, getTemplate, parseCustomField} from "metersphere-frontend/src/utils/custom_field";
import {
buildTestCaseOldFields,
getTemplate,
parseCustomField,
} from "metersphere-frontend/src/utils/custom_field";
import TestCaseEditOtherInfo from "@/business/case/components/TestCaseEditOtherInfo";
import {SYSTEM_FIELD_NAME_MAP} from "metersphere-frontend/src/utils/table-constants";
import { SYSTEM_FIELD_NAME_MAP } from "metersphere-frontend/src/utils/table-constants";
import FormRichTextItem from "metersphere-frontend/src/components/FormRichTextItem";
import CustomFiledComponent from "metersphere-frontend/src/components/template/CustomFiledComponent";
import StepChangeItem from "@/business/case/components/StepChangeItem";
@ -164,12 +226,12 @@ import TestCaseStepItem from "@/business/case/components/TestCaseStepItem";
import MsPreviousNextButton from "metersphere-frontend/src/components/MsPreviousNextButton";
import TestReviewTestCaseExecute from "./TestReviewTestCaseExecute";
import StatusTableItem from "@/business/common/tableItems/planview/StatusTableItem";
import {getTestTemplate} from "@/api/custom-field-template";
import { getTestTemplate } from "@/api/custom-field-template";
import {
editTestCaseReviewStatus,
editTestReviewTestCase,
getRelateTest,
getTestReviewTestCase
getTestReviewTestCase,
} from "@/api/test-review";
export default {
@ -184,7 +246,7 @@ export default {
FormRichTextItem,
TestCaseEditOtherInfo,
ReviewComment,
TestCaseAttachment
TestCaseAttachment,
},
data() {
return {
@ -193,44 +255,44 @@ export default {
testCase: {},
index: 0,
testCases: [],
readConfig: {toolbar: []},
readConfig: { toolbar: [] },
test: {},
activeTab: 'detail',
activeTab: "detail",
isFailure: true,
users: [],
activeName: 'comment',
activeName: "comment",
comments: [],
tableData: [],
currentScenario: {},
mark: 'detail',
mark: "detail",
api: {},
apiCase: {},
testCaseTemplate: {},
formLabelWidth: '100px',
formLabelWidth: "100px",
isCustomFiledActive: false,
oldReviewStatus: '',
oldReviewStatus: "",
titleWith: 0,
relationGraphOpen: false,
};
},
props: {
total: {
type: Number
type: Number,
},
searchParam: {
type: Object
type: Object,
},
isReadOnly: {
type: Boolean,
default: false
default: false,
},
pageNum: Number,
pageSize: {
type: Number,
default: 1
default: 1,
},
nextPageData: Object,
prePageData: Object
prePageData: Object,
},
computed: {
projectId() {
@ -241,7 +303,7 @@ export default {
},
pageTotal() {
return Math.ceil(this.total / this.pageSize);
}
},
},
methods: {
openTest(item) {
@ -250,25 +312,35 @@ export default {
switch (type) {
case "performance": {
let performanceData = this.$router.resolve({
path: '/performance/test/edit/' + id,
path: "/performance/test/edit/" + id,
});
window.open(performanceData.href, '_blank');
window.open(performanceData.href, "_blank");
break;
}
case "testcase": {
let caseData = this.$router.resolve({
name: 'ApiDefinition',
params: {redirectID: getUUID(), dataType: "apiTestCase", dataSelectRange: 'single:' + id}
name: "ApiDefinition",
params: {
versionId: "default",
redirectID: getUUID(),
dataType: "apiTestCase",
dataSelectRange: "single:" + id,
},
});
window.open(caseData.href, '_blank');
window.open(caseData.href, "_blank");
break;
}
case "automation": {
let automationData = this.$router.resolve({
name: 'ApiAutomation',
params: {redirectID: getUUID(), dataType: "scenario", dataSelectRange: 'edit:' + id}
name: "ApiAutomation",
params: {
versionId: "default",
redirectID: getUUID(),
dataType: "scenario",
dataSelectRange: "edit:" + id,
},
});
window.open(automationData.href, '_blank');
window.open(automationData.href, "_blank");
break;
}
}
@ -282,7 +354,7 @@ export default {
},
cancel() {
this.handleClose();
this.$emit('refreshTable');
this.$emit("refreshTable");
},
saveCase() {
let param = {};
@ -291,22 +363,21 @@ export default {
param.reviewId = this.testCase.reviewId;
param.comment = this.testCase.comment;
param.status = this.testCase.reviewStatus;
editTestReviewTestCase(param)
.then(() => {
this.$success(this.$t('commons.save_success'));
this.updateTestCases(param);
this.setReviewStatus(this.testCase.reviewId);
editTestReviewTestCase(param).then(() => {
this.$success(this.$t("commons.save_success"));
this.updateTestCases(param);
this.setReviewStatus(this.testCase.reviewId);
//
this.testCases[this.index].status = this.testCase.status;
//
this.oldReviewStatus = this.testCase.reviewStatus;
//
this.testCases[this.index].status = this.testCase.status;
//
this.oldReviewStatus = this.testCase.reviewStatus;
if (this.testCase.comment) {
this.$refs.comment.getComments();
this.testCase.comment = '';
}
})
if (this.testCase.comment) {
this.$refs.comment.getComments();
this.testCase.comment = "";
}
});
},
saveCaseReview() {
let param = {};
@ -315,18 +386,17 @@ export default {
param.caseId = this.testCase.caseId;
param.reviewId = this.testCase.reviewId;
param.status = status;
editTestReviewTestCase(param)
.then(() => {
this.updateTestCases(param);
this.setReviewStatus(this.testCase.reviewId);
this.oldReviewStatus = status;
//
this.testCases[this.index].status = status;
if (this.index < this.testCases.length - 1) {
this.handleNext();
}
this.$success(this.$t('commons.save_success'));
});
editTestReviewTestCase(param).then(() => {
this.updateTestCases(param);
this.setReviewStatus(this.testCase.reviewId);
this.oldReviewStatus = status;
//
this.testCases[this.index].status = status;
if (this.index < this.testCases.length - 1) {
this.handleNext();
}
this.$success(this.$t("commons.save_success"));
});
},
updateTestCases(param) {
for (let i = 0; i < this.testCases.length; i++) {
@ -338,12 +408,15 @@ export default {
}
},
handleNext() {
if (this.index === this.testCases.length - 1 && this.pageNum === this.pageTotal) {
if (
this.index === this.testCases.length - 1 &&
this.pageNum === this.pageTotal
) {
//
return;
} else if (this.index === this.testCases.length - 1) {
//
this.$emit('nextPage');
this.$emit("nextPage");
this.index = 0;
return;
}
@ -351,13 +424,16 @@ export default {
this.getTestCase(this.testCases[this.index].id);
},
isLastData() {
return this.index === this.testCases.length - 1 && this.pageNum === this.pageTotal;
return (
this.index === this.testCases.length - 1 &&
this.pageNum === this.pageTotal
);
},
handlePre() {
if (this.index === 0 && this.pageNum === 1) {
return;
} else if (this.index === 0) {
this.$emit('prePage');
this.$emit("prePage");
this.index = this.pageSize - 1;
return;
}
@ -366,31 +442,35 @@ export default {
},
getTestCase(id) {
this.loading = true;
getTestReviewTestCase(id)
.then((response) => {
this.loading = false;
let item = {};
let data = response.data;
Object.assign(item, data);
item.results = JSON.parse(item.results);
if (item.issues) {
item.issues = JSON.parse(item.issues);
} else {
item.issues = {};
}
item.steps = JSON.parse(item.steps);
if (!item.stepModel) {
item.stepModel = 'STEP';
}
parseCustomField(item, this.testCaseTemplate, null, buildTestCaseOldFields(item));
this.isCustomFiledActive = true;
this.testCase = item;
this.oldReviewStatus = this.testCase.reviewStatus;
if (!this.testCase.actualResult) {
// ,使
this.testCase.actualResult = this.testCaseTemplate.actualResult;
}
});
getTestReviewTestCase(id).then((response) => {
this.loading = false;
let item = {};
let data = response.data;
Object.assign(item, data);
item.results = JSON.parse(item.results);
if (item.issues) {
item.issues = JSON.parse(item.issues);
} else {
item.issues = {};
}
item.steps = JSON.parse(item.steps);
if (!item.stepModel) {
item.stepModel = "STEP";
}
parseCustomField(
item,
this.testCaseTemplate,
null,
buildTestCaseOldFields(item)
);
this.isCustomFiledActive = true;
this.testCase = item;
this.oldReviewStatus = this.testCase.reviewStatus;
if (!this.testCase.actualResult) {
// ,使
this.testCase.actualResult = this.testCaseTemplate.actualResult;
}
});
},
setTitleWith() {
this.$nextTick(() => {
@ -405,7 +485,7 @@ export default {
this.showDialog = true;
//
this.oldReviewStatus = testCase.reviewStatus;
this.activeTab = 'detail';
this.activeTab = "detail";
listenGoBack(this.handleClose);
let initFuc = this.getTestCase;
this.setTitleWith();
@ -421,26 +501,34 @@ export default {
}
}
getTestTemplate(testCase.projectId)
.then((response) => {
this.testCaseTemplate = response;
initFuc(testCase.id);
});
getTestTemplate(testCase.projectId).then((response) => {
this.testCaseTemplate = response;
initFuc(testCase.id);
});
if (this.$refs.otherInfo) {
this.$refs.otherInfo.reset();
}
},
openTestTestCase(item) {
let testCaseData = this.$router.resolve(
{path: '/track/case/all', query: {redirectID: getUUID(), dataType: "testCase", dataSelectRange: item.caseId}}
);
window.open(testCaseData.href, '_blank');
let testCaseData = this.$router.resolve({
path: "/track/case/all",
query: {
redirectID: getUUID(),
dataType: "testCase",
dataSelectRange: item.caseId,
},
});
window.open(testCaseData.href, "_blank");
},
getRelatedTest() {
if (this.testCase.method === 'auto' && this.testCase.testId && this.testCase.testId !== 'other') {
getRelateTest(this.testCase.type, this.testCase.testId)
.then((response) => {
if (
this.testCase.method === "auto" &&
this.testCase.testId &&
this.testCase.testId !== "other"
) {
getRelateTest(this.testCase.type, this.testCase.testId).then(
(response) => {
let data = response.data;
if (data) {
this.test = data;
@ -448,8 +536,9 @@ export default {
this.test = {};
this.$warning(this.$t("test_track.case.relate_test_not_find"));
}
});
} else if (this.testCase.testId === 'other') {
}
);
} else if (this.testCase.testId === "other") {
this.$warning(this.$t("test_track.case.other_relate_test_not_find"));
}
},
@ -457,18 +546,20 @@ export default {
editTestCaseReviewStatus(reviewId);
},
stepResultChange() {
if (this.testCase.method === 'manual') {
this.isFailure = this.testCase.steptResults.filter(s => {
return s.executeResult === 'Failure' || s.executeResult === 'Blocking';
}).length > 0;
if (this.testCase.method === "manual") {
this.isFailure =
this.testCase.steptResults.filter((s) => {
return (
s.executeResult === "Failure" || s.executeResult === "Blocking"
);
}).length > 0;
}
},
}
}
},
};
</script>
<style scoped>
.border-hidden :deep(.el-textarea__inner) {
border-style: hidden;
background-color: white;
@ -509,7 +600,7 @@ export default {
}
.el-switch :deep(.el-switch__label.is-active) {
color: #409EFF;
color: #409eff;
}
.container :deep(.el-card__body) {

View File

@ -1120,7 +1120,7 @@ export default {
resource.protocol = 'DUBBO'
}
let definitionData = this.$router.resolve({
path: '/api/definition/'+getUUID()+'/api/edit:'+resource.id+'/'+resource.projectId+'/'+resource.protocol+'/'+workspaceId,
path: '/api/definition/default/' + getUUID() + '/api/edit:' + resource.id + '/' + resource.projectId + '/' + resource.protocol + '/' + workspaceId,
});
if (isTurnSpace) {
window.open(definitionData.href, '_blank');

View File

@ -607,7 +607,7 @@ export default {
edit(row) {
let uuid = getUUID();
let apiResolve = this.$router.resolve({
path: '/api/automation/'+uuid+'/scenario/edit:'+row.id+'/'+row.projectId+'/'+getCurrentWorkspaceId(),
path: '/api/automation/default/' + uuid + '/scenario/edit:' + row.id + '/' + row.projectId + '/' + getCurrentWorkspaceId(),
});
window.open(apiResolve.href, '_blank');
},

View File

@ -654,12 +654,13 @@ export default {
this.initTableData();
},
handleEdit(testCase, column) {
this.$router.push({
let caseResolve = this.$router.resolve({
path: '/track/case/edit',
query:{
caseId:testCase.id,
query: {
caseId: testCase.id,
},
});
window.open(caseResolve.href, '_blank');
},
refresh() {
this.$refs.table.clear();

View File

@ -1,7 +1,8 @@
<template>
<el-card class="table-card">
<ms-table
:table-is-loading="page.result.loading"
v-loading="loading"
row-key="id"
:data="page.data"
:enableSelection="false"
:condition="page.condition"
@ -10,13 +11,16 @@
:show-select-all="false"
:screen-height="screenHeight"
:remember-order="true"
@handlePageChange="getIssues"
@handleRowClick="handleEdit"
:fields.sync="fields"
:field-key="tableHeaderKey"
@refresh="getIssues"
ref="table"
>
:custom-fields="issueTemplate.customFields"
@headChange="handleHeadChange"
@handleRowClick="handleEdit"
@filter="search"
@order="getIssues"
@handlePageChange="getIssues"
ref="table">
<ms-table-column
v-for="(item) in fields" :key="item.key"
:label="item.label"
@ -88,6 +92,7 @@
</template>
</ms-table-column>
</ms-table>
<ms-table-pagination :change="getIssues" :current-page.sync="page.currentPage" :page-size.sync="page.pageSize"
@ -104,46 +109,94 @@ import MsTablePagination from "metersphere-frontend/src/components/pagination/Ta
import {
ISSUE_PLATFORM_OPTION,
ISSUE_STATUS_MAP,
SYSTEM_FIELD_NAME_MAP,
TAPD_ISSUE_STATUS_MAP
} from "metersphere-frontend/src/utils/table-constants";
import MsTableHeader from "metersphere-frontend/src/components/MsTableHeader";
import {getDashboardIssues, getIssuePartTemplateWithProject, getIssues, getPlatformOption} from "@/api/issue";
import {
getDashboardIssues,
getIssuePartTemplateWithProject,
getIssues,
getPlatformOption,
} from "@/api/issue";
import {
getCustomFieldValue,
getCustomTableWidth,
getLastTableSortField,
getPageDate,
getPageInfo, parseCustomFilesForList
getPageInfo, getTableHeaderWithCustomFields, getLastTableSortField, getCustomFieldFilter, parseCustomFilesForList
} from "metersphere-frontend/src/utils/tableUtils";
import MsContainer from "metersphere-frontend/src/components/MsContainer";
import MsMainContainer from "metersphere-frontend/src/components/MsMainContainer";
import {getCurrentProjectID, getCurrentWorkspaceId} from "metersphere-frontend/src/utils/token";
import {getProjectMember} from "@/api/user";
import {getTableHeaderWithCustomFieldsByXpack} from "@/business/component/js/table-head-util";
import {getProjectMember, getProjectMemberUserFilter} from "@/api/user";
import {LOCAL} from "metersphere-frontend/src/utils/constants";
import {TEST_TRACK_ISSUE_LIST} from "metersphere-frontend/src/components/search/search-components";
import {
getAdvSearchCustomField
} from "metersphere-frontend/src/components/search/custom-component";
import MsMarkDownText from "metersphere-frontend/src/components/MsMarkDownText";
import MsReviewTableItem from "@/business/component/MsReviewTableItem";
import {getUUID} from "metersphere-frontend/src/utils";
import IssueDescriptionTableItem from "@/business/component/IssueDescriptionTableItem";
export default {
name: "IssueTableList",
name: "IssueList",
components: {
MsMainContainer,
MsReviewTableItem,
MsMarkDownText,
MsMainContainer,
MsContainer,
IssueDescriptionTableItem,
MsTableHeader,
MsTablePagination, MsTableButton, MsTableOperators, MsTableColumn, MsTable
},
data() {
return {
page: getPageInfo(),
page: getPageInfo({
components: TEST_TRACK_ISSUE_LIST,
custom: false,
}),
fields: [],
customFields: [], //
tableHeaderKey: "ISSUE_LIST",
fieldsWidth: getCustomTableWidth('ISSUE_LIST'),
issueTemplate: {},
members: [],
userFilter: [],
isThirdPart: false,
creatorFilters: [],
loading: false,
dataSelectRange: "",
platformOptions: [],
platformStatus: [],
platformStatusMap: new Map(),
hasLicense: false,
columns: {
num: {
sortable: true,
minWidth: 100
},
title: {
sortable: true,
minWidth: 120,
},
platform: {
minWidth: 80,
filters: this.platformFilters
},
platformStatus: {
minWidth: 110,
},
creatorName: {
columnKey: 'creator',
minWidth: 100,
filters: this.creatorFilters
},
resourceName: {},
createTime: {
sortable: true,
minWidth: 180
},
caseCount: {}
}
};
},
activated() {
@ -192,48 +245,87 @@ export default {
tapdIssueStatusMap() {
return TAPD_ISSUE_STATUS_MAP;
},
systemNameMap() {
return SYSTEM_FIELD_NAME_MAP;
},
projectId() {
return getCurrentProjectID();
},
workspaceId() {
return getCurrentWorkspaceId();
}
},
created() {
this.getMaintainerOptions();
this.page.result.loading = true;
this.$nextTick(() => {
getProjectMember((data) => {
this.members = data;
});
getIssuePartTemplateWithProject((template) => {
this.initFields(template);
this.page.result.loading = false;
});
this.getIssues();
});
},
methods: {
getCustomFieldValue(row, field) {
getCustomFieldValue(row, field, defaultVal) {
let value = getCustomFieldValue(row, field, this.members);
if (!value) {
if (field.name === '处理人') {
return row.maintainerName;
}
}
return value;
return value ? value : defaultVal;
},
getCustomFieldFilter(field) {
return getCustomFieldFilter(field, this.userFilter);
},
initFields(template) {
this.issueTemplate = template;
if (this.issueTemplate.platform === LOCAL) {
if (template.platform === LOCAL) {
this.isThirdPart = false;
} else {
this.isThirdPart = true;
}
this.fields = getTableHeaderWithCustomFieldsByXpack('ISSUE_LIST_HEAD', this.issueTemplate.customFields);
let fields = getTableHeaderWithCustomFields('ISSUE_LIST', template.customFields, this.members);
if (!this.isThirdPart) {
for (let i = 0; i < this.fields.length; i++) {
if (this.fields[i].id === 'platformStatus') {
this.fields.splice(i, 1);
for (let i = 0; i < fields.length; i++) {
if (fields[i].id === 'platformStatus') {
fields.splice(i, 1);
break;
}
}
//
let removeField = {id: 'platformStatus', name: 'platformStatus', remove: true};
this.issueTemplate.customFields.push(removeField);
template.customFields.push(removeField);
}
this.$nextTick(() => {
if (this.$refs.table) {
this.$refs.table.reloadTable();
this.issueTemplate = template;
fields.forEach(item => {
if (this.columns[item.id]) {
Object.assign(item, this.columns[item.id]);
if (this.columns[item.id].filters) {
item.filters = this.columns[item.id].filters;
}
}
});
this.fields = fields;
//
this.page.condition.components = this.page.condition.components.filter(item => item.custom !== true);
let comp = getAdvSearchCustomField(this.page.condition, template.customFields);
this.page.condition.components.push(...comp);
this.initCustomFieldValue();
if (this.$refs.table) {
this.$refs.table.reloadTable();
}
},
search() {
//
this.page.currentPage = 1;
this.getIssues();
},
handleHeadChange() {
this.initFields(this.issueTemplate);
},
handleEdit(resource) {
let issueData = this.$router.resolve({path: '/track/issue', query: {id: resource.id}});
window.open(issueData.href, '_blank');
},
getIssues() {
if (this.isSelectAll === false) {
@ -313,24 +405,11 @@ export default {
});
this.loading = false;
},
handleEdit(resource) {
let issueData = this.$router.resolve({path: '/track/issue', query: {id: resource.id}});
window.open(issueData.href, '_blank');
getMaintainerOptions() {
getProjectMemberUserFilter((data) => {
this.creatorFilters = data;
});
},
},
created() {
this.page.result.loading = true;
this.$nextTick(() => {
getProjectMember((data) => {
this.members = data;
});
getIssuePartTemplateWithProject((template) => {
this.initFields(template);
this.page.result.loading = false;
});
this.getIssues();
});
}
};
</script>

View File

@ -22,7 +22,7 @@
width="80"
show-overflow-tooltip>
<template v-slot:default="scope">
<span @click="link(scope.row)" style="cursor: pointer;">{{ scope.row.name }}</span>
<span @click="link(scope.row)" style="cursor: pointer;">{{ scope.row.num }}</span>
</template>
</el-table-column>

View File

@ -1,18 +1,32 @@
<template>
<el-dialog :close-on-click-modal="false" :title="$t('api_test.automation.case_ref')" :visible.sync="visible"
:modal="false" width="45%" :destroy-on-close="true">
<span>{{ $t('api_test.automation.scenario_ref') }}</span>
<el-dialog
:close-on-click-modal="false"
:title="$t('api_test.automation.case_ref')"
:visible.sync="visible"
:modal="false"
width="45%"
:destroy-on-close="true"
>
<span>{{ $t("api_test.automation.scenario_ref") }}</span>
<div class="refs" v-loading="scenarioLoading">
<div v-for="(item, index) in scenarioRefs" :key="index" class="el-button--text">
<div
v-for="(item, index) in scenarioRefs"
:key="index"
class="el-button--text"
>
<el-link @click="openScenario(item)">
{{ item.name }}
</el-link>
</div>
</div>
<span>{{ $t('api_test.automation.plan_ref') }}</span>
<span>{{ $t("api_test.automation.plan_ref") }}</span>
<div class="refs">
<div v-for="(item, index) in planRefs" :key="index" class="el-button--text">
<div
v-for="(item, index) in planRefs"
:key="index"
class="el-button--text"
>
<el-link @click="openTestPlan(item)">
{{ item.name }}
</el-link>
@ -21,8 +35,12 @@
<template v-slot:footer>
<div class="dialog-footer">
<el-button type="primary" @click="visible = false" @keydown.enter.native.prevent>
{{ $t('commons.confirm') }}
<el-button
type="primary"
@click="visible = false"
@keydown.enter.native.prevent
>
{{ $t("commons.confirm") }}
</el-button>
</div>
</template>
@ -30,93 +48,105 @@
</template>
<script>
import {getCurrentProjectID, getCurrentWorkspaceId} from "metersphere-frontend/src/utils/token";
import {getUUID} from "metersphere-frontend/src/utils";
import {getOwnerProjectIds, getProject} from "@/api/project";
import {getScenarioReference} from "@/api/scenario";
import {
getCurrentProjectID,
getCurrentWorkspaceId,
} from "metersphere-frontend/src/utils/token";
import { getUUID } from "metersphere-frontend/src/utils";
import { getOwnerProjectIds, getProject } from "@/api/project";
import { getScenarioReference } from "@/api/scenario";
export default {
name: "MsReferenceView",
components: {},
data() {
return {
visible: false,
scenarioLoading: false,
scenarioRefs: [],
planRefs: []
name: "MsReferenceView",
components: {},
data() {
return {
visible: false,
scenarioLoading: false,
scenarioRefs: [],
planRefs: [],
};
},
methods: {
getReferenceData(row) {
if (row.id === undefined) {
return;
}
this.scenarioLoading = true;
this.scenarioRefs = [];
getScenarioReference(row).then((response) => {
this.scenarioRefs = response.data.scenarioList;
this.planRefs = response.data.testPlanList;
this.scenarioLoading = false;
});
},
open(row) {
this.getReferenceData(row);
this.visible = true;
},
openScenario(resource) {
let workspaceId = getCurrentWorkspaceId();
let isTurnSpace = true;
if (resource.projectId !== getCurrentProjectID()) {
isTurnSpace = false;
getProject(resource.projectId).then((response) => {
if (response.data) {
workspaceId = response.data.workspaceId;
isTurnSpace = true;
this.checkPermission(resource, workspaceId, isTurnSpace);
}
});
} else {
this.checkPermission(resource, workspaceId, isTurnSpace);
}
},
methods: {
getReferenceData(row) {
if (row.id === undefined) {
return;
}
this.scenarioLoading = true;
this.scenarioRefs = [];
getScenarioReference(row).then(response => {
this.scenarioRefs = response.data.scenarioList;
this.planRefs = response.data.testPlanList;
this.scenarioLoading = false;
})
},
open(row) {
this.getReferenceData(row);
this.visible = true
},
openScenario(resource) {
let workspaceId = getCurrentWorkspaceId();
let isTurnSpace = true
if (resource.projectId !== getCurrentProjectID()) {
isTurnSpace = false;
getProject(resource.projectId).then(response => {
if (response.data) {
workspaceId = response.data.workspaceId;
isTurnSpace = true;
this.checkPermission(resource, workspaceId, isTurnSpace);
}
});
} else {
this.checkPermission(resource, workspaceId, isTurnSpace);
}
},
gotoTurn(resource, workspaceId, isTurnSpace) {
let automationData = this.$router.resolve({
name: 'ApiAutomation',
params: {redirectID: getUUID(), dataType: "scenario", dataSelectRange: 'edit:' + resource.id, projectId: resource.projectId, workspaceId: workspaceId}
});
if (isTurnSpace) {
window.open(automationData.href, '_blank');
}
},
checkPermission(resource, workspaceId, isTurnSpace) {
getOwnerProjectIds().then(res => {
const project = res.data.find(p => p === resource.projectId);
if (!project) {
this.$warning(this.$t('commons.no_permission'));
} else {
this.gotoTurn(resource, workspaceId, isTurnSpace)
}
})
},
openTestPlan(item){
let automationData = this.$router.resolve({
path: '/track/plan/view/' + item.id,
query: { workspaceId: item.workspaceId, projectId: item.projectId, charType: 'api'}
});
window.open(automationData.href, '_blank');
gotoTurn(resource, workspaceId, isTurnSpace) {
let automationData = this.$router.resolve({
name: "ApiAutomation",
params: {
versionId: "default",
redirectID: getUUID(),
dataType: "scenario",
dataSelectRange: "edit:" + resource.id,
projectId: resource.projectId,
workspaceId: workspaceId,
},
});
if (isTurnSpace) {
window.open(automationData.href, "_blank");
}
}
}
},
checkPermission(resource, workspaceId, isTurnSpace) {
getOwnerProjectIds().then((res) => {
const project = res.data.find((p) => p === resource.projectId);
if (!project) {
this.$warning(this.$t("commons.no_permission"));
} else {
this.gotoTurn(resource, workspaceId, isTurnSpace);
}
});
},
openTestPlan(item) {
let automationData = this.$router.resolve({
path: "/track/plan/view/" + item.id,
query: {
workspaceId: item.workspaceId,
projectId: item.projectId,
charType: "api",
},
});
window.open(automationData.href, "_blank");
},
},
};
</script>
<style scoped>
.refs {
min-height: 50px;
max-height: 200px;
overflow-y: auto;
font-size: 12px;
padding-bottom: 10px;
}
.refs {
min-height: 50px;
max-height: 200px;
overflow-y: auto;
font-size: 12px;
padding-bottom: 10px;
}
</style>