Commit 8cf764fe authored by 王晓铜's avatar 王晓铜

提交场景用例模块

parent 3f04c32f
......@@ -10,4 +10,5 @@ module.exports = merge(prodEnv, {
// HOLMES: '"//localhost:8084"',
QA_PLATFORM: '"//qa-platform-fe.liangkebang.net/"',
HOLMES: '"//holmes-fe.liangkebang.net/"',
// HOLMES: '"//192.168.29.143:8084/"'
})
......@@ -11,9 +11,9 @@ module.exports = {
assetsSubDirectory: 'static',
assetsPublicPath: '/',
proxyTable: {},
// Various Dev Server settings
host: 'localhost', // can be overwritten by process.env.HOST
// Various Dev Server settings localhost
host: '0.0.0.0', // can be overwritten by process.env.HOST
port: 8080, // can be overwritten by process.env.PORT, if port is in use, a free one will be determined
autoOpenBrowser: false,
errorOverlay: true,
......
......@@ -14006,6 +14006,11 @@
"is-plain-obj": "^1.0.0"
}
},
"sortablejs": {
"version": "1.13.0",
"resolved": "https://registry.npmjs.org/sortablejs/-/sortablejs-1.13.0.tgz",
"integrity": "sha512-RBJirPY0spWCrU5yCmWM1eFs/XgX2J5c6b275/YyxFRgnzPhKl/TDeU2hNR8Dt7ITq66NRPM4UlOt+e5O4CFHg=="
},
"source-list-map": {
"version": "2.0.1",
"resolved": "https://registry.npmjs.org/source-list-map/-/source-list-map-2.0.1.tgz",
......
......@@ -30,3 +30,19 @@ export function getSceneCaseList(queryInfo) {
params: queryInfo
})
}
// 添加场景用例接口
export function addSceneCase(data) {
return request({
url: '/auto/sceneTestcase/saveOrUpdate',
method: 'post',
data
})
}
// 执行场景用例接口
export function executeScene(queryInfo) {
return request({
url: '/auto/execute/scene',
method: 'get',
params: queryInfo
})
}
// The Vue build version to load with the `import` command
// (runtime-only or standalone) has been set in webpack.base.conf with an alias.
import Vue from 'vue'
import VueBus from 'vue-bus'
import App from './App'
import '../src/assets/css/global.css'
import router from './router'
......@@ -10,6 +9,8 @@ import 'element-ui/lib/theme-chalk/index.css'
import axios from 'axios'
import store from './store/store'
import JsonViewer from 'vue-json-viewer'
import bus from '../src/utils/bus'
// import Sortable from 'sortablejs'
import {
Container,
Header,
......@@ -55,6 +56,7 @@ Vue.prototype.$echarts = echarts
Vue.prototype.$message = Message
Vue.prototype.$loading = Loading
Vue.prototype.$messageBox = MessageBox
Vue.prototype.$bus = bus
// axios.defaults.baseURL = 'https://qa-platform-pre.liangkebang.net'
// axios.defaults.baseURL = 'http://localhost:8082'
......@@ -89,8 +91,8 @@ Vue.use(RadioGroup)
Vue.use(Radio)
Vue.use(Row)
Vue.use(Col)
Vue.use(VueBus)
Vue.use(JsonViewer)
// Vue.use(Sortable)
/* eslint-disable no-new */
new Vue({
el: '#app',
......
......@@ -24,6 +24,7 @@ import CaseList from '../views/auto/CaseList'
import AddCase from '../views/auto/AddCase'
import SceneList from '../views/auto/SceneList'
import EditScene from '../views/auto/EditScene'
Vue.use(Router)
const router = new Router({
mode: 'history',
......
......@@ -202,7 +202,7 @@
<script>
import { getModulList, interfaceDetailList } from '@/api/getAotoInterface'
import { getInterfaceDetail, addCase, editCase } from '@/api/getAutoCase'
import bus from '@/utils/bus'
// import bus from '@/utils/bus'
export default {
data() {
return {
......@@ -272,7 +272,7 @@ export default {
},
created() {
this.getModelList()
bus.$on('casemsg', (row) => {
this.$bus.$on('casemsg', (row) => {
// console.log('接收到的信息', row)
if (row !== null) {
if (row === '新增') {
......@@ -455,8 +455,6 @@ export default {
this.caseForm.extract = JSON.stringify(responseObj)
// 断言
this.caseForm.validate = JSON.stringify(this.assertionList)
// console.log('保存信息', this.caseForm)
if (this.caseForm.id) {
// 编辑接口
editCase(this.caseForm).then((resp) => {
......@@ -484,12 +482,13 @@ export default {
})
}
},
// 刷新列表
sendResh() {
// bus使用
this.$nextTick(function () {
// DOM 现在更新了
bus.$emit('refresh')
this.$bus.$emit('refresh')
})
}
}
......
......@@ -169,7 +169,7 @@ import {
addInterface,
editInterface
} from '@/api/getAotoInterface'
import bus from '@/utils/bus'
// import bus from '@/utils/bus'
export default {
data() {
return {
......@@ -257,7 +257,7 @@ export default {
}
},
created() {
bus.$on('msg', (row) => {
this.$bus.$on('msg', (row) => {
if (row !== null) {
if (row === '新增') {
this.interfaceForm.id = ''
......@@ -356,7 +356,7 @@ export default {
// bus使用
this.$nextTick(function () {
// DOM 现在更新了
bus.$emit('refresh')
this.$bus.$emit('refresh')
})
},
// 保存接口信息
......
......@@ -44,7 +44,7 @@
<script>
import { getModulList } from '@/api/getAotoInterface'
import { singleCaseList, delCase, executeCase } from '@/api/getAutoCase'
import bus from '@/utils/bus'
// import bus from '@/utils/bus'
export default {
data() {
return {
......@@ -77,7 +77,7 @@ export default {
this.isShow = false
this.getModulList()
this.getCaseList()
bus.$on('refresh', () => {
this.$bus.$on('refresh', () => {
this.isShow = false
this.getCaseList()
})
......@@ -110,7 +110,7 @@ export default {
this.$nextTick(function () {
// DOM 现在更新了
var row = '新增'
bus.$emit('casemsg', row)
this.$bus.$emit('casemsg', row)
})
},
// 执行用例
......@@ -130,7 +130,7 @@ export default {
// bus使用
this.$nextTick(function () {
// DOM 现在更新了
bus.$emit('casemsg', row)
this.$bus.$emit('casemsg', row)
})
},
// 对话框方法
......
......@@ -11,12 +11,14 @@
</el-form-item>
<el-form-item>
<el-button type="success" plain @click="DialogVisible = true" class="el-icon-circle-plus">添加</el-button>
<el-table :data="sceneCaseList" border style="width: 100%;margin-top:20px">
<el-table-column type='index' width="50px"></el-table-column>
<el-table-column prop="moduleName" label="模块名称" width="200px"></el-table-column>
<el-table-column prop="interfaceName" label="接口名称" width="200px"></el-table-column>
<!-- <el-table-column prop="createTime" label="创建时间" width="200px"></el-table-column>
<el-table-column prop="updateTime" label="修改时间" width="200px"></el-table-column> -->
<el-table :data="sceneTestcaseList" border style="width: 100%;margin-top:20px" row-key="sequence">
<!-- <el-table-column prop='sequence' width="50px"></el-table-column> -->
<!-- <el-table-column type='index' width="50px"></el-table-column> -->
<!-- <el-table-column prop="moduleName" label="模块名称" width="200px"></el-table-column>
<el-table-column prop="interfaceName" label="接口名称" width="200px"></el-table-column> -->
<el-table-column v-for="(item, index) in col" :key="`col_${index}`" :prop="col[index].prop" :label="item.label" align="center"></el-table-column>
<el-table-column label="操作">
<slot slot-scope="scope">
<el-button type="success" @click="editeSceneFrom(scope.row)">编辑</el-button>
......@@ -26,26 +28,27 @@
</el-table>
</el-form-item>
<el-form-item>
<div style="margin-left:500px;margin-top:20px">
<div style="margin-top:20px;float:right;margin-right:500px">
<el-button type="primary" @click="addSceneCaseFrom">确 定</el-button>
</div>
</el-form-item>
</el-form>
<!-- 添加场景用例 -->
<el-dialog title="新增场景用例" :visible.sync="DialogVisible" width="30%">
<el-form :model="sceneCaseForm" label-width="90px">
<el-form-item label="模块名称:" style="width:300px">
<el-select v-model="moduleFrom" value-key="id" placeholder="请选择模块" @change="selectChangeModel" clearable>
<el-select v-model="sceneCaseForm.moduleFrom" value-key="id" placeholder="请选择模块" @change="selectChangeModel" clearable>
<el-option v-for="item in modelList" :key="item.id" :label="item.name" :value="item"></el-option>
</el-select>
</el-form-item>
<el-form-item label="接口名称:" style="width:500px">
<el-select v-model="interfaceFrom" value-key="id" placeholder="请选择接口" @change="selectChangeInterface" clearable>
<el-select v-model="sceneCaseForm.interfaceFrom" value-key="id" placeholder="请选择接口" @change="selectChangeInterface" clearable>
<el-option v-for="item in interfaceList" :key="item.id" :label="item.name" :value="item"></el-option>
</el-select>
</el-form-item>
<el-form-item>
<el-table :data="caseList" border style="width: 100%;margin-left:1px" @selection-change="handleSelectionChange">
<el-table :data="sceneCaseForm.caseList" border style="width: 100%;margin-left:1px" @selection-change="handleSelectionChange">
<el-table-column type="selection" style="width:10%">
</el-table-column>
<el-table-column type='index' style="width:15%"></el-table-column>
......@@ -58,20 +61,214 @@
<el-button type="primary" @click="addSceneFrom">确 定</el-button>
</span>
</el-dialog>
<!-- 编辑场景用例 -->
<el-dialog title="编辑场景用例" :visible.sync="editDialogVisible" width="60%">
<el-card>
<el-form>
<!-- <el-form-item label="用例名称:" style="width:310px;">
<el-input v-model="caseForm.name" :disabled="true"></el-input>
</el-form-item> -->
<el-collapse v-model="activeNames">
<!-- Headers -->
<el-collapse-item name="1" title="请求头">
<el-button type="success" plain @click="AddHeaderListRow()" class="el-icon-circle-plus">添加行</el-button>
<el-form-item>
<el-row>
<el-col :span="6">
<div class="grid-content" style="margin-left:15px">参数名称</div>
</el-col>
<el-col :span="6">
<div class="grid-content" style="margin-left:15px">参数值</div>
</el-col>
<el-col :span="6">
<div class="grid-content" style="margin-left:25px">操作</div>
</el-col>
</el-row>
<el-row v-for="(item,index) in headersList" :key="index">
<el-col :span="6">
<div>
<el-input v-model.trim="item.paramsName" placeholder="请输入参数名称"></el-input>
</div>
</el-col>
<el-col :span="6">
<div>
<el-input v-model.trim="item.paramsValue" placeholder="请输入参数值"></el-input>
</div>
</el-col>
<el-col :span="6">
<div>
<el-button size="mini" type="danger" @click="advanceDelss(index)" style="height:40px;margin-left:20px">删除</el-button>
</div>
</el-col>
</el-row>
</el-form-item>
</el-collapse-item>
<!-- 请求参数 -->
<el-collapse-item name="2" title="请求参数">
<el-button type="success" plain @click="AddRequestParamsListRow()" class="el-icon-circle-plus">添加行</el-button>
<el-form-item>
<el-row>
<el-col :span="6">
<div class="grid-content" style="margin-left:15px">参数名称</div>
</el-col>
<el-col :span="6">
<div class="grid-content" style="margin-left:15px">参数值</div>
</el-col>
<el-col :span="6">
<div class="grid-content" style="margin-left:25px">操作</div>
</el-col>
</el-row>
<el-row v-for="(item,index) in requestParamsList" :key="index">
<el-col :span="6">
<div>
<el-input v-model.trim="item.paramsName" placeholder="请输入参数名称"></el-input>
</div>
</el-col>
<el-col :span="6">
<div>
<el-input v-model.trim="item.paramsValue" placeholder="请输入参数值"></el-input>
</div>
</el-col>
<el-col :span="6">
<div>
<el-button size="mini" type="danger" @click="requestParamsDel(index)" style="height:40px;margin-left:20px">删除</el-button>
</div>
</el-col>
</el-row>
</el-form-item>
</el-collapse-item>
<!-- 参数列表 -->
<el-collapse-item name="3" title="参数列表">
<el-button type="success" plain @click="AddParamsListRow()" class="el-icon-circle-plus">添加行</el-button>
<el-form-item>
<el-row>
<el-col :span="6">
<div class="grid-content" style="margin-left:15px">参数名称</div>
</el-col>
<el-col :span="6">
<div class="grid-content" style="margin-left:15px">参数值</div>
</el-col>
<el-col :span="6">
<div class="grid-content" style="margin-left:25px">操作</div>
</el-col>
</el-row>
<el-row v-for="(item,index) in paramsList" :key="index">
<el-col :span="6">
<div>
<el-input v-model.trim="item.paramsName" placeholder="请输入参数名称"></el-input>
</div>
</el-col>
<el-col :span="6">
<div>
<el-input v-model.trim="item.paramsValue" placeholder="请输入参数值"></el-input>
</div>
</el-col>
<el-col :span="6">
<div>
<el-button size="mini" type="danger" @click="paramsDel(index)" style="height:40px;margin-left:20px">删除</el-button>
</div>
</el-col>
</el-row>
</el-form-item>
</el-collapse-item>
<!-- 响应解析列表 -->
<el-collapse-item name="4" title="响应列表">
<el-button type="success" plain @click="AddResponseListRow()" class="el-icon-circle-plus">添加行</el-button>
<el-form-item>
<el-row>
<el-col :span="6">
<div class="grid-content" style="margin-left:15px">参数名称</div>
</el-col>
<el-col :span="6">
<div class="grid-content" style="margin-left:15px">参数值</div>
</el-col>
<el-col :span="6">
<div class="grid-content" style="margin-left:25px">操作</div>
</el-col>
</el-row>
<el-row v-for="(item,index) in responseList" :key="index">
<el-col :span="6">
<div>
<el-input v-model.trim="item.paramsName" placeholder="请输入参数名称"></el-input>
</div>
</el-col>
<el-col :span="6">
<div>
<el-input v-model.trim="item.paramsValue" placeholder="请输入参数值"></el-input>
</div>
</el-col>
<el-col :span="6">
<div>
<el-button size="mini" type="danger" @click="responeDel(index)" style="height:40px;margin-left:20px">删除</el-button>
</div>
</el-col>
</el-row>
</el-form-item>
</el-collapse-item>
<!-- 断言 -->
<el-collapse-item name="5" title="结果断言">
<el-button type="success" plain @click="AddAssertionListRow()" class="el-icon-circle-plus">添加行</el-button>
<el-table :data="assertionList" border style="width:100%;margin-top: 15px;">
<el-table-column label="参数名称" width="150">
<template slot-scope="scope">
<el-input v-model="scope.row.paramsName">
</el-input>
</template>
</el-table-column>
<el-table-column label="参数值" width="150">
<template slot-scope="scope">
<el-input v-model="scope.row.paramsValue">
</el-input>
</template>
</el-table-column>
<el-table-column label="是否必填" width="150" style="text-align:center">
<template slot-scope="scope">
<el-switch v-model="scope.row.isRequired" active-color="#13ce66" inactive-color="#A9A9A9" active-text="是" inactive-text="否" @change="changeState()"></el-switch>
</template>
</el-table-column>
<el-table-column label="示例" width="300">
<template slot-scope="scope">
<el-input v-model="scope.row.examples"></el-input>
</template>
</el-table-column>
<el-table-column label="备注" width="300">
<template slot-scope="scope">
<el-input v-model="scope.row.remarks"></el-input>
</template>
</el-table-column>
<el-table-column label="操作">
<template slot-scope="scope">
<el-button size="mini" type="danger" @click="AssertionDelete(scope.$index)">删除</el-button>
</template>
</el-table-column>
</el-table>
</el-collapse-item>
</el-collapse>
<div style="margin-top:20px;margin-left:400px">
<el-button @click="cancelCaseFrom">取 消</el-button>
<el-button type="primary" @click="addCaseFrom">确 定</el-button>
</div>
</el-form>
</el-card>
</el-dialog>
</div>
</template>
<script>
import bus from '@/utils/bus'
import {
getProjectList,
getModulList,
interfaceDetailList,
getCaseByInterface
} from '@/api/getAotoInterface'
import { getSceneCaseList } from '@/api/getAutoScene'
import { getSceneCaseList, addSceneCase } from '@/api/getAutoScene'
import Sortable from 'sortablejs'
export default {
data() {
return {
col: [
{ label: '模块名称', prop: 'moduleName' },
{ label: '接口名称', prop: 'interfaceName' }
],
queryProjectList: {
pageNum: 1,
pageSize: 20
......@@ -97,8 +294,32 @@ export default {
}
]
},
sceneCaseForm: {},
sceneCaseList: [],
sceneCaseForm: {
caseDetialList: [],
moduleName: '',
moduleId: '',
interfaceName: '',
interfaceId: '',
caseList: [],
moduleFrom: {
id: '',
name: ''
},
interfaceFrom: {
id: '',
name: ''
},
sequence: 0,
caseId: '',
caseName: '',
headers: '',
parameters: '',
variables: '',
extract: '',
validate: '',
sceneId: ''
},
sceneTestcaseList: [],
sceneCaseInfo: {
sceneId: ''
},
......@@ -117,30 +338,63 @@ export default {
caseInfo: {
interfaceId: ''
},
moduleFrom: {},
interfaceFrom: {},
caseList: [],
newFrom: {
moduleName: '',
moduleId: '',
interfaceName: '',
editDialogVisible: false,
activeNames: '1',
headersList: [],
requestParamsList: [],
paramsList: [],
responseList: [],
assertionList: [],
caseForm: {
sceneId: '',
interfaceId: '',
caseDetialList: []
name: '',
headers: '',
parameters: '',
variables: '',
extract: '',
validate: '',
sequence: '',
caseId: '',
newInterfaceId: ''
},
newIndex: 0,
newCaseIndex: 0,
newSceneForm: {
sceneId: '',
sceneTestcaseList: []
}
}
},
created() {
this.getProjectList()
bus.$on('scenemsg', (row) => {
this.getModelList()
this.$bus.$off('scenemsg').$on('scenemsg', (row) => {
// console.log('参数信息', row)
this.sceneForm.name = row.name
this.sceneForm.projectId = row.projectId
this.sceneCaseInfo.sceneId = row.id
this.getSceneCaseList()
this.rowDrop()
})
this.getModelList()
},
mounted() {
this.rowDrop()
},
methods: {
rowDrop() {
const tbody = document.querySelector('.el-table__body-wrapper tbody')
const _this = this
Sortable.create(tbody, {
draggable: '.el-table__row',
onEnd({ newIndex, oldIndex }) {
// console.log('索引新', newIndex)
// console.log('索引旧', oldIndex)
const currRow = _this.sceneTestcaseList.splice(oldIndex, 1)[0]
_this.sceneTestcaseList.splice(newIndex, 0, currRow)
}
})
},
// 获取项目列表
getProjectList() {
getProjectList(this.queryProjectList).then((resp) => {
......@@ -150,7 +404,7 @@ export default {
// 获取场景用例列表
getSceneCaseList() {
getSceneCaseList(this.sceneCaseInfo).then((resp) => {
this.sceneCaseList = resp.data.data.list
this.sceneTestcaseList = resp.data.data
})
},
// 获取模块列表
......@@ -161,42 +415,250 @@ export default {
},
// 模块下拉框改变事件
selectChangeModel() {
this.interfaceInfo.moduleId = this.moduleFrom.id
this.interfaceInfo.moduleId = this.sceneCaseForm.moduleFrom.id
interfaceDetailList(this.interfaceInfo).then((resp) => {
this.interfaceList = resp.data.data.list
})
},
// 选择接口下拉框改变事件
selectChangeInterface() {
this.caseInfo.interfaceId = this.interfaceFrom.id
this.caseInfo.interfaceId = this.sceneCaseForm.interfaceFrom.id
getCaseByInterface(this.caseInfo).then((resp) => {
this.caseList = resp.data.data
this.sceneCaseForm.caseList = resp.data.data
})
},
// 选择事件
handleSelectionChange(row) {
this.newFrom.caseDetialList = row
this.sceneCaseForm.caseDetialList = row
},
// 确定按钮
// 添加确定按钮
addSceneFrom() {
this.newFrom.moduleId = this.moduleFrom.id
this.newFrom.moduleName = this.moduleFrom.name
this.newFrom.interfaceId = this.interfaceFrom.id
this.newFrom.interfaceName = this.interfaceFrom.name
console.log('列表信息', this.sceneCaseList)
// var newCaseList = []
this.sceneCaseList.push({
moduleName: this.newFrom.moduleName,
interfaceName: this.newFrom.interfaceName
})
console.log('新列表信息', this.sceneCaseList)
this.sceneTestcaseList.push({
moduleName: this.sceneCaseForm.moduleFrom.name,
interfaceName: this.sceneCaseForm.interfaceFrom.name,
name: this.sceneCaseForm.caseDetialList[0].name,
headers: this.sceneCaseForm.caseDetialList[0].headers,
parameters: this.sceneCaseForm.caseDetialList[0].parameters,
variables: this.sceneCaseForm.caseDetialList[0].variables,
extract: this.sceneCaseForm.caseDetialList[0].extract,
validate: this.sceneCaseForm.caseDetialList[0].validate,
id: this.sceneCaseForm.caseDetialList[0].id,
interfaceId: this.sceneCaseForm.caseDetialList[0].interfaceId,
sceneId: this.sceneCaseInfo.sceneId,
sequence: this.sceneTestcaseList.length + 1
})
console.log('save----', this.sceneTestcaseList)
this.DialogVisible = false
this.moduleFrom = ''
this.interfaceFrom = ''
this.caseList = []
this.sceneCaseForm.moduleFrom = ''
this.sceneCaseForm.interfaceFrom = ''
this.sceneCaseForm.caseList = []
},
// 编辑场景用例
editeSceneFrom(row) {
console.log('11', row)
this.editDialogVisible = true
this.sceneCaseForm.sequence = row.sequence
this.sceneCaseForm.interfaceId = row.interfaceId
this.sceneCaseForm.caseId = row.id
this.sceneCaseForm.caseName = row.name
var newHeaders = JSON.parse(row.headers)
// 请求头(将json字符串转化为对象)
this.headersList = []
for (var i in newHeaders) {
this.headersList.push({
paramsName: i,
paramsValue: newHeaders[i]
})
}
// 请求参数
var newParamters = JSON.parse(row.parameters)
this.requestParamsList = []
for (var j in newParamters) {
this.requestParamsList.push({
paramsName: j,
paramsValue: newParamters[j]
})
}
// 参数列表
var newVariables = JSON.parse(row.variables)
this.paramsList = []
for (var k in newVariables) {
this.paramsList.push({
paramsName: k,
paramsValue: newVariables[k]
})
}
// 响应解析列表
var newExtract = JSON.parse(row.extract)
this.responseList = []
for (var o in newExtract) {
this.responseList.push({
paramsName: o,
paramsValue: newExtract[o]
})
}
// 返回断言
this.assertionList = JSON.parse(row.validate)
},
// 保存场景用例方法
addSceneCaseFrom() {}
addSceneCaseFrom() {
var index = 1
this.sceneTestcaseList.forEach((item) => {
item.sequence = index
index += 1
})
this.newSceneForm.sceneId = this.sceneCaseInfo.sceneId
this.newSceneForm.sceneTestcaseList = this.sceneTestcaseList
addSceneCase(this.newSceneForm).then((resp) => {
if (resp.data.data === true) {
this.$message.success('保存成功!')
// 返回列表页
this.$router.push({ path: 'SceneList' })
// 刷新列表页
this.sendResh()
} else {
this.$message.error(resp.data.msg)
}
})
},
// 刷新列表
sendResh() {
// bus使用
this.$nextTick(function () {
// DOM 现在更新了
this.$bus.$emit('refreshScene')
})
},
// 添加Header行
AddHeaderListRow() {
this.headersList.push({
paramsName: '',
paramsValue: ''
})
},
// 删除Header行
advanceDelss(index) {
this.headersList.splice(index, 1)
},
// 添加请求参数行
AddRequestParamsListRow() {
this.requestParamsList.push({
paramsName: '',
paramsValue: ''
})
},
// 删除请求参数行
requestParamsDel(index) {
this.requestParamsList.splice(index, 1)
},
// 天机参数列表行
AddParamsListRow() {
this.paramsList.push({
paramsName: '',
paramsValue: ''
})
},
// 删除参数列表行
paramsDel(index) {
this.paramsList.splice(index, 1)
},
// 添加响应解析行
AddResponseListRow() {
this.responseList.push({
paramsName: '',
paramsValue: ''
})
},
// 删除响应解析行
responeDel(index) {
this.responseList.splice(index, 1)
},
// 添加断言行
AddAssertionListRow() {
this.assertionList.push({
paramsName: '',
paramsValue: '',
isRequired: true,
examples: '',
remarks: ''
})
},
// 断言改变
changeState(e) {
if (e === true) {
this.assertionList.isRequired = e
} else {
this.assertionList.isRequired = e
}
},
// 删除断言行
AssertionDelete(index) {
this.assertionList.splice(index, 1)
},
// 修改确定按钮
addCaseFrom() {
// 将数组重新赋值(将数组转化为对象)
var headersObj = {}
this.headersList.forEach((item) => {
headersObj[item.paramsName] = item.paramsValue
})
// 将对象转化为Json
this.sceneCaseForm.headers = JSON.stringify(headersObj)
// 请求参数
var requestParamsObj = {}
this.requestParamsList.forEach((item) => {
requestParamsObj[item.paramsName] = item.paramsValue
})
this.sceneCaseForm.parameters = JSON.stringify(requestParamsObj)
// 参数列表
var paramsListObj = {}
this.paramsList.forEach((item) => {
paramsListObj[item.paramsName] = item.paramsValue
})
this.sceneCaseForm.variables = JSON.stringify(paramsListObj)
// 响应解析列表
var responseObj = {}
this.responseList.forEach((item) => {
responseObj[item.paramsName] = item.paramsValue
})
this.sceneCaseForm.extract = JSON.stringify(responseObj)
// 断言
this.sceneCaseForm.validate = JSON.stringify(this.assertionList)
// 循环数组并删除对应的数组下标的整条数据信息
// for (var i = 0; i < this.sceneTestcaseList.length; i++) {
// if (
// this.sceneTestcaseList[i].sequence === this.sceneCaseForm.sequence
// ) {
// var moduleName = this.sceneTestcaseList[i].moduleName
// var interfaceName = this.sceneTestcaseList[i].interfaceName
// this.sceneTestcaseList.splice(i, 1)
// }
// }
for (var i = 0; i < this.sceneTestcaseList.length; i++) {
if (
this.sceneTestcaseList[i].sequence === this.sceneCaseForm.sequence
) {
this.sceneTestcaseList[i].headers = this.sceneCaseForm.headers
this.sceneTestcaseList[i].parameters = this.sceneCaseForm.parameters
this.sceneTestcaseList[i].variables = this.sceneCaseForm.variables
this.sceneTestcaseList[i].extract = this.sceneCaseForm.extract
this.sceneTestcaseList[i].validate = this.sceneCaseForm.validate
}
}
this.editDialogVisible = false
console.log('新集合信息', this.sceneTestcaseList)
},
cancelCaseFrom() {
this.editDialogVisible = false
},
// 删除场景用例
deleSceneFrom(row) {
for (var i = 0; i < this.sceneTestcaseList.length; i++) {
if (this.sceneTestcaseList[i].id === row.id) {
this.sceneTestcaseList.splice(i, 1)
}
}
}
}
}
</script>
......@@ -25,7 +25,7 @@
</el-pagination>
</el-card>
<!-- 新增页面 /编辑页面-->
<el-dialog title="新增项目" :visible.sync="DialogVisible" width="30%" @close="closeEditDialog">
<el-dialog title="新增项目" :visible.sync="DialogVisible" width="30%">
<el-form ref="projectForm" :rules="rules" :model="projectForm" label-width="90px">
<el-form-item label="项目名称:" prop="name" style="width:400px">
<el-input v-model="projectForm.name"></el-input>
......
......@@ -55,9 +55,13 @@
</div>
</template>
<script>
import { getSceneList, addSecene, delSecne } from '@/api/getAutoScene'
import {
getSceneList,
addSecene,
delSecne,
executeScene
} from '@/api/getAutoScene'
import { getProjectList } from '@/api/getAotoInterface'
import bus from '@/utils/bus'
export default {
data() {
return {
......@@ -97,13 +101,20 @@ export default {
delSceneForm: {
sceneId: ''
},
isShow: false,
requestData: ''
isShow: true,
requestData: '',
executeScene: {
sceneId: '',
namespace: ''
}
}
},
created() {
this.getSecneList()
this.getProjectList()
this.$bus.$on('refreshScene', () => {
this.getSecneList()
})
},
methods: {
// 获取场景列表
......@@ -124,14 +135,26 @@ export default {
this.getSecneList()
},
// 执行场景
executeSceneFrom() {},
executeSceneFrom(row) {
// 获取用例id
this.executeScene.sceneId = row.id
this.executeScene.namespace = window.sessionStorage.getItem('env')
// this.isShow = true
executeScene(this.executeScene).then((resp) => {
console.log('接口返回结果', resp)
this.requestData = resp.data.data
})
},
// 编辑场景
editeSceneFrom(row) {
window.sessionStorage.setItem('curScene', JSON.stringify(row))
this.$router.push({ path: 'EditScene' })
// this.$router.push({ path: 'tese' })
// bus使用
this.$nextTick(function () {
// DOM 现在更新了
bus.$emit('scenemsg', row)
this.$bus.$emit('scenemsg', row)
})
},
// 对话框方法
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment