Skip to content

Commit 00e5345

Browse files
authored
feat: support to duplicate test suite and case (#455)
* feat: support to duplicate test suite and case * add e2e testing for the new apis * fix the e2e testing --------- Co-authored-by: rick <[email protected]>
1 parent e7620a4 commit 00e5345

17 files changed

+1866
-759
lines changed

Diff for: .editorconfig

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# EditorConfig is awesome: https://EditorConfig.org
2+
3+
# top-most EditorConfig file
4+
root = true
5+
6+
# Unix-style newlines with a newline ending every file
7+
[*]
8+
end_of_line = lf
9+
insert_final_newline = true
10+
charset = utf-8
11+
12+
# 4 space indentation
13+
[*.{py,proto,go,js,ts,json,vue}]
14+
indent_style = space
15+
indent_size = 4

Diff for: .github/workflows/build.yaml

+2-2
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ jobs:
7676
# - name: Operator
7777
# run: cd operator && make build
7878

79-
BuildImage:
79+
E2E:
8080
runs-on: ubuntu-22.04
8181
steps:
8282
- uses: actions/checkout@0ad4b8fadaa221de15dcec353f45205ec38ea70b # v4.1.4
@@ -95,7 +95,7 @@ jobs:
9595
fi
9696
make helm-pkg
9797
- name: Core Image
98-
run: GOPROXY=direct IMG_TOOL=docker make build
98+
run: GOPROXY=direct IMG_TOOL=docker TAG=master REGISTRY=ghcr.io make image
9999
- name: Run e2e
100100
env:
101101
GITEE_TOKEN: ${{ secrets.GITEE_TOKEN }}

Diff for: console/atest-ui/src/locales/en.json

+4
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,15 @@
1010
"delete": "Delete",
1111
"send": "Send",
1212
"copy": "Copy",
13+
"ok": "OK",
14+
"reload": "Reload",
15+
"insertSample": "Insert Sample",
1316
"toolbox": "Tool Box",
1417
"refresh": "Refresh",
1518
"newtestcase": "New TestCase",
1619
"viewYaml":"View YAML",
1720
"verify": "Verify",
21+
"duplicate": "Duplicate",
1822
"generateCode": "Generate Code",
1923
"sendWithParam": "Send With Parameter",
2024
"fullScreen": "Full Screen",

Diff for: console/atest-ui/src/locales/zh.json

+6-2
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,15 @@
1010
"delete": "删除",
1111
"send": "发送",
1212
"copy": "拷贝",
13+
"ok": "确定",
14+
"reload": "重新加载",
15+
"insertSample": "插入样例",
1316
"toolbox": "工具箱",
1417
"refresh": "刷新",
1518
"newtestcase": "新建测试用例",
16-
"viewYaml":"查看 YAML",
19+
"viewYaml": "查看 YAML",
1720
"verify": "检查",
21+
"duplicate": "复制",
1822
"generateCode": "生成代码",
1923
"sendWithParam": "参数化",
2024
"fullScreen": "全屏显示",
@@ -57,4 +61,4 @@
5761
"key": "",
5862
"value": ""
5963
}
60-
}
64+
}

Diff for: console/atest-ui/src/views/MockManager.vue

+33-12
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@
22
import { ref } from 'vue';
33
import { Codemirror } from 'vue-codemirror';
44
import { API } from './net';
5+
import {useI18n} from "vue-i18n";
6+
7+
const { t } = useI18n()
58
69
const mockConfig = ref('');
710
const link = ref('')
@@ -10,19 +13,37 @@ API.GetMockConfig((d) => {
1013
link.value = window.location.origin + d.Prefix + "/api.json"
1114
})
1215
const tabActive = ref('yaml')
16+
const insertSample = () => {
17+
mockConfig.value = `objects:
18+
- name: projects
19+
initCount: 3
20+
sample: |
21+
{
22+
"name": "api-testing",
23+
"color": "{{ randEnum "blue" "read" "pink" }}"
24+
}
25+
items:
26+
- name: base64
27+
request:
28+
path: /v1/base64
29+
response:
30+
body: aGVsbG8=
31+
encoder: base64`
32+
}
1333
</script>
1434

1535
<template>
16-
<div>
17-
<el-button type="warning" @click="API.ReloadMockServer(mockConfig)">Reload</el-button>
18-
<el-divider direction="vertical" />
19-
<el-link target="_blank" :href="link">{{ link }}</el-link> <!-- Noncompliant -->
20-
</div>
21-
<div>
22-
<el-tabs v-model="tabActive">
23-
<el-tab-pane label="YAML" name="yaml">
24-
<Codemirror v-model="mockConfig" />
25-
</el-tab-pane>
26-
</el-tabs>
27-
</div>
36+
<div>
37+
<el-button type="primary" @click="insertSample">{{t('button.insertSample')}}</el-button>
38+
<el-button type="warning" @click="API.ReloadMockServer(mockConfig)">{{t('button.reload')}}</el-button>
39+
<el-divider direction="vertical" />
40+
<el-link target="_blank" :href="link">{{ link }}</el-link> <!-- Noncompliant -->
41+
</div>
42+
<div>
43+
<el-tabs v-model="tabActive">
44+
<el-tab-pane label="YAML" name="yaml">
45+
<Codemirror v-model="mockConfig" />
46+
</el-tab-pane>
47+
</el-tabs>
48+
</div>
2849
</template>

Diff for: console/atest-ui/src/views/TestCase.vue

+30-3
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<script setup lang="ts">
22
import { ref, watch } from 'vue'
33
import { ElMessage } from 'element-plus'
4-
import { Edit, Delete, Search } from '@element-plus/icons-vue'
4+
import { Edit, Delete, Search, CopyDocument } from '@element-plus/icons-vue'
55
import JsonViewer from 'vue-json-viewer'
66
import type { Pair, TestResult, TestCaseWithSuite } from './types'
77
import { NewSuggestedAPIsQuery, CreateFilter, GetHTTPMethods, FlattenObject } from './types'
@@ -433,7 +433,7 @@ function bodyTypeChange(e: number) {
433433
}
434434
}
435435
436-
function jsonForamt() {
436+
function jsonFormat() {
437437
if (bodyType.value !== 5) {
438438
return
439439
}
@@ -500,6 +500,23 @@ const queryHeaderValues = (queryString: string, cb: (arg: any) => void) => {
500500
})
501501
cb(results)
502502
}
503+
504+
const duplicateTestCaseDialog = ref(false)
505+
const targetTestCaseName = ref('')
506+
const openDuplicateTestCaseDialog = () => {
507+
duplicateTestCaseDialog.value = true
508+
targetTestCaseName.value = props.name + '-copy'
509+
}
510+
const duplicateTestCase = () => {
511+
API.DuplicateTestCase(props.suite, props.suite, props.name, targetTestCaseName.value,(d) => {
512+
duplicateTestCaseDialog.value = false
513+
ElMessage({
514+
message: 'Duplicated.',
515+
type: 'success'
516+
})
517+
emit('updated')
518+
})
519+
}
503520
</script>
504521

505522
<template>
@@ -513,6 +530,7 @@ const queryHeaderValues = (queryString: string, cb: (arg: any) => void) => {
513530
v-if="!Cache.GetCurrentStore().readOnly"
514531
>{{ t('button.save') }}</el-button>
515532
<el-button type="primary" @click="deleteTestCase" :icon="Delete">{{ t('button.delete') }}</el-button>
533+
<el-button type="primary" @click="openDuplicateTestCaseDialog" :icon="CopyDocument">{{ t('button.duplicate') }}</el-button>
516534
<el-button type="primary" @click="openCodeDialog">{{ t('button.generateCode') }}</el-button>
517535
</div>
518536
<div style="display: flex;">
@@ -649,7 +667,7 @@ const queryHeaderValues = (queryString: string, cb: (arg: any) => void) => {
649667

650668
<div style="flex-grow: 1;">
651669
<Codemirror v-if="bodyType === 3 || bodyType === 5"
652-
@change="jsonForamt"
670+
@change="jsonFormat"
653671
v-model="testCaseWithSuite.data.request.body"/>
654672
<el-table :data="testCaseWithSuite.data.request.form" style="width: 100%" v-if="bodyType === 4">
655673
<el-table-column label="Key" width="180">
@@ -845,4 +863,13 @@ const queryHeaderValues = (queryString: string, cb: (arg: any) => void) => {
845863
</el-tabs>
846864
</el-footer>
847865
</el-container>
866+
867+
<el-drawer v-model="duplicateTestCaseDialog">
868+
<template #default>
869+
New Test Case Name:<el-input v-model="targetTestCaseName" />
870+
</template>
871+
<template #footer>
872+
<el-button type="primary" @click="duplicateTestCase">{{ t('button.ok') }}</el-button>
873+
</template>
874+
</el-drawer>
848875
</template>

0 commit comments

Comments
 (0)