fix(接口自动化): 修复创建场景问题

This commit is contained in:
fit2-zhao 2020-12-15 19:02:35 +08:00
parent ff9ecf6ec3
commit 43fbccb2a6
3 changed files with 20 additions and 8 deletions

View File

@ -20,7 +20,7 @@
:name="item.name" :name="item.name"
closable> closable>
<div class="ms-api-scenario-div"> <div class="ms-api-scenario-div">
<ms-edit-api-scenario :currentScenario="item.currentScenario" :moduleOptions="moduleOptions"/> <ms-edit-api-scenario @refresh="refresh" :currentScenario="item.currentScenario" :moduleOptions="moduleOptions"/>
</div> </div>
</el-tab-pane> </el-tab-pane>
@ -64,7 +64,7 @@
let label = this.$t('api_test.automation.add_scenario'); let label = this.$t('api_test.automation.add_scenario');
let name = getUUID().substring(0, 8); let name = getUUID().substring(0, 8);
this.activeName = name; this.activeName = name;
this.tabs.push({label: label, name: name, currentScenario: {}}); this.tabs.push({label: label, name: name, currentScenario: {apiScenarioModuleId: "", id: getUUID()}});
} }
if (tab.name === 'edit') { if (tab.name === 'edit') {
let label = this.$t('api_test.automation.add_scenario'); let label = this.$t('api_test.automation.add_scenario');

View File

@ -95,13 +95,21 @@
try { try {
let urlObject = new URL(this.request.url); let urlObject = new URL(this.request.url);
let url = urlObject.protocol + "//" + urlObject.host + "/"; let url = urlObject.protocol + "//" + urlObject.host + "/";
if (url) {
let path = this.request.url.substr(url.length); let path = this.request.url.substr(url.length);
if (!path.startsWith('/')) { if (!path.startsWith('/')) {
path = "/" + path; path = "/" + path;
} }
this.request.path = path; this.request.path = path;
} else {
this.request.url = this.request.path;
}
} catch (e) { } catch (e) {
if (this.request.url) {
this.request.path = this.request.url; this.request.path = this.request.url;
} else {
this.request.url = this.request.path;
}
} }
} }
}, },

View File

@ -682,6 +682,7 @@
this.$success(this.$t('commons.save_success')); this.$success(this.$t('commons.save_success'));
this.path = "/api/automation/update"; this.path = "/api/automation/update";
this.currentScenario.tagId = JSON.parse(this.currentScenario.tagId); this.currentScenario.tagId = JSON.parse(this.currentScenario.tagId);
this.$emit('refresh');
}) })
} }
}) })
@ -708,6 +709,7 @@
}, },
setParameter() { setParameter() {
this.currentScenario.stepTotal = this.scenarioDefinition.length; this.currentScenario.stepTotal = this.scenarioDefinition.length;
this.currentScenario.projectId = getCurrentProjectID();
this.currentScenario.modulePath = this.getPath(this.currentScenario.apiScenarioModuleId); this.currentScenario.modulePath = this.getPath(this.currentScenario.apiScenarioModuleId);
// 便 // 便
let scenario = { let scenario = {
@ -715,7 +717,9 @@
type: "scenario", referenced: 'Created', environmentId: this.currentEnvironmentId, hashTree: this.scenarioDefinition type: "scenario", referenced: 'Created', environmentId: this.currentEnvironmentId, hashTree: this.scenarioDefinition
}; };
this.currentScenario.scenarioDefinition = scenario; this.currentScenario.scenarioDefinition = scenario;
if (this.currentScenario.tagId instanceof Array) {
this.currentScenario.tagId = JSON.stringify(this.currentScenario.tagId); this.currentScenario.tagId = JSON.stringify(this.currentScenario.tagId);
}
if (this.currentModule != null) { if (this.currentModule != null) {
this.currentScenario.modulePath = this.currentModule.method !== undefined ? this.currentModule.method : null; this.currentScenario.modulePath = this.currentModule.method !== undefined ? this.currentModule.method : null;
this.currentScenario.apiScenarioModuleId = this.currentModule.id; this.currentScenario.apiScenarioModuleId = this.currentModule.id;