fix (接口自动化): 修复单条执行有未执行的情况
--bug=1006591 --user=赵勇 【接口自动化】执行场景,执行完成,报告状态异常 https://www.tapd.cn/55049933/s/1046338
This commit is contained in:
parent
410d443ea0
commit
3233768933
|
@ -108,15 +108,6 @@ export default {
|
||||||
this.isRequestResult = false;
|
this.isRequestResult = false;
|
||||||
},
|
},
|
||||||
created() {
|
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) {
|
if (this.scenario && this.scenario.scenarioDefinition) {
|
||||||
this.content.scenarioStepTotal = this.scenario.scenarioDefinition.hashTree.length;
|
this.content.scenarioStepTotal = this.scenario.scenarioDefinition.hashTree.length;
|
||||||
this.initTree();
|
this.initTree();
|
||||||
|
@ -124,7 +115,6 @@ export default {
|
||||||
this.initMessageSocket();
|
this.initMessageSocket();
|
||||||
this.clearDebug();
|
this.clearDebug();
|
||||||
}
|
}
|
||||||
}
|
|
||||||
},
|
},
|
||||||
props: {
|
props: {
|
||||||
reportId: String,
|
reportId: String,
|
||||||
|
@ -135,36 +125,6 @@ export default {
|
||||||
scenarioId: String
|
scenarioId: String
|
||||||
},
|
},
|
||||||
methods: {
|
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() {
|
initTree() {
|
||||||
this.fullTreeNodes = [];
|
this.fullTreeNodes = [];
|
||||||
let obj = {index: 1, label: this.scenario.name, value: {responseResult: {}, unexecute: true, testing: false}, children: [], unsolicited: true};
|
let obj = {index: 1, label: this.scenario.name, value: {responseResult: {}, unexecute: true, testing: false}, children: [], unsolicited: true};
|
||||||
|
|
|
@ -184,7 +184,7 @@
|
||||||
<ms-table-operator-button v-permission=" ['PROJECT_API_SCENARIO:READ+RUN']"
|
<ms-table-operator-button v-permission=" ['PROJECT_API_SCENARIO:READ+RUN']"
|
||||||
:tip="$t('api_test.automation.execute')" icon="el-icon-video-play"
|
:tip="$t('api_test.automation.execute')" icon="el-icon-video-play"
|
||||||
class="run-button"
|
class="run-button"
|
||||||
@exec="execute(scope.row)" v-if="!scope.row.isStop && !trashEnable"
|
@exec="run(scope.row)" v-if="!scope.row.isStop && !trashEnable"
|
||||||
style="margin-right: 10px;"/>
|
style="margin-right: 10px;"/>
|
||||||
<el-tooltip :content="$t('report.stop_btn')" placement="top" :enterable="false" v-else>
|
<el-tooltip :content="$t('report.stop_btn')" placement="top" :enterable="false" v-else>
|
||||||
<el-button v-if="!trashEnable" @click.once="stop(scope.row)" size="mini"
|
<el-button v-if="!trashEnable" @click.once="stop(scope.row)" size="mini"
|
||||||
|
@ -218,7 +218,7 @@
|
||||||
<el-drawer :visible.sync="showReportVisible" :destroy-on-close="true" direction="ltr" :withHeader="true"
|
<el-drawer :visible.sync="showReportVisible" :destroy-on-close="true" direction="ltr" :withHeader="true"
|
||||||
:modal="false"
|
:modal="false"
|
||||||
size="90%">
|
size="90%">
|
||||||
<ms-api-report-detail @refresh="search" :infoDb="infoDb" :report-id="reportId" :currentProjectId="projectId"/>
|
<ms-api-report-detail @refresh="search" :infoDb="infoDb" :report-id="showReportId" :currentProjectId="projectId"/>
|
||||||
</el-drawer>
|
</el-drawer>
|
||||||
<!--测试计划-->
|
<!--测试计划-->
|
||||||
<el-drawer :visible.sync="planVisible" :destroy-on-close="true" direction="ltr" :withHeader="false"
|
<el-drawer :visible.sync="planVisible" :destroy-on-close="true" direction="ltr" :withHeader="false"
|
||||||
|
@ -233,6 +233,8 @@
|
||||||
:dialog-title="$t('test_track.case.batch_edit_case')"/>
|
:dialog-title="$t('test_track.case.batch_edit_case')"/>
|
||||||
<batch-move @refresh="search" @moveSave="moveSave" ref="testBatchMove"/>
|
<batch-move @refresh="search" @moveSave="moveSave" ref="testBatchMove"/>
|
||||||
<ms-run-mode @handleRunBatch="handleRunBatch" ref="runMode"/>
|
<ms-run-mode @handleRunBatch="handleRunBatch" ref="runMode"/>
|
||||||
|
<ms-run :debug="true" v-if="type!=='detail'" :environment="projectEnvMap" @runRefresh="runRefresh" :reportId="reportId" :saved="true"
|
||||||
|
:run-data="debugData" ref="runTest"/>
|
||||||
<ms-task-center ref="taskCenter"/>
|
<ms-task-center ref="taskCenter"/>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
@ -274,7 +276,8 @@ export default {
|
||||||
MsTestPlanList: () => import("./testplan/TestPlanList"),
|
MsTestPlanList: () => import("./testplan/TestPlanList"),
|
||||||
MsTableOperatorButton: () => import("@/business/components/common/components/MsTableOperatorButton"),
|
MsTableOperatorButton: () => import("@/business/components/common/components/MsTableOperatorButton"),
|
||||||
MsRunMode: () => import("./common/RunMode"),
|
MsRunMode: () => import("./common/RunMode"),
|
||||||
MsTaskCenter: () => import("../../../task/TaskCenter")
|
MsTaskCenter: () => import("../../../task/TaskCenter"),
|
||||||
|
MsRun: () => import("./DebugRun")
|
||||||
},
|
},
|
||||||
props: {
|
props: {
|
||||||
referenced: {
|
referenced: {
|
||||||
|
@ -339,6 +342,8 @@ export default {
|
||||||
pageSize: 10,
|
pageSize: 10,
|
||||||
total: 0,
|
total: 0,
|
||||||
reportId: "",
|
reportId: "",
|
||||||
|
showReportId: "",
|
||||||
|
projectEnvMap: new Map(),
|
||||||
batchReportId: "",
|
batchReportId: "",
|
||||||
content: {},
|
content: {},
|
||||||
infoDb: false,
|
infoDb: false,
|
||||||
|
@ -354,6 +359,7 @@ export default {
|
||||||
selectRows: new Set(),
|
selectRows: new Set(),
|
||||||
isStop: false,
|
isStop: false,
|
||||||
enableOrderDrag: true,
|
enableOrderDrag: true,
|
||||||
|
debugData: {},
|
||||||
trashOperators: [
|
trashOperators: [
|
||||||
{
|
{
|
||||||
tip: this.$t('commons.reduction'),
|
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) {
|
execute(row) {
|
||||||
this.infoDb = false;
|
this.infoDb = false;
|
||||||
this.scenarioId = row.id;
|
this.scenarioId = row.id;
|
||||||
|
@ -869,6 +902,35 @@ export default {
|
||||||
this.$set(row, "isStop", false);
|
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) {
|
copy(row) {
|
||||||
let rowParam = JSON.parse(JSON.stringify(row));
|
let rowParam = JSON.parse(JSON.stringify(row));
|
||||||
rowParam.copy = true;
|
rowParam.copy = true;
|
||||||
|
@ -879,7 +941,7 @@ export default {
|
||||||
showReport(row) {
|
showReport(row) {
|
||||||
this.showReportVisible = true;
|
this.showReportVisible = true;
|
||||||
this.infoDb = true;
|
this.infoDb = true;
|
||||||
this.reportId = row.reportId;
|
this.showReportId = row.reportId;
|
||||||
},
|
},
|
||||||
//判断是否只显示本周的数据。 从首页跳转过来的请求会带有相关参数
|
//判断是否只显示本周的数据。 从首页跳转过来的请求会带有相关参数
|
||||||
isSelectThissWeekData() {
|
isSelectThissWeekData() {
|
||||||
|
|
Loading…
Reference in New Issue