feat(接口测试): 接口API用例列表无差异手动清空状态标识

This commit is contained in:
xinxin.wu 2024-08-09 19:00:10 +08:00 committed by Craftsman
parent 0ff0ea75f2
commit a17b78c141
2 changed files with 94 additions and 84 deletions

View File

@ -316,6 +316,7 @@
@close="closeDifferent"
@clear-this-change="handleClearThisChange"
@sync="syncParamsHandler"
@load-list="loadCaseListAndResetSelector"
/>
</template>

View File

@ -148,6 +148,7 @@
(e: 'close'): void;
(e: 'clearThisChange', isEvery: boolean): void;
(e: 'sync', mergeRequest: RequestParam): void;
(e: 'loadList'): void;
}>();
const showDiffVisible = defineModel<boolean>('visible', {
@ -196,13 +197,6 @@
const form = ref({ ...initForm });
function cancel() {
form.value = { ...initForm };
checkType.value = [...initCheckList];
showDiffVisible.value = false;
emit('close');
}
const syncLoading = ref<boolean>(false);
const defaultCaseParams = inject<RequestParam>('defaultCaseParams');
@ -210,9 +204,52 @@
const apiDetailInfo = ref<Record<string, any>>({});
const apiDefinedRequest = ref<Record<string, any>>({});
const syncCaseDetail = ref<Record<string, any>>({});
const diffDistanceMap = ref<Record<string, any>>({});
//
async function getCaseDetailInfo(id: string) {
try {
const res = await getCaseDetail(id);
syncCaseDetail.value = res;
const result = await diffDataRequest(id);
const { caseRequest, apiRequest } = result;
caseDetail.value = {
...caseDetail.value,
...caseRequest,
num: caseDetail.value.num,
};
apiDefinedRequest.value = apiRequest;
let parseRequestBodyResult;
if (res.protocol === 'HTTP') {
parseRequestBodyResult = parseRequestBodyFiles(res.request.body); // id
}
caseDetail.value = {
...cloneDeep(defaultCaseParams as RequestParam),
...({
...res,
...caseRequest,
num: res.num,
url: res.path,
...parseRequestBodyResult,
} as Partial<TabItem>),
};
form.value.ignoreApiChange = caseDetail.value.ignoreApiChange;
} catch (error) {
// eslint-disable-next-line no-console
console.log(error);
}
}
async function getApiDetail(apiDefinitionId: string) {
try {
const detail = await getDefinitionDetail(apiDefinitionId);
apiDetailInfo.value = detail as ApiDefinitionDetail;
} catch (error) {
// eslint-disable-next-line no-console
console.log(error);
}
}
/**
* 设置对比
* @params apiValue 接口数据
@ -332,11 +369,57 @@
getBodyData(RequestBodyFormat.FORM_DATA);
getBodyData(RequestBodyFormat.WWW_FORM);
}
const loading = ref<boolean>(false);
async function getRequestDetail(definedId: string, apiCaseId: string) {
loading.value = true;
try {
await Promise.all([getApiDetail(definedId), getCaseDetailInfo(apiCaseId)]);
processData();
} catch (error) {
// eslint-disable-next-line no-console
console.error(error);
} finally {
loading.value = false;
}
}
const ignoreThisChangeLoading = ref(false);
//
async function clearThisChangeHandler() {
if (props.activeApiCaseId) {
ignoreThisChangeLoading.value = true;
try {
await clearThisChange(props.activeApiCaseId);
getRequestDetail(props.activeDefinedId, props.activeApiCaseId);
emit('clearThisChange', true);
} catch (error) {
// eslint-disable-next-line no-console
console.log(error);
} finally {
ignoreThisChangeLoading.value = false;
}
}
}
async function cancel() {
if (!caseDetail.value.inconsistentWithApi) {
try {
await clearThisChange(props.activeApiCaseId);
emit('loadList');
} catch (error) {
console.log(error);
}
}
form.value = { ...initForm };
checkType.value = [...initCheckList];
showDiffVisible.value = false;
emit('close');
}
//
const showSyncConfig = computed(() => caseDetail.value.inconsistentWithApi && !form.value.ignoreApiChange);
const syncCaseDetail = ref<Record<string, any>>({});
//
async function confirmSync() {
if (
@ -371,80 +454,6 @@
}
}
//
async function getCaseDetailInfo(id: string) {
try {
const res = await getCaseDetail(id);
syncCaseDetail.value = res;
const result = await diffDataRequest(id);
const { caseRequest, apiRequest } = result;
caseDetail.value = {
...caseDetail.value,
...caseRequest,
num: caseDetail.value.num,
};
apiDefinedRequest.value = apiRequest;
let parseRequestBodyResult;
if (res.protocol === 'HTTP') {
parseRequestBodyResult = parseRequestBodyFiles(res.request.body); // id
}
caseDetail.value = {
...cloneDeep(defaultCaseParams as RequestParam),
...({
...res,
...caseRequest,
num: res.num,
url: res.path,
...parseRequestBodyResult,
} as Partial<TabItem>),
};
form.value.ignoreApiChange = caseDetail.value.ignoreApiChange;
} catch (error) {
// eslint-disable-next-line no-console
console.log(error);
}
}
async function getApiDetail(apiDefinitionId: string) {
try {
const detail = await getDefinitionDetail(apiDefinitionId);
apiDetailInfo.value = detail as ApiDefinitionDetail;
} catch (error) {
// eslint-disable-next-line no-console
console.log(error);
}
}
const loading = ref<boolean>(false);
async function getRequestDetail(definedId: string, apiCaseId: string) {
loading.value = true;
try {
await Promise.all([getApiDetail(definedId), getCaseDetailInfo(apiCaseId)]);
processData();
} catch (error) {
// eslint-disable-next-line no-console
console.error(error);
} finally {
loading.value = false;
}
}
const ignoreThisChangeLoading = ref(false);
//
async function clearThisChangeHandler() {
if (props.activeApiCaseId) {
ignoreThisChangeLoading.value = true;
try {
await clearThisChange(props.activeApiCaseId);
getRequestDetail(props.activeDefinedId, props.activeApiCaseId);
emit('clearThisChange', true);
} catch (error) {
// eslint-disable-next-line no-console
console.log(error);
} finally {
ignoreThisChangeLoading.value = false;
}
}
}
//
async function changeIgnore(newValue: string | number | boolean) {
try {