refactor(接口测试): 优化引用场景代码
This commit is contained in:
parent
ea5caf0ec8
commit
e94873c09d
|
@ -37,16 +37,16 @@
|
|||
</template>
|
||||
|
||||
<script>
|
||||
import MsContainer from "../../../../common/components/MsContainer";
|
||||
import MsAsideContainer from "../../../../common/components/MsAsideContainer";
|
||||
import MsMainContainer from "../../../../common/components/MsMainContainer";
|
||||
import MsApiScenarioModule from "../ApiScenarioModule";
|
||||
import MsApiScenarioList from "../ApiScenarioList";
|
||||
import {getUUID} from "../../../../../../common/js/utils";
|
||||
import RelevanceDialog from "../../../../track/plan/view/comonents/base/RelevanceDialog";
|
||||
import TestCaseRelevanceBase from "@/business/components/track/plan/view/comonents/base/TestCaseRelevanceBase";
|
||||
import MsContainer from "../../../../common/components/MsContainer";
|
||||
import MsAsideContainer from "../../../../common/components/MsAsideContainer";
|
||||
import MsMainContainer from "../../../../common/components/MsMainContainer";
|
||||
import MsApiScenarioModule from "../ApiScenarioModule";
|
||||
import MsApiScenarioList from "../ApiScenarioList";
|
||||
import {getUUID} from "../../../../../../common/js/utils";
|
||||
import RelevanceDialog from "../../../../track/plan/view/comonents/base/RelevanceDialog";
|
||||
import TestCaseRelevanceBase from "@/business/components/track/plan/view/comonents/base/TestCaseRelevanceBase";
|
||||
|
||||
export default {
|
||||
export default {
|
||||
name: "ScenarioRelevance",
|
||||
components: {
|
||||
TestCaseRelevanceBase,
|
||||
|
@ -84,65 +84,30 @@
|
|||
}
|
||||
},
|
||||
methods: {
|
||||
changeButtonLoadingType(){
|
||||
changeButtonLoadingType() {
|
||||
this.buttonIsWorking = false;
|
||||
},
|
||||
reference() {
|
||||
this.buttonIsWorking = true;
|
||||
let scenarios = [];
|
||||
let conditions = this.getConditions();
|
||||
if (conditions.selectAll) {
|
||||
let params = {};
|
||||
params.ids = this.currentScenarioIds;
|
||||
params.condition = conditions;
|
||||
let url = "/api/automation/list/all/";
|
||||
this.result = this.$post(url, params, (response) => {
|
||||
this.currentScenario = response.data;
|
||||
if (!this.currentScenario || this.currentScenario.length < 1) {
|
||||
this.$emit('请选择场景');
|
||||
this.buttonIsWorking = false;
|
||||
return;
|
||||
}
|
||||
this.currentScenario.forEach(item => {
|
||||
createScenarioDefinition(scenarios, data, referenced) {
|
||||
data.forEach(item => {
|
||||
let scenarioDefinition = JSON.parse(item.scenarioDefinition);
|
||||
if (scenarioDefinition && scenarioDefinition.hashTree) {
|
||||
let obj = {
|
||||
id: item.id,
|
||||
name: item.name,
|
||||
type: "scenario",
|
||||
referenced: 'REF',
|
||||
headers: scenarioDefinition.headers,
|
||||
variables: scenarioDefinition.variables,
|
||||
environmentMap: scenarioDefinition.environmentMap,
|
||||
referenced: referenced,
|
||||
resourceId: getUUID(),
|
||||
hashTree: scenarioDefinition.hashTree,
|
||||
projectId: item.projectId
|
||||
};
|
||||
scenarios.push(obj);
|
||||
});
|
||||
this.$emit('save', scenarios);
|
||||
this.$refs.baseRelevance.close();
|
||||
this.buttonIsWorking = false;
|
||||
},(error) => {
|
||||
this.buttonIsWorking = false;
|
||||
});
|
||||
} else {
|
||||
if (!this.currentScenario || this.currentScenario.length < 1) {
|
||||
this.$emit('请选择场景');
|
||||
this.buttonIsWorking = false;
|
||||
return;
|
||||
}
|
||||
this.currentScenario.forEach(item => {
|
||||
let obj = {
|
||||
id: item.id,
|
||||
name: item.name,
|
||||
type: "scenario",
|
||||
referenced: 'REF',
|
||||
resourceId: getUUID(),
|
||||
projectId: item.projectId
|
||||
};
|
||||
scenarios.push(obj);
|
||||
});
|
||||
this.$emit('save', scenarios);
|
||||
this.$refs.baseRelevance.close();
|
||||
this.buttonIsWorking = false;
|
||||
}
|
||||
},
|
||||
copy() {
|
||||
getScenarioDefinition(referenced) {
|
||||
this.buttonIsWorking = true;
|
||||
let scenarios = [];
|
||||
let conditions = this.getConditions();
|
||||
|
@ -160,32 +125,15 @@
|
|||
}
|
||||
this.result = this.$post("/api/automation/getApiScenarios/", this.currentScenarioIds, response => {
|
||||
if (response.data) {
|
||||
response.data.forEach(item => {
|
||||
let scenarioDefinition = JSON.parse(item.scenarioDefinition);
|
||||
if (scenarioDefinition && scenarioDefinition.hashTree) {
|
||||
let obj = {
|
||||
id: item.id,
|
||||
name: item.name,
|
||||
type: "scenario",
|
||||
headers: scenarioDefinition.headers,
|
||||
variables: scenarioDefinition.variables,
|
||||
environmentMap: scenarioDefinition.environmentMap,
|
||||
referenced: 'Copy',
|
||||
resourceId: getUUID(),
|
||||
hashTree: scenarioDefinition.hashTree,
|
||||
projectId: item.projectId
|
||||
};
|
||||
scenarios.push(obj);
|
||||
}
|
||||
});
|
||||
this.createScenarioDefinition(scenarios, response.data, referenced);
|
||||
this.$emit('save', scenarios);
|
||||
this.$refs.baseRelevance.close();
|
||||
this.buttonIsWorking = false;
|
||||
}
|
||||
},(error) => {
|
||||
}, (error) => {
|
||||
this.buttonIsWorking = false;
|
||||
});
|
||||
},(error) => {
|
||||
}, (error) => {
|
||||
this.buttonIsWorking = false;
|
||||
});
|
||||
} else {
|
||||
|
@ -196,33 +144,22 @@
|
|||
}
|
||||
this.result = this.$post("/api/automation/getApiScenarios/", this.currentScenarioIds, response => {
|
||||
if (response.data) {
|
||||
response.data.forEach(item => {
|
||||
let scenarioDefinition = JSON.parse(item.scenarioDefinition);
|
||||
if (scenarioDefinition && scenarioDefinition.hashTree) {
|
||||
let obj = {
|
||||
id: item.id,
|
||||
name: item.name,
|
||||
type: "scenario",
|
||||
headers: scenarioDefinition.headers,
|
||||
variables: scenarioDefinition.variables,
|
||||
environmentMap: scenarioDefinition.environmentMap,
|
||||
referenced: 'Copy',
|
||||
resourceId: getUUID(),
|
||||
hashTree: scenarioDefinition.hashTree,
|
||||
projectId: item.projectId
|
||||
};
|
||||
scenarios.push(obj);
|
||||
}
|
||||
});
|
||||
this.createScenarioDefinition(scenarios, response.data, referenced);
|
||||
this.$emit('save', scenarios);
|
||||
this.$refs.baseRelevance.close();
|
||||
this.buttonIsWorking = false;
|
||||
}
|
||||
},(error) => {
|
||||
}, (error) => {
|
||||
this.buttonIsWorking = false;
|
||||
});
|
||||
}
|
||||
},
|
||||
reference() {
|
||||
this.getScenarioDefinition("REF")
|
||||
},
|
||||
copy() {
|
||||
this.getScenarioDefinition("Copy")
|
||||
},
|
||||
close() {
|
||||
this.$emit('close');
|
||||
this.refresh();
|
||||
|
@ -259,7 +196,7 @@
|
|||
return this.$refs.apiScenarioList.getConditions();
|
||||
},
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
|
|
Loading…
Reference in New Issue