fix: validation is missing on the testsuite creation UI (#126)
This commit is contained in:
parent
581b6527ae
commit
7bd43cc4a5
|
@ -2,7 +2,7 @@
|
|||
import { ElMessage } from 'element-plus'
|
||||
import { reactive, ref, watch } from 'vue'
|
||||
import { Edit } from '@element-plus/icons-vue'
|
||||
import type { FormInstance } from 'element-plus'
|
||||
import type { FormInstance, FormRules } from 'element-plus'
|
||||
|
||||
const props = defineProps({
|
||||
name: String,
|
||||
|
@ -62,6 +62,12 @@ const testCaseForm = reactive({
|
|||
name: "",
|
||||
api: "",
|
||||
})
|
||||
const rules = reactive<FormRules<Suite>>({
|
||||
name: [
|
||||
{ required: true, message: 'Please input TestCase name', trigger: 'blur' },
|
||||
]
|
||||
})
|
||||
|
||||
function openNewTestCaseDialog() {
|
||||
loadTestSuites()
|
||||
dialogVisible.value = true
|
||||
|
@ -80,8 +86,10 @@ function loadTestSuites() {
|
|||
});
|
||||
}
|
||||
|
||||
const submitForm = (formEl: FormInstance | undefined) => {
|
||||
const submitForm = async (formEl: FormInstance | undefined) => {
|
||||
if (!formEl) return
|
||||
await formEl.validate((valid: boolean, fields) => {
|
||||
if (valid) {
|
||||
suiteCreatingLoading.value = true
|
||||
|
||||
const requestOptions = {
|
||||
|
@ -106,6 +114,8 @@ const submitForm = (formEl: FormInstance | undefined) => {
|
|||
});
|
||||
|
||||
dialogVisible.value = false
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
function del() {
|
||||
|
@ -147,6 +157,8 @@ const testSuiteList = ref([])
|
|||
<template #footer>
|
||||
<span class="dialog-footer">
|
||||
<el-form
|
||||
:rules="rules"
|
||||
:model="testCaseForm"
|
||||
ref="testcaseFormRef"
|
||||
status-icon
|
||||
label-width="120px"
|
||||
|
|
|
@ -112,6 +112,7 @@ func (l *fileLoader) CreateSuite(name, api string) (err error) {
|
|||
l.parent = path.Dir(absPath)
|
||||
}
|
||||
newSuiteFile := path.Join(l.parent, fmt.Sprintf("%s.yaml", name))
|
||||
if newSuiteFile, err = filepath.Abs(newSuiteFile); err == nil {
|
||||
fmt.Println("new suite file:", newSuiteFile)
|
||||
|
||||
suite := &TestSuite{
|
||||
|
@ -122,6 +123,7 @@ func (l *fileLoader) CreateSuite(name, api string) (err error) {
|
|||
l.Put(newSuiteFile)
|
||||
}
|
||||
}
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue