fix(接口测试): 修复批量编辑缺少追加标签的缺陷

--bug=1037501 --user=王孝刚 【接口测试】接口定义-API列表-批量编辑-属性选标签,没有“追加标签”功能
https://www.tapd.cn/55049933/s/1479560
This commit is contained in:
wxg0103 2024-03-23 17:42:12 +08:00 committed by Craftsman
parent 844b076dc2
commit ca5478bcf3
11 changed files with 99 additions and 29 deletions

View File

@ -26,7 +26,7 @@ public class ApiCaseBatchEditRequest extends ApiTestCaseBatchRequest implements
@NotBlank
private String type;
@Schema(description = "默认覆盖原标签")
private boolean appendTag = false;
private boolean append = false;
@Schema(description = "环境id")
@Size(max = 50, message = "{api_test_case.env_id.length_range}")
private String environmentId;

View File

@ -26,7 +26,7 @@ public class ApiScenarioBatchEditRequest extends ApiScenarioBatchRequest impleme
@NotBlank
private String type;
@Schema(description = "默认覆盖原标签")
private boolean appendTag = false;
private boolean append = false;
@Schema(description = "环境id")
@Size(max = 50, message = "{api_test_case.environment_id.length_range}")
private String envId;

View File

@ -473,7 +473,7 @@ public class ApiTestCaseService extends MoveNodeService {
if (CollectionUtils.isEmpty(request.getTags())) {
throw new MSException(Translator.get("tags_is_null"));
}
if (request.isAppendTag()) {
if (request.isAppend()) {
Map<String, ApiTestCase> caseMap = extApiTestCaseMapper.getTagsByIds(ids, false)
.stream()
.collect(Collectors.toMap(ApiTestCase::getId, Function.identity()));

View File

@ -330,7 +330,7 @@ public class ApiScenarioService extends MoveNodeService {
if (CollectionUtils.isEmpty(request.getTags())) {
throw new MSException(Translator.get("tags_is_null"));
}
if (request.isAppendTag()) {
if (request.isAppend()) {
Map<String, ApiScenario> scenarioMap = extApiScenarioMapper.getTagsByIds(ids, false)
.stream()
.collect(Collectors.toMap(ApiScenario::getId, Function.identity()));

View File

@ -1397,7 +1397,7 @@ public class ApiScenarioControllerTests extends BaseTest {
ApiScenarioBatchEditRequest request = new ApiScenarioBatchEditRequest();
request.setProjectId(DEFAULT_PROJECT_ID);
request.setType("Tags");
request.setAppendTag(true);
request.setAppend(true);
request.setSelectAll(true);
request.setTags(new LinkedHashSet<>(List.of("tag1", "tag3", "tag4")));
requestPostAndReturn(BATCH_EDIT, request);
@ -1411,7 +1411,7 @@ public class ApiScenarioControllerTests extends BaseTest {
});
//覆盖标签
request.setTags(new LinkedHashSet<>(List.of("tag1")));
request.setAppendTag(false);
request.setAppend(false);
requestPostAndReturn(BATCH_EDIT, request);
apiScenarioMapper.selectByExample(example).forEach(scenario -> {
Assertions.assertEquals(scenario.getTags(), List.of("tag1"));

View File

@ -895,7 +895,7 @@ public class ApiTestCaseControllerTests extends BaseTest {
ApiCaseBatchEditRequest request = new ApiCaseBatchEditRequest();
request.setProjectId(DEFAULT_PROJECT_ID);
request.setType("Tags");
request.setAppendTag(true);
request.setAppend(true);
request.setSelectAll(true);
request.setTags(new LinkedHashSet<>(List.of("tag1", "tag3", "tag4")));
requestPostWithOkAndReturn(BATCH_EDIT, request);
@ -909,7 +909,7 @@ public class ApiTestCaseControllerTests extends BaseTest {
});
//覆盖标签
request.setTags(new LinkedHashSet<>(List.of("tag1")));
request.setAppendTag(false);
request.setAppend(false);
requestPostWithOkAndReturn(BATCH_EDIT, request);
apiTestCaseMapper.selectByExample(example).forEach(apiTestCase -> {
Assertions.assertEquals(apiTestCase.getTags(), List.of("tag1"));

View File

@ -338,6 +338,7 @@ export interface ApiCaseBatchEditParams extends ApiCaseBatchParams {
status?: string;
environmentId?: string;
type: string;
append?: boolean;
}
// 添加用例参数
export interface AddApiCaseParams extends ExecuteRequestParams {

View File

@ -124,7 +124,7 @@ export interface ApiScenarioBatchEditParams extends ApiScenarioBatchParams {
type?: string;
// 修改标签相关
appendTag?: boolean;
append?: boolean;
tags?: string[];
// 修改环境相关

View File

@ -199,12 +199,31 @@
</a-form-item>
</a-form>
<template #footer>
<a-button type="secondary" :disabled="batchUpdateLoading" @click="cancelBatch">
{{ t('common.cancel') }}
</a-button>
<a-button type="primary" :loading="batchUpdateLoading" @click="batchUpdate">
{{ t('common.update') }}
</a-button>
<div class="flex" :class="[batchForm.attr === 'tags' ? 'justify-between' : 'justify-end']">
<div
v-if="batchForm.attr === 'tags'"
class="flex flex-row items-center justify-center"
style="padding-top: 10px"
>
<a-switch v-model="batchForm.append" class="mr-1" size="small" type="line" />
<a-tooltip :content="t('caseManagement.featureCase.enableTags')">
<span class="flex items-center">
<span class="mr-1">{{ t('caseManagement.featureCase.appendTag') }}</span>
<span class="mt-[2px]">
<IconQuestionCircle class="h-[16px] w-[16px] text-[rgb(var(--primary-5))]" />
</span>
</span>
</a-tooltip>
</div>
<div class="flex justify-end">
<a-button type="secondary" :disabled="batchUpdateLoading" @click="cancelBatch">
{{ t('common.cancel') }}
</a-button>
<a-button class="ml-3" type="primary" :loading="batchUpdateLoading" @click="batchUpdate">
{{ t('common.update') }}
</a-button>
</div>
</div>
</template>
</a-modal>
<a-modal
@ -626,6 +645,7 @@
attr: '',
value: '',
values: [],
append: false,
});
const fullAttrs = [
{
@ -680,6 +700,7 @@
attr: '',
value: '',
values: [],
append: false,
};
}
@ -697,6 +718,7 @@
moduleIds: await getModuleIds(),
protocol: props.protocol,
type: batchForm.value.attr,
append: batchForm.value.append,
[batchForm.value.attr]: batchForm.value.attr === 'tags' ? batchForm.value.values : batchForm.value.value,
});
Message.success(t('common.updateSuccess'));

View File

@ -248,12 +248,31 @@
</a-form-item>
</a-form>
<template #footer>
<a-button type="secondary" :disabled="batchEditLoading" @click="cancelBatchEdit">
{{ t('common.cancel') }}
</a-button>
<a-button type="primary" :loading="batchEditLoading" @click="handleBatchEditCase">
{{ t('common.update') }}
</a-button>
<div class="flex" :class="[batchForm.attr === 'tags' ? 'justify-between' : 'justify-end']">
<div
v-if="batchForm.attr === 'tags'"
class="flex flex-row items-center justify-center"
style="padding-top: 10px"
>
<a-switch v-model="batchForm.append" class="mr-1" size="small" type="line" />
<a-tooltip :content="t('caseManagement.featureCase.enableTags')">
<span class="flex items-center">
<span class="mr-1">{{ t('caseManagement.featureCase.appendTag') }}</span>
<span class="mt-[2px]">
<IconQuestionCircle class="h-[16px] w-[16px] text-[rgb(var(--primary-5))]" />
</span>
</span>
</a-tooltip>
</div>
<div class="flex justify-end">
<a-button type="secondary" :disabled="batchEditLoading" @click="cancelBatchEdit">
{{ t('common.cancel') }}
</a-button>
<a-button class="ml-3" type="primary" :loading="batchEditLoading" @click="handleBatchEditCase">
{{ t('common.update') }}
</a-button>
</div>
</div>
</template>
</a-modal>
<createAndEditCaseDrawer
@ -723,6 +742,7 @@
attr: '',
value: '',
values: [],
append: false,
});
const attrOptions = [
@ -785,6 +805,7 @@
attr: '',
value: '',
values: [],
append: false,
};
}
function handleBatchEditCase() {
@ -799,6 +820,7 @@
excludeIds: batchParams.value?.excludeIds || [],
...batchConditionParams,
type: batchForm.value.attr.charAt(0).toUpperCase() + batchForm.value.attr.slice(1), //
append: batchForm.value.append,
[batchForm.value.attr]: batchForm.value.attr === 'tags' ? batchForm.value.values : batchForm.value.value,
});
Message.success(t('common.updateSuccess'));

View File

@ -173,7 +173,7 @@
</a-select>
</a-form-item>
<a-form-item
v-if="batchForm.attr === 'TAGS'"
v-if="batchForm.attr === 'Tags'"
field="values"
:label="t('api_scenario.table.batchUpdate')"
:validate-trigger="['blur', 'input']"
@ -221,12 +221,31 @@
</a-form-item>
</a-form>
<template #footer>
<a-button type="secondary" :disabled="batchUpdateLoading" @click="cancelBatch">
{{ t('common.cancel') }}
</a-button>
<a-button type="primary" :loading="batchUpdateLoading" @click="batchUpdate">
{{ t('common.update') }}
</a-button>
<div class="flex" :class="[batchForm.attr === 'Tags' ? 'justify-between' : 'justify-end']">
<div
v-if="batchForm.attr === 'Tags'"
class="flex flex-row items-center justify-center"
style="padding-top: 10px"
>
<a-switch v-model="batchForm.append" class="mr-1" size="small" type="line" />
<a-tooltip :content="t('caseManagement.featureCase.enableTags')">
<span class="flex items-center">
<span class="mr-1">{{ t('caseManagement.featureCase.appendTag') }}</span>
<span class="mt-[2px]">
<IconQuestionCircle class="h-[16px] w-[16px] text-[rgb(var(--primary-5))]" />
</span>
</span>
</a-tooltip>
</div>
<div class="flex justify-end">
<a-button type="secondary" :disabled="batchUpdateLoading" @click="cancelBatch">
{{ t('common.cancel') }}
</a-button>
<a-button class="ml-3" type="primary" :loading="batchUpdateLoading" @click="batchUpdate">
{{ t('common.update') }}
</a-button>
</div>
</div>
</template>
</a-modal>
<!-- </MsDialog>-->
@ -711,6 +730,7 @@
attr: '',
value: '',
values: [],
append: false,
});
const fullAttrs = [
{
@ -722,7 +742,7 @@
value: 'Status',
},
{
name: '标签(待定)',
name: '标签',
value: 'Tags',
},
{
@ -760,6 +780,7 @@
attr: '',
value: '',
values: [],
append: false,
};
}
@ -781,12 +802,16 @@
type: batchForm.value?.attr,
priority: '',
status: '',
tags: [],
append: batchForm.value.append,
};
if (batchForm.value.attr === 'Priority') {
batchEditParam.priority = batchForm.value.value;
} else if (batchForm.value.attr === 'Status') {
batchEditParam.status = batchForm.value.value;
} else if (batchForm.value.attr === 'Tags') {
batchEditParam.tags = batchForm.value.values;
}
await batchEditScenario(batchEditParam);