diff --git a/frontend/src/business/components/api/automation/report/SysnApiReportDetail.vue b/frontend/src/business/components/api/automation/report/SysnApiReportDetail.vue index 9cfba87d09..158714d87d 100644 --- a/frontend/src/business/components/api/automation/report/SysnApiReportDetail.vue +++ b/frontend/src/business/components/api/automation/report/SysnApiReportDetail.vue @@ -108,22 +108,12 @@ export default { this.isRequestResult = false; }, created() { - if (this.scenarioId) { - this.getApiScenario().then(() => { - this.initTree(); - this.initWebSocket(); - this.initMessageSocket(); - this.clearDebug(); - this.loading = false; - }); - } else { - if (this.scenario && this.scenario.scenarioDefinition) { - this.content.scenarioStepTotal = this.scenario.scenarioDefinition.hashTree.length; - this.initTree(); - this.initWebSocket(); - this.initMessageSocket(); - this.clearDebug(); - } + if (this.scenario && this.scenario.scenarioDefinition) { + this.content.scenarioStepTotal = this.scenario.scenarioDefinition.hashTree.length; + this.initTree(); + this.initWebSocket(); + this.initMessageSocket(); + this.clearDebug(); } }, props: { @@ -135,36 +125,6 @@ export default { scenarioId: String }, methods: { - getApiScenario() { - this.loading = true; - return new Promise((resolve) => { - this.result = this.$get("/api/automation/getApiScenario/" + this.scenarioId, response => { - if (response.data) { - if (response.data.scenarioDefinition != null) { - let obj = JSON.parse(response.data.scenarioDefinition); - this.scenario.scenarioDefinition = obj; - this.scenario.name = response.data.name; - this.content.scenarioStepTotal = obj.hashTree.length; - if (this.scenario.scenarioDefinition && this.scenario.scenarioDefinition.hashTree) { - this.sort(this.scenario.scenarioDefinition.hashTree); - } - resolve(); - } - } - }) - }) - }, - sort(stepArray) { - for (let i in stepArray) { - stepArray[i].index = Number(i) + 1; - if (!stepArray[i].resourceId) { - stepArray[i].resourceId = getUUID(); - } - if (stepArray[i].hashTree && stepArray[i].hashTree.length > 0) { - this.sort(stepArray[i].hashTree); - } - } - }, initTree() { this.fullTreeNodes = []; let obj = {index: 1, label: this.scenario.name, value: {responseResult: {}, unexecute: true, testing: false}, children: [], unsolicited: true}; diff --git a/frontend/src/business/components/api/automation/scenario/ApiScenarioList.vue b/frontend/src/business/components/api/automation/scenario/ApiScenarioList.vue index ce97623b0d..52554f94ac 100644 --- a/frontend/src/business/components/api/automation/scenario/ApiScenarioList.vue +++ b/frontend/src/business/components/api/automation/scenario/ApiScenarioList.vue @@ -184,7 +184,7 @@ - + + @@ -274,7 +276,8 @@ export default { MsTestPlanList: () => import("./testplan/TestPlanList"), MsTableOperatorButton: () => import("@/business/components/common/components/MsTableOperatorButton"), MsRunMode: () => import("./common/RunMode"), - MsTaskCenter: () => import("../../../task/TaskCenter") + MsTaskCenter: () => import("../../../task/TaskCenter"), + MsRun: () => import("./DebugRun") }, props: { referenced: { @@ -339,6 +342,8 @@ export default { pageSize: 10, total: 0, reportId: "", + showReportId: "", + projectEnvMap: new Map(), batchReportId: "", content: {}, infoDb: false, @@ -354,6 +359,7 @@ export default { selectRows: new Set(), isStop: false, enableOrderDrag: true, + debugData: {}, trashOperators: [ { tip: this.$t('commons.reduction'), @@ -849,7 +855,34 @@ export default { }); } }, - + getApiScenario(scenarioId) { + return new Promise((resolve) => { + this.result = this.$get("/api/automation/getApiScenario/" + scenarioId, response => { + if (response.data) { + if (response.data.scenarioDefinition != null) { + let obj = JSON.parse(response.data.scenarioDefinition); + this.currentScenario.scenarioDefinition = obj; + this.currentScenario.name = response.data.name; + if (this.currentScenario.scenarioDefinition && this.currentScenario.scenarioDefinition.hashTree) { + this.sort(this.currentScenario.scenarioDefinition.hashTree); + } + resolve(); + } + } + }) + }) + }, + sort(stepArray) { + for (let i in stepArray) { + stepArray[i].index = Number(i) + 1; + if (!stepArray[i].resourceId) { + stepArray[i].resourceId = getUUID(); + } + if (stepArray[i].hashTree && stepArray[i].hashTree.length > 0) { + this.sort(stepArray[i].hashTree); + } + } + }, execute(row) { this.infoDb = false; this.scenarioId = row.id; @@ -869,6 +902,35 @@ export default { this.$set(row, "isStop", false); }); }, + runRefresh(row) { + this.$set(row, "isStop", false); + }, + run(row) { + this.scenarioId = row.id; + this.getApiScenario(row.id).then(() => { + let scenarioStep = this.currentScenario.scenarioDefinition; + if (scenarioStep) { + this.debugData = { + id: this.currentScenario.id, + name: this.currentScenario.name, + type: "scenario", + variables: scenarioStep.variables, + referenced: 'Created', + onSampleError: scenarioStep.onSampleError, + enableCookieShare: scenarioStep.enableCookieShare, + headers: scenarioStep.headers, + environmentMap: scenarioStep.environmentMap ? new Map(Object.entries(scenarioStep.environmentMap)) : new Map, + hashTree: scenarioStep.hashTree + }; + if (scenarioStep.environmentMap) { + this.projectEnvMap = new Map(Object.entries(scenarioStep.environmentMap)); + } + this.reportId = getUUID().substring(0, 8); + this.runVisible = true; + this.$set(row, "isStop", true); + } + }); + }, copy(row) { let rowParam = JSON.parse(JSON.stringify(row)); rowParam.copy = true; @@ -879,7 +941,7 @@ export default { showReport(row) { this.showReportVisible = true; this.infoDb = true; - this.reportId = row.reportId; + this.showReportId = row.reportId; }, //判断是否只显示本周的数据。 从首页跳转过来的请求会带有相关参数 isSelectThissWeekData() {