Skip to content

Commit 6c1552d

Browse files
committed
feat: support import test suite as in-line
1 parent ce1f79f commit 6c1552d

File tree

2 files changed

+33
-10
lines changed

2 files changed

+33
-10
lines changed

console/atest-ui/src/components/TestSuiteImportDialog.vue

Lines changed: 31 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
<script setup lang="ts">
22
import { useI18n } from 'vue-i18n'
33
import { reactive, ref } from 'vue'
4-
import type { Suite } from '@/views/types'
54
import { API } from '@/views/net'
65
import { ElMessage } from 'element-plus'
6+
import type { ImportSource } from '@/views/net'
77
import type { FormInstance, FormRules } from 'element-plus'
88
99
const { t } = useI18n()
@@ -16,14 +16,16 @@ const importSuiteFormRef = ref<FormInstance>()
1616
const importSuiteForm = reactive({
1717
url: '',
1818
store: '',
19-
kind: ''
20-
})
19+
kind: '',
20+
data: ''
21+
} as ImportSource)
2122
22-
const importSuiteFormRules = reactive<FormRules<Suite>>({
23+
const importSuiteFormRules = reactive<FormRules<ImportSource>>({
2324
url: [
24-
{ required: true, message: 'URL is required', trigger: 'blur' },
25+
{ required: importSuiteForm.kind !== 'native-inline', message: 'URL is required', trigger: 'blur' },
2526
{ type: 'url', message: 'Should be a valid URL value', trigger: 'blur' }
2627
],
28+
data: [{ required: importSuiteForm.kind === 'native-inline', message: 'Data is required', trigger: 'blur' }],
2729
store: [{ required: true, message: 'Location is required', trigger: 'blur' }],
2830
kind: [{ required: true, message: 'Kind is required', trigger: 'blur' }]
2931
})
@@ -32,6 +34,9 @@ const importSuiteFormSubmit = async (formEl: FormInstance | undefined) => {
3234
if (!formEl) return
3335
await formEl.validate((valid: boolean) => {
3436
if (valid) {
37+
if (importSuiteForm.kind === 'native-inline') {
38+
importSuiteForm.kind = 'native'
39+
}
3540
API.ImportTestSuite(importSuiteForm, () => {
3641
emit('created')
3742
formEl.resetFields()
@@ -69,12 +74,16 @@ const importSourceKinds = [{
6974
"name": "Native",
7075
"value": "native",
7176
"description": "http://your-server/api/v1/suites/xxx/yaml?x-store-name=xxx"
77+
}, {
78+
"name": "Native-Inline",
79+
"value": "native-inline",
80+
"description": "Native test suite content in YAML format"
7281
}]
73-
const placeholderOfImportURL = ref("")
82+
const importSourceDesc = ref("")
7483
const kindChanged = (e) => {
7584
importSourceKinds.forEach(k => {
7685
if (k.value === e) {
77-
placeholderOfImportURL.value = k.description
86+
importSourceDesc.value = k.description
7887
}
7988
});
8089
}
@@ -117,8 +126,15 @@ const kindChanged = (e) => {
117126
/>
118127
</el-select>
119128
</el-form-item>
120-
<el-form-item label="URL" prop="url">
121-
<el-input v-model="importSuiteForm.url" test-id="suite-import-form-api" :placeholder="placeholderOfImportURL" />
129+
<el-form-item label="Data" prop="data" v-if="importSuiteForm.kind === 'native-inline'">
130+
<el-input v-model="importSuiteForm.data"
131+
class="full-width" type="textarea"
132+
:placeholder="importSourceDesc" />
133+
</el-form-item>
134+
<el-form-item label="URL" prop="url" v-else>
135+
<el-input v-model="importSuiteForm.url" test-id="suite-import-form-api"
136+
class="full-width"
137+
:placeholder="importSourceDesc" />
122138
</el-form-item>
123139
<el-form-item>
124140
<el-button
@@ -130,3 +146,9 @@ const kindChanged = (e) => {
130146
</el-form>
131147
</el-dialog>
132148
</template>
149+
150+
<style scoped>
151+
.full-width {
152+
width: 100%;
153+
}
154+
</style>

console/atest-ui/src/views/net.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -190,10 +190,11 @@ function CreateTestSuite(suite: TestSuite,
190190
.then(callback).catch(emptyOrDefault(errHandle))
191191
}
192192

193-
interface ImportSource {
193+
export interface ImportSource {
194194
store: string
195195
url: string
196196
kind: string
197+
data: string
197198
}
198199

199200
function UpdateTestSuite(suite: any,

0 commit comments

Comments
 (0)